nut: Fix upsd runs as root
authorDaniel F. Dickinson <cshored@thecshore.com>
Wed, 5 Dec 2018 06:31:40 +0000 (01:31 -0500)
committerDaniel F. Dickinson <cshored@thecshore.com>
Thu, 6 Dec 2018 08:02:29 +0000 (03:02 -0500)
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>
net/nut/Makefile
net/nut/files/nut-server.init

index db0897926673a3c962207d913716800ecd2a57e4..0074aa060671abb7b251efdeb69860823bab6e16 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=nut
 PKG_VERSION:=2.7.4
-PKG_RELEASE:=10
+PKG_RELEASE:=11
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/
index 201a3ba85090906b16a6696810b2a934be80a5d5..045b29d48d06e1428b7b120c0ac94be68955f979 100755 (executable)
@@ -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
 }