daf71ef61c
This is just some refactoring: shifting around of code, not change in codeflow. This splits up the way too huge systemctl.c in multiple more easily digestable files. It roughly follows the rule that each family of verbs gets its own .c/.h file pair, and so do all the compat executable names we support. Plus three extra files for sysv compat (which existed before already, but I renamed slightly, to get the systemctl- prefix lik everything else), a -util file with generic stuff everything uses, and a -logind file with everything that talks directly to logind instead of PID1. systemctl is still a bit too complex for my taste, but I think this way itc omes in a more digestable bits at least. No change of behaviour, just reshuffling of some code.
62 lines
2 KiB
C
62 lines
2 KiB
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#include "bus-error.h"
|
|
#include "bus-locator.h"
|
|
#include "systemctl-daemon-reload.h"
|
|
#include "systemctl-preset-all.h"
|
|
#include "systemctl-util.h"
|
|
#include "systemctl.h"
|
|
|
|
int preset_all(int argc, char *argv[], void *userdata) {
|
|
UnitFileChange *changes = NULL;
|
|
size_t n_changes = 0;
|
|
int r;
|
|
|
|
if (install_client_side()) {
|
|
r = unit_file_preset_all(arg_scope, unit_file_flags_from_args(), arg_root, arg_preset_mode, &changes, &n_changes);
|
|
unit_file_dump_changes(r, "preset", changes, n_changes, arg_quiet);
|
|
|
|
if (r > 0)
|
|
r = 0;
|
|
} else {
|
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
|
sd_bus *bus;
|
|
|
|
r = acquire_bus(BUS_MANAGER, &bus);
|
|
if (r < 0)
|
|
return r;
|
|
|
|
polkit_agent_open_maybe();
|
|
|
|
r = bus_call_method(
|
|
bus,
|
|
bus_systemd_mgr,
|
|
"PresetAllUnitFiles",
|
|
&error,
|
|
&reply,
|
|
"sbb",
|
|
unit_file_preset_mode_to_string(arg_preset_mode),
|
|
arg_runtime,
|
|
arg_force);
|
|
if (r < 0)
|
|
return log_error_errno(r, "Failed to preset all units: %s", bus_error_message(&error, r));
|
|
|
|
r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet, &changes, &n_changes);
|
|
if (r < 0)
|
|
goto finish;
|
|
|
|
if (arg_no_reload) {
|
|
r = 0;
|
|
goto finish;
|
|
}
|
|
|
|
r = daemon_reload(argc, argv, userdata);
|
|
}
|
|
|
|
finish:
|
|
unit_file_changes_free(changes, n_changes);
|
|
|
|
return r;
|
|
}
|