aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-03 13:53:36 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-03 13:53:36 +0100
commit53352c467ec736da985172ac4748516f8fd59ab6 (patch)
tree118cf3560f6dee19cbfc642147e741e2886915f2
parentm (diff)
downloadradharc-53352c467ec736da985172ac4748516f8fd59ab6.tar.gz
radharc-53352c467ec736da985172ac4748516f8fd59ab6.tar.bz2
radharc-53352c467ec736da985172ac4748516f8fd59ab6.tar.xz
restart-radharc: only kill your own radharc, otherwise it is possible that root kills another user's radharc and replaces it with an instances own by root.
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rwxr-xr-xextra/restart-radharc7
1 files changed, 5 insertions, 2 deletions
diff --git a/extra/restart-radharc b/extra/restart-radharc
index d652deb..96af888 100755
--- a/extra/restart-radharc
+++ b/extra/restart-radharc
@@ -31,10 +31,13 @@ for fd in $(ls -1 /dev/fd/); do
fi
done
+# Get the user's real UID, in a sh-portable way.
+uid="$(cat /proc/self/status | grep '^Uid:' | cut -f 2)"
+
# Restart all instances of radharc.
-for pid in pgrep -x radharc; do
+for pid in pgrep -x -U $uid radharc; do
# Open environ and cmdline and be sure that they we successfully opened.
- # It is possible that the process has exited, or is not yours.
+ # It is possible that the process has exited.
exec 3<proc/"$pid"/environ 2>/dev/null
if [ ! $? = 0 ]; then
continue