Re: [Linuxcommand-discuss] security_check
Brought to you by:
bshotts
|
From: Tomi O. <Tom...@so...> - 2000-06-19 06:15:11
|
Sunday Jun 18 13:23:08 -0400 2000 root <ro...@te...> wrote:
>
> Here's a small function that may want to be included into the the
> new_script program:
>
> --CUT--
>
> function security_check
> {
> #####
> # check to make sure the person running this is root or
> # equivalent
> #####
>
> if [ `id -u` != 0 ]; then
> echo "ERROR: Only Superuser may use this program."
> exit 1
> fi
> }
What I have used instead of this:
if [ x`id | sed 's/uid=\([0-9]*\).*/\1/'` != x0 ]
then
echo "$0 needs root access."
echo -n "Please enter your root account name (Default: root) "
read account
exec /bin/su ${account:-root} -c $0 $*
fi
The reason for using id like this that it is more portable across UNIX
platforms.
> | Systems Administrator . technolust.cx irc.spamnet.org 6667 |
Tomi
|