File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
#
3
- # $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.17 2006/03/03 16:49:21 momjian Exp $
3
+ # $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.18 2006/03/03 21:52:37 momjian Exp $
4
4
#
5
5
6
6
CMDNAME=` basename $0 `
@@ -19,8 +19,19 @@ if [ "$1" = '-?' -o "$1" = "--help" ]; then
19
19
exit 0
20
20
fi
21
21
22
- # only check $LOGNAME if $USER is not set
23
- if [ " $USER " = ' root' -o \( ! " $USER " -a " $LOGNAME " = ' root' \) ]
22
+ # test for running as root
23
+
24
+ ISROOT=" N"
25
+ if id -u > /dev/null 2>&1
26
+ then if [ ` id -u` -eq 0 ]
27
+ then ISROOT=" Y"
28
+ fi
29
+ elif # only check $LOGNAME if $USER is not set
30
+ [ " $USER " = ' root' -o \( ! " $USER " -a " $LOGNAME " = ' root' \) ]
31
+ then ISROOT=" Y"
32
+ fi
33
+
34
+ if [ " $ISROOT " = " Y" ]
24
35
then
25
36
(
26
37
echo " $CMDNAME : cannot be run as root" 1>&2
You can’t perform that action at this time.
0 commit comments