From d06bd2d7e3853fe025cd92b37a5d7218a0345a5f Mon Sep 17 00:00:00 2001 From: "Daniel F. Dickinson" Date: Mon, 26 Aug 2019 23:38:10 -0400 Subject: [PATCH] nut: Fix unset of runas user (upsmon) Running as non-root was failing due to misplace local keyword causing runas to be unset from calling value. Signed-off-by: Daniel F. Dickinson --- net/nut/files/nut-monitor.init | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/nut/files/nut-monitor.init b/net/nut/files/nut-monitor.init index 56c12c0ae..f094a82ba 100755 --- a/net/nut/files/nut-monitor.init +++ b/net/nut/files/nut-monitor.init @@ -6,11 +6,13 @@ UPSMON_C=/var/etc/nut/upsmon.conf nut_upsmon_conf() { local cfg="$1" + local RUNAS val optval echo "# Config file automatically generated from UCI config" > "$UPSMON_C" - config_get runas "$cfg" runas - [ -n "$runas" ] && echo "RUN_AS_USER $runas" >> $UPSMON_C + config_get RUNAS "$cfg" runas + [ -n "$RUNAS" ] && echo "RUN_AS_USER $RUNAS" >> "$UPSMON_C" + runas="$RUNAS" config_get val "$cfg" minsupplies 1 echo "MINSUPPLIES $val" >> "$UPSMON_C" @@ -143,7 +145,6 @@ nut_upsmon_add() { } build_config() { - local runas mkdir -m 0750 -p "$(dirname "$UPSMON_C")" config_load nut_monitor @@ -162,6 +163,7 @@ build_config() { } start_service() { + local runas local havemon havems build_config @@ -178,6 +180,7 @@ start_service() { reload_service() { if pgrep upsmon >/dev/null 2>/dev/null; then + local runas build_config /usr/sbin/upsmon -c reload else