summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/login/loginctl.c15
-rw-r--r--src/machine/machinectl.c1
-rw-r--r--src/systemctl/systemctl.c21
3 files changed, 33 insertions, 4 deletions
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 57a0ab0840..9f7790389a 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -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"
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 2c29f1495e..939b648150 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -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;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index b44c6d78ba..ded4943c10 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -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,