in reply to why does perl-suid not mount

Developers are trying to get rid of suid. See Using setcap instead of suid . Also the sudo command might be helpful to you, see sudo

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: why does perl-suid not mount
by Anonymous Monk on Nov 10, 2010 at 13:08 UTC

    setcap was worth a try.

    # install -o root -g users -m 750 /home/lh/prog/hmount/hmount.pl /home +/lh/prog/hmount/hmount # setcap cap_dac_override,cap_sys_admin+ep /home/lh/prog/hmount/hmount

    I'm not proficient with the capability system, but these caps were proposed for the mount command in the link that you supplied. The effect was similar and still mount denies its service:

    ~/prog/hmount$ ./hmount --usb= ~/mnt Real uid: 1000 Effective uid: 1000 whoami> lh INFO: Attached sda: (sda1 sda2 sda3) on USB bus 17:0:0:0 mount: only root can do that

    sudo on the other hand does not transport the real uid to the program, does it? So the program cannot determine what the $home of the real user may be, i.e. where mounting is deemed to be allowed.

    Anyhow, thanks for theese ideas.

      So the program cannot determine what the $home of the real user may be...
      sudo normally sets $SUDO_UID and $SUDO_USER to the calling (original) user, which you could query in your script.

        That was a great hint. I modified the script to check for $SUDO_UID and it runs like a charm.

        Thanks a lot.

        After tidying it up, I'll put it on github in case anybody faces similar challenges.