diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-07 21:06:44 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-07 21:06:44 +0100 |
commit | 46e65dcc3a522b5e992e165b5e61d14254026859 (patch) | |
tree | 84ea0d49f1c502972e8bfa85587cfbf9c875b586 /src/hostname/hostnamectl.c | |
parent | 0d49cfa264e8afc52526cd0cd73b2309dff498b2 (diff) |
polkit: don't spawn local client if we access a remote system
Diffstat (limited to 'src/hostname/hostnamectl.c')
-rw-r--r-- | src/hostname/hostnamectl.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index af42817914..523177b27d 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -48,6 +48,18 @@ 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; @@ -192,12 +204,9 @@ static int show_status(sd_bus *bus, char **args, unsigned n) { static int set_simple_string(sd_bus *bus, const char *method, const char *value) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - static bool first=true; int r = 0; - if (first && arg_ask_password) - polkit_agent_open(); - first = false; + polkit_agent_open_if_enabled(); r = sd_bus_call_method( bus, |