0

I want to run a command automatically. The problem is that it may only be run after I logged in and that it requires superuser privileges. I've heard of suid before, so I thought I'd use it for this.

I created a script /mountDropbox.sh which only contains the bash shebang and a mount command. Then I ran this command to set the setuid bit:

sudo chmod 4755 /mountDropbox.sh

However, when I try to run it as a normal user, mount complains about not being executed with superuser privileges:

$ /mountDropbox.sh 
mount: only root can do that

Why does this happen? How can I achieve that this file is always executed with superuser privileges?

I use Ubuntu 16.04 with kernel 4.4.0-134-generic. / is an ext4 file system.

$ ll /mountDropbox.sh 
-rwsr-xr-x 1 root root 77 Sep  4 17:35 /mountDropbox.sh*
UTF-8
  • 3,175
  • 5
  • 23
  • 50
  • You cannot make scripts suid – Andy Dalton Sep 04 '18 at 21:18
  • Possible duplicate of [How to run a specific program as root without a password prompt?](https://unix.stackexchange.com/questions/18830/how-to-run-a-specific-program-as-root-without-a-password-prompt) [as per chat](https://chat.stackexchange.com/transcript/message/46585482#46585482) – Fabby Sep 04 '18 at 22:30
  • @Thomas See above: wrong dupe. Too low rep to vote for reopen. – Fabby Sep 04 '18 at 22:31
  • Hum, I had a duplicate comment, but it seems to have disappeared. It was: https://unix.stackexchange.com/questions/364/allow-setuid-on-shell-scripts – Andy Dalton Sep 05 '18 at 13:36

0 Answers0