Article View: sco.opendesktop
Article #65Re: Setting set-uid on a script
From: Dave Carrigan
Date: Mon, 13 Jun 1994 15:29
Date: Mon, 13 Jun 1994 15:29
37 lines
2612 bytes
2612 bytes
gb@buran.fb10.tu-berlin.de (Guenter Becker) writes:
>You are right, you can't suid a shell script. Someone said, this is for
>security reasons. What you can do, if you have network software installed:
>rcmd localhost -l root <command>
>This is not very secure, however ...
Suid shell scripts are extremely dangerous. One owned by root means
guaranteed root access to any bad guy who wants it. If you absolutely
must run a shell script suid, the trick is to write a C wrapper
program. The wrapper is suid instead of the script, and its job is to
call the shell script. This avoids the biggest danger of suid shell
scripts (a race condition; see the security faq). The truly paranoid
will turf the environment before calling the script as well. I'm not
saying that this is 100% safe, no script run by root can ever be safe.
However it avoids some of the real big holes.
The following program demonstrates a wrapper. It ain't that tough, and
will offer you much more protection.
Naturally, I'm not responsible for anything if the stupid little thing
does something ugly to your system...
--------wrapper.c-----------
#include <stdio.h>
extern char **environ;
main (int argc, char *argv[])
{
environ[0] = NULL;
execv("/the/path/to/my/script",argv);
fprintf(stderr, "Hmm, this shouldn't happen.\n");
}
--
^
dcarrigan@nofc.forestry.ca /|\ Canadian Forest Service, NW Region
Dave Carrigan /|\ Northern Forestry Centre
|
Technical Details
Message-ID:
<2thu1d$hai@dragon.nofc.forestry.ca>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!unixg.ubc.ca!quartz.ucs.ualberta.ca!NoFC.Forestry.CA!usenetReferences:
<gburnoreCr7Czw.Jnz@netcom.com> <2thlav$oio@news.cs.tu-berlin.de>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 134180,ddbf95e66b947726 X-Google-Attributes: gid134180,public X-Google-Thread: 1122ea,ddbf95e66b947726 X-Google-Attributes: gid1122ea,public X-Google-Thread: ff1d1,ddbf95e66b947726 X-Google-Attributes: gidff1d1,public X-Google-Thread: 1020c6,ddbf95e66b947726 X-Google-Attributes: gid1020c6,public X-Google-ArrivalTime: 1994-06-13 08:51:40 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!unixg.ubc.ca!quartz.ucs.ualberta.ca!NoFC.Forestry.CA!usenet From: dcarriga@dragon.nofc.forestry.ca (Dave Carrigan) Newsgroups: sco.opendesktop,biz.sco.general,biz.sco.opendesktop,comp.unix.admin Subject: Re: Setting set-uid on a script Date: 13 Jun 1994 09:29:49 -0600 Organization: Northern Forestry Centre, Northwest Region, Canadian Forest Service Lines: 37 Message-ID: <2thu1d$hai@dragon.nofc.forestry.ca> References: <gburnoreCr7Czw.Jnz@netcom.com> <2thlav$oio@news.cs.tu-berlin.de> NNTP-Posting-Host: dragon.nofc.forestry.ca