From: Klemens Nanni Subject: Re: spotifyd: add user and rc.d script To: Bjorn Ketelaars , ports@openbsd.org, Alexandre Ratchov Date: Tue, 2 Jan 2024 10:59:17 +0000 On Mon, Jan 01, 2024 at 01:40:24PM +0000, Klemens Nanni wrote: > On Mon, Jan 01, 2024 at 09:16:40AM +0100, Bjorn Ketelaars wrote: > > Works for me as well. > > > > Recycling id 593 should be ok. I am not sure if using aucat(1) in > > spotifyd.rc has any downsides. Maybe doing something like 'mkdir > > ~/.sndiod && if=/dev/urandom bs=16 count=1 of=~/.sndio/cookie' is a good > > alternative, which is more self explaining. > > Thanks for testing. Why handroll things if a base tool does the whole > dance correctly, incl. ownership and permissions? > > Not intended, but nice to have: aucat(1) also fails whether sndiod(8) > runs and/or the cookie actually works, i.e. 'rcctl start spotifyd' would > fail if sound isn't set up properly, which 'mkdir && dd' does not. Not needed actually. I forgot '-m 0600' in README's install(1) instructions, causing wrong 0755 permissions, thus libsndio recreated the cookie, but only when playing, not immediately on startup. Thanks to ratchov for some clarification around sndio behaviour and rubber-ducking this, the cookie API is a bit cumbersome to notice/debug. Someone also pointed at audio/mpd and audio/sharepoint-sync having similar instructions and that those ports should probably be kept in sync. I don't like how they repeat what's in sndio(7) already or vaguely instruct to copy the cookie when you really need to get ownership/permissions right, so I'm inclined to stick with a short reference and clear example. Feedback? OK? Index: infrastructure/db/user.list =================================================================== RCS file: /cvs/ports/infrastructure/db/user.list,v diff -u -p -r1.435 user.list --- infrastructure/db/user.list 17 Dec 2023 21:25:50 -0000 1.435 +++ infrastructure/db/user.list 29 Dec 2023 23:59:22 -0000 @@ -101,7 +101,7 @@ id user group port 590 _smsd _smsd comms/smstools 591 _bacula _bacula sysutils/bacula 592 _imapproxy _imapproxy mail/imapproxy -#593 _nginx _nginx www/nginx +593 _spotifyd _spotifyd audio/spotifyd #594 _ejabberd _ejabberd net/ejabberd 595 _poppassd _poppassd sysutils/openpoppassd #596 _heartbeat _heartbeat sysutils/heartbeat Index: audio/spotifyd/Makefile =================================================================== RCS file: /cvs/ports/audio/spotifyd/Makefile,v diff -u -p -r1.4 Makefile --- audio/spotifyd/Makefile 31 Dec 2023 18:45:17 -0000 1.4 +++ audio/spotifyd/Makefile 2 Jan 2024 10:36:55 -0000 @@ -4,7 +4,7 @@ NOT_FOR_ARCHS = powerpc64 riscv6 COMMENT = Spotify client running as UNIX daemon DIST_TUPLE = github Spotifyd spotifyd v0.3.5 . CATEGORIES = audio net -REVISION = 2 +REVISION = 3 MAINTAINER = Klemens Nanni @@ -31,10 +31,15 @@ MODCARGO_FEATURES = dbus_keyring \ portaudio_backend DOC_DIR = ${PREFIX}/doc/${PKGSTEM} +EXAMPLES_DIR = ${PREFIX}/share/examples/${PKGSTEM} +HOME_DIR = ${LOCALSTATEDIR}/${PKGSTEM} +SUBST_VARS = HOME_DIR post-install: ${INSTALL_DATA_DIR} ${DOC_DIR} ${INSTALL_DATA} ${WRKSRC}/docs/src/config/File.md ${DOC_DIR}/ + ${INSTALL_DATA_DIR} ${EXAMPLES_DIR} + ${SUBST_DATA} {${FILESDIR},${EXAMPLES_DIR}}/${PKGSTEM}.conf .include "crates.inc" .include Index: audio/spotifyd/files/spotifyd.conf =================================================================== RCS file: audio/spotifyd/files/spotifyd.conf diff -N audio/spotifyd/files/spotifyd.conf --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ audio/spotifyd/files/spotifyd.conf 31 Dec 2023 19:58:21 -0000 @@ -0,0 +1,8 @@ +[global] +username = "user@example.com" +password = "secret" + +# TODO needs D-Bus policy to allow '_spotifyd' owning the MPRIS service +use_mpris = false + +#cache_path = "${HOME_DIR}/cache" Index: audio/spotifyd/pkg/PLIST =================================================================== RCS file: /cvs/ports/audio/spotifyd/pkg/PLIST,v diff -u -p -r1.2 PLIST --- audio/spotifyd/pkg/PLIST 29 Dec 2023 22:09:21 -0000 1.2 +++ audio/spotifyd/pkg/PLIST 31 Dec 2023 21:40:04 -0000 @@ -1,5 +1,19 @@ +@newgroup _spotifyd:593 +@newuser _spotifyd:593:_spotifyd::Spotify Daemon:${HOME_DIR}:/sbin/nologin +@rcscript ${RCDIR}/spotifyd +@owner _spotifyd +@group _spotifyd +@sample ${HOME_DIR}/ +@extraunexec rm -rf ${HOME_DIR} +@owner +@group @bin bin/spotifyd doc/ doc/spotifyd/ doc/spotifyd/File.md share/doc/pkg-readmes/${PKGSTEM} +share/examples/spotifyd/ +share/examples/spotifyd/spotifyd.conf +@mode 0640 +@group _spotifyd +@sample ${SYSCONFDIR}/spotifyd.conf Index: audio/spotifyd/pkg/README =================================================================== RCS file: /cvs/ports/audio/spotifyd/pkg/README,v diff -u -p -r1.1.1.1 README --- audio/spotifyd/pkg/README 27 Dec 2023 19:47:33 -0000 1.1.1.1 +++ audio/spotifyd/pkg/README 2 Jan 2024 10:43:49 -0000 @@ -1,8 +1,14 @@ With credentials in an XDG configuration file spotifyd is ready to run, e.g. as daemon in ~/.xsession or on-demand via clients such as "spotify-qt": - [global] + [spotifyd] username = "user@example.com" password = "secret" -See https://docs.spotifyd.rs/ for more information. +Alternatively, the rc.d(8) script runs as dedicated user, but lacks D-Bus +configuration, hence features like the MPRIS interface do not work (yet). + +Follow sndio(7) Authentication if both dedicated and your own user shall be +able to play audio at the same time, e.g. on a desktop system: + + # install -D -p -o _spotifyd -m 0600 ~/.sndio/cookie ${HOME_DIR}/.sndio/cookie Index: audio/spotifyd/pkg/spotifyd.rc =================================================================== RCS file: audio/spotifyd/pkg/spotifyd.rc diff -N audio/spotifyd/pkg/spotifyd.rc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ audio/spotifyd/pkg/spotifyd.rc 2 Jan 2024 10:37:12 -0000 @@ -0,0 +1,10 @@ +#!/bin/ksh + +daemon="/usr/local/bin/spotifyd" +daemon_user="_spotifyd" + +. /etc/rc.d/rc.subr + +rc_reload=NO + +rc_cmd $1