[78140] trunk/dports/audio/mpd

jmr at macports.org jmr at macports.org
Mon Apr 25 07:46:43 PDT 2011


Revision: 78140
          http://trac.macports.org/changeset/78140
Author:   jmr at macports.org
Date:     2011-04-25 07:46:39 -0700 (Mon, 25 Apr 2011)
Log Message:
-----------
mpd: don't run as root (#24042), fix config file handling, use notes

Modified Paths:
--------------
    trunk/dports/audio/mpd/Portfile
    trunk/dports/audio/mpd/files/mpd.conf

Modified: trunk/dports/audio/mpd/Portfile
===================================================================
--- trunk/dports/audio/mpd/Portfile	2011-04-25 12:56:57 UTC (rev 78139)
+++ trunk/dports/audio/mpd/Portfile	2011-04-25 14:46:39 UTC (rev 78140)
@@ -5,6 +5,7 @@
 
 name                mpd
 version             0.16.2
+revision            1
 categories          audio
 maintainers         milosh rmstonecipher openmaintainer
 description         Music Player Daemon
@@ -63,6 +64,13 @@
 platform darwin 10 {
     patchfiles patch-src-output-osx_plugin.c 
 }
+
+if {"darwin" == ${os.platform} && ${os.major} > 8} {
+    set mpduser       _mpd
+} else {
+    set mpduser       mpd
+}
+
 startupitem.create  yes
 startupitem.start   "${prefix}/bin/mpd --no-daemon ${prefix}/etc/mpd.conf"
 startupitem.stop    "${prefix}/bin/mpd --kill"
@@ -70,26 +78,37 @@
     ${destroot}${prefix}/var/lib/mpd/playlists \
     ${destroot}${prefix}/var/log/mpd
 post-destroot {
+    # Create new user for mpd:
+    addgroup ${mpduser}
+    adduser ${mpduser} gid=[existsgroup ${mpduser}] realname=Music\ Player\ Daemon
     # ensure ${prefix}/var/[lib/mpd/[music,playlists],log/mpd] exist 
-    xinstall -m 755 -d \
+    xinstall -m 755 -o ${mpduser} -g ${mpduser} -d \
     ${destroot}${prefix}/var/lib/mpd/music \
     ${destroot}${prefix}/var/lib/mpd/playlists \
     ${destroot}${prefix}/var/log/mpd
+
+    xinstall -m 644 ${filespath}/mpd.conf ${destroot}${prefix}/etc/mpd.conf.default
+    reinplace "s|%%PREFIX%%|${prefix}|g" \
+        ${destroot}${prefix}/etc/mpd.conf.default
+    reinplace "s|%%MPDUSER%%|${mpduser}|g" \
+        ${destroot}${prefix}/etc/mpd.conf.default
+}
+post-activate {
     if {![file exists ${prefix}/etc/mpd.conf]} {
-        xinstall -o root -m 0644 ${filespath}/mpd.conf ${destroot}${prefix}/etc/
-        reinplace "s|%%PREFIX%%|${prefix}|g" \
-        ${destroot}${prefix}/etc/mpd.conf
-        ui_msg "A basic configuration file has been created for you.  \
-        To add music to mpd's database, create symbolic links in \
-        ${prefix}/var/lib/mpd/music using 'ln -s'.  For advanced \
-        configuration, run \"man mpd.conf\" or refer to \
-        ${prefix}/share/doc/mpd/mpdconf.example for an example configuration file."
+        copy ${prefix}/etc/mpd.conf.default ${prefix}/etc/mpd.conf
     }
 }
-post-activate {
-    ui_msg "You may get \"Problems shmget'ing\" message when launching mpd.  \
-    In this case, you can increase the values of kern.sysv.shmmax and \
-    kern.sysv.shmall in /etc/rc."
-}
+
+notes "A basic configuration file has been created for you.
+To add music to mpd's database, create symbolic links in
+${prefix}/var/lib/mpd/music using 'ln -s'.  For advanced
+configuration, run \"man mpd.conf\" or refer to
+${prefix}/share/doc/mpd/mpdconf.example for an example configuration file.
+
+You may get \"Problems shmget'ing\" message when launching mpd.
+In this case, you can increase the values of kern.sysv.shmmax and
+kern.sysv.shmall in /etc/rc."
+
+
 livecheck.url   http://sourceforge.net/projects/musicpd/files/${name}/
 livecheck.regex "${name}\/(\\d+(?:\\.\\d+)*)"

Modified: trunk/dports/audio/mpd/files/mpd.conf
===================================================================
--- trunk/dports/audio/mpd/files/mpd.conf	2011-04-25 12:56:57 UTC (rev 78139)
+++ trunk/dports/audio/mpd/files/mpd.conf	2011-04-25 14:46:39 UTC (rev 78140)
@@ -4,3 +4,4 @@
 log_file                "%%PREFIX%%/var/log/mpd/log"
 state_file              "%%PREFIX%%/var/lib/mpd/state"
 mixer_type      "software"
+user                    "%%MPDUSER%%"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110425/ae0977c1/attachment.html>


More information about the macports-changes mailing list