canonical / lightdm

Display Manager
GNU General Public License v3.0
840 stars 138 forks source link

LightDM doesn't list users created with systemd-homed #255

Open Tachi107 opened 2 years ago

Tachi107 commented 2 years ago

Hi, it seems that LightDM is unable to list users created with homectl. homectl creates users with an UID in the range 60001…60513, and doesn't store them in /etc/passwd, nor /etc/shadow; users have to be retrieved with getent or similar, simply parsing /etc/passwd is not enough.

I'm using Debian Testing (12) with Xfce. Thanks :)

Tachi107 commented 2 years ago

I've just discovered that LightDM is capable of showing users created via systemd-homed, but only when freedesktop's AccountsService is not installed. This is because the load_users() function, in common/user-list.c, falls back to manually parsing passwd when account retrieval via org.freedesktop.Accounts fails.

The badly named load_passwd_file() function loads the list of users with getpwent(), instead of manually parsing /etc/passwd. As getpwent() is hooked into glibc's NSS thing, LightDM is able to correctly get users from systemd-homed, that installs a NSS module so that its users are retrievable via getpwent() while not being in /etc/passwd.

In short, the bug is mainly in AccountsService (see accountsservice/accountsservice#89), but LightDM shows an unpredictable behaviour depending on whether org.freedesktop.Accounts is available or not and should either workaround the bug or fix it upstream.