Skip to content

Commit 966f3a2

Browse files
committed
run/mount/systemctl: don't fork off PolicyKit/ask-pw agent when in --user mode
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
1 parent 93d2e0b commit 966f3a2

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/mount/mount-tool.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ static int parse_argv(int argc, char *argv[]) {
332332
assert_not_reached();
333333
}
334334

335+
if (arg_user)
336+
arg_ask_password = false;
337+
335338
if (arg_user && arg_transport != BUS_TRANSPORT_LOCAL)
336339
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
337340
"Execution in user context is not supported on non-local systems.");

‎src/run/run.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,10 @@ static int parse_argv(int argc, char *argv[]) {
507507
assert_not_reached();
508508
}
509509

510+
/* If we are talking to the per-user instance PolicyKit isn't going to help */
511+
if (arg_user)
512+
arg_ask_password = false;
513+
510514
with_trigger = !!arg_path_property || !!arg_socket_property || arg_with_timer;
511515

512516
/* currently, only single trigger (path, socket, timer) unit can be created simultaneously */

‎src/systemctl/systemctl.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
925925
assert_not_reached();
926926
}
927927

928+
/* If we are in --user mode, there's no point in talking to PolicyKit or the infra to query system
929+
* passwords */
930+
if (arg_scope != UNIT_FILE_SYSTEM)
931+
arg_ask_password = false;
932+
928933
if (arg_transport == BUS_TRANSPORT_REMOTE && arg_scope != UNIT_FILE_SYSTEM)
929934
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
930935
"Cannot access user instance remotely.");

0 commit comments

Comments
 (0)