NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.35k stars 13.59k forks source link

AccountService reports incorrect info #84634

Open jtojnar opened 4 years ago

jtojnar commented 4 years ago
$ 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’s 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.)

matthewbauer commented 4 years ago

Here's the code which determines is_system_account:

https://github.com/freedesktop/accountsservice/blob/34bedecf7da81a8b42382254e3f9a32398c1ca5d/src/user-classify.c#L147-L168

jtojnar commented 4 years ago

According to @worldofpeace, there is some cache in the ¿library? and that is what actually returns the incorrect value.

worldofpeace commented 4 years ago

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

jtojnar commented 3 years ago

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.

worldofpeace commented 3 years ago

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.

jtojnar commented 3 years ago

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.

worldofpeace commented 3 years ago

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.

jtojnar commented 3 years ago

Yes. I am pretty sure we have discussed this few cycles ago. Here is the code:

https://github.com/GNOME/gnome-shell/blob/b2d6c11ec39042855910f36d59e0789e16593fb9/js/misc/systemActions.js#L394

worldofpeace commented 3 years ago

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.

jtojnar commented 3 years ago

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.

Screenshot from 2020-10-08 19-44-45

Triggering the _updateLogout() method manually correctly hides it.

worldofpeace commented 3 years ago

I opened https://github.com/NixOS/nixpkgs/issues/100108 because that is the issue we're fixing.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cannot-switch-between-users-gnome-40-1/13977/2

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info