mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-03 15:30:38 +00:00
shared/install: avoid prematurely rejecting "missing" units
f7101b7368copied some logic to prevent enabling masked units, but also added a check which causes attempts to enable templated units to fail. Since we know the logic beyond this check will properly handle units which truly do not exist, we can rely on the unit file state comparison to suffice for expressing the intent off7101b7368. ref: https://bugs.archlinux.org/task/42616 (cherry picked from commit0ffce503cd)
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
b994526e7f
commit
deb5897054
@@ -1620,12 +1620,10 @@ int unit_file_enable(
|
||||
STRV_FOREACH(i, files) {
|
||||
UnitFileState state;
|
||||
|
||||
/* We only want to know if this unit is masked, so we ignore
|
||||
* errors from unit_file_get_state, deferring other checks.
|
||||
* This allows templated units to be enabled on the fly. */
|
||||
state = unit_file_get_state(scope, root_dir, *i);
|
||||
if (state < 0) {
|
||||
log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
|
||||
return state;
|
||||
}
|
||||
|
||||
if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) {
|
||||
log_error("Failed to enable unit: Unit %s is masked", *i);
|
||||
return -ENOTSUP;
|
||||
|
||||
Reference in New Issue
Block a user