mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
shared/install: ignore enablement of template units w/o instance when presetting
When we have a unit which cannot be enabled: # foo@.service: ... [Install] WantedBy=foo.target # there is no instance, so we don't know what to enable we should throw an error when invoked directly with 'enable', but not when doing 'preset' or 'preset-all'. Fixes #19856.
This commit is contained in:
parent
9b69770a49
commit
ad5fdd3912
@ -1916,8 +1916,16 @@ static int install_info_symlink_wants(
|
||||
return q;
|
||||
|
||||
if (!unit_name_is_valid(dst, valid_dst_type)) {
|
||||
/* Generate a proper error here: EUCLEAN if the name is generally bad,
|
||||
* EIDRM if the template status doesn't match. */
|
||||
/* Generate a proper error here: EUCLEAN if the name is generally bad, EIDRM if the
|
||||
* template status doesn't match. If we are doing presets don't bother reporting the
|
||||
* error. This also covers cases like 'systemctl preset serial-getty@.service', which
|
||||
* has no DefaultInstance, so there is nothing we can do. At the same time,
|
||||
* 'systemctl enable serial-getty@.service' should fail, the user should specify an
|
||||
* instance like in 'systemctl enable serial-getty@ttyS0.service'.
|
||||
*/
|
||||
if (file_flags & UNIT_FILE_IGNORE_AUXILIARY_FAILURE)
|
||||
continue;
|
||||
|
||||
if (unit_name_is_valid(dst, UNIT_NAME_ANY)) {
|
||||
unit_file_changes_add(changes, n_changes, -EIDRM, dst, n);
|
||||
r = -EIDRM;
|
||||
@ -3214,7 +3222,9 @@ static int execute_preset(
|
||||
int q;
|
||||
|
||||
/* Returns number of symlinks that where supposed to be installed. */
|
||||
q = install_context_apply(scope, file_flags, plus, paths, config_path, SEARCH_LOAD, changes, n_changes);
|
||||
q = install_context_apply(scope,
|
||||
file_flags | UNIT_FILE_IGNORE_AUXILIARY_FAILURE,
|
||||
plus, paths, config_path, SEARCH_LOAD, changes, n_changes);
|
||||
if (r >= 0) {
|
||||
if (q < 0)
|
||||
r = q;
|
||||
|
@ -39,10 +39,11 @@ enum {
|
||||
};
|
||||
|
||||
enum UnitFileFlags {
|
||||
UNIT_FILE_RUNTIME = 1 << 0, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_FORCE = 1 << 1, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_PORTABLE = 1 << 2, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_DRY_RUN = 1 << 3,
|
||||
UNIT_FILE_RUNTIME = 1 << 0, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_FORCE = 1 << 1, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_PORTABLE = 1 << 2, /* Public API via DBUS, do not change */
|
||||
UNIT_FILE_DRY_RUN = 1 << 3,
|
||||
UNIT_FILE_IGNORE_AUXILIARY_FAILURE = 1 << 4,
|
||||
_UNIT_FILE_FLAGS_MASK_PUBLIC = UNIT_FILE_RUNTIME|UNIT_FILE_PORTABLE|UNIT_FILE_FORCE,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user