mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
Merge pull request #33491 from keszybz/allow-interactive-auth-in-inhibit
Allow interactive auth in inhibit
This commit is contained in:
commit
8e6d95846b
@ -114,6 +114,7 @@
|
||||
acquiring one.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="no-ask-password" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager" />
|
||||
<xi:include href="standard-options.xml" xpointer="no-legend" />
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
|
@ -39,13 +39,13 @@
|
||||
#include "path-util.h"
|
||||
#include "percent-util.h"
|
||||
#include "pkcs11-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "process-util.h"
|
||||
#include "recurse-dir.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "terminal-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-classification.h"
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "hostname-util.h"
|
||||
#include "main-func.h"
|
||||
#include "parse-argument.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "socket-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "terminal-util.h"
|
||||
#include "verbs.h"
|
||||
|
||||
|
@ -24,10 +24,10 @@
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "signal-util.h"
|
||||
#include "sort-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "string-table.h"
|
||||
#include "verbs.h"
|
||||
#include "web-util.h"
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include "main-func.h"
|
||||
#include "memory-util.h"
|
||||
#include "pager.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "set.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "verbs.h"
|
||||
|
@ -25,10 +25,11 @@
|
||||
#include "terminal-util.h"
|
||||
#include "user-util.h"
|
||||
|
||||
static const char* arg_what = "idle:sleep:shutdown";
|
||||
static const char* arg_who = NULL;
|
||||
static const char* arg_why = "Unknown reason";
|
||||
static const char* arg_mode = NULL;
|
||||
static const char *arg_what = "idle:sleep:shutdown";
|
||||
static const char *arg_who = NULL;
|
||||
static const char *arg_why = "Unknown reason";
|
||||
static const char *arg_mode = NULL;
|
||||
static bool arg_ask_password = true;
|
||||
static PagerFlags arg_pager_flags = 0;
|
||||
static bool arg_legend = true;
|
||||
|
||||
@ -42,6 +43,8 @@ static int inhibit(sd_bus *bus, sd_bus_error *error) {
|
||||
int r;
|
||||
int fd;
|
||||
|
||||
(void) polkit_agent_open_if_enabled(BUS_TRANSPORT_LOCAL, arg_ask_password);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, "Inhibit", error, &reply, "ssss", arg_what, arg_who, arg_why, arg_mode);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -145,6 +148,7 @@ static int help(void) {
|
||||
"\n%sExecute a process while inhibiting shutdown/sleep/idle.%s\n\n"
|
||||
" -h --help Show this help\n"
|
||||
" --version Show package version\n"
|
||||
" --no-ask-password Do not attempt interactive authorization\n"
|
||||
" --no-pager Do not pipe output into a pager\n"
|
||||
" --no-legend Do not show the headers and footers\n"
|
||||
" --what=WHAT Operations to inhibit, colon separated list of:\n"
|
||||
@ -173,20 +177,22 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_WHY,
|
||||
ARG_MODE,
|
||||
ARG_LIST,
|
||||
ARG_NO_ASK_PASSWORD,
|
||||
ARG_NO_PAGER,
|
||||
ARG_NO_LEGEND,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "what", required_argument, NULL, ARG_WHAT },
|
||||
{ "who", required_argument, NULL, ARG_WHO },
|
||||
{ "why", required_argument, NULL, ARG_WHY },
|
||||
{ "mode", required_argument, NULL, ARG_MODE },
|
||||
{ "list", no_argument, NULL, ARG_LIST },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||
{ "what", required_argument, NULL, ARG_WHAT },
|
||||
{ "who", required_argument, NULL, ARG_WHO },
|
||||
{ "why", required_argument, NULL, ARG_WHY },
|
||||
{ "mode", required_argument, NULL, ARG_MODE },
|
||||
{ "list", no_argument, NULL, ARG_LIST },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||
{}
|
||||
};
|
||||
|
||||
@ -228,6 +234,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_action = ACTION_LIST;
|
||||
break;
|
||||
|
||||
case ARG_NO_ASK_PASSWORD:
|
||||
arg_ask_password = false;
|
||||
break;
|
||||
|
||||
case ARG_NO_PAGER:
|
||||
arg_pager_flags |= PAGER_DISABLE;
|
||||
break;
|
||||
@ -267,6 +277,8 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
|
||||
|
||||
(void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
|
||||
|
||||
if (arg_action == ACTION_LIST)
|
||||
return print_inhibitors(bus);
|
||||
else {
|
||||
|
@ -25,12 +25,12 @@
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "sysfs-show.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
<description gettext-domain="systemd">Allow applications to inhibit system shutdown</description>
|
||||
<message gettext-domain="systemd">Authentication is required for an application to inhibit system shutdown.</message>
|
||||
<defaults>
|
||||
<allow_any>no</allow_any>
|
||||
<allow_any>auth_admin_keep</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
@ -44,7 +44,7 @@
|
||||
<description gettext-domain="systemd">Allow applications to inhibit system sleep</description>
|
||||
<message gettext-domain="systemd">Authentication is required for an application to inhibit system sleep.</message>
|
||||
<defaults>
|
||||
<allow_any>no</allow_any>
|
||||
<allow_any>auth_admin_keep</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ask-password-agent.h"
|
||||
#include "build.h"
|
||||
#include "build-path.h"
|
||||
#include "bus-common-errors.h"
|
||||
@ -47,6 +48,7 @@
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "ptyfwd.h"
|
||||
@ -54,8 +56,6 @@
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "sort-util.h"
|
||||
#include "spawn-ask-password-agent.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
|
@ -28,10 +28,10 @@
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "sort-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "stat-util.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "portable.h"
|
||||
#include "pretty-print.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
|
@ -30,11 +30,11 @@
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "ptyfwd.h"
|
||||
#include "signal-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "special.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
|
@ -4,10 +4,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ask-password-agent.h"
|
||||
#include "exec-util.h"
|
||||
#include "log.h"
|
||||
#include "process-util.h"
|
||||
#include "spawn-ask-password-agent.h"
|
||||
|
||||
static pid_t agent_pid = 0;
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "argv-util.h"
|
||||
#include "ask-password-agent.h"
|
||||
#include "hashmap.h"
|
||||
#include "pager.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "spawn-ask-password-agent.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "static-destruct.h"
|
||||
|
||||
#define _DEFINE_MAIN_FUNCTION(intro, impl, result_to_exit_status, result_to_return_value) \
|
||||
|
@ -4,6 +4,7 @@ shared_sources = files(
|
||||
'acl-util.c',
|
||||
'acpi-fpdt.c',
|
||||
'apparmor-util.c',
|
||||
'ask-password-agent.c',
|
||||
'ask-password-api.c',
|
||||
'async.c',
|
||||
'barrier.c',
|
||||
@ -141,6 +142,7 @@ shared_sources = files(
|
||||
'pe-binary.c',
|
||||
'pkcs11-util.c',
|
||||
'plymouth-util.c',
|
||||
'polkit-agent.c',
|
||||
'pretty-print.c',
|
||||
'capsule-util.c',
|
||||
'ptyfwd.c',
|
||||
@ -160,8 +162,6 @@ shared_sources = files(
|
||||
'smbios11.c',
|
||||
'socket-label.c',
|
||||
'socket-netlink.c',
|
||||
'spawn-ask-password-agent.c',
|
||||
'spawn-polkit-agent.c',
|
||||
'specifier.c',
|
||||
'switch-root.c',
|
||||
'tmpfile-util-label.c',
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "io-util.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "process-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "stdio-util.h"
|
||||
#include "time-util.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "sd-bus.h"
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "ask-password-agent.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-locator.h"
|
||||
#include "bus-map-properties.h"
|
||||
@ -19,11 +20,10 @@
|
||||
#include "macro.h"
|
||||
#include "path-util.h"
|
||||
#include "pidref.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "process-util.h"
|
||||
#include "reboot-util.h"
|
||||
#include "set.h"
|
||||
#include "spawn-ask-password-agent.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "stat-util.h"
|
||||
#include "systemctl-util.h"
|
||||
#include "systemctl.h"
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "main-func.h"
|
||||
#include "pager.h"
|
||||
#include "parse-util.h"
|
||||
#include "polkit-agent.h"
|
||||
#include "pretty-print.h"
|
||||
#include "sparse-endian.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user