Gnome-team dbus socket in /var/run/dbus, not /run/dbus

  • Done
  • quality assurance status badge
Details
5 participants
  • Liliana Marie Prikler
  • Maxim Cournoyer
  • Bruno Victal
  • Vivien Kraus
  • Vivien Kraus
Owner
unassigned
Submitted by
Vivien Kraus
Severity
normal
V
V
Vivien Kraus wrote on 4 Oct 2023 12:51
(name . bug-guix)(address . bug-guix@gnu.org)
3121a39dc569ff872afe74a8871ef71456ea5451.camel@univ-reims.fr
Dear guix,

The gnome-team branch starts the dbus service to provide a system
session socket in /var/run/dbus, but the dbus client expects it in
/run/dbus. This is the case for gdm and upowerd, and possibly many
more.

If I add

(symlink "/var/run/dbus" "/run/dbus")

in the script provided by dbus-activation (gnu/services/dbus.scm), then
gdm starts, and I?can log in (with XFCE, GNOME still can’t load) and
verify upowerd works.

I don’t think this is a good solution though. I think we need to dig
into how to bind the socket in /run/dbus, and check the dbus clients to
make sure they all expect the socket in /run/dbus.

Best regards,

Vivien
V
V
Vivien Kraus wrote on 4 Oct 2023 12:47
[WIP PATCH gnome-team] gnu: dbus-service: make the session available under /run/dbus
(address . 66339@debbugs.gnu.org)
91a5894be67c0ef0fc1478255ec86f0248344aa4.1696438388.git.vivien@planete-kraus.eu
* gnu/services/dbus.scm (dbus-activation): Symlink /var/run/dbus to /run/dbus.
---
gnu/services/dbus.scm | 1 +
1 file changed, 1 insertion(+)

Toggle diff (16 lines)
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 5a0c634393..80968ac1a4 100644
--- a/gnu/services/dbus.scm
+++ b/gnu/services/dbus.scm
@@ -187,6 +187,7 @@ (define (dbus-activation config)
;; This directory contains the daemon's socket so it must be
;; world-readable.
(mkdir-p/perms "/var/run/dbus" user #o755))
+ (symlink "/var/run/dbus" "/run/dbus")
(unless (file-exists? "/etc/machine-id")
(format #t "creating /etc/machine-id...~%")

base-commit: b18b2d13488f2a92331ccad2dc8cbb54ee15582f
--
2.41.0
L
L
Liliana Marie Prikler wrote on 4 Oct 2023 20:30
479a5d9dda7ac8bb26589f755e4caf3a820325a6.camel@gmail.com
Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
Toggle quote (16 lines)
> * gnu/services/dbus.scm (dbus-activation): Symlink /var/run/dbus to
> /run/dbus.
> ---
>  gnu/services/dbus.scm | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> index 5a0c634393..80968ac1a4 100644
> --- a/gnu/services/dbus.scm
> +++ b/gnu/services/dbus.scm
> @@ -187,6 +187,7 @@ (define (dbus-activation config)
>            ;; This directory contains the daemon's socket so it must
> be
>            ;; world-readable.
>            (mkdir-p/perms "/var/run/dbus" user #o755))
> +        (symlink "/var/run/dbus" "/run/dbus")
From [1]:
Toggle quote (6 lines)
> As documented in the NEWS file in
> https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209, it’s
> only valid to use /run – rather than /var/run – for D-Bus if the two
> paths are interoperable. i.e. /var/run should be a symlink to /run,
> and the D-Bus daemon should be configured to put its socket there.

Thus, the order of the two ought to be reversed. Alternatively, we
could add '-Druntime_dir=/var/run' to glib. WDYT?

V
V
Vivien Kraus wrote on 4 Oct 2023 12:47
[PATCH gnome-team v2] gnu: dbus-service: make the session available under /run/dbus
751681ee8d9123e869111a11ce1446d9156117da.1696456123.git.vivien@planete-kraus.eu
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.
---

Le mercredi 04 octobre 2023 à 20:30 +0200, Liliana Marie Prikler a écrit :
Toggle quote (31 lines)
> Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
> > * gnu/services/dbus.scm (dbus-activation): Symlink /var/run/dbus to
> > /run/dbus.
> > ---
> > gnu/services/dbus.scm | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> > index 5a0c634393..80968ac1a4 100644
> > --- a/gnu/services/dbus.scm
> > +++ b/gnu/services/dbus.scm
> > @@ -187,6 +187,7 @@ (define (dbus-activation config)
> > ;; This directory contains the daemon's socket so it
> > must
> > be
> > ;; world-readable.
> > (mkdir-p/perms "/var/run/dbus" user #o755))
> > + (symlink "/var/run/dbus" "/run/dbus")
> From [1]:
> > As documented in the NEWS file in
> > https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209, it’s
> > only valid to use /run – rather than /var/run – for D-Bus if the
> > two
> > paths are interoperable. i.e. /var/run should be a symlink to /run,
> > and the D-Bus daemon should be configured to put its socket there.
>
> Thus, the order of the two ought to be reversed. Alternatively, we
> could add '-Druntime_dir=/var/run' to glib. WDYT?
>
> [1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3101

Thank you for finding this information. I think we should follow glib, and
have the socket in /run/dbus, with the symlink for standard interoperability.

I’m still concerned about doing a symlink in the activation function. What if
we activate a new system from an existing one? Won’t the symlink fail? I think
we should preemptively delete /var/run/dbus and make a new symlink every
time. But I could be wrong, maybe this is not needed.

What do you think?

Best regards,

Vivien

gnu/services/dbus.scm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Toggle diff (39 lines)
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 5a0c634393..53efa7adea 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,11 @@ (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))
+
+ (when (file-exists? "/var/run/dbus")
+ (delete-file "/var/run/dbus"))
+ (symlink "/run/dbus" "/var/run/dbus")
(unless (file-exists? "/etc/machine-id")
(format #t "creating /etc/machine-id...~%")
@@ -210,7 +214,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
--
2.41.0
L
L
Liliana Marie Prikler wrote on 5 Oct 2023 06:41
efb710855c0cf1f2ca5cd9dc513aad854b4f47fe.camel@gmail.com
Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
Toggle quote (59 lines)
> 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.
> ---
>
> Le mercredi 04 octobre 2023 à 20:30 +0200, Liliana Marie Prikler a
> écrit :
> > Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
> > > * gnu/services/dbus.scm (dbus-activation): Symlink /var/run/dbus
> > > to
> > > /run/dbus.
> > > ---
> > >  gnu/services/dbus.scm | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> > > index 5a0c634393..80968ac1a4 100644
> > > --- a/gnu/services/dbus.scm
> > > +++ b/gnu/services/dbus.scm
> > > @@ -187,6 +187,7 @@ (define (dbus-activation config)
> > >            ;; This directory contains the daemon's socket so it
> > > must
> > > be
> > >            ;; world-readable.
> > >            (mkdir-p/perms "/var/run/dbus" user #o755))
> > > +        (symlink "/var/run/dbus" "/run/dbus")
> > From [1]:
> > > As documented in the NEWS file in
> > > https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209,
> > > it’s only valid to use /run – rather than /var/run – for D-Bus if
> > > the two paths are interoperable. i.e. /var/run should be a
> > > symlink to /run, and the D-Bus daemon should be configured to put
> > > its socket there.
> >
> > Thus, the order of the two ought to be reversed.  Alternatively, we
> > could add '-Druntime_dir=/var/run' to glib.  WDYT?
> >
> > [1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3101
>
> Thank you for finding this information. I think we should follow
> glib, and have the socket in /run/dbus, with the symlink for standard
> interoperability.
>
> I’m still concerned about doing a symlink in the activation function.
> What if we activate a new system from an existing one? Won’t the
> symlink fail? I think we should preemptively delete /var/run/dbus and
> make a new symlink every time. But I could be wrong, maybe this is
> not needed.
>
> What do you think?
If we go this route, I think we should first check whether
/var/run/dbus is indeed a symlink to /run/dbus and move the existing
files if not before deleting the directory and creating the symlink.
But before that, we should try to symlink, which will fail with EEXIST
if the file already exists, regardless of whether it's a symlink –
thereafter you can check the cause of this failure through lstat.

Toggle quote (30 lines)
> Best regards,
>
> Vivien
>
>  gnu/services/dbus.scm | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> index 5a0c634393..53efa7adea 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,11 @@ (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))
> +
> +        (when (file-exists? "/var/run/dbus")
> +          (delete-file "/var/run/dbus"))
This assumes "/var/run/dbus" to be a regular file or symlink, which
it's not on reconfiguration IIUC.
Toggle quote (18 lines)
> +        (symlink "/run/dbus" "/var/run/dbus")
>  
>          (unless (file-exists? "/etc/machine-id")
>            (format #t "creating /etc/machine-id...~%")
> @@ -210,7 +214,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
V
V
Vivien Kraus wrote on 4 Oct 2023 12:47
[PATCH gnome-team v3] gnu: dbus-service: make the session available under /run/dbus
3b537fed577176c82c604ac9762a9c5ec2835a21.1696613607.git.vivien@planete-kraus.eu
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.
---

Le jeudi 05 octobre 2023 à 06:41 +0200, Liliana Marie Prikler a écrit :
Toggle quote (13 lines)
> > I’m still concerned about doing a symlink in the activation function.
> > What if we activate a new system from an existing one? Won’t the symlink
> > fail? I think we should preemptively delete /var/run/dbus and make a new
> > symlink every time. But I could be wrong, maybe this is not needed.
> >
> > What do you think?
> If we go this route, I think we should first check whether /var/run/dbus is
> indeed a symlink to /run/dbus and move the existing files if not before
> deleting the directory and creating the symlink. But before that, we should
> try to symlink, which will fail with EEXIST if the file already exists,
> regardless of whether it's a symlink – thereafter you can check the cause of
> this failure through lstat.

I changed my mind! I now think it is OK for the system reconfigure to fail if
a different symlink already exists.

Best regards,

Vivien

gnu/services/dbus.scm | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

Toggle diff (52 lines)
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 5a0c634393..206a7bb491 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,24 @@ (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
+ (readlink "/run/dbus")))
+ (unless (equal? existing-name "/var/run/dbus")
+ (error "the symlink /run/dbus exists and does not point to /var/run/dbus"))))
+ (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 +227,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
--
2.41.0
L
L
Liliana Marie Prikler wrote on 6 Oct 2023 20:50
2b14a21b9cc4987434a5cd0dd0cfd0b0d015a18a.camel@gmail.com
Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
Toggle quote (38 lines)
> 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.
> ---
>
> Le jeudi 05 octobre 2023 à 06:41 +0200, Liliana Marie Prikler a écrit
> :
> > > I’m still concerned about doing a symlink in the activation
> > > function.
> > > What if we activate a new system from an existing one? Won’t the
> > > symlink
> > > fail? I think we should preemptively delete /var/run/dbus and
> > > make a new
> > > symlink every time. But I could be wrong, maybe this is not
> > > needed.
> > >
> > > What do you think?
> > If we go this route, I think we should first check whether
> > /var/run/dbus is indeed a symlink to /run/dbus and move the
> > existing files if not before deleting the directory and creating
> > the symlink.  But before that, we should try to symlink, which will
> > fail with EEXIST if the file already exists, regardless of whether
> > it's a symlink – thereafter you can check the cause of this failure
> > through lstat.
>
> I changed my mind! I now think it is OK for the system reconfigure to
> fail if a different symlink already exists.
Perhaps, but it's not okay to fail if it's a regular directory. We
should move those!


Cheers
V
V
Vivien Kraus wrote on 4 Oct 2023 12:47
[PATCH gnome-team v4] gnu: dbus-service: make the session available under /run/dbus
0c667260f50d8a098bcec9b312de552584c2e450.1696622314.git.vivien@planete-kraus.eu
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.
---

Toggle quote (3 lines)
> 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?

Best regards,

Vivien

gnu/services/dbus.scm | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)

Toggle diff (67 lines)
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")))))
+ (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
--
2.41.0
L
L
Liliana Marie Prikler wrote on 6 Oct 2023 23:41
45f8d9661e3ed9bcfd7b84df4890f4f1b551e572.camel@gmail.com
Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
Toggle quote (29 lines)
> 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.

Toggle quote (57 lines)
> 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)))))
Toggle quote (22 lines)
> +               (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
V
V
Vivien Kraus wrote on 6 Oct 2023 23:12
[PATCH gnome-team v5] gnu: glib: Set runstatedir.
0f234811bdabf42660367dfae5ecdf88439b48e3.1696688485.git.vivien@planete-kraus.eu
Glib has made /run the default runstatedir:


However, in Guix, the default runstatedir is /var/run.

* gnu/packages/glib.scm (glib): Set runtime_dir to /var/run.
---

I changed my mind again! Following the IRC discussion, Guix has a separate
/var/run and /run (and puts /run/current-system/ in /run). So, /var/run/dbus
is actually the correct place to put the system session socket.

gnu/packages/glib.scm | 1 +
1 file changed, 1 insertion(+)

Toggle diff (16 lines)
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 8af89d60e0..c4fcc20bb6 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -254,6 +254,7 @@ (define glib
#:configure-flags #~(list "--default-library=both"
"-Dman=false"
"-Dselinux=disabled"
+ "-Druntime_dir=/var/run"
(string-append "--bindir="
#$output:bin "/bin"))
#:phases

base-commit: b18b2d13488f2a92331ccad2dc8cbb54ee15582f
--
2.41.0
M
M
Maxim Cournoyer wrote on 7 Oct 2023 16:39
Re: bug#66339: Gnome-team dbus socket in /var/run/dbus, not /run/dbus
(name . Vivien Kraus)(address . vivien@planete-kraus.eu)
87y1geijiu.fsf_-_@gmail.com
Hi,

Vivien Kraus <vivien@planete-kraus.eu> writes:

Toggle quote (13 lines)
> Glib has made /run the default runstatedir:
>
> https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3101
>
> However, in Guix, the default runstatedir is /var/run.
>
> * gnu/packages/glib.scm (glib): Set runtime_dir to /var/run.
> ---
>
> I changed my mind again! Following the IRC discussion, Guix has a separate
> /var/run and /run (and puts /run/current-system/ in /run). So, /var/run/dbus
> is actually the correct place to put the system session socket.

I don't follow; why does it matter that Guix puts its current-system
directory under /run? /run is to be shared by many applications, like
/tmp, no?

I still see /var/run as the legacy directory of /run, so I'd prefer we
standardize to use the modern variant to reduce this kind of friction
with the applications which will only grow in the future.

--
Thanks,
Maxim
V
V
Vivien Kraus wrote on 4 Oct 2023 12:47
[PATCH gnome-team v6] gnu: dbus-service: make the session available under /run/dbus
(address . rg@raghavgururajan.name)
178db70e715f9e3c6a25e42034d90d672e893349.1696761183.git.vivien@planete-kraus.eu
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.
---

Hello,

I changed my mind back to a previous mind change, so: the socket should be
installed in /run. I believe that the code moves the content of the existing
/var/run/dbus to /run/dbus before trying the symlink again, if /var/run/dbus
exists and is not a symlink to /run/dbus. I don’t really have a way to check
the interesting case where existing files need to be moved. However, the
gnome-team-configured VM works.

Best regards,

Vivien

gnu/services/dbus.scm | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)

Toggle diff (68 lines)
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 5a0c634393..aa9ce0720c 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,40 @@ (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 ((next (readdir dir)))
+ (cond
+ ((eof-object? next)
+ (closedir dir))
+ ((member next '("." ".."))
+ (move-to-/run/dbus (readdir dir)))
+ (else
+ (begin
+ (rename-file (string-append "/var/run/dbus/" next)
+ (string-append "/run/dbus/" next))
+ (move-to-/run/dbus (readdir dir))))))))
+ (rmdir "/var/run/dbus")
+ (symlink "/run/dbus" "/var/run/dbus")))
+ (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 +243,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
--
2.41.0
L
L
Liliana Marie Prikler wrote on 8 Oct 2023 16:53
(address . rg@raghavgururajan.name)
59169352e8b09119c850fd2b5e80cb668ccd47fb.camel@gmail.com
Am Mittwoch, dem 04.10.2023 um 12:47 +0200 schrieb Vivien Kraus:
Toggle quote (85 lines)
> 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.
> ---
>
> Hello,
>
> I changed my mind back to a previous mind change, so: the socket
> should be
> installed in /run.  I believe that the code moves the content of the
> existing
> /var/run/dbus to /run/dbus before trying the symlink again, if
> /var/run/dbus
> exists and is not a symlink to /run/dbus.  I don’t really have a way
> to check
> the interesting case where existing files need to be moved.  However,
> the
> gnome-team-configured VM works.
>
> Best regards,
>
> Vivien
>
>  gnu/services/dbus.scm | 39 ++++++++++++++++++++++++++++++++++++---
>  1 file changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
> index 5a0c634393..aa9ce0720c 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,40 @@ (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 ((next (readdir dir)))
> +                        (cond
> +                         ((eof-object? next)
> +                          (closedir dir))
> +                         ((member next '("." ".."))
> +                          (move-to-/run/dbus (readdir dir)))
> +                         (else
> +                          (begin
> +                            (rename-file (string-append
> "/var/run/dbus/" next)
> +                                         (string-append "/run/dbus/"
> next))
> +                            (move-to-/run/dbus (readdir dir))))))))
I'd rename "move-to-/run/dbus" to the boring but more idiomatic "loop".
This saves us some horizontal real-estate that'd allow us to squash
some lines.
Toggle quote (24 lines)
> +                      (rmdir "/var/run/dbus")
> +                      (symlink "/run/dbus" "/var/run/dbus")))
> +               (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 +243,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
Otherwise LGTM. I'd commit it, but my machine is currently busy
building half of core-updates for no reason.

Cheers
B
B
Bruno Victal wrote on 8 Oct 2023 17:40
Re: bug#66339: Gnome-team dbus socket in /var/run/dbus, not /run/dbus
b577c49c-1264-41e5-8145-9e0d1b28c5c0@makinata.eu
Hi,

On 2023-10-07 15:39, Maxim Cournoyer wrote:
Toggle quote (17 lines)
> Hi,
>
> Vivien Kraus <vivien@planete-kraus.eu> writes:
>
>> Glib has made /run the default runstatedir:
>>
>> https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3101
>>
>> However, in Guix, the default runstatedir is /var/run.
>>
>> * gnu/packages/glib.scm (glib): Set runtime_dir to /var/run.
>> ---
>>
>> I changed my mind again! Following the IRC discussion, Guix has a separate
>> /var/run and /run (and puts /run/current-system/ in /run). So, /var/run/dbus
>> is actually the correct place to put the system session socket.

I recommend consulting the dbus spec [1] (System message bus subsection).
If I understood it correctly, `/var/run/dbus' is correct when the environment
variable DBUS_SYSTEM_BUS_ADDRESS is not set.
The /var/run/dbus or /run/dbus confusion is clarified in the third paragraph:
“On systems where /var/run/ is known to be synonymous with /run/ (such as most Linux
operating system distributions), implementations might prefer to make use of that knowledge
to connect to or listen on unix:path=/run/dbus/system_bus_socket instead, […]”

So it's up for the dbus implementation to detect whether /var/run/ is a symlink
to /run and whether it wants to explicitly choose /run if that's the case though
none of this is mandatory.

[…]

Toggle quote (4 lines)
> I still see /var/run as the legacy directory of /run, so I'd prefer we
> standardize to use the modern variant to reduce this kind of friction
> with the applications which will only grow in the future.

My understanding is that the implementation should be placing them under
/var/run/dbus but this is orthogonal to the value of runstatedir.
In view with [2] I think runstatedir should be /run and Guix should be
modernized to have /var/run symlinked to /run.



--
Furthermore, I consider that nonfree software must be eradicated.

Cheers,
Bruno.
L
L
Liliana Marie Prikler wrote on 9 Oct 2023 22:36
Re: [PATCH gnome-team v6] gnu: dbus-service: make the session available under /run/dbus
(address . rg@raghavgururajan.name)
20ed3340de4b64b61ec33fb929b83ed4b86b4e93.camel@gmail.com
Am Sonntag, dem 08.10.2023 um 16:53 +0200 schrieb Liliana Marie
Prikler:
Toggle quote (3 lines)
> [...]
> Otherwise LGTM.  I'd commit it, but my machine is currently busy
> building half of core-updates for no reason.
No longer busy, time to commit.

Thanks
Closed
?