Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] XAUTHORITY is not set because host-spawn is not working. Move env setup to distrobox-enter #1383

Closed
tymonx opened this issue May 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tymonx
Copy link

tymonx commented May 9, 2024

This kinda a bug and change request /suggestion in the same time.

Describe the bug
The XAUTHORITY environment variable is not set because the host-spawn is not working.

This is Linux distro and OS environment specific. Cannot reproduce easy without Virtual Machine.

  1. Install stable distrobox:
curl -s https://raw.githubusercontent.com/89luca89/distrobox/1.7.2.1/install | sh -s -- --prefix ~/.local
  1. Create new container using distrobox:
distrobox create --name <name> --init --image <image>
  1. Enter into created container:
distrobox enter <name>
  1. Try to print XAUTHORITY:
echo $AXUTHORITY

It will return nothing.

  1. Try to run anything using host-spawn:
host-spawn env

It will return nothing.

  1. Try to run any GUI application:
Authorization required, but no authorization protocol specified
Application initialization failed: couldn't connect to display ":0"

To Reproduce

Not that easy to reproduce that. Unknown reason why the host-spawn is not working. Linux distro specific, Kinoite version 39.

Expected behavior

  • The XAUTHORITY environment variable set using value from host side
  • GUI application is working

Logs

Desktop (please complete the following information):

  • Are you using podman, docker or lilipod?
podman
  • Which version or podman, docker or lilipod?
4.9.4
  • Which version of distrobox?
1.7.2.1
  • Which host distribution?
Kinoite 39
  • How did you install distrobox?
curl -s https://raw.githubusercontent.com/89luca89/distrobox/1.7.2.1/install | sh -s -- --prefix ~/.local

Additional context

I want to propose a change request. I can prepare a Pull Request. If we move setting the XAUTHORITY environment variable and XAUTH from the distrobox-init to the distrobox-enter and simple use --env container option, then we could remove need of host-spawn call from container side and simplify logic in the same time.

@tymonx tymonx added the bug Something isn't working label May 9, 2024
@tymonx
Copy link
Author

tymonx commented May 9, 2024

It seems that distrobox enter adds --env XAUTHORITY=${XAUTHORITY} anyway in that generic for-loop: https://github.com/89luca89/distrobox/blob/1.7.2.1/distrobox-enter#L443

But still it is not present when doing:

env | grep XAUTHORITY

But if I run created container by distrobox create using podman exec:

podman exec --interactive --tty --detach-keys="" --user=root --workdir="${HOME}" --env XAUTHORITY <container> su "${USER}" --pty

Then the XAUTHORITY environment variable is not empty. I'm trying to narrow the issue here. Above command is also ran by distrobox enter. After podman exec and before <container> the distrobox enter adds bunch of additionals --env. Something is causing that the XAUTHORITY environment variable is unset after switching from root to user.

@tymonx
Copy link
Author

tymonx commented May 9, 2024

Short story. When --env DISPLAY=:0 is present, it will clear XAUTHORITY. I have been using custom AlmaLinux OS 9.3 with added user etc.. Somehow when calling su "${USER}" --pty when switching from root to user by distrobox enter, it clears XAUTHORITY environment variable. With vanilla AlmaLinux OS 9.3 it doesn't happen.

Not working host-spawn in distrobox-init is OK/not relavant for me because it should be fixed by distrobox-enter and --env XAUTHORITY from this loop https://github.com/89luca89/distrobox/blob/1.7.2.1/distrobox-enter#L443

I will try to narrow problem in my custom container image based on AlmaLinux OS 9.3 and share minimum Dockerfile to reproduce that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant