bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66339: [PATCH gnome-team v4] gnu: dbus-service: make the session ava


From: Liliana Marie Prikler
Subject: bug#66339: [PATCH gnome-team v4] gnu: dbus-service: make the session available under /run/dbus
Date: Fri, 06 Oct 2023 23:41:10 +0200
User-agent: Evolution 3.46.4

Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
> According to
> https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3101, glib
> now searches for the session bus socket in runstatedir. The dbus
> service must thus have its socket in /run/dbus.
> 
> For interoperability with the dbus standard, /run/dbus is also
> symlinked to /var/run/dbus.
> 
> * gnu/services/dbus.scm (dbus-activation): Symlink /run/dbus to
> /var/run/dbus.
> (%dbus-accounts): Run dbus in /run/dbus.
> (dbus-root-service-type): Save the pid file in /run/dbus.
> ---
> 
> > Perhaps, but it's not okay to fail if it's a regular directory.  We
> > should
> > move those!
> 
> I’m not sure I understand.  What comes to my mind is:
> 
> 1. Try to make the symlink. If it fails with EEXIST:
> 2. Try to read /var/run/dbus as a symlink. If it points to /run/dbus
> already,
>    stop. Otherwise:
> 3. Move everything in /var/run/dbus to /run/dbus.
> 4. Delete the now-empty /var/run/dbus.
> 5. Symlink /run/dbus to /var/run/dbus.
> 
> Is it what you meant?
Yep, that's what I meant.

> Best regards,
> 
> Vivien
> 
>  gnu/services/dbus.scm | 38 +++++++++++++++++++++++++++++++++++---
>  1 file changed, 35 insertions(+), 3 deletions(-)
> 
> diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> index 5a0c634393..44bf0c910b 100644
> --- a/gnu/services/dbus.scm
> +++ b/gnu/services/dbus.scm
> @@ -163,7 +163,7 @@ (define %dbus-accounts
>           (group "messagebus")
>           (system? #t)
>           (comment "D-Bus system bus user")
> -         (home-directory "/var/run/dbus")
> +         (home-directory "/run/dbus")
>           (shell (file-append shadow "/sbin/nologin")))))
>  
>  (define dbus-setuid-programs
> @@ -186,7 +186,39 @@ (define (dbus-activation config)
>          (let ((user (getpwnam "messagebus")))
>            ;; This directory contains the daemon's socket so it must
> be
>            ;; world-readable.
> -          (mkdir-p/perms "/var/run/dbus" user #o755))
> +          (mkdir-p/perms "/run/dbus" user #o755))
> +
> +        (catch 'system-error
> +          (lambda ()
> +            (symlink "/run/dbus" "/var/run/dbus"))
> +          (lambda args
> +            (let ((errno (system-error-errno args)))
> +              (cond
> +               ((= errno EEXIST)
> +                (let ((existing-name
> +                       (false-if-exception
> +                        (readlink "/var/run/dbus"))))
> +                  (unless (equal? existing-name "/run/dbus")
> +                    ;; Move the content of /var/run/dbus to
> /run/dbus, and
> +                    ;; retry.
> +                    (let ((dir (opendir "/var/run/dbus")))
> +                      (let move-to-/run/dbus ()
> +                        (let ((next (readdir dir)))
> +                          (unless (or (equal? next ".")
> +                                      (equal? next "..")
> +                                      (eof-object? next))
> +                            (rename-file (string-append
> "/var/run/dbus/" next)
> +                                         (string-append "/run/dbus/"
> next)))
> +                          (unless (eof-object? next)
> +                            (move-to-/run/dbus))))
> +                      (closedir dir)
> +                      (rmdir "/var/run/dbus")
> +                      (symlink "/run/dbus" "/var/run/dbus")))))
You might want to express this in terms of a function similar to copy-
recursively, or at the very least a let loop.
  (let loop ((next (readdir dir)))
    (cond
      ((eof-object? next) (closedir dir))
      ((member next "." "..") (loop (readdir dir)))
      (else (rename-file …) (loop (readdir dir)))))
> +               (else
> +                (format (current-error-port)
> +                        "Failed to symlink /run/dbus to
> /var/run/dbus: ~s~%"
> +                        (strerror errno))
> +                (error "cannot create /var/run/dbus"))))))
>  
>          (unless (file-exists? "/etc/machine-id")
>            (format #t "creating /etc/machine-id...~%")
> @@ -210,7 +242,7 @@ (define dbus-shepherd-service
>                               '(#:environment-variables
> '("DBUS_VERBOSE=1")
>                                 #:log-file "/var/log/dbus-
> daemon.log")
>                               '())
> -                      #:pid-file "/var/run/dbus/pid"))
> +                      #:pid-file "/run/dbus/pid"))
>              (stop #~(make-kill-destructor)))))))
>  
>  (define dbus-root-service-type
> 
> base-commit: b18b2d13488f2a92331ccad2dc8cbb54ee15582f
Cheers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]