nut: Fix unset of runas user (ups server)
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:
parent
ccdec71b5c
commit
5f69f9a065
1 changed files with 5 additions and 7 deletions
|
@ -39,12 +39,11 @@ upsd_statepath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
upsd_runas() {
|
upsd_runas() {
|
||||||
local cfg="$1"
|
|
||||||
local runas
|
local runas
|
||||||
|
|
||||||
[ -n "$RUNAS" ] && return
|
[ -n "$RUNAS" ] && return 0
|
||||||
|
|
||||||
config_get runas "$cfg" runas
|
config_get runas upsd runas
|
||||||
RUNAS="$runas"
|
RUNAS="$runas"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +222,6 @@ build_global_driver_config() {
|
||||||
get_write_driver_config "$cfg" synchronous
|
get_write_driver_config "$cfg" synchronous
|
||||||
config_get runas "$cfg" user
|
config_get runas "$cfg" user
|
||||||
RUNAS="$runas"
|
RUNAS="$runas"
|
||||||
upsd_runas
|
|
||||||
|
|
||||||
echo "" >>$UPS_C
|
echo "" >>$UPS_C
|
||||||
}
|
}
|
||||||
|
@ -239,11 +237,13 @@ build_config() {
|
||||||
config_load nut_server
|
config_load nut_server
|
||||||
config_foreach upsd_statepath upsd
|
config_foreach upsd_statepath upsd
|
||||||
|
|
||||||
|
upsd_runas
|
||||||
config_foreach build_global_driver_config driver_global
|
config_foreach build_global_driver_config driver_global
|
||||||
config_foreach build_driver_config driver
|
config_foreach build_driver_config driver
|
||||||
[ -n "$RUNAS" ] && chgrp $(id -gn $RUNAS) "$UPS_C"
|
[ -n "$RUNAS" ] && chgrp $(id -gn $RUNAS) "$UPS_C"
|
||||||
|
|
||||||
build_server_config
|
build_server_config
|
||||||
|
[ -n "$RUNAS" ] && chgrp "$(id -gn "$RUNAS")" "$UPS_C"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_driver_instance() {
|
start_driver_instance() {
|
||||||
|
@ -284,8 +284,7 @@ start_driver_instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start_server_instance() {
|
start_server_instance() {
|
||||||
local RUNAS
|
local cfg="$1"
|
||||||
build_config
|
|
||||||
|
|
||||||
[ "$haveserver" != 1 ] && return
|
[ "$haveserver" != 1 ] && return
|
||||||
|
|
||||||
|
@ -300,7 +299,6 @@ start_server_instance() {
|
||||||
start_service() {
|
start_service() {
|
||||||
local havedriver haveserver
|
local havedriver haveserver
|
||||||
local STATEPATH=/var/run/nut
|
local STATEPATH=/var/run/nut
|
||||||
local RUNAS
|
|
||||||
|
|
||||||
# Avoid hotplug inadvertenly restarting driver during
|
# Avoid hotplug inadvertenly restarting driver during
|
||||||
# forced shutdown
|
# forced shutdown
|
||||||
|
|
Loading…
Reference in a new issue