dnsmasq: run as dedicated UID/GID
authorJohn Crispin <john@openwrt.org>
Tue, 26 Apr 2016 11:44:10 +0000 (11:44 +0000)
committerJohn Crispin <john@openwrt.org>
Tue, 26 Apr 2016 11:44:10 +0000 (11:44 +0000)
Running dnsmasq in a dedicated user/group allows matching its outgoing
traffic more easily using iptables' owner match.
Add UID/GID to the package metadata and append the user/group
parameters to the init script.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
SVN-Revision: 49252

package/network/services/dnsmasq/Makefile
package/network/services/dnsmasq/files/dnsmasq.init

index a5c37401798e4f9edf655e11f8a15eac7ddf8aea..a5b96a3d28e7735f39040f3a5b08beda75d0e142 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsmasq
 PKG_VERSION:=2.75
-PKG_RELEASE:=6
+PKG_RELEASE:=7
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
@@ -34,6 +34,7 @@ define Package/dnsmasq/Default
   CATEGORY:=Base system
   TITLE:=DNS and DHCP server
   URL:=http://www.thekelleys.org.uk/dnsmasq/
+  USERID:=dnsmasq=453:dnsmasq=453
 endef
 
 define Package/dnsmasq
index 0cda02d4feaa70a3502b8d99021bca1c65504931..7f90b8fa3e2744d9cb685671b67057e221006ff0 100644 (file)
@@ -218,6 +218,8 @@ dnsmasq() {
        mkdir -p /tmp/hosts /tmp/dnsmasq.d
        xappend "--addn-hosts=/tmp/hosts"
        xappend "--conf-dir=/tmp/dnsmasq.d"
+       xappend "--user=dnsmasq"
+       xappend "--group=dnsmasq"
 
        echo >> $CONFIGFILE
 
@@ -592,7 +594,7 @@ start_service() {
 
        if [ ! -f "$TIMESTAMPFILE" ]; then
                touch "$TIMESTAMPFILE"
-               chown nobody.nogroup "$TIMESTAMPFILE"
+               chown dnsmasq.dnsmasq "$TIMESTAMPFILE"
        fi
 
        echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE