mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 23:18:42 +01:00
nut: Fix upsd runs as root
Closes #6997 - Allows upsd to runas a non-privileged user. If any driver is running as non-privileged user, the last driver's user will be used as the server non-privileged user, otherwise the user specified in config upsd, otherwise nut. Previously the localisation of RUNAS variable was in the wrong locations. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
This commit is contained in:
@@ -38,6 +38,16 @@ upsd_statepath() {
|
||||
STATEPATH="$statepath"
|
||||
}
|
||||
|
||||
upsd_runas() {
|
||||
local cfg="$1"
|
||||
local runas
|
||||
|
||||
[ -n "$RUNAS" ] && return
|
||||
|
||||
config_get runas "$cfg" runas "nut"
|
||||
RUNAS="$runas"
|
||||
}
|
||||
|
||||
listen_address() {
|
||||
local cfg="$1"
|
||||
|
||||
@@ -213,6 +223,7 @@ build_global_driver_config() {
|
||||
get_write_driver_config "$cfg" synchronous
|
||||
config_get runas "$cfg" user "nut"
|
||||
RUNAS="$runas"
|
||||
upsd_runas
|
||||
|
||||
echo "" >>$UPS_C
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user