mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
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 <cshored@thecshore.com>
This commit is contained in:
@@ -6,11 +6,13 @@ UPSMON_C=/var/etc/nut/upsmon.conf
|
|||||||
|
|
||||||
nut_upsmon_conf() {
|
nut_upsmon_conf() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
|
local RUNAS val optval
|
||||||
|
|
||||||
echo "# Config file automatically generated from UCI config" > "$UPSMON_C"
|
echo "# Config file automatically generated from UCI config" > "$UPSMON_C"
|
||||||
|
|
||||||
config_get runas "$cfg" runas
|
config_get RUNAS "$cfg" runas
|
||||||
[ -n "$runas" ] && echo "RUN_AS_USER $runas" >> $UPSMON_C
|
[ -n "$RUNAS" ] && echo "RUN_AS_USER $RUNAS" >> "$UPSMON_C"
|
||||||
|
runas="$RUNAS"
|
||||||
|
|
||||||
config_get val "$cfg" minsupplies 1
|
config_get val "$cfg" minsupplies 1
|
||||||
echo "MINSUPPLIES $val" >> "$UPSMON_C"
|
echo "MINSUPPLIES $val" >> "$UPSMON_C"
|
||||||
@@ -143,7 +145,6 @@ nut_upsmon_add() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build_config() {
|
build_config() {
|
||||||
local runas
|
|
||||||
mkdir -m 0750 -p "$(dirname "$UPSMON_C")"
|
mkdir -m 0750 -p "$(dirname "$UPSMON_C")"
|
||||||
|
|
||||||
config_load nut_monitor
|
config_load nut_monitor
|
||||||
@@ -162,6 +163,7 @@ build_config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
local runas
|
||||||
local havemon havems
|
local havemon havems
|
||||||
build_config
|
build_config
|
||||||
|
|
||||||
@@ -178,6 +180,7 @@ start_service() {
|
|||||||
|
|
||||||
reload_service() {
|
reload_service() {
|
||||||
if pgrep upsmon >/dev/null 2>/dev/null; then
|
if pgrep upsmon >/dev/null 2>/dev/null; then
|
||||||
|
local runas
|
||||||
build_config
|
build_config
|
||||||
/usr/sbin/upsmon -c reload
|
/usr/sbin/upsmon -c reload
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user