Ahhh; the code watching for a password prompt from su was giving the impression you weren't root already.

If you just need to switch to a different user and you're already root then just fork, set $< to the uid of the user in question (or call POSIX::setuid), and exec the script which does the real work.

Update: OK, reading again it looks like it is nobody that'll be running this. Again, I'd see no problems with a sudo config which allows nobody to run one specific script which immediately drops to the user UID and execs another specific script to do the actual work. If you were truly paranoid you'd write a minimalist wrapper in C and make that suid root (if you're really, really paranoid you'll snip the cat5 and be done with it . . . :).

Another possibility: use suexec to run this one CGI as another not-nobody unpriviledged account which is allowed to sudo to the desired user and run the real work.


In reply to Re: Re: Re: Faster way to do su by Fletch
in thread Faster way to do su by jcpunk

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.