1

I want to execute a script embedding commands requiring a root user from my not root account without sudoing:

/usr/local/bin/dodo

#!/bin/bash
/bin/sync && /usr/sbin/pm-suspend-hybrid

What I did is making it root and setting the SUID bit:

chown root:root /usr/local/bin/dodo
chmod a+xrs /usr/local/bin/dodo

But when I try to execute it, the result is:

$ /usr/local/bin/dodo
This utility may only be run by the root user.

I have tried also a sudoer solution by adding the file /etc/sudoers.d/dodo:

%family ALL = (root) NOPASSWD: /usr/local/bin/dodo

Which is supposed, if I am not mistaken, to authorise users of group family to execute dodo as root without password. But the result is the same.

What do I miss please? I am on Debian Jessie

EDIT: In the last case, sudo dodo works without password

lalebarde
  • 203

1 Answers1

0

From the link of AlexP and the different answers there, here is what works fine:

cat /usr/local/bin/dodo
#!/bin/bash
/bin/sync
exec sudo /usr/sbin/pm-suspend-hybrid

_

ls -l /usr/local/bin/dodo
-rwxr-xr-x 1 laurent family 60 déc.  18 17:47 /usr/local/bin/dodo

_

cat /etc/sudoers.d/dodo 
%family ALL = (root) NOPASSWD: /usr/sbin/pm-suspend-hybrid

Then for anyone in the family group:

dodo

executes sync and pm-suspend-hybrid without password nor sudo

lalebarde
  • 203