Re: Executing run command for scripts as su
Posted in 2004
Franz Grutzmacher needed to run shell scripts as root on old SCO Unix but had no C compiler for Doug Lawry's setuid wrapper. Doug thought SCO 5.0.5 included one or else free GNU gcc could be installed. Clive Eisen said there is no free compiler but free headers exist. Paul Watson said the development kit might be needed and gcc from source failed for him. Unresolved.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Ahhh but that is another catch.. We don't have a c compiler for this environment and because it is so old I can get any c compiler. Do anyone of you have a compiler for me? ----- Original Message ----- From: "Doug Lawry" <lawry@nildram.co.uk> To: <informix-list@iiug.org> Sent: Thursday, June 24, 2004 2:52 PM Subject: Re: Executing run command for scripts as su 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 sending to informix-list
I thought SCO Unix 5.0.5 came with a C compiler as standard: check the CD. If not, install the free GNU C compiler. See: http://gcc.gnu.org ftp://ftp2.sco.com/pub/skunkware/osr5/devtools/gcc/ Franz Gr'tzmacher said: > Ahhh but that is another catch.. We don't have a c compiler for this > environment and because it is so old I can get any c compiler. Do anyone of > you have a compiler for me? > > > ----- Original Message ----- > From: "Doug Lawry" <lawry@nildram.co.uk> > To: <informix-list@iiug.org> > Sent: Thursday, June 24, 2004 2:52 PM > Subject: Re: Executing run command for scripts as su > > > 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
Doug Lawry wrote: > I thought SCO Unix 5.0.5 came with a C compiler as standard: check the CD. > If not, install the free GNU C compiler. See: > Nope - no free C compiler but you do have free headers Then - as you say - install GCC
I think you need the development kit. The last time I looked it could be downloaded, but I think you needed a username/password. I might still have a copy somewhere. I tried to install gcc from source but it threw a wobbler and I couldn't find a binary install Doug Lawry wrote: > > I thought SCO Unix 5.0.5 came with a C compiler as standard: check the CD. > If not, install the free GNU C compiler. See: > > http://gcc.gnu.org > ftp://ftp2.sco.com/pub/skunkware/osr5/devtools/gcc/ > > Franz Gr'tzmacher said: > > > Ahhh but that is another catch.. We don't have a c compiler for this > > environment and because it is so old I can get any c compiler. Do anyone of > > you have a compiler for me? > > > > > > ----- Original Message ----- > > From: "Doug Lawry" <lawry@nildram.co.uk> > > To: <informix-list@iiug.org> > > Sent: Thursday, June 24, 2004 2:52 PM > > Subject: Re: Executing run command for scripts as su > > > > > > 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 -- Paul Watson # Oninit Ltd # Growing old is mandatory Tel: +44 1436 672201 # Growing up is optional Fax: +44 1436 678693 # Mob: +44 7818 003457 # www.oninit.com #