2

I ned to be able to access the RPi's GPIO pins, and to do that, my python script needs to be able to access /dev/mem. I can post code if you need it, but i'm really just looking for suggestions on how to get my python cgi script to be able to access the directory. This is my first project on linux, i dont know html very well, and javascript even less, i have a good foundation in python, and i've been working on this for days, any help would be greatly appreciated

Security does not matter to me, its for a science fair project, so running apache as root, or similar, like changing permissions on /dev/mem are fair game, i jusqt dont know how to do that.

User98764431
5691 gold badge19 silver badges33 bronze badges
asked Jan 22, 2014 at 20:01

2 Answers 2

2

looks like you want to running python script via web pages served by apache(httpd).

by default, apache runs with limited account, which dosen't have 'shell'. so you can't run script or command.

before solve this, you should check your apache daemon account like this :

cat /etc/passwd|grep wwwrun
wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false

as you can see, its 'shell' is /bin/false which is 'dummy shell' and account name is 'wwwrun', but some case it has different name like 'daemon'.

after you change /bin/false to /bin/bash or other shell, then you can run python script and shell command.

but... why don't use python web framework like flask or web.py? Its much better...

answered Jan 23, 2014 at 3:17
1

The easiest way around the permissions problem is to simply make /dev/mem globally writeable.

sudo chmod 666 /dev/mem

This way, anyone can access it, including the CGI Python. In general for security reasons this might not be advisable, but if it's just something you're using on your home network it's probably fine.

answered Mar 24, 2014 at 10:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.