postgres.git / summary / log / commit / refs
commit bf8337b8af5a8eebb8f495da0c6fe0a4d3006d54
Author: Bruce Momjian <bruce@momjian.us>
Date: Fri Mar 03 21:52:37 2006 +0000
First released in: 8.2.0, 8.1.4
Update ipcclean to use try 'id' first for root check.
src/bin/ipcclean/ipcclean.sh | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/bin/ipcclean/ipcclean.sh b/src/bin/ipcclean/ipcclean.sh
index 9fc764e8a9a..f55f8c7e3a4 100644
--- a/src/bin/ipcclean/ipcclean.sh
+++ b/src/bin/ipcclean/ipcclean.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.17 2006/03/03 16:49:21 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.18 2006/03/03 21:52:37 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
[parent: 28edbdb7be4f]