mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-28 11:55:23 +03:00
systemctl,loginctl: start polkit agent for all polkit enabled operations
This commit is contained in:
parent
acf97e213e
commit
079dac08c6
@ -50,8 +50,8 @@ static bool arg_legend = true;
|
||||
static const char *arg_kill_who = NULL;
|
||||
static int arg_signal = SIGTERM;
|
||||
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
|
||||
static bool arg_ask_password = true;
|
||||
static char *arg_host = NULL;
|
||||
static bool arg_ask_password = true;
|
||||
static unsigned arg_lines = 10;
|
||||
static OutputMode arg_output = OUTPUT_SHORT;
|
||||
|
||||
@ -827,6 +827,8 @@ static int activate(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
|
||||
r = sd_bus_call_method (
|
||||
@ -856,6 +858,8 @@ static int kill_session(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
|
||||
@ -921,6 +925,8 @@ static int terminate_user(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
uid_t uid;
|
||||
|
||||
@ -952,6 +958,8 @@ static int kill_user(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
|
||||
@ -1036,6 +1044,8 @@ static int lock_sessions(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = sd_bus_call_method (
|
||||
bus,
|
||||
"org.freedesktop.login1",
|
||||
@ -1057,6 +1067,8 @@ static int terminate_seat(sd_bus *bus, char **args, unsigned n) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
|
||||
r = sd_bus_call_method (
|
||||
@ -1077,6 +1089,7 @@ static int terminate_seat(sd_bus *bus, char **args, unsigned n) {
|
||||
}
|
||||
|
||||
static void help(void) {
|
||||
|
||||
printf("%s [OPTIONS...] {COMMAND} ...\n\n"
|
||||
"Send control commands to or query the login manager.\n\n"
|
||||
" -h --help Show this help\n"
|
||||
|
@ -72,7 +72,6 @@ static OutputMode arg_output = OUTPUT_SHORT;
|
||||
|
||||
static void pager_open_if_enabled(void) {
|
||||
|
||||
/* Cache result before we open the pager */
|
||||
if (arg_no_pager)
|
||||
return;
|
||||
|
||||
|
@ -176,7 +176,6 @@ static void ask_password_agent_open_if_enabled(void) {
|
||||
ask_password_agent_open();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LOGIND
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
@ -192,7 +191,6 @@ static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
#endif
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
return
|
||||
@ -2706,6 +2704,7 @@ static int start_unit(sd_bus *bus, char **args) {
|
||||
assert(bus);
|
||||
|
||||
ask_password_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (arg_action == ACTION_SYSTEMCTL) {
|
||||
enum action action;
|
||||
@ -3029,6 +3028,8 @@ static int kill_unit(sd_bus *bus, char **args) {
|
||||
assert(bus);
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
|
||||
@ -4601,6 +4602,8 @@ static int set_property(sd_bus *bus, char **args) {
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
@ -4661,6 +4664,8 @@ static int snapshot(sd_bus *bus, char **args) {
|
||||
const char *path;
|
||||
int r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (strv_length(args) > 1)
|
||||
n = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".snapshot");
|
||||
else
|
||||
@ -4723,6 +4728,8 @@ static int delete_snapshot(sd_bus *bus, char **args) {
|
||||
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = expand_names(bus, args + 1, ".snapshot", &names);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to expand names: %m");
|
||||
@ -4766,6 +4773,8 @@ static int daemon_reload(sd_bus *bus, char **args) {
|
||||
const char *method;
|
||||
int r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (arg_action == ACTION_RELOAD)
|
||||
method = "Reload";
|
||||
else if (arg_action == ACTION_REEXEC)
|
||||
@ -4824,6 +4833,8 @@ static int reset_failed(sd_bus *bus, char **args) {
|
||||
if (strv_length(args) <= 1)
|
||||
return daemon_reload(bus, args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = expand_names(bus, args + 1, NULL, &names);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to expand names: %m");
|
||||
@ -5285,6 +5296,8 @@ static int enable_unit(sd_bus *bus, char **args) {
|
||||
bool send_force = true, send_preset_mode = false;
|
||||
const char *method;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
if (streq(verb, "enable")) {
|
||||
method = "EnableUnitFiles";
|
||||
expect_carries_install_info = true;
|
||||
@ -5430,6 +5443,8 @@ static int add_dependency(sd_bus *bus, char **args) {
|
||||
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
|
||||
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
@ -5493,6 +5508,8 @@ static int preset_all(sd_bus *bus, char **args) {
|
||||
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
|
||||
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
|
Loading…
Reference in New Issue
Block a user