mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Update ipcclean to use try 'id' first for root check.
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.15.6.1 2006/03/03 16:49:30 momjian Exp $
|
# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.15.6.2 2006/03/03 21:52:47 momjian Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
CMDNAME=`basename $0`
|
CMDNAME=`basename $0`
|
||||||
@ -19,8 +19,19 @@ if [ "$1" = '-?' -o "$1" = "--help" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only check $LOGNAME if $USER is not set
|
# test for running as root
|
||||||
if [ "$USER" = 'root' -o \( ! "$USER" -a "$LOGNAME" = 'root' \) ]
|
|
||||||
|
ISROOT="N"
|
||||||
|
if id -u >/dev/null 2>&1
|
||||||
|
then if [ `id -u` -eq 0 ]
|
||||||
|
then ISROOT="Y"
|
||||||
|
fi
|
||||||
|
elif # only check $LOGNAME if $USER is not set
|
||||||
|
[ "$USER" = 'root' -o \( ! "$USER" -a "$LOGNAME" = 'root' \) ]
|
||||||
|
then ISROOT="Y"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ISROOT" = "Y" ]
|
||||||
then
|
then
|
||||||
(
|
(
|
||||||
echo "$CMDNAME: cannot be run as root" 1>&2
|
echo "$CMDNAME: cannot be run as root" 1>&2
|
||||||
|
Reference in New Issue
Block a user