jobin-sun / raspberry-gpio-python

Automatically exported from code.google.com/p/raspberry-gpio-python
MIT License
0 stars 0 forks source link

Run as unprivileged user #26

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Add a mechanism to be able to run a script using RPi.GPIO without root 
privileges. 

Original issue reported on code.google.com by btcros...@googlemail.com on 7 Mar 2013 at 2:47

GoogleCodeExporter commented 9 years ago

Original comment by btcros...@googlemail.com on 15 Mar 2013 at 5:02

GoogleCodeExporter commented 9 years ago

Original comment by btcros...@googlemail.com on 6 Sep 2013 at 7:07

GoogleCodeExporter commented 9 years ago
This would be extremely helpful in allowing us to use this great library in a 
web-server context (for example).  Thank you for making this a high priority!

Original comment by malouf.d...@gmail.com on 21 Oct 2013 at 4:29

GoogleCodeExporter commented 9 years ago
Hello, I am running a Python program which needs GPIO access. How is it 
possible to access GPIO without root rights (sudo)?

Original comment by reute...@gmail.com on 18 Dec 2013 at 5:24

GoogleCodeExporter commented 9 years ago
I'd be thankful for that, too...

Original comment by chri...@gmail.com on 10 Jan 2014 at 5:34

GoogleCodeExporter commented 9 years ago
Hi, using subprocess or os.system directly in python, you don't need sudo rights

Original comment by lorkscor...@gmail.com on 27 Jan 2014 at 9:50

GoogleCodeExporter commented 9 years ago
Hello, you could use a subprocess.call or os.sytem and echo [1|0] under the 
desired PI, you could check 
http://hertaville.com/2012/11/18/introduction-to-accessing-the-raspberry-pis-gpi
o-in-c/, the first part, explain how to interact using bash with GPIO, so you 
should not use RPi.GPIO if you want to use the pins with a non root users. Just 
configure them at startup and then write to the pin using echo, thats it, i 
checked and is working, I have not the code on this computer but using 
subprocess.call on python and inside a "echo 1 > /sys/class/gpio/gpio18/value" 
should be enough. 

Original comment by a.e.v.r....@gmail.com on 31 Jan 2015 at 2:31

GoogleCodeExporter commented 9 years ago
I've had success in this by creating a copy of my python interpreter binary and 
setting its permissions to run as root (cp python-2.7 python-2.7_root; chmod 
u+s python-2.7_root) and then telling my script to use that interpreter with #! 
/usr/bin/python-2.7_root. It's a security risk, to be sure, but it works. I 
haven't gotten it to work with service scripts in Kodi/XBMC though, as those 
scripts are executed differently it seems.

Original comment by jdean6...@email.vccs.edu on 31 Jan 2015 at 8:37