-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
loginctl
user lingering configuration revisited
#261319
base: master
Are you sure you want to change the base?
Conversation
2bfffd3
to
4b78e1e
Compare
Thank you for this comprehensive and welcome improvement to lingering support! The diff looks good; I can try patching this in and testing it locally, if you like, although I don't have any Thoughts on the questions: (1) In general, my experience with nixos activation scripts is that most things are warnings, and in particular failing to successfully start/shutdown services are warnings and the activation script still runs to completion. Since this will have similar effects on failure (some services that should stop will keep running, or services that should start won't) I'd expect it to have the same severity level. (2,3) My preference is always to use the version from the nix store rather than trust the one in |
d37ced4
to
5a670ab
Compare
@ToxicFrog -- thank you for the feedback! Re (1) sounds good; thanks for the shot of confidence. |
5a670ab
to
cd707e9
Compare
Reviewed points
Possible improvements
CommentsI strongly support this pull request: I have users that would like to control their lingering by themselves, and #260248 broke this. Also I like the trinary design of the option: It's quick and clear! |
@Yarny0 -- thanks for catching the boot-time issue. I've added fallback lingering management methods to Re managing user lingering in an activation script: I implemented it like that in order to hook into the existing user creation and deletion logic. I suppose it would be possible to make |
in order to respect `users.mutableUsers = true` by only enabling or disabling lingering when creating a given user account, otherwise leaving the existing lingering configuration untouched.
that do not rely on systemd having booted or the systemd login manager being up. Detect whether the login manager is available by running `loginctl show-sessions`; if this returns a nonzero status, touch `/var/lib/systemd/linger/${user}` when enabling lingering, and unlink same when disabling lingering.
to distinguish between this and removing lingering for users who have `{ linger = false; }`.
1e6b743
to
72fe0f9
Compare
purely informational but i'll mention #264879 as a landing point for you to look at - why? there are people who have intentions involving the scripts you're working on here |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Description of changes
Follow-up to #260248 (and related to #3702). The main goal is to address the concerns expressed in this review comment; namely, that user lingering settings should be left alone when
users.mutableUsers
is enabled.Questions for reviewers:
update-users-groups.pl
. This script warns, but does not abort, if something goes wrong with enabling or disabling lingering (e.g. failure to create or remove files under/var/lib/systemd/linger
) (at least, this is true when using the fallback implementations ofdo{En,Dis}ableLinger
). Should these warnings be promoted to fatal exceptions?do{En,Dis}ableLinger
? IIUC/run/booted-system/sw/bin/loginctl
is not guaranteed to exist when the relevant activation script runs./run/booted-system/sw/bin/loginctl
the correct choice ofloginctl
path? Shouldupdate-users-groups.pl
instead use (for instance)${pkgs.systemd}/bin/loginctl
?Note that I incorporated the user lingering management implementation into
update-users-groups.pl
because this makes it easy to detect whether a given user account is newly-created or not, and thereby determine whether it is okay to touch the user's lingering setting whenusers.mutableUsers
is enabled.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
) (kinda sorta non-applicable, though I did test the functionality of the executable [update-users-groups.pl
])