Executing run command for scripts as su
Posted in 2004
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi All Do anybody know how I can execute a script that need to modify root owned files as a normal user. I am executing a script with the run command from within 4gl program. This script generates an index.html file on my Sco UNIX server but the problem is that the file belongs to root. I have already set the files permissions to 777 but still my normal user can't overwrite the new file. Is there a way to run as su ??? Our versions: SCO Unix vers 5.0.5 Informix SE 5.08.UD1 SQL vers 4.17.UC1 RDS vers 4.17.UC1 Thanx Franz Gr'tzmacher sending to informix-list
Make root the owner of the script and set the so-called "su" bit on (see man chmod, but usually chmod 4755 file will do it), that way it'll execute as "root." Better yet, think it through -- why are you altering a file that belongs to root? Is there an alternative? Franz Gr'tzmacher wrote: >Hi All > >Do anybody know how I can execute a script that need to modify root owned >files as a normal user. > >I am executing a script with the run command from within 4gl program. This >script generates an index.html file on my Sco UNIX server but the problem is >that the file belongs to root. I have already set the files permissions to >777 >but still my normal user can't overwrite the new file. > >Is there a way to run as su ??? > >Our versions: >SCO Unix vers 5.0.5 >Informix SE 5.08.UD1 >SQL vers 4.17.UC1 >RDS vers 4.17.UC1 > >Thanx >Franz Gr'tzmacher > > > > >sending to informix-list > >
That doesn't work on Shell scripts unless you: 1) compile the C program "setuid" (source follows); 2) use "chown root" and "chmod 4755" on this and the script; 3) run using "setuid script-path-name". -- Regards, Doug Lawry www.douglawry.webhop.org __________ __| setuid.c |______________________________________________________ /* Run a Shell script with "setuid" bits - Doug Lawry, 24/06/2004 */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> main(argc, argv) int argc; char *argv[]; { struct stat st; if (argc < 2) { fprintf(stderr, "Usage: %s command [arguments]\\n", argv[0]); exit(1); } if (stat(argv[1], &st) != 0) { fprintf(stderr, "%s: cannot stat %s\\n", argv[0], argv[1]); exit(2); } st.st_mode & S_ISGID && setgid(st.st_gid); st.st_mode & S_ISUID && setuid(st.st_uid); execvp(argv[1], ++argv); exit(3); } "Thomas Ronayne" <trona@REMOVETHISameritech.net> wrote: > Make root the owner of the script and set the so-called "su" bit on (see > man chmod, but usually chmod 4755 file will do it), that way it'll > execute as "root." > > Better yet, think it through -- why are you altering a file that belongs > to root? Is there an alternative? > > "Franz Gr'tzmacher" <franzg@biblesociety.co.za> wrote: > >> Hi All >> >> Do anybody know how I can execute a script that need to modify root owned >> files as a normal user. >> >> I am executing a script with the run command from within 4gl program. This >> script generates an index.html file on my Sco UNIX server but the problem is >> that the file belongs to root. I have already set the files permissions to >> 777 but still my normal user can't overwrite the new file. >> >> Is there a way to run as su ??? >> >> Our versions: >> SCO Unix vers 5.0.5 >> Informix SE 5.08.UD1 >> SQL vers 4.17.UC1 >> RDS vers 4.17.UC1 >> >> Thanx >> Franz Gr'tzmacher