]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run/mount/systemctl: don't fork off PolicyKit/ask-pw agent when in --user mode
authorLennart Poettering <lennart@poettering.net>
Mon, 30 Aug 2021 11:21:55 +0000 (13:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 30 Aug 2021 11:37:06 +0000 (13:37 +0200)
When we are in --user mode there's no point in doing PolicyKit/ask-pw
because both of these systems are only used by system-level services.
Let's disable the two agents for that automaticlly hence.

Prompted by: #20576

src/mount/mount-tool.c
src/run/run.c
src/systemctl/systemctl.c

index b0de83b8d0365d63cf00d267eaf8eaf13d3532f8..8b1cb247e94eab29e436996717692bfc6003bc67 100644 (file)
@@ -332,6 +332,9 @@ static int parse_argv(int argc, char *argv[]) {
                         assert_not_reached();
                 }
 
+        if (arg_user)
+                arg_ask_password = false;
+
         if (arg_user && arg_transport != BUS_TRANSPORT_LOCAL)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "Execution in user context is not supported on non-local systems.");
index fb3857122819200645e75fd81f5d4842b7aa0695..664153137dfdf7685c6198f2d4965bde50ccf4ef 100644 (file)
@@ -507,6 +507,10 @@ static int parse_argv(int argc, char *argv[]) {
                         assert_not_reached();
                 }
 
+        /* If we are talking to the per-user instance PolicyKit isn't going to help */
+        if (arg_user)
+                arg_ask_password = false;
+
         with_trigger = !!arg_path_property || !!arg_socket_property || arg_with_timer;
 
         /* currently, only single trigger (path, socket, timer) unit can be created simultaneously */
index f5ecc1f60f37e97f372b1f162b4a67205e871710..e2a8aef11470c8ed652e279bc52c1fd1074a2845 100644 (file)
@@ -925,6 +925,11 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         assert_not_reached();
                 }
 
+        /* If we are in --user mode, there's no point in talking to PolicyKit or the infra to query system
+         * passwords */
+        if (arg_scope != UNIT_FILE_SYSTEM)
+                arg_ask_password = false;
+
         if (arg_transport == BUS_TRANSPORT_REMOTE && arg_scope != UNIT_FILE_SYSTEM)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "Cannot access user instance remotely.");