Permissions setuid sudo raspberry pi2

Hello, i’m trying to migrate from my raspberry with raspbmc to a raspberry pi 2 with osmc.
I am having problems with the gpio and the wiringpi library.

gpio is complaining:

gpio: Must be root to run. Program should be suid root. This is an error.

but the permissions are correct:

osmc@osmc:~/wiringPi$ ls -l /usr/local/bin/gpio 
-rwsr-xr-x 1 root root 30460 mar 12 09:36 /usr/local/bin/gpio

thanks!

Get root access by typing: sudo passwd root
Then put your root password…then log in with root privileges and do your thing shaola

Thanks, but that’s not the point.

No need to enable the root accout, I just need to know why suid is not working in this derivate of debian

Enabling the root account here is not the solution at all.

is gpio a real binary or just a shell script?

  • When a shell script runs with setuid it executes as the user you currently are (osmc) not the user that owns the script.
  • Conversely, when you setuid on a binary it runs as the owner instead of the current user context.

you have two choices:

  • just run ‘sudo scriptname’
  • build a small wrapper that is a binary:

sudo apt-get install build-essential

Then, create wrapper.c

int main()
{
setuid(0);
system("/your/script/here");
return 0;
}

And compile it and install it:

sudo chown root:root /usr/bin/wrapper
sudo chmod 4755 /usr/bin/wraper

Now you can just run ./wrapper without specifying sudo.

S

1 Like

it is a binary indeed, i already knew that trick but thanks anyway.

OMG, my fault, sorry, there was another gpio binary in ~/bin directory from the migration and that one was the one taking before in the path…

So, it’s not a bug neither in the osmc nor in the binary, completely my fault.

Thanks everybody.