$ nix-shell -p gobject-introspection -p accountsservice -p gjs --run "gjs -c \"print(imports.gi.GLib.get_user_name()); let u = imports.gi.AccountsService.UserManager.get_default().get_user(imports.gi.GLib.get_user_name()); print(imports.gi.GLib.get_user_name()); print(u.is_local_account()); print(u.is_system_account())\""
jtojnar
jtojnar
false
true
I am local non-system user, though.
Even more curiously, in GNOME Shell鈥檚 looking glass (press alt-F2 and then enter lg), the values are correct:
>>> u = imports.gi.AccountsService.UserManager.get_default().get_user(imports.gi.GLib.get_user_name())
r(0) = u.is_local_account()); print(u.is_system_account()
>>> u.get_real_name()
r(1) = jtojnar
>>> u.is_local_account()
r(2) = true
>>> u.is_system_account()
r(3) = false
@worldofpeace
I believe multi user setups and logging and logging out is kinda broken in gnome. And similarly, since we updated to 3.36.0 pantheon's logout has had similar issues #95658. Though I'm not actually sure that is related since I haven't had time to look into the issue. (I don't use a multi user system or log out frequently to notice these things.)
Here's the code which determines is_system_account:
According to @worldofpeace, there is some cache in the 驴library? and that is what actually returns the incorrect value.
I believe multi user setups and logging and logging out is kinda broken in gnome. And similarly, since we updated to 3.36.0 pantheon's logout has had similar issues https://github.com/NixOS/nixpkgs/issues/95658. Though I'm not actually sure that is related since I haven't had time to look into the issue. (I don't use a multi user system or log out frequently to notice these things.)
In any case, what we really need is a distinct test case that is testing login. An example of what fedora checks is https://pagure.io/fedora-qa/os-autoinst-distri-fedora/blob/master/f/tests/desktop_login.pm
I am able to reproduce the incorrect values as reported by the bindings on Ubuntu 20.04, including the correct values in looking glass.
I am unable to reproduce the log out issue. I can log in, log out, and then log in to another account in a NixOS VM successfully.
I will try this in a VM also. For me it's that sometimes in the Power off/log out there is no log out at all. And in terms of frequency it has been almost always. This is with a single user system, if that changes things. As you did test switching to another account.
IIRC, since long time ago, log out is not supposed to be there on single user systems and it is a bug when it is there.
IIRC, since long time ago, log out is not supposed to be there on single user systems and it is a bug when it is there.
Really? The thing is, you have to logout to switch a session to xorg, for example. For every past release this did work for me.
Yes. I am pretty sure we have discussed this few cycles ago. Here is the code:
Okay, that code right there is just what we're looking for.
One thing I can already assume is that, the default installation is going to have two sessions xorg and the default wayland one. multiSession should be true, but actually there's no session installed in a way that gdm is going to expect (in the environment of the running session) https://github.com/GNOME/gdm/blob/master/libgdm/gdm-sessions.c#L254.
When I do imports.gi.Gdm.get_session_ids().length it's 0 in lookinglass. Maybe this changed and because of that we go further in the || uncovering the issues with systemAccount || !localAccount because accountsservice has the wrong info (maybe for a similar reason?).
I did this
nix-shell -p gobject-introspection -p gnome3.gdm -p gjs --run 'gjs -c "print(imports.gi.Gdm.get_session_ids().length)"'
and got 0, but after doing
environment.systemPackages = [
config.services.xserver.displayManager.sessionData.desktops
];
I have 2 and the logout button shows.
But the AccountsService bug is consistently not occurring in GNOME Shell process. It correctly detects that systemAccount === false and localAccount === true, thus hiding the menu item.
There is another independent bug that makes the menu item visible even when it should not be, as we noticed in https://github.com/NixOS/nixpkgs/pull/81626#issuecomment-602147213.

Triggering the _updateLogout() method manually correctly hides it.
I opened https://github.com/NixOS/nixpkgs/issues/100108 because that is the issue we're fixing.