GNU bug report logs - #59132
[PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.

Previous Next

Package: guix-patches;

Reported by: dan <i <at> dan.games>

Date: Tue, 8 Nov 2022 20:07:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59132 in the body.
You can then email your comments to 59132 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Tue, 08 Nov 2022 20:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to dan <i <at> dan.games>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 08 Nov 2022 20:07:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: dan <i <at> dan.games>
To: guix-patches <at> gnu.org
Subject: [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
Date: Wed,  9 Nov 2022 04:05:53 +0800
* gnu/system/images/wsl2.scm (wsl-boot-program): Create $XDG_RUNTIME_DIR on
first login.

copyright info
---
 gnu/system/images/wsl2.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/system/images/wsl2.scm b/gnu/system/images/wsl2.scm
index 80c2e775b4..e3e7503da3 100644
--- a/gnu/system/images/wsl2.scm
+++ b/gnu/system/images/wsl2.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Alex Griffin <a <at> ajgrf.com>
 ;;; Copyright © 2022 Mathieu Othacehe <othacehe <at> gnu.org>
+;;; Copyright © 2022 dan <i <at> dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -75,7 +76,11 @@ (define (wsl-boot-program user)
          (let* ((pw (getpw #$user))
                 (shell (passwd:shell pw))
                 (sudo #+(file-append sudo "/bin/sudo"))
-                (args (cdr (command-line))))
+                (args (cdr (command-line)))
+                (uid (passwd:uid pw))
+                (gid (passwd:gid pw))
+                (runtime-dir (string-append "/run/user/"
+                                            (number->string uid))))
            ;; Save the value of $PATH set by WSL.  Useful for finding
            ;; Windows binaries to run with WSL's binfmt interop.
            (setenv "WSLPATH" (getenv "PATH"))
@@ -88,6 +93,11 @@ (define (wsl-boot-program user)
                   MS_REMOUNT
                   #:update-mtab? #f)
 
+           ;; create XDG_RUNTIME_DIR for the login user
+           (unless (file-exists? runtime-dir)
+             (mkdir runtime-dir)
+             (chown runtime-dir uid gid))
+
            ;; Start login shell as user.
            (apply execl sudo "sudo"
                   "--preserve-env=WSLPATH"

base-commit: 96ae718c516a289124a0b91ceeef78b20d187825
-- 
2.38.0





Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Tue, 08 Nov 2022 20:12:01 GMT) Full text and rfc822 format available.

Message #8 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: "(" <paren <at> disroot.org>
To: "dan" <i <at> dan.games>, <59132 <at> debbugs.gnu.org>
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create
 $XDG_RUNTIME_DIR on first login.
Date: Tue, 08 Nov 2022 20:11:39 +0000
On Tue Nov 8, 2022 at 8:05 PM GMT, dan wrote:
> * gnu/system/images/wsl2.scm (wsl-boot-program): Create $XDG_RUNTIME_DIR on
> first login.
>
> copyright info

> --- a/gnu/system/images/wsl2.scm
> +++ b/gnu/system/images/wsl2.scm

> @@ -88,6 +93,11 @@ (define (wsl-boot-program user)
>                    MS_REMOUNT
>                    #:update-mtab? #f)
>  

> +           ;; create XDG_RUNTIME_DIR for the login user
> +           (unless (file-exists? runtime-dir)
> +             (mkdir runtime-dir)
> +             (chown runtime-dir uid gid))
> +

Shouldn't this be handled by elogind/seatd?

>             ;; Start login shell as user.
>             (apply execl sudo "sudo"
>                    "--preserve-env=WSLPATH"

    -- (




Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Tue, 08 Nov 2022 20:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: dan <i <at> dan.games>
To: "(" <paren <at> disroot.org>, 59132 <at> debbugs.gnu.org
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR
 on first login.
Date: Tue, 08 Nov 2022 14:23:13 -0600

On Tue, Nov 8, 2022, at 14:11, ( wrote:
>> +           ;; create XDG_RUNTIME_DIR for the login user
>> +           (unless (file-exists? runtime-dir)
>> +             (mkdir runtime-dir)
>> +             (chown runtime-dir uid gid))
>> +
>
> Shouldn't this be handled by elogind/seatd?

I'm not familiar with the job of elogind/seatd.  I might take a look.  Other than that, I'm also not sure if these work on WSL2.

--
dan




Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Tue, 08 Nov 2022 20:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: "(" <paren <at> disroot.org>
To: "dan" <i <at> dan.games>, <59132 <at> debbugs.gnu.org>
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create
 $XDG_RUNTIME_DIR on first login.
Date: Tue, 08 Nov 2022 20:27:02 +0000
Heya,

On Tue Nov 8, 2022 at 8:23 PM GMT, dan wrote:
> I'm not familiar with the job of elogind/seatd.  I might take a look.  Other than that, I'm also not sure if these work on WSL2.

elogind/seatd are tasked with setting up login sessions, which includes creating
XDG_RUNTIME_DIR. They probably do work on WSL, since I'm pretty sure desktops do?

    -- (




Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Tue, 08 Nov 2022 20:28:02 GMT) Full text and rfc822 format available.

Message #17 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: "(" <paren <at> disroot.org>
To: "dan" <i <at> dan.games>, <59132 <at> debbugs.gnu.org>
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create
 $XDG_RUNTIME_DIR on first login.
Date: Tue, 08 Nov 2022 20:27:26 +0000
To be clear, s/desktops/desktop environments/.

    -- (




Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Wed, 09 Nov 2022 04:27:02 GMT) Full text and rfc822 format available.

Message #20 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: dan <i <at> dan.games>
To: "(" <paren <at> disroot.org>, 59132 <at> debbugs.gnu.org
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR
 on first login.
Date: Wed, 9 Nov 2022 12:26:12 +0800
On 11/9/2022 4:27 AM, ( wrote:
> elogind/seatd are tasked with setting up login sessions, which includes creating
> XDG_RUNTIME_DIR. They probably do work on WSL, since I'm pretty sure desktops do?

i tried the following things:

adding `(syslog-service)' and `(service elogind-service-type)' to the 
operating-system's service list.  and when i login to wsl, it shows the 
following error:

> sudo: pam_open_session: Error in service module
> sudo: policy plugin failed session initialization

also tried seatd, by adding `(udev-service)' and `(service 
seatd-service-type)' to the service list.  and when logging in, it shows:

> warning: XDG_RUNTIME_DIR doesn't exists, on-first-login script won't 
execute anything.  You can check if xdg runtime directory exists, 
XDG_RUNTIME_DIR variable is set to appropriate value and manually 
execute the script by running '$HOME/.guix-home/on-first-login'

normally, when logging into wsl, users don't need to type their 
password.  i'm not sure if it related to the issue, but it might perform 
differently with a normal linux distro.

-- 
dan





Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Wed, 09 Nov 2022 07:25:01 GMT) Full text and rfc822 format available.

Message #23 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: dan <i <at> dan.games>
To: "(" <paren <at> disroot.org>, 59132 <at> debbugs.gnu.org
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR
 on first login.
Date: Wed, 9 Nov 2022 15:24:41 +0800
On 11/9/2022 4:27 AM, ( wrote:
> elogind/seatd are tasked with setting up login sessions, which includes creating
> XDG_RUNTIME_DIR. They probably do work on WSL, since I'm pretty sure desktops do?

I searched on the internet and found the manual from Void Linux[1], 
saying that seatd is not creating XDG_RUNTIME_DIR for login users.

[1]: 
https://docs.voidlinux.org/config/session-management.html#xdg_runtime_dir

-- 
dan





Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Wed, 09 Nov 2022 12:27:01 GMT) Full text and rfc822 format available.

Message #26 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: dan <i <at> dan.games>
Cc: 59132 <at> debbugs.gnu.org
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR
 on first login.
Date: Wed, 09 Nov 2022 13:26:45 +0100
Hi dan,

Thanks!  Why is this needed?

On 2022-11-08 21:05, dan wrote:
> * gnu/system/images/wsl2.scm (wsl-boot-program): Create 
> $XDG_RUNTIME_DIR
                                                          
^^^^^^^^^^^^^^^^
There's no reference to this in the actual patch.

Kind regards,

T G-R

Sent from a Web browser.  Excuse or enjoy my brevity.




Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Wed, 09 Nov 2022 13:50:02 GMT) Full text and rfc822 format available.

Message #29 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: dan <i <at> dan.games>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 59132 <at> debbugs.gnu.org
Subject: Re: [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR
 on first login.
Date: Wed, 9 Nov 2022 21:48:50 +0800
Hi Tobias,

On 11/9/2022 8:26 PM, Tobias Geerinckx-Rice wrote:
> Thanks!  Why is this needed?
> 
> On 2022-11-08 21:05, dan wrote:
>> * gnu/system/images/wsl2.scm (wsl-boot-program): Create $XDG_RUNTIME_DIR
> ^^^^^^^^^^^^^^^^
> There's no reference to this in the actual patch.
In my understanding, user level shepherd services need XDG_RUNTIME_DIR 
to run, and shepherd create a socket under XDG_RUNTIME_DIR/shepherd/. 
I'm not sure how WSL handle user login, but what we usually do is just 
type `wsl' in powershell, and it automatically logged into the default 
account, without prompting for password input.  Thus, relying ot elogind 
or greetd doesn't really help, it's better for us to manually create the 
directory.

There is also a warning on login, and I think it's from shepherd:
> warning: XDG_RUNTIME_DIR doesn't exists, on-first-login script won't 
> execute anything.  You can check if xdg runtime directory exists, 
> XDG_RUNTIME_DIR variable is set to appropriate value and manually 
> execute the script by running '$HOME/.guix-home/on-first-login
Anyway... I wasn't fully sure about if it's the right thing to do, since 
I'm not familiar enough with both Linux and WSL. But at least this makes 
user level services usable.  If this is the right thing to do, I'll 
update the patch with explanation included in the commit message.

Would like to hear feedback from someone authoritative!

-- 
dan





Information forwarded to guix-patches <at> gnu.org:
bug#59132; Package guix-patches. (Fri, 18 Nov 2022 14:02:02 GMT) Full text and rfc822 format available.

Message #32 received at 59132 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: dan <i <at> dan.games>, Mathieu Othacehe <othacehe <at> gnu.org>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>, 59132 <at> debbugs.gnu.org
Subject: Re: bug#59132: [PATCH] system: images: wsl2: Create
 $XDG_RUNTIME_DIR on first login.
Date: Fri, 18 Nov 2022 15:00:49 +0100
Hi Mathieu,

Could you comment on this patch dan submitted?

  https://issues.guix.gnu.org/59132

Thanks in advance.  :-)

Ludo’.

dan <i <at> dan.games> skribis:

> Hi Tobias,
>
> On 11/9/2022 8:26 PM, Tobias Geerinckx-Rice wrote:
>> Thanks!  Why is this needed?
>> On 2022-11-08 21:05, dan wrote:
>>> * gnu/system/images/wsl2.scm (wsl-boot-program): Create $XDG_RUNTIME_DIR
>> ^^^^^^^^^^^^^^^^
>> There's no reference to this in the actual patch.
> In my understanding, user level shepherd services need XDG_RUNTIME_DIR
> to run, and shepherd create a socket under
> XDG_RUNTIME_DIR/shepherd/. I'm not sure how WSL handle user login, but
> what we usually do is just type `wsl' in powershell, and it
> automatically logged into the default account, without prompting for
> password input.  Thus, relying ot elogind or greetd doesn't really
> help, it's better for us to manually create the directory.
>
> There is also a warning on login, and I think it's from shepherd:
>> warning: XDG_RUNTIME_DIR doesn't exists, on-first-login script won't
>> execute anything.  You can check if xdg runtime directory exists,
>> XDG_RUNTIME_DIR variable is set to appropriate value and manually
>> execute the script by running '$HOME/.guix-home/on-first-login
> Anyway... I wasn't fully sure about if it's the right thing to do,
> since I'm not familiar enough with both Linux and WSL. But at least
> this makes user level services usable.  If this is the right thing to
> do, I'll update the patch with explanation included in the commit
> message.
>
> Would like to hear feedback from someone authoritative!




Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Mon, 26 Dec 2022 08:37:02 GMT) Full text and rfc822 format available.

Notification sent to dan <i <at> dan.games>:
bug acknowledged by developer. (Mon, 26 Dec 2022 08:37:02 GMT) Full text and rfc822 format available.

Message #37 received at 59132-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: dan <i <at> dan.games>
Cc: 59132-done <at> debbugs.gnu.org
Subject: Re: bug#59132: [PATCH] system: images: wsl2: Create
 $XDG_RUNTIME_DIR on first login.
Date: Mon, 26 Dec 2022 09:36:10 +0100
Hello,

> * gnu/system/images/wsl2.scm (wsl-boot-program): Create $XDG_RUNTIME_DIR on
> first login.

I did set the XDG_RUNTIME_DIR variable as well, and applied as
c50cd1bbece27097456242f246f89c053e7cc1a2.

Thanks,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 23 Jan 2023 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.