mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
treewide: unify identical definitions of polkit_agent_open_if_enabled() (#7187)
Follows the same pattern as pager_open() now.
This commit is contained in:
parent
f630daaae9
commit
8a4b13c5cb
@ -41,18 +41,6 @@ static bool arg_transient = false;
|
||||
static bool arg_pretty = false;
|
||||
static bool arg_static = false;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
typedef struct StatusInfo {
|
||||
char *hostname;
|
||||
char *static_hostname;
|
||||
@ -243,7 +231,7 @@ static int set_simple_string(sd_bus *bus, const char *method, const char *value)
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
int r = 0;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
|
@ -46,18 +46,6 @@ static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
|
||||
static char *arg_host = NULL;
|
||||
static bool arg_convert = true;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
typedef struct StatusInfo {
|
||||
char **locale;
|
||||
char *vconsole_keymap;
|
||||
@ -195,7 +183,7 @@ static int set_locale(sd_bus *bus, char **args, unsigned n) {
|
||||
assert(bus);
|
||||
assert(args);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
@ -253,7 +241,7 @@ static int set_vconsole_keymap(sd_bus *bus, char **args, unsigned n) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
map = args[1];
|
||||
toggle_map = n > 2 ? args[2] : "";
|
||||
@ -356,7 +344,7 @@ static int set_x11_keymap(sd_bus *bus, char **args, unsigned n) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
layout = args[1];
|
||||
model = n > 2 ? args[2] : "";
|
||||
|
@ -61,19 +61,6 @@ static bool arg_ask_password = true;
|
||||
static unsigned arg_lines = 10;
|
||||
static OutputMode arg_output = OUTPUT_SHORT;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
|
||||
return
|
||||
@ -1081,7 +1068,7 @@ static int activate(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
if (argc < 2) {
|
||||
/* No argument? Let's either use $XDG_SESSION_ID (if specified), or an empty
|
||||
@ -1125,7 +1112,7 @@ static int kill_session(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
@ -1159,7 +1146,7 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
b = streq(argv[0], "enable-linger");
|
||||
|
||||
@ -1210,7 +1197,7 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
uid_t uid;
|
||||
@ -1244,7 +1231,7 @@ static int kill_user(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
@ -1281,7 +1268,7 @@ static int attach(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 2; i < argc; i++) {
|
||||
|
||||
@ -1311,7 +1298,7 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1335,7 +1322,7 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1359,7 +1346,7 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
|
||||
|
@ -89,19 +89,6 @@ static int arg_addrs = 1;
|
||||
|
||||
static int print_addresses(sd_bus *bus, const char *name, int, const char *pr1, const char *pr2, int n_addr);
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
return
|
||||
arg_all * OUTPUT_SHOW_ALL |
|
||||
@ -1179,7 +1166,7 @@ static int kill_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
@ -1224,7 +1211,7 @@ static int terminate_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
r = sd_bus_call_method(
|
||||
@ -1256,7 +1243,7 @@ static int copy_files(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
copy_from = streq(argv[0], "copy-from");
|
||||
dest = argv[3] ?: argv[2];
|
||||
@ -1305,7 +1292,7 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1463,7 +1450,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0)
|
||||
@ -1536,7 +1523,7 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0)
|
||||
@ -1604,7 +1591,7 @@ static int remove_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
@ -1638,7 +1625,7 @@ static int rename_image(int argc, char *argv[], void *userdata) {
|
||||
sd_bus *bus = userdata;
|
||||
int r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1663,7 +1650,7 @@ static int clone_image(int argc, char *argv[], void *userdata) {
|
||||
sd_bus *bus = userdata;
|
||||
int r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
@ -1700,7 +1687,7 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
@ -1771,7 +1758,7 @@ static int start_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = bus_wait_for_jobs_new(bus, &w);
|
||||
if (r < 0)
|
||||
@ -1836,7 +1823,7 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
method = streq(argv[0], "enable") ? "EnableUnitFiles" : "DisableUnitFiles";
|
||||
|
||||
@ -1991,7 +1978,7 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
|
||||
assert(bus);
|
||||
assert(m);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0)
|
||||
@ -2542,7 +2529,7 @@ static int cancel_transfer(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
uint32_t id;
|
||||
|
@ -69,18 +69,6 @@ static char **arg_automount_property = NULL;
|
||||
static int arg_bind_device = -1;
|
||||
static bool arg_fsck = true;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
static void help(void) {
|
||||
printf("systemd-mount [OPTIONS...] WHAT [WHERE]\n"
|
||||
"systemd-mount [OPTIONS...] --list\n"
|
||||
@ -549,7 +537,7 @@ static int start_transient_mount(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0)
|
||||
@ -664,7 +652,7 @@ static int start_transient_automount(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0)
|
||||
@ -848,7 +836,7 @@ static int stop_mount(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0)
|
||||
|
@ -76,18 +76,6 @@ static const char *arg_on_calendar = NULL;
|
||||
static char **arg_timer_property = NULL;
|
||||
static bool arg_quiet = false;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
static void help(void) {
|
||||
printf("%s [OPTIONS...] {COMMAND} [ARGS...]\n\n"
|
||||
"Run the specified command in a transient scope or service.\n\n"
|
||||
@ -1027,7 +1015,7 @@ static int start_transient_service(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0)
|
||||
@ -1226,7 +1214,7 @@ static int start_transient_scope(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
@ -1436,7 +1424,7 @@ static int start_transient_timer(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
|
@ -19,5 +19,22 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "bus-util.h"
|
||||
|
||||
int polkit_agent_open(void);
|
||||
void polkit_agent_close(void);
|
||||
|
||||
static inline void polkit_agent_open_if_enabled(
|
||||
BusTransport transport,
|
||||
bool ask_password) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
|
||||
if (transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
if (!ask_password)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
@ -268,20 +268,13 @@ static void ask_password_agent_open_if_enabled(void) {
|
||||
ask_password_agent_open();
|
||||
}
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
static void polkit_agent_open_maybe(void) {
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_scope != UNIT_FILE_SYSTEM)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
}
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
@ -2163,7 +2156,7 @@ static int set_default(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
sd_bus *bus;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = acquire_bus(BUS_MANAGER, &bus);
|
||||
if (r < 0)
|
||||
@ -2391,7 +2384,7 @@ static int cancel_job(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
STRV_FOREACH(name, strv_skip(argv, 1)) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
@ -3099,7 +3092,7 @@ static int start_unit(int argc, char *argv[], void *userdata) {
|
||||
return r;
|
||||
|
||||
ask_password_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
if (arg_action == ACTION_SYSTEMCTL) {
|
||||
enum action action;
|
||||
@ -3301,7 +3294,7 @@ static int logind_reboot(enum action a) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
(void) logind_set_wall_message();
|
||||
|
||||
r = sd_bus_call_method(
|
||||
@ -3673,7 +3666,7 @@ static int kill_unit(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
if (!arg_kill_who)
|
||||
arg_kill_who = "all";
|
||||
@ -5486,7 +5479,7 @@ static int set_property(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
@ -5536,7 +5529,7 @@ static int daemon_reload(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
switch (arg_action) {
|
||||
|
||||
@ -5596,7 +5589,7 @@ static int trivial_method(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
method =
|
||||
streq(argv[0], "clear-jobs") ||
|
||||
@ -5639,7 +5632,7 @@ static int reset_failed(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
|
||||
if (r < 0)
|
||||
@ -5824,7 +5817,7 @@ static int set_environment(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
method = streq(argv[0], "set-environment")
|
||||
? "SetEnvironment"
|
||||
@ -5861,7 +5854,7 @@ static int import_environment(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
@ -6286,7 +6279,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
if (streq(verb, "enable")) {
|
||||
method = "EnableUnitFiles";
|
||||
@ -6456,7 +6449,7 @@ static int add_dependency(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
@ -6518,7 +6511,7 @@ static int preset_all(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
|
@ -40,18 +40,6 @@ static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
|
||||
static char *arg_host = NULL;
|
||||
static bool arg_adjust_system_clock = false;
|
||||
|
||||
static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
/* Open the polkit agent as a child process if necessary */
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
polkit_agent_open();
|
||||
}
|
||||
|
||||
typedef struct StatusInfo {
|
||||
usec_t time;
|
||||
char *timezone;
|
||||
@ -195,7 +183,7 @@ static int set_time(sd_bus *bus, char **args, unsigned n) {
|
||||
assert(args);
|
||||
assert(n == 2);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = parse_timestamp(args[1], &t);
|
||||
if (r < 0) {
|
||||
@ -224,7 +212,7 @@ static int set_timezone(sd_bus *bus, char **args, unsigned n) {
|
||||
assert(args);
|
||||
assert(n == 2);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.timedate1",
|
||||
@ -247,7 +235,7 @@ static int set_local_rtc(sd_bus *bus, char **args, unsigned n) {
|
||||
assert(args);
|
||||
assert(n == 2);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
b = parse_boolean(args[1]);
|
||||
if (b < 0) {
|
||||
@ -276,7 +264,7 @@ static int set_ntp(sd_bus *bus, char **args, unsigned n) {
|
||||
assert(args);
|
||||
assert(n == 2);
|
||||
|
||||
polkit_agent_open_if_enabled();
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
b = parse_boolean(args[1]);
|
||||
if (b < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user