Browse Source

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>
lilik-openwrt-22.03
Daniel F. Dickinson 6 years ago
parent
commit
f48b060fa7
2 changed files with 12 additions and 1 deletions
  1. +1
    -1
      net/nut/Makefile
  2. +11
    -0
      net/nut/files/nut-server.init

+ 1
- 1
net/nut/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nut PKG_NAME:=nut
PKG_VERSION:=2.7.4 PKG_VERSION:=2.7.4
PKG_RELEASE:=10
PKG_RELEASE:=11
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/ PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/


+ 11
- 0
net/nut/files/nut-server.init View File

@ -38,6 +38,16 @@ upsd_statepath() {
STATEPATH="$statepath" STATEPATH="$statepath"
} }
upsd_runas() {
local cfg="$1"
local runas
[ -n "$RUNAS" ] && return
config_get runas "$cfg" runas "nut"
RUNAS="$runas"
}
listen_address() { listen_address() {
local cfg="$1" local cfg="$1"
@ -213,6 +223,7 @@ build_global_driver_config() {
get_write_driver_config "$cfg" synchronous get_write_driver_config "$cfg" synchronous
config_get runas "$cfg" user "nut" config_get runas "$cfg" user "nut"
RUNAS="$runas" RUNAS="$runas"
upsd_runas
echo "" >>$UPS_C echo "" >>$UPS_C
} }


Loading…
Cancel
Save