Skip to content

Commit bf8337b

Browse files
committed
Update ipcclean to use try 'id' first for root check.
1 parent 28edbdb commit bf8337b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/bin/ipcclean/ipcclean.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
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 $
44
#
55

66
CMDNAME=`basename $0`
@@ -19,8 +19,19 @@ if [ "$1" = '-?' -o "$1" = "--help" ]; then
1919
exit 0
2020
fi
2121

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" ]
2435
then
2536
(
2637
echo "$CMDNAME: cannot be run as root" 1>&2

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy