*BSD News Article 67382


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!inquo!in-news.erinet.com!bug.rahul.net!rahul.net!a2i!samba.rahul.net!rahul.net!a2i!news.PBI.net!decwrl!lll-winken.llnl.gov!hookup!news.mathworks.com!solaris.cc.vt.edu!jmurray
From: jmurray@vt.edu (John Murray)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Does setuid work???
Date: 30 Apr 1996 14:31:25 GMT
Organization: Virginia Tech
Lines: 34
Message-ID: <4m587t$8h6@solaris.cc.vt.edu>
References: <4m3ekt$7ar@portal.gmu.edu>
NNTP-Posting-Host: jmurray.async.vt.edu

[[CCed to author]]
In article <4m3ekt$7ar@portal.gmu.edu>,
Glen W. Mann <gmann@bugs.aditech.com> wrote:
>I have a script (perl 5) which needs to reset owner and permissions for
>a directory tree and its (harmless nuisance) files.  I've got the script 
>set to
>
>  -rwsr-xr-x  1 root   bin     1234 somedate/time FixFiles
>
>The script starts with #!/usr/bin/perl
>that is no switches.  I'm using the perl chmod and chown functions.  The 
>script only works if I run it as root.  As another user, it does nothing
>(unless of course the permissions allow it).
>Perhaps I am ignorant to the ways of setuid?  The documentation is a
>little sketchy for this. Can I do what I want?
>
>Any help for setuid?

FreeBSD and most other modern UNIX's will not let you run setuid scripts. 
But the perl authors knew this and made a special version of perl(comes with
the standard distribution) called suidperl, that allows setuid perl scripts. 
This version of perl also does checking to make sure your setuid prog is
some what safe.  To use suidperl just replace the #!/usr/bin/perl with
#!/usr/bin/suidperl and now your script should work.

Hope this Helps

-- 
	 Person Man aka John Murray -={+}=- <jmurray@vt.edu>
 		     http://jmurray.async.vt.edu/
 	The Unoffical Pritchard Web Site & Mailing List Admin
 	Check it out @ http://jmurray.async.vt.edu/pritchard/
 	      Powered By FreeBSD http://www.freebsd.org
  "I don't know whether I'd rather be having a bottle of vinegar" -TMBG