Merge pull request #14339 from keszybz/invalid-enablement-logs

Small enhancements to logs for enabling of invalid units
This commit is contained in:
Yu Watanabe 2019-12-17 15:04:14 +09:00 committed by GitHub
commit e16f18bddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

3
TODO
View File

@ -1033,12 +1033,11 @@ Features:
- allow Type=simple with PIDFile=
https://bugzilla.redhat.com/show_bug.cgi?id=723942
- allow writing multiple conditions in unit files on one line
- load-fragment: when loading a unit file via a chain of symlinks
verify that it is not masked via any of the names traversed.
- introduce Type=pid-file
- introduce mix of BindTo and Requisite
- add a concept of RemainAfterExit= to scope units
- Allow multiple ExecStart= for all Type= settings, so that we can cover rescue.service nicely
- add verification of [Install] section to systemd-analyze verify
* udev-link-config:
- Make sure ID_PATH is always exported and complete for

View File

@ -1902,6 +1902,12 @@ static int install_error(
"Unit %s is transient or generated.", changes[i].path);
goto found;
case -EUCLEAN:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"\"%s\" is not a valid unit name.",
changes[i].path);
goto found;
case -ELOOP:
r = sd_bus_error_setf(error, BUS_ERROR_UNIT_LINKED,
"Refusing to operate on alias name or linked unit file: %s",

View File

@ -362,6 +362,12 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
verb, changes[i].path);
logged = true;
break;
case -EUCLEAN:
log_error_errno(changes[i].type,
"Failed to %s unit, \"%s\" is not a valid unit name.",
verb, changes[i].path);
logged = true;
break;
case -ELOOP:
log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s",
verb, changes[i].path);
@ -1138,9 +1144,6 @@ static int config_parse_also(
if (r < 0)
return r;
if (!unit_name_is_valid(printed, UNIT_NAME_ANY))
return -EINVAL;
r = install_info_add(c, printed, NULL, true, &alsoinfo);
if (r < 0)
return r;
@ -1194,7 +1197,8 @@ static int config_parse_default_instance(
}
if (!unit_instance_is_valid(printed))
return -EINVAL;
return log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"Invalid DefaultInstance= value \"%s\".", printed);
return free_and_replace(i->default_instance, printed);
}
@ -1797,7 +1801,8 @@ static int install_info_symlink_wants(
return q;
if (!unit_name_is_valid(dst, UNIT_NAME_ANY)) {
r = -EINVAL;
unit_file_changes_add(changes, n_changes, -EUCLEAN, dst, NULL);
r = -EUCLEAN;
continue;
}