Skip to content
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

Added option --check-inhibitors for non-tty usage #18210

Merged

Conversation

deepak-rawat
Copy link
Contributor

As described in #2680, systemctl did ignore inhibitors if it is not
attached to a tty to allow scripts to ignore inhibitors automatically.
This pull request preserves this behavior but allows scripts to
explicit check inhibitors if required.

The new parameter '--check-inhibitors=yes' enables this feature.
The old parameter '-i'/'--ignore-inhibitors' was deprecated in favor
of '--check-inhibitors=no', the default behaviour can be specified
with '--check-inhibitors=auto'.
The new parameter is also described in the documentations and shell
completions found here.

This PR is to address feedback to PR #16215, credit to original author @Zocker1999NET

Testing: Followed the same test cases as done in the original PR #16215:

inhibit lock by request by =auto with tty =auto with no tty =yes =no
root root suspended suspended denied suspended
root user denied asked denied asked
user root suspended suspended denied suspended
user user denied suspended denied suspended

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks excellent. Some minor points

src/systemctl/systemctl-logind.c Outdated Show resolved Hide resolved
man/systemctl.xml Show resolved Hide resolved
src/systemctl/systemctl.c Show resolved Hide resolved
As described in systemd#2680, systemctl did ignore inhibitors if it is not
attached to a tty to allow scripts to ignore inhibitors automatically.
This pull request preserves this behavior but allows scripts to
explicit check inhibitors if required.

The new parameter '--check-inhibitors=yes' enables this feature.
The old parameter '-i'/'--ignore-inhibitors' was deprecated in favor
of '--check-inhibitors=no', the default behaviour can be specified
with '--check-inhibitors=auto'.
The new parameter is also described in the documentations and shell
completions found here.
@amishmm
Copy link

amishmm commented Feb 2, 2021

Please also add (extend) this option to /etc/systemd/system.conf (or under /usr or any other appropriate place) which would then become a default behavior when check-inhibitors is not specified.

Something like:

[Manager]
CheckInhibitors=auto|yes|no

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks systemctl
Development

Successfully merging this pull request may close these issues.

4 participants