marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

wiringpi with another user

Sat Jan 03, 2015 7:57 pm

I set up wiringPi like described here.

It works with the user pi.
Now I run

Code: Select all

sudo -u user1 /usr/local/bin/gpio export 17 out
and log in as user1 and try to run the python script. It runs without errors but commands to the GPIO pins are ignored.

What did I do wrong?

User avatar
DougieLawson
Posts: 35373
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: wiringpi with another user

Sun Jan 04, 2015 12:46 am

Try using the gpio utility. It looks after all security problems for you, gpio runs as a setuid root program.
http://wiringpi.com/the-gpio-utility/
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Sun Jan 04, 2015 11:46 pm

I just tested this tool and I can write to pins with this as both users.
Still no success with the python script (only as user pi).

User avatar
joan
Posts: 14017
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wiringpi with another user

Sun Jan 04, 2015 11:53 pm

marian42 wrote:I just tested this tool and I can write to pins with this as both users.
Still no success with the python script (only as user pi).
Does the other user need to be added to /etc/sudoers ?

User avatar
iinnovations
Posts: 621
Joined: Thu Jun 06, 2013 5:17 pm

Re: wiringpi with another user

Mon Jan 05, 2015 12:12 am

What is your python script? I use the gpio utility with subprocess.call() with no problems.

Look here for the commands preceded with 'wp' like wptogglegpiopin():

https://github.com/iinnovations/iicontr ... actions.py

Demonstration here:
http://www.cupidcontrols.com/2014/09/di ... -wiringpi/

C
CuPID Controls :: Open Source browser-based sensor and device control
interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Tue Jan 06, 2015 4:09 pm

Does the other user need to be added to /etc/sudoers ?
Just added the user, still the same problem.
What is your python script? I use the gpio utility with subprocess.call() with no problems.
The script is linked in the first post. The script works fine, it just only works with user pi and not with the user user1.

User avatar
iinnovations
Posts: 621
Joined: Thu Jun 06, 2013 5:17 pm

Re: wiringpi with another user

Tue Jan 06, 2015 6:24 pm

Login as user user1 and run gpio. Are you piping call into a file? It should produce error output.

This must be a perms issue with user1. Some googling around 'wiringpi permissions gpio' should get you what you need. Or a 'which gpio' and perms listing of it.
CuPID Controls :: Open Source browser-based sensor and device control
interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Tue Jan 06, 2015 7:10 pm

Are you piping call into a file?
How do I do that?
There is no error output.

jamiesk
Posts: 95
Joined: Mon Nov 26, 2012 8:48 pm
Location: Ipswich, Suffolk, England, UK.

Re: wiringpi with another user

Tue Jan 06, 2015 10:28 pm

marian42 wrote:
Are you piping call into a file?
How do I do that?
There is no error output.
sudo -u user1 /usr/local/bin/gpio export 17 out > error.file
then
more error.file
to see the output
Pi1 (Nov 2012 loft)= 1KW immersion controller for Solar panel
Pi2 (Jan 2013 living room)=Play thing
Pi3 (Feb 2013 mobile)= Play thing with Tandy Ladder board,breakout board,Nokia display
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=28193

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Tue Jan 06, 2015 11:01 pm

The more command doesn't output anything.

jamiesk
Posts: 95
Joined: Mon Nov 26, 2012 8:48 pm
Location: Ipswich, Suffolk, England, UK.

Re: wiringpi with another user

Tue Jan 06, 2015 11:13 pm

marian42 wrote:The more command doesn't output anything.
Guess that means this command worked ok. And a "ls -al" will show the file is zero length too
Pi1 (Nov 2012 loft)= 1KW immersion controller for Solar panel
Pi2 (Jan 2013 living room)=Play thing
Pi3 (Feb 2013 mobile)= Play thing with Tandy Ladder board,breakout board,Nokia display
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=28193

User avatar
DougieLawson
Posts: 35373
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: wiringpi with another user

Tue Jan 06, 2015 11:23 pm

marian42 wrote:The more command doesn't output anything.
Try the less command or the cat command.
Or take a look at whether the file has any data with ls -la filename or wc filename.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Tue Jan 06, 2015 11:24 pm

And a "ls -al" will show the file is zero length too
Yes

User avatar
DougieLawson
Posts: 35373
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: wiringpi with another user

Tue Jan 06, 2015 11:50 pm

Try
sudo -u user1 /usr/local/bin/gpio export 17 out 2> error.file
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

marian42
Posts: 51
Joined: Mon Jul 15, 2013 2:11 pm

Re: wiringpi with another user

Wed Jan 07, 2015 10:47 am

Same result. I'm wondering how there could be permission problems with this command since it's executed with superuser rights so it can do anything it wants anyway. I'd expect problems to occur with the commands that don't have superuser rights (the python script).

Return to “Raspbian”