1

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.

1

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...

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.