in reply to setuid scripts, how?

Unfortunatley Suid scripts don't work so well with perl, even when you use suidperl. It does set the euid and egid right, but not the uid and gid. So its really running as root but when it executes other programs like useradd for example they wont run as root when executed which is a major neusense.
So a good solution is to write a small wrapper in C and have it execute the script.

Something like this:
#include <unistd.h> int main(int argc, char** argv) { if (getuid() == 110) { setuid(geteuid()); setgid(getegid()); execl("/path/to/script.pl", NULL); } return 0; }

Replies are listed 'Best First'.
RE: RE: setuid scripts, how?
by tye (Sage) on Jul 27, 2000 at 01:10 UTC

    Your C code is the same as this Perl code:

    if( 110 == $< ) { $< = $>; $( = $); }

    So you could write this wrapper in Perl or, much better, just add this code to your SUID perl script.