arkane-systems / genie

A quick way into a systemd "bottle" for WSL
Other
1.85k stars 104 forks source link

User runtime directory not correctly mounted anymore for non WSLg environment #160

Closed graben closed 3 years ago

graben commented 3 years ago

Windows version (build number): 20H2 19042.964

Linux distribution: CentOS8 Stream

Genie version: 1.40

Describe the bug /run/user/${ID} not mounted (Bug with user-runtime-dir@.service.d override)

from /var/log/messages: Apr 29 19:47:16 localhost systemd[1]: Started Shell for User osiris. Apr 29 19:47:16 localhost systemd[1]: user-runtime-dir@2009.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing. Apr 29 19:47:16 localhost systemd-logind[221]: Failed to start user service 'user@2009.service', ignoring: Unit user-runtime-dir@2009.service has a bad unit file setting. Apr 29 19:47:16 localhost systemd[1]: Created slice User Slice of UID 2009. Apr 29 19:47:16 localhost systemd[1]: Started Session c1 of user osiris.

If the bug involves systemctl or a service running under systemd, confirm that you are running inside the bottle: inside

To Reproduce Steps to reproduce the behavior:

Expected behavior User systemd service is correctly started

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Could be solved by deleting override.conf

PavelSosin-320 commented 3 years ago

Looks OK in Fedora34, genie ver 40, noWSLg Several sessions opened via WT"

ls -il /run/user/ total 0 1 drwx------ 3 root root 80 Apr 29 10:09 0 5 drwx------ 5 pavel users 160 Apr 30 11:48 1000 1 drwx------ 5 dog dog 120 Apr 29 15:43 1001 [root@MSI-wsl ~]# id dog uid=1001(dog) gid=1001(dog) groups=1001(dog) [root@MSI-wsl ~]# id pavel uid=1000(pavel) gid=1000(pavel) groups=1000(pavel),4(adm),10(wheel),11(cdrom) [root@MSI-wsl ~]# id dog uid=1001(dog) gid=1001(dog) groups=1001(dog)

Rootfull, rootless Podman 3.1 are OK

See UserRubtimeServiceNotNeeded. maybe cab be masked?

PavelSosin-320 commented 3 years ago

@cerebrate CentOS 8 stream vs Fedora 34 + Podman, i.e. Containers package with the latest FUSE: As I see My Podman installation brought a lot of new stuff including fuse-overlays utilities responsible on FS mounting as dependencies. My big luck is that the recent WSL Kernel 5.10 contains FUSE module: Apr 29 10:09:50 MSI-wsl kernel: fuse: init (API version 7.32) Apr 29 10:09:50 MSI-wsl systemd[1]: modprobe@fuse.service: Succeeded. Apr 29 10:09:50 MSI-wsl systemd[1]: Finished Load Kernel Module fuse. Fedora 34 is much newer than CentOS 8 It uses different systemd and alternative mount utility Simple option passed by service implementation to the mount can change everything. -o allow_other allow access by all users -o allow_root allow access by root I think that it has to be tested how genie -l works after installation of FUSE package on Debian and Ubuntu.

PavelSosin-320 commented 3 years ago

@graben You didn't mention how user 2009 was created. Please update your system using yum, remove old 2009 uid user and create it again using useradd from the CentOS distro following useradd documentation. Then exit old session, restart CentOS and log on again using genie -l. It will create all necessary configurations for the new rootless user. If you need administrative privileges for the user you will have to add the wheel group. All other ways to create users in RedHat Linux systems results in broken user creation. If you need to run rootless services, please, check FUSE and FUSE utilities dependencies. Good luck, I almost sure it will help.

cerebrate commented 3 years ago

@graben Well, looks like CentOS must be doing something clever with user-runtime-dir@.service over and above the standard part-of-systemd implementation of it, because that is a oneshot service.

Can you send me the /lib/systemd/system/user-runtime-dir@.service file, please? Also any /etc/systemd/system/user-runtime-dir@.service file, if it exists.

graben commented 3 years ago

@cerebrate user-runtime-dir@.service.txt from /usr/lib/... there is no one under /etc/systemd

graben commented 3 years ago

@PavelSosin-320 : I'm still on latest updates and user is created with useradd, yet. Without override (deleted) everything works with mounting /run/user/2009 and also podman with fuse-overlay is working. That was exactly the test why I found this "issue". ;)

cerebrate commented 3 years ago

@graben Ah, I think I see the problem. (Just to confirm, and so I can add this to the repo wiki, what's the output of systemd --version?) I've had trouble with CentOS before (although that was CentOS 7) because of it using a significantly downlevel version of systemd. See #104 for the gory details of that.

Anyway, the user-runtime-dir@.service unit file on the Debian system I use - which matches the version distributed with current systemd -- reads like this:

#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=User Runtime Directory /run/user/%i
Documentation=man:user@.service(5)
After=systemd-user-sessions.service dbus.service
StopWhenUnneeded=yes
IgnoreOnIsolate=yes

[Service]
ExecStart=/lib/systemd/systemd-user-runtime-dir start %i
ExecStop=/lib/systemd/systemd-user-runtime-dir stop %i
Type=oneshot
RemainAfterExit=yes
Slice=user-%i.slice

...which as you can see is similar, but contains more, including the crucial Type=oneshot line.

Short of finding a way to upgrade your whole systemd - and insofar as I don't have time or resources to spend on officially supporting downlevel systemds and their dependencies - my unofficial recommendation for getting it working is to add the Type=oneshot line to the user-runtime-dir@.service file, or copy it into /etc/systemd/system and then add it there.

graben commented 3 years ago

@cerebrate

systemd --version systemd 239 (239-45.el8) +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=legacy

cerebrate commented 3 years ago

...huh, that's newer than I was expecting.

Okay, checking the systemd source, it looks like they changed the unit file to the newer version in 240 , and I probably don't want to bump the dependency up that far yet, sigh.

Well, okay, I'll see what I can figure out by way of an appropriate fix; in the meantime, the above is still probably the best workaround.

graben commented 3 years ago

@cerebrate : add Type=oneshot to copy of user-runtime-dir@.service in /etc/systemd/system works.

PavelSosin-320 commented 3 years ago

In my Fedoraremix I have already systemctl --version systemd 246 (v246.13-1.fc33) +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified. But FedoraRemix is maintained by a separate company - Whitewater foundation. They work much faster than Microsoft. They just released Fedora34.3remix final for WSL Anyway, Podman team targeting Fedora34. For future development using RedHat tools, it will be the better option.

cerebrate commented 3 years ago

Patched around in 1.41; forthcoming.