unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
@ 2022-11-08 20:05 dan
  2022-11-08 20:11 ` ( via Guix-patches via
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: dan @ 2022-11-08 20:05 UTC (permalink / raw)
  To: 59132

* 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@ajgrf.com>
 ;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
+;;; Copyright © 2022 dan <i@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





^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:05 [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login dan
@ 2022-11-08 20:11 ` ( via Guix-patches via
  2022-11-08 20:23   ` dan
  2022-11-09 12:26 ` Tobias Geerinckx-Rice via Guix-patches via
  2022-12-26  8:36 ` bug#59132: " Mathieu Othacehe
  2 siblings, 1 reply; 11+ messages in thread
From: ( via Guix-patches via @ 2022-11-08 20:11 UTC (permalink / raw)
  To: dan, 59132

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"

    -- (




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:11 ` ( via Guix-patches via
@ 2022-11-08 20:23   ` dan
  2022-11-08 20:27     ` ( via Guix-patches via
  2022-11-08 20:27     ` ( via Guix-patches via
  0 siblings, 2 replies; 11+ messages in thread
From: dan @ 2022-11-08 20:23 UTC (permalink / raw)
  To: (, 59132



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




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:23   ` dan
@ 2022-11-08 20:27     ` ( via Guix-patches via
  2022-11-09  4:26       ` dan
  2022-11-09  7:24       ` dan
  2022-11-08 20:27     ` ( via Guix-patches via
  1 sibling, 2 replies; 11+ messages in thread
From: ( via Guix-patches via @ 2022-11-08 20:27 UTC (permalink / raw)
  To: dan, 59132

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?

    -- (




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:23   ` dan
  2022-11-08 20:27     ` ( via Guix-patches via
@ 2022-11-08 20:27     ` ( via Guix-patches via
  1 sibling, 0 replies; 11+ messages in thread
From: ( via Guix-patches via @ 2022-11-08 20:27 UTC (permalink / raw)
  To: dan, 59132

To be clear, s/desktops/desktop environments/.

    -- (




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:27     ` ( via Guix-patches via
@ 2022-11-09  4:26       ` dan
  2022-11-09  7:24       ` dan
  1 sibling, 0 replies; 11+ messages in thread
From: dan @ 2022-11-09  4:26 UTC (permalink / raw)
  To: (, 59132

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:27     ` ( via Guix-patches via
  2022-11-09  4:26       ` dan
@ 2022-11-09  7:24       ` dan
  1 sibling, 0 replies; 11+ messages in thread
From: dan @ 2022-11-09  7:24 UTC (permalink / raw)
  To: (, 59132

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:05 [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login dan
  2022-11-08 20:11 ` ( via Guix-patches via
@ 2022-11-09 12:26 ` Tobias Geerinckx-Rice via Guix-patches via
  2022-11-09 13:48   ` dan
  2022-12-26  8:36 ` bug#59132: " Mathieu Othacehe
  2 siblings, 1 reply; 11+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2022-11-09 12:26 UTC (permalink / raw)
  To: dan; +Cc: 59132

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.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-09 12:26 ` Tobias Geerinckx-Rice via Guix-patches via
@ 2022-11-09 13:48   ` dan
  2022-11-18 14:00     ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: dan @ 2022-11-09 13:48 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 59132

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





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-09 13:48   ` dan
@ 2022-11-18 14:00     ` Ludovic Courtès
  0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2022-11-18 14:00 UTC (permalink / raw)
  To: dan, Mathieu Othacehe; +Cc: Tobias Geerinckx-Rice, 59132

Hi Mathieu,

Could you comment on this patch dan submitted?

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

Thanks in advance.  :-)

Ludo’.

dan <i@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!




^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#59132: [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login.
  2022-11-08 20:05 [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login dan
  2022-11-08 20:11 ` ( via Guix-patches via
  2022-11-09 12:26 ` Tobias Geerinckx-Rice via Guix-patches via
@ 2022-12-26  8:36 ` Mathieu Othacehe
  2 siblings, 0 replies; 11+ messages in thread
From: Mathieu Othacehe @ 2022-12-26  8:36 UTC (permalink / raw)
  To: dan; +Cc: 59132-done


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




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-12-26  8:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 20:05 [bug#59132] [PATCH] system: images: wsl2: Create $XDG_RUNTIME_DIR on first login dan
2022-11-08 20:11 ` ( via Guix-patches via
2022-11-08 20:23   ` dan
2022-11-08 20:27     ` ( via Guix-patches via
2022-11-09  4:26       ` dan
2022-11-09  7:24       ` dan
2022-11-08 20:27     ` ( via Guix-patches via
2022-11-09 12:26 ` Tobias Geerinckx-Rice via Guix-patches via
2022-11-09 13:48   ` dan
2022-11-18 14:00     ` Ludovic Courtès
2022-12-26  8:36 ` bug#59132: " Mathieu Othacehe

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).