mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
Merge pull request #14037 from poettering/machinectl-pw-agent
spawn ask pw tty agent from "machinectl start"
This commit is contained in:
commit
f0bfae7265
@ -46,6 +46,7 @@
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "sort-util.h"
|
||||
#include "spawn-ask-password-agent.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-table.h"
|
||||
@ -1722,6 +1723,7 @@ static int start_machine(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
ask_password_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = bus_wait_for_jobs_new(bus, &w);
|
||||
if (r < 0)
|
||||
|
@ -46,3 +46,16 @@ void ask_password_agent_close(void) {
|
||||
(void) wait_for_terminate(agent_pid, NULL);
|
||||
agent_pid = 0;
|
||||
}
|
||||
|
||||
int ask_password_agent_open_if_enabled(BusTransport transport, bool ask_password) {
|
||||
|
||||
/* Open the ask password agent as a child process if necessary */
|
||||
|
||||
if (transport != BUS_TRANSPORT_LOCAL)
|
||||
return 0;
|
||||
|
||||
if (!ask_password)
|
||||
return 0;
|
||||
|
||||
return ask_password_agent_open();
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "bus-util.h"
|
||||
|
||||
int ask_password_agent_open(void);
|
||||
void ask_password_agent_close(void);
|
||||
|
||||
int ask_password_agent_open_if_enabled(BusTransport transport, bool ask_password);
|
||||
|
@ -83,3 +83,16 @@ void polkit_agent_close(void) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int 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 0;
|
||||
|
||||
if (!ask_password)
|
||||
return 0;
|
||||
|
||||
return polkit_agent_open();
|
||||
}
|
||||
|
@ -1,22 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "bus-util.h"
|
||||
|
||||
int polkit_agent_open(void);
|
||||
void polkit_agent_close(void);
|
||||
|
||||
static inline int 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 0;
|
||||
|
||||
if (!ask_password)
|
||||
return 0;
|
||||
|
||||
return polkit_agent_open();
|
||||
}
|
||||
int polkit_agent_open_if_enabled(BusTransport transport, bool ask_password);
|
||||
|
@ -236,22 +236,16 @@ static void release_busses(void) {
|
||||
buses[w] = sd_bus_flush_close_unref(buses[w]);
|
||||
}
|
||||
|
||||
static void ask_password_agent_open_if_enabled(void) {
|
||||
static void ask_password_agent_open_maybe(void) {
|
||||
/* Open the password agent as a child process if necessary */
|
||||
|
||||
if (arg_dry_run)
|
||||
return;
|
||||
|
||||
if (!arg_ask_password)
|
||||
return;
|
||||
|
||||
if (arg_scope != UNIT_FILE_SYSTEM)
|
||||
return;
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL)
|
||||
return;
|
||||
|
||||
ask_password_agent_open();
|
||||
ask_password_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
}
|
||||
|
||||
static void polkit_agent_open_maybe(void) {
|
||||
@ -3071,7 +3065,7 @@ static int start_unit(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
ask_password_agent_open_if_enabled();
|
||||
ask_password_agent_open_maybe();
|
||||
polkit_agent_open_maybe();
|
||||
|
||||
if (arg_action == ACTION_SYSTEMCTL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user