Article View: sco.opendesktop
Article #61Re: Setting set-uid on a script
From: Chris Frederick
Date: Sat, 11 Jun 1994 01:33
Date: Sat, 11 Jun 1994 01:33
39 lines
2449 bytes
2449 bytes
>: We are running SCO v3.2.4.2 and are trying to make a root
>: owned script have a setuid attribute. We have done a chmod u+s
>: to it has well as having it owned by root. All to no avail. I am sure
>: this is in the FAQ but we couldn't find the FAQ. Could anybody give
>: us a lead ?
To the best of my knowledge, a shell script cannot be run SUID. This
appears to be true in SCO as well as most other flavors of Unix. However,
if you have either the development system or the GCC compiler, simply
compile a short C program to call the shell script. Make the C program
SUID root, and for security purposes chmod the shell script itself to 700.
Another word of caution: be absolutely sure that you specify a full
pathname to each external command you execute from the script, and be sure
that none of them are writable by unprivileged users. If you don't do
these things, it's very simple for anyone who can execute the script to
run (as root) anything they like.
Also note that for execl() to work properly (on most systems), the
"#! /bin/sh" must exist as the first line of the shell script. Use
whatever shell name you've written the script for, of course.
Sample code follows:
myscript.sh:
#! /bin/sh
/bin/ls -l | /bin/more
myls:
int main()
{
execl ("/usr/local/bin/myscript.sh", "myscript.sh", 0);
}
--
Chris Frederick | All things considered, insanity | To excel at something,
f1rederc@iia.org | is the only logical alternative. | you must love doing it.
Technical Details
Message-ID:
<2tb48i$8pe@mary.iia.org>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!EU.net!uunet!ankh.iia.org!mary.iia.org!not-for-mailReferences:
<Cr72uu.6Eo@world.std.com> <gburnoreCr7Czw.Jnz@netcom.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1020c6,ddbf95e66b947726 X-Google-Attributes: gid1020c6,public X-Google-Thread: ff1d1,ddbf95e66b947726 X-Google-Attributes: gidff1d1,public X-Google-Thread: 1122ea,ddbf95e66b947726 X-Google-Attributes: gid1122ea,public X-Google-Thread: 134180,ddbf95e66b947726 X-Google-Attributes: gid134180,public X-Google-ArrivalTime: 1994-06-10 18:41:59 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!EU.net!uunet!ankh.iia.org!mary.iia.org!not-for-mail From: f1rederc@mary.iia.org (Chris Frederick) Newsgroups: sco.opendesktop,biz.sco.general,biz.sco.opendesktop,comp.unix.admin Subject: Re: Setting set-uid on a script Date: 10 Jun 1994 21:33:06 -0400 Organization: International Internet Association Lines: 39 Message-ID: <2tb48i$8pe@mary.iia.org> References: <Cr72uu.6Eo@world.std.com> <gburnoreCr7Czw.Jnz@netcom.com> NNTP-Posting-Host: mary.iia.org