X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemctl.c;h=28bdfa96a4e06d9b9c393e7b3357dd96b28f79e8;hp=43a1446a8c246535ed274ef9c667cc8c34c2a628;hb=5430f7f2bc7330f3088b894166bf3524a067e3d8;hpb=04ebb5956719e3e301e1c08443c496ad97399544 diff --git a/src/systemctl.c b/src/systemctl.c index 43a1446a8..28bdfa96a 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -57,7 +57,8 @@ #include "build.h" #include "unit-name.h" #include "pager.h" -#include "spawn-agent.h" +#include "spawn-ask-password-agent.h" +#include "spawn-polkit-agent.h" #include "install.h" #include "logs-show.h" @@ -78,7 +79,7 @@ static bool arg_dry = false; static bool arg_quiet = false; static bool arg_full = false; static int arg_force = 0; -static bool arg_ask_password = false; +static bool arg_ask_password = true; static bool arg_failed = false; static bool arg_runtime = false; static char **arg_wall = NULL; @@ -154,7 +155,7 @@ static void pager_open_if_enabled(void) { pager_open(); } -static void agent_open_if_enabled(void) { +static void ask_password_agent_open_if_enabled(void) { /* Open the password agent as a child process if necessary */ @@ -164,7 +165,20 @@ static void agent_open_if_enabled(void) { if (arg_scope != UNIT_FILE_SYSTEM) return; - agent_open(); + ask_password_agent_open(); +} + +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_scope != UNIT_FILE_SYSTEM) + return; + + polkit_agent_open(); } static const char *ansi_highlight_red(bool b) { @@ -1601,7 +1615,7 @@ static int start_unit(DBusConnection *bus, char **args) { assert(bus); - agent_open_if_enabled(); + ask_password_agent_open_if_enabled(); if (arg_action == ACTION_SYSTEMCTL) { method = @@ -1695,6 +1709,8 @@ static int reboot_with_logind(DBusConnection *bus, enum action a) { dbus_error_init(&error); + polkit_agent_open_if_enabled(); + switch (a) { case ACTION_REBOOT: @@ -4290,9 +4306,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - /* Only when running as systemctl we ask for passwords */ - arg_ask_password = true; - while ((c = getopt_long(argc, argv, "ht:p:aqfs:H:Pn:o:", options, NULL)) >= 0) { switch (c) { @@ -5503,7 +5516,8 @@ finish: strv_free(arg_property); pager_close(); - agent_close(); + ask_password_agent_close(); + polkit_agent_close(); return retval; }