Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 4d3ddef

Browse files
author
Jeremy McCoy
committed
changed requireuser back to USER, reversed check for checkpid
1 parent 3a0891f commit 4d3ddef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bblib.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ checkpid () {
169169
local PIDFILE="${PIDFILE:-${0}.pid}"
170170
if [ ! -d "/proc/$$" ]; then
171171
quit "ERROR" "This function requires procfs. Are you on Linux?"
172-
elif [ -f "${PIDFILE}" ] && [ "$(cat "${PIDFILE}" 2> /dev/null)" != "$$" ] ; then
172+
elif [ -f "${PIDFILE}" ] && [ "$(cat "${PIDFILE}" 2> /dev/null)" == "$$" ] ; then
173173
quit "WARN" "This script is already running with PID $(cat "${PIDFILE}" 2> /dev/null), exiting"
174174
else
175175
echo -n "$$" > "${PIDFILE}"
@@ -185,10 +185,10 @@ requireuser () {
185185
local REQUIREUSER="${1:-${REQUIREUSER:-}}"
186186
if [ -z "${REQUIREUSER:-}" ] ; then
187187
quit "ERROR" "requireuser was called, but \$REQUIREUSER is not set"
188-
elif [ "$REQUIREUSER" != "$EUID" ] ; then
188+
elif [ "$REQUIREUSER" != "$USER" ] ; then
189189
quit "ERROR" "Only $REQUIREUSER is allowed to run this script"
190190
else
191-
log "DEBUG" "User '$EUID' matches '$REQUIREUSER' and is allowed to run this script"
191+
log "DEBUG" "User '$USER' matches '$REQUIREUSER' and is allowed to run this script"
192192
fi
193193
}
194194

0 commit comments

Comments
 (0)