unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Fabio Natali <me@fabionatali.com>
Cc: arunisaac@systemreboot.net,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>,
	Florian Pelz <pelzflorian@pelzflorian.de>,
	mirai@makinata.eu, 72398@debbugs.gnu.org,
	Matthew Trzcinski <matt@excalamus.com>
Subject: [bug#72398] [PATCH v5] services: Add readymedia-service-type.
Date: Sat, 07 Sep 2024 00:17:02 +0200	[thread overview]
Message-ID: <874j6swhpd.fsf@gnu.org> (raw)
In-Reply-To: <a53c63eb4306b19741f0c4ed531ae6067d47ac2a.1724666874.git.me@fabionatali.com> (Fabio Natali's message of "Mon, 26 Aug 2024 11:11:36 +0100")

Hello,

Fabio Natali <me@fabionatali.com> skribis:

> * doc/guix.texi: Add documentation.
> * gnu/local.mk: Add mention of new files.

This is really minor, but please mention the place where this is added,
like:

  * doc/guix.texi (Section Name): New node.

> On a Guix system tests can be run with this command:
>
> make check-system TESTS="readymedia-service"

I get two failures:

--8<---------------cut here---------------start------------->8---
PASS: ReadyMedia user exists
PASS: ReadyMedia group exists
PASS: cache directory exists
PASS: cache directory has correct ownership
PASS: cache directory has expected permissions
/gnu/store/3z061ii32vr6klh3y8p9b43zq6lwibja-readymedia-service-test-builder:1: FAIL cache file exists
/gnu/store/3z061ii32vr6klh3y8p9b43zq6lwibja-readymedia-service-test-builder:1: FAIL cache file has expected permissions
PASS: cache file is non-empty
PASS: log directory exists
PASS: log directory has correct ownership
PASS: log directory has expected permissions
PASS: log file exists
PASS: log file has expected permissions
PASS: log file is non-empty
PASS: ReadyMedia service is running
PASS: ReadyMedia service is listening for connections
# of expected passes      14
# of unexpected failures  2
--8<---------------cut here---------------end--------------->8---

This might have to do with activation, see below.

> +The @code{(gnu services upnp)} module offers services related to the
> +DLNA and UPnP-VA networking protocols.  For now, it provides the

I would add a few words about what DLNA and UPnP-VA allow users to do,
and perhaps what they mean.

> +@code{readymedia-service-type} is a Guix service that wraps around
> +ReadyMedia's @code{minidlnad}.  For increased security, the service
> +makes use of @code{least-authority-wrapper} which limits the resources
> +that the daemon has access to.  The daemon runs as the
> +@code{readymedia} unprivileged user, which is a member of the
> +@code{readymedia} group.

I would omit everything that follows “For increased security” since it’s
largely an implementation detail (a nice one though!) and could get out
of sync over time.

> +    (list (shepherd-service
> +           (documentation "Run the ReadyMedia/MiniDLNA daemon.")
> +           (provision '(readymedia))
> +           (requirement '(networking user-processes))
> +           (start
> +            #~(begin
> +                (use-modules (gnu build activation))
> +                (let* ((user (getpw #$%readymedia-user-account))
> +                       (dirs (list
> +                              #$cache-directory
> +                              #$log-directory
> +                              #$@(map (lambda (e)
> +                                        (readymedia-media-directory-path e))
> +                                      media-directories)))
> +                       (init-directory (lambda (d)
> +                                         (unless (file-exists? d)
> +                                           (mkdir-p/perms d user #o755)))))
> +                  (for-each init-directory dirs))
> +                (make-forkexec-constructor
> +                 ;; "-S" is to daemonise minidlnad.
> +                 (list #$readymedia "-f" #$minidlna-conf "-S")
> +                 #:log-file #$%readymedia-log-file
> +                 #:user #$%readymedia-user-account
> +                 #:group #$%readymedia-user-group)))

This is problematic because the code above ‘make-forkexec-constructor’
is effectively executed as soon as shepherd reads the config file, which
may be too early or undesirable.

If you intended it to run when the service is started, you’ll have to
structure it like this:

  (start #~(lambda ()
             ;; create directories etc.
             (fork+exec-command (list #$readymedia …) …)))

Also, use the ‘modules’ field instead of ‘use-modules’ right in the
middle.

But! While I agree in principle with what Bruno wrote about the
shortcomings of activation snippets, I would stick to an activation
snippet here to create directories etc.  The change Bruno proposes
should be treated separately and systematically across all the services,
not just one of them.

> +(define %test-readymedia-service

Just ‘%test-readymedia’…

> +  (system-test
> +   (name "readymedia-service")

… and “readymedia”, for consistency with other tests.

Thanks,
Ludo’.




  reply	other threads:[~2024-09-06 22:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 10:27 [bug#72398] [PATCH] services: Add readymedia-service-type Fabio Natali via Guix-patches via
2024-08-12 23:19 ` Arun Isaac
2024-08-19  0:27   ` Fabio Natali via Guix-patches via
2024-08-20  2:14     ` [bug#72398] [PATCH v2] " Bruno Victal
2024-08-22 10:13       ` Fabio Natali via Guix-patches via
2024-08-22 23:28         ` Arun Isaac
2024-08-23 11:04           ` [bug#72398] [PATCH v4] " Fabio Natali via Guix-patches via
2024-08-23 15:35             ` Bruno Victal
2024-08-26 10:11               ` [bug#72398] [PATCH v5] " Fabio Natali via Guix-patches via
2024-09-06 22:17                 ` Ludovic Courtès [this message]
2024-09-08 20:04                   ` [bug#72398] [PATCH v6] " Fabio Natali via Guix-patches via
2024-08-23 15:25           ` [bug#72398] [PATCH v2] " Bruno Victal
2024-08-28 22:51             ` Arun Isaac
2024-08-29 14:37               ` Fabio Natali via Guix-patches via
2024-08-22 23:22       ` Arun Isaac
2024-08-22 10:17 ` [bug#72398] [PATCH v3] " Fabio Natali via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874j6swhpd.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=72398@debbugs.gnu.org \
    --cc=arunisaac@systemreboot.net \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=me@fabionatali.com \
    --cc=mirai@makinata.eu \
    --cc=pelzflorian@pelzflorian.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).