probonopd / go-appimage

Go implementation of AppImage tools
MIT License
680 stars 69 forks source link

openLDAP user: appimaged fails to start #215

Closed archont00 closed 1 year ago

archont00 commented 2 years ago

Hi,

Kubuntu 22.04.

Starting as openLDAP user, uid 10000, /home/users/ldap_user, the appimaged fails:

$ /Applications/appimaged-711-x86_64.AppImage 
appimaged-711-x86_64.AppImage 65
2022/07/09 22:01:25 Desktop notification:  Not running on one of the supported Live systems This configuration is currently unsupported but may still work, please give feedback.
2022/07/09 22:01:25 main: PATH: /usr/local/bin:/opt:/home/users/ldap_user/Desktop:/home/users/ldap_user/Downloads:/tmp/.mount_appimaadMhhD/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
panic: user: unknown userid 10000

goroutine 1 [running]:
main.TerminateOtherInstances()
        github.com/probonopd/go-appimage/src/appimaged/prerequisites.go:270 +0x4a7
main.checkPrerequisites()
        github.com/probonopd/go-appimage/src/appimaged/prerequisites.go:49 +0xe5
main.main()
        github.com/probonopd/go-appimage/src/appimaged/appimaged.go:130 +0x1d7

When I run appimaged as local user (uid: 1000, /home/localuser), it seems to start fine.

mneiger commented 1 year ago

Same problem and error message with ldap users on version 7.30. OS is Mint 21 (Ubuntu 22.04 based)

probonopd commented 1 year ago

appimaged is only tested with local users. I do not have ldap to test with.

mneiger commented 1 year ago

I understand, but what would you like/need/plan in this respect. I wished I could simply offer a PR, but my skills are not sufficient for this. Though I can test, or suggest a debian based distribution with ldap preinstalled such as yunohost

CalebQ42 commented 1 year ago

Taking a quick look at it, it should be a fairly easy fix since the function that's throwing the error also doesn't really do anything ATM. It'll be fairly easy to gracefully fail instead of panicking, though I'd like to find out exactly why it's giving an error in the first place and probably make the function... function.

I also don't actually know what ldap is so I'll have to look that up and setup a VM so I can test it properly.

mneiger commented 1 year ago

LDAP is a directory database for users and groups (and many other stuff in enterprise settings). I my case and many small linux networks, it's used to have a centralized database of users, groups, and is also used for user authentication through PAM and sssd. Actually is allows to have users and groups beyond /etc/passwd and /etc/groups usually using higher userid numbers (> 10000 or 100000). As a standard system, it also allows to use the same user/password for many different apps, including many web apps.

it's likely that the issue depends on the layer (i'm not knowledgeable about the details) addressed to check for users. It depends whether it checks users against the /etc/passwd content (where ldap user are not included) or a higher level abstraction where ldap (external) users will be included.

yunohost is easy to set up as a VM, it's a debian based distrib for self hosting internet/mail/web services, and it sets up ldap a central user database for all apps. Although as it doesn't have a graphical environement, it may be an issue to check appimaged.

CalebQ42 commented 1 year ago

We're just using user.Current() and I'm guessing it's just looking at /etc/passwd then. That function isn't really essential anyways so we'll probably just elegantly fail instead of panicking.

Thanks for the info.

mneiger commented 1 year ago

hi @CalebQ42 , thanks for your reaction. Indeed the explanation here https://pkg.go.dev/os/user confirms it is directly checking /ect/passwd. I suspect the library based on glibc will rather check also for domain/AD/LDAP users.

ananthb commented 1 year ago

user.Current uses the NSS libraries on Linux when.CGO is enabled. When it isn't, it simply falls back to parsing /etc/passwd.

mneiger commented 1 year ago

Sorry, I'm not sure whether you did change anything yet toward this, just to let you know it's still the same as of today on v754.

probonopd commented 1 year ago

Can you verify that @CalebQ42's https://github.com/probonopd/go-appimage/pull/235 fixes this? I have no openLDSP setup to test with. Thanks.

ananthb commented 1 year ago

You don't need LDAP to reproduce this bug. There's a disparity in Go's os/user package when Cgo is enabled vs when it isn't. When the binary uses Cgo, user and group queries go through NSS. If Cgo is disabled, it falls back to parsing /etc/passwd and friends. So I ran into this issue because my user account is created by systemd-homed and doesn't reside in /etc/passwd.

So any user defined via NSS and not via shadow files will trigger this bug. This includes LDAP, systemd dynamic users, systemd drop-in users, systemd homed users, etc.

Relevant docs: https://pkg.go.dev/os/user

ananthb commented 1 year ago

I tried testing out #235, but it doesn't play nicely with Gnome on Wayland apparently.

CalebQ42 commented 1 year ago

What's the problem you're having? I've been mostly testing it on Gnome with Wayland.

ananthb commented 1 year ago

I chmod+x the appimaged binary for my platform and then got this:

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
execv error: No such file or directory.

I tried running it with QT_QPA_PLATFORM=wayland but that gave me a different error

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

I don't think I have qt installed.

CalebQ42 commented 1 year ago

You're getting this error when trying to run appimaged? It shouldn't have any qt components at all and nothing in #235 should change that.

ananthb commented 1 year ago

@CalebQ42 #235 works. I get an error about an unknown user, but appimaged continues to run. I had appimagelauncherd installed and that was messing with appimaged.

ananthb commented 1 year ago

I've closed my other issue about systemd-homed. This issue could be re-titled to "appimaged panics enumerating NSS users".

mneiger commented 1 year ago

Just to confirm this is now working as of release 765. It reports 2023/03/06 ERROR term other instances: user: unknown userid 1000013

But seems to work fine otherwise Thanks a lot