Subject: Re: [bug#77023] [PATCH v5] home: services: Add readymedia.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 19 May 2025 09:18:27 +0900

Hi Ludovic,

Ludovic Courtès <[email-masked]> writes:

> Hi Sughosha,
>
> Sughosha <[email-masked]> writes:
>
>> * gnu/home/services/upnp.scm: New file.
>> * gnu/local.mk: Register it.
>> * gnu/services/upnp.scm: Export readymedia-activation and
>> readymedia-shepherd-service.
>> (<readymedia-configuration>)[home-service?]: New field.
>> [cache-directory]: Adjust value depending on 'for-home?'.
>> [log-directory]: Ditto.
>> (readymedia-shepherd-service): Adjust 'requirement' and 'start' according to
>> 'home-service?'.
>> (readymedia-activation): Adjust creating 'media-directories' with permissions
>> according to 'home-service?'.
>> * gnu/tests/upnp.scm (%readymedia-configuration-test): Configure port with
>> %readymedia-default-port.
>> * doc/guix.texi (Miscellaneous Home Services): Document Readymedia Service.
>> (Miscellaneous Services): Add cross-reference.
>>
>> Change-Id: I5c48595d84a815d98e03c7f68a716f048903720c
>
> Finally applied, thanks!
>
> The system test passes, but it fails once every two runs or so.  Could
> you take look?
>
> However, I do not see the ‘unshare’ issue that Maxim was reporting: I
> double-checked by running the test VM manually, and here’s what I could
> see:
>
> root@komputilo ~# herd status readymedia
> herd status readymedia
> ● Status of readymedia:
>   It is running since 10:12:32 PM (15 seconds ago).
>   Main PID: 145
>   Command: /gnu/store/39m4bp93cc65h8i60if803hcfjw5jzyj-minidlna -f /gnu/store/x8vqpc3yqbblm7wbmg0798vvl0mj2rn6-minidlna.conf -S
>   It is enabled.
>   Provides: readymedia
>   Requires: networking user-processes
>   Will be respawned.
>   Log file: /var/log/readymedia/minidlna.log
>
> Recent messages (use '-n' to view more or less):
>   2025-05-18 22:12:33 scanner.c:731: warn: Scanning /media
>   2025-05-18 22:12:33 scanner.c:820: warn: Scanning /media finished (0 files)!
>   2025-05-18 22:12:33 playlist.c:135: warn: Parsing playlists...
>   2025-05-18 22:12:33 playlist.c:269: warn: Finished parsing playlists.
>   2025-05-18 22:12:33 monitor_inotify.c:223: warn: WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [2] and I do not have permission to increase this limit.  Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.
> root@komputilo ~# cat /var/log/readymedia/minidlna.log
> cat /var/log/readymedia/minidlna.log
> 2025-05-18 22:12:33 utils.c:295: warn: make_dir: cannot create directory '/var/run/'
> 2025-05-18 22:12:33 minidlna.c:466: error: Unable to create pidfile directory: /var/run/minidlna/minidlna.pid
> 2025-05-18 22:12:33 minidlna.c:520: warn: Unset locale
> 2025-05-18 22:12:33 minidlna.c:1134: warn: Starting MiniDLNA version 1.3.3.
> 2025-05-18 22:12:33 minidlna.c:394: warn: Creating new database at /var/cache/readymedia/files.db
> 2025-05-18 22:12:33 minidlna.c:1182: warn: HTTP listening on port 8200
> 2025-05-18 22:12:33 scanner.c:731: warn: Scanning /media
> 2025-05-18 22:12:33 scanner.c:820: warn: Scanning /media finished (0 files)!
> 2025-05-18 22:12:33 playlist.c:135: warn: Parsing playlists...
> 2025-05-18 22:12:33 playlist.c:269: warn: Finished parsing playlists.
> 2025-05-18 22:12:33 monitor_inotify.c:223: warn: WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [2] and I do not have permission to increase this limit.  Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.

I had applied the diff below to fix it, maybe only is the unshare error
exposed?

--8<---------------cut here---------------start------------->8---
services: Fix readymedia service.

The containerized process didn't have access to the run and db directories.

* gnu/services/upnp.scm (%readymedia-run-directory)
(%readymedia-db-directory): New variables.
(readymedia-shepherd-service) <least-authority-wrapper>: Map directories.
(readymedia-activation): Create directories in activation script.

Change-Id: I76547eb483ee65472ab0e6ec7164bf7e40fd745b

1 file changed, 15 insertions(+), 1 deletion(-)
gnu/services/upnp.scm | 16 +++++++++++++++-

modified   gnu/services/upnp.scm
@@ -122,6 +122,10 @@ (define (readymedia-configuration->config-file config)
                            (string-append key "=" value "\n")))
                         extra-config)))))
 
+(define %readymedia-run-directory "/var/run/minidlna")
+
+(define %readymedia-db-directory "/var/db/minidlna")
+
 (define (readymedia-shepherd-service config)
   "Return a least-authority ReadyMedia/MiniDLNA Shepherd service."
   (match-record config <readymedia-configuration>
@@ -149,6 +153,14 @@ (define (readymedia-shepherd-service config)
                            (file-system-mapping
                             (source minidlna-conf)
                             (target source))
+                           (file-system-mapping
+                            (source %readymedia-db-directory)
+                            (target source)
+                            (writable? #t))
+                           (file-system-mapping
+                            (source %readymedia-run-directory)
+                            (target source)
+                            (writable? #t))
                            (map (lambda (directory)
                                   (file-system-mapping
                                    (source (readymedia-media-directory-path directory))
@@ -195,7 +207,9 @@ (define (readymedia-activation config)
                         (mkdir-p/perms directory
                                        (getpw #$%readymedia-user-account)
                                        #o755)))
-                    (list #$cache-directory #$log-directory))))))
+                    (list #$cache-directory #$log-directory
+                          #$%readymedia-db-directory
+                          #$%readymedia-run-directory))))))
 
 (define readymedia-service-type
   (service-type
--8<---------------cut here---------------end--------------->8---

-- 
Thanks,
Maxim