[SC.LUG] set user id

Dr A V Le Blanc sc at mailman.lug.org.uk
Mon Jul 14 07:34:00 2003


On 13 Jul 2003, Garry Stanway wrote:
> Just create the script as root and then use 
> 
> chmod 4755 script
> 
> and it should work.

On Sun, Jul 13, 2003 at 06:13:05PM +0100, Robert Marshall wrote:
> You can't set scripts to run as root by that method - it would be a big
> security hole!
> I suggest you use sudo - if you have it if not install it

Or alternatively, write a C program to wrap the script, and make
the compiled binary suid.

     void execl (char *path, ...);
     extern int errno;

     int main (void) {
       setgid(0);
       setuid(0);
       execl("/usr/sbin/myscript", "myscript", (char *) 0);
       return (errno);
     }

ought to work for most purposes.

     -- Owen
     LeBlanc@mcc.ac.uk