Dear keepers of wisdom,

I'm trying to write a perl program to allow users to mount removable media and Samba shares into their own home directory. The script shall enforce certain options and will not allow file systems, which cannot be squashed to the user, i.e. support uid,gid options. The program has suid root and uses the perl-suid interpreter. The system is a Debian Lenny Linux.

The program basically works nicely, except for a crucial detail

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

As can be seen from the debugging output EUID is 0, which is confirmed by a forked whoami. mount obviously considers the program as non-root. This is how I call this mount:

system("$cmd_mount -t $fs -o $mand_opt $dev $mountpath");

Since Google produces a lot of hits indicating that Perl shall be the choice for such mount scripts, but does not produce a good example, I guess that this issue should be nothing principle.

Could you initiate me to the blessings of perl-suid?


In reply to why does perl-suid not mount by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.