Bash scripting question

Roger Oberholtzer roger.oberholtzer
Mon May 17 11:47:52 PDT 2004


On Tue, 27 May 2003 13:49:56 -0400 (EDT)
<listmail at rotundus.com> wrote:

> Roger Oberholtzer wrote,
> > # This should echo command line parameters (or function paramaeters if
> > # placed in a shell function), one per line.
> >
> >
> > for param in $*
> > do
> > 	echo $param
> > done
> 
> Thanks to you and also David Bandel for the help.  I was hoping for a
> way in which I could reference a particular argument by number, but I
> suppose that I can accomplish the same by keeping a separate counter.
> 
> The next silly question, how to get something running w/ setuid root.
> 
> I have a little test script which has the following contents:
> ---
> #!/bin/bash
> set | grep UID

SUID scripts are a thorny issue. On UnixWare, for example, you had to
specify it on the command line of the shell command, so the very first
line in the script was something like:

#!/bin/sh -r

(probably not -r, but whatever command told the script to run SUID.)

We decided to skip SUID scripts in our software because support was more
iffy than the vagaries of the shells involved.

And, don't restrict yourself to bash and the like. Tcl is a fantastic
script language, with full access to the command line and
external commands.

Anyway, try adding -p to your shell command on the first line of the
script:

#!/bin/bash -p

and changing the script to belong to root, and 'chmod u+s' it.

Hope that works. I even recall something somewhere about kernel flags to
allow this. Maybe that is old. But if the -p does not do the trick...

-- 

Roger Oberholtzer
Sunny Stockholm


More information about the Linux-users mailing list