Browse Source

mpd: run mpd as a non-root user

* Make /etc/mpd.conf worldreadable.

Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
lilik-openwrt-22.03
Alexander Egorenkov 4 years ago
parent
commit
c9b28a3125
2 changed files with 12 additions and 3 deletions
  1. +3
    -2
      sound/mpd/Makefile
  2. +9
    -1
      sound/mpd/files/mpd.init

+ 3
- 2
sound/mpd/Makefile View File

@ -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


+ 9
- 1
sound/mpd/files/mpd.init View File

@ -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"


Loading…
Cancel
Save