containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

Handling Env for Headless Dev / with user session | Support inference of XDG_RUNTIME_DIR #1465

Open ehdis opened 4 months ago

ehdis commented 4 months ago

Describe the bug Steps how to reproduce the behaviour

Env for Headless Dev / with user session

The creation of the container fails

[root@tbx ~]# useradd test
[root@tbx ~]# passwd test
[root@tbx ~]# loginctl enable-linger $(id -u test)
[root@tbx ~]# su - test
[test@tbx ~]$ toolbox create --distro fedora -r 39
Image required to create toolbox container.
Download registry.fedoraproject.org/fedora-toolbox:39 (500MB)? [y/N]: y
Error: failed to create container fedora-toolbox-39
[test@tbx ~]$ echo $?
1

Expected behaviour A container in $ podman ps -a

Actual behaviour Empty $ podman ps -a output.

Output of toolbox --version (v0.0.90+) toolbox version 0.0.99.4

Toolbx package info (rpm -q toolbox) toolbox-0.0.99.4-6.el9_3.x86_64

Additional context The user manager (systemd session) is spawned for the user at boot but the XDG_RUNTIME_DIR is not set.

[test@tbx ~]$ printenv |grep ^XDG_R || echo "No env"
No env

albeit

[test@tbx ~]$ test -S /run/user/$(id -u)/bus && echo "Socket available"
Socket available

Should toolbx infer the environment var (via socket availability)?

The empty XDG_RUNTIME_DIR is the cause for the failed creation of the container. When setting it the process runs ...

[test@tbx ~]$ export XDG_RUNTIME_DIR=/run/user/$(id -u "${USER}")
[test@tbx ~]$  toolbox create --distro fedora -r 39
Created container: fedora-toolbox-39
Enter with: toolbox enter fedora-toolbox-39
[test@tbx ~]$ echo $?
0