systemctl: convert return value of install_client_side() to enum
The checks are reordered to do checks that don't require interacting with the system first.
This commit is contained in:
@@ -523,7 +523,7 @@ int unit_find_paths(
|
||||
|
||||
/* Go via the bus to acquire the path, unless we are explicitly told not to, or when the unit name is a template */
|
||||
if (!force_client_side &&
|
||||
!install_client_side() &&
|
||||
install_client_side() == INSTALL_CLIENT_SIDE_NO &&
|
||||
!unit_name_is_valid(unit_name, UNIT_NAME_TEMPLATE)) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *load_state = NULL, *dbus_path = NULL;
|
||||
@@ -880,26 +880,27 @@ bool output_show_unit(const UnitInfo *u, char **patterns) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool install_client_side(void) {
|
||||
/* Decides when to execute enable/disable/... operations client-side rather than server-side. */
|
||||
|
||||
if (running_in_chroot_or_offline())
|
||||
return true;
|
||||
|
||||
if (sd_booted() <= 0)
|
||||
return true;
|
||||
|
||||
if (!isempty(arg_root))
|
||||
return true;
|
||||
|
||||
if (arg_runtime_scope == RUNTIME_SCOPE_GLOBAL)
|
||||
return true;
|
||||
InstallClientSide install_client_side(void) {
|
||||
/* Decides whether to execute enable/disable/… client-side offline operation rather than
|
||||
* server-side. */
|
||||
|
||||
/* Unsupported environment variable, mostly for debugging purposes */
|
||||
if (getenv_bool("SYSTEMCTL_INSTALL_CLIENT_SIDE") > 0)
|
||||
return true;
|
||||
return INSTALL_CLIENT_SIDE_OVERRIDE;
|
||||
|
||||
return false;
|
||||
if (!isempty(arg_root))
|
||||
return INSTALL_CLIENT_SIDE_ARG_ROOT;
|
||||
|
||||
if (running_in_chroot_or_offline())
|
||||
return INSTALL_CLIENT_SIDE_OFFLINE;
|
||||
|
||||
if (sd_booted() <= 0)
|
||||
return INSTALL_CLIENT_SIDE_NOT_BOOTED;
|
||||
|
||||
if (arg_runtime_scope == RUNTIME_SCOPE_GLOBAL)
|
||||
return INSTALL_CLIENT_SIDE_GLOBAL_SCOPE;
|
||||
|
||||
return INSTALL_CLIENT_SIDE_NO;
|
||||
}
|
||||
|
||||
int output_table(Table *table) {
|
||||
|
||||
Reference in New Issue
Block a user