From c9b28a3125156df1e5361ed5e9c246739159d51e Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Mon, 29 Mar 2021 08:06:10 +0200 Subject: [PATCH] mpd: run mpd as a non-root user * Make /etc/mpd.conf worldreadable. Signed-off-by: Alexander Egorenkov --- sound/mpd/Makefile | 5 +++-- sound/mpd/files/mpd.init | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sound/mpd/Makefile b/sound/mpd/Makefile index f8fd18cb5a..8a7af13685 100644 --- a/sound/mpd/Makefile +++ b/sound/mpd/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mpd PKG_VERSION:=0.22.6 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://www.musicpd.org/download/mpd/0.22/ @@ -35,6 +35,7 @@ define Package/mpd/Default URL:=https://www.musicpd.org/ DEPENDS:= +zlib +libcurl +libpthread +libmpdclient +boost $(ICONV_DEPENDS) \ +AUDIO_SUPPORT:alsa-lib +libexpat +libflac +libid3tag +libfaad2 +libopus + USERID:=mpd:mpd endef define Package/mpd/Default/description @@ -220,7 +221,7 @@ define Package/mpd/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mpd $(1)/usr/bin/ $(INSTALL_DIR) $(1)/etc - $(INSTALL_CONF) $(PKG_BUILD_DIR)/doc/mpdconf.example $(1)/etc/mpd.conf + $(INSTALL_DATA) $(PKG_BUILD_DIR)/doc/mpdconf.example $(1)/etc/mpd.conf $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/mpd.init $(1)/etc/init.d/mpd endef diff --git a/sound/mpd/files/mpd.init b/sound/mpd/files/mpd.init index 9ec164db7e..f89049d6cc 100644 --- a/sound/mpd/files/mpd.init +++ b/sound/mpd/files/mpd.init @@ -9,6 +9,9 @@ PROG=/usr/bin/mpd CONFIGFILE=/etc/mpd.conf NICEPRIO=-10 +USER="mpd" +GROUP="mpd" + #TODO: Add uci config - nice, config start_service() { @@ -16,7 +19,10 @@ start_service() { #create mpd directories from config pld=$(grep ^playlist_directory "$CONFIGFILE" | cut -d "\"" -f 2 | sed "s/~/\/root/g") - [ -d "$pld" ] || mkdir -m 0755 -p "$pld" + if [ ! -d "$pld" ]; then + mkdir -m 0755 -p "$pld" + chown $USER:$GROUP $pld + fi lport=$(grep ^port "$CONFIGFILE" | cut -d "\"" -f 2) [ -z "$lport" ] && lport=6600 @@ -24,6 +30,8 @@ start_service() { procd_open_instance procd_add_mdns "mpd" "tcp" "$lport" procd_set_param command "$PROG" --no-daemon "$CONFIGFILE" + procd_set_param user "$USER" + procd_set_param group "$GROUP" procd_set_param stderr 1 # Give MPD some real-time priority procd_set_param nice "$NICEPRIO" -- 2.30.2