From 473a2c59e2c82d7b2798fa1b82d1574d7655e433 Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 24 Nov 2021 12:09:42 +0300 Subject: [PATCH] install_easy: do not use privileged /proc/1/exe --- install_easy.sh | 3 ++- uninstall_easy.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/install_easy.sh b/install_easy.sh index 2d6a91f..219d116 100755 --- a/install_easy.sh +++ b/install_easy.sh @@ -206,7 +206,8 @@ check_system() local UNAME=$(uname) if [ "$UNAME" = "Linux" ]; then - local INIT="$(basename $(readlink /proc/1/exe))" + # do not use 'exe' because it requires root + local INIT="$(basename $(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1))" # some distros include systemctl without systemd if [ -d "$SYSTEMD_DIR" ] && [ -x "$SYSTEMCTL" ] && [ "$INIT" = "systemd" ]; then SYSTEM=systemd diff --git a/uninstall_easy.sh b/uninstall_easy.sh index 84eb903..5e3b6c0 100755 --- a/uninstall_easy.sh +++ b/uninstall_easy.sh @@ -53,7 +53,8 @@ check_system() local UNAME=$(uname) if [ "$UNAME" = "Linux" ]; then - local INIT="$(basename $(readlink /proc/1/exe))" + # do not use 'exe' because it requires root + local INIT="$(basename $(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1))" # some distros include systemctl without systemd if [ -d "$SYSTEMD_DIR" ] && [ -x "$SYSTEMCTL" ] && [ "$INIT" = "systemd" ]; then SYSTEM=systemd