]> granicus.if.org Git - postgresql/commitdiff
Update ipcclean to use try 'id' first for root check.
authorBruce Momjian <bruce@momjian.us>
Fri, 3 Mar 2006 21:52:47 +0000 (21:52 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 3 Mar 2006 21:52:47 +0000 (21:52 +0000)
src/bin/ipcclean/ipcclean.sh

index 0aff9071a7faf81cb9f2f694484c2b69520a2700..62490dfb48eef7502dba27e80ea330d15d0c51a6 100644 (file)
@@ -1,6 +1,6 @@
 #!/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`
@@ -19,8 +19,19 @@ if [ "$1" = '-?' -o "$1" = "--help" ]; then
     exit 0
 fi
 
-# only check $LOGNAME if $USER is not set
-if [ "$USER" = 'root' -o \( ! "$USER" -a "$LOGNAME" = 'root' \) ]
+# test for running as 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
   (
     echo "$CMDNAME: cannot be run as root" 1>&2