shared/install: provide a nicer error message for invalid WantedBy=/Required= values
$ build/systemctl --user cat badinstall # /home/zbyszek/.config/systemd/user/badinstall.service [Service] ExecStart=true [Install] WantedBy=asdf $ build/systemctl --user enable badinstall Failed to enable unit: "asdf" is not a valid unit name. Fixes #4209.
This commit is contained in:
parent
d9c1c43e67
commit
d7ceaf7261
|
@ -1902,6 +1902,12 @@ static int install_error(
|
||||||
"Unit %s is transient or generated.", changes[i].path);
|
"Unit %s is transient or generated.", changes[i].path);
|
||||||
goto found;
|
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:
|
case -ELOOP:
|
||||||
r = sd_bus_error_setf(error, BUS_ERROR_UNIT_LINKED,
|
r = sd_bus_error_setf(error, BUS_ERROR_UNIT_LINKED,
|
||||||
"Refusing to operate on alias name or linked unit file: %s",
|
"Refusing to operate on alias name or linked unit file: %s",
|
||||||
|
|
|
@ -362,6 +362,12 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
|
||||||
verb, changes[i].path);
|
verb, changes[i].path);
|
||||||
logged = true;
|
logged = true;
|
||||||
break;
|
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:
|
case -ELOOP:
|
||||||
log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s",
|
log_error_errno(changes[i].type, "Failed to %s unit, refusing to operate on linked unit file %s",
|
||||||
verb, changes[i].path);
|
verb, changes[i].path);
|
||||||
|
@ -1794,7 +1800,8 @@ static int install_info_symlink_wants(
|
||||||
return q;
|
return q;
|
||||||
|
|
||||||
if (!unit_name_is_valid(dst, UNIT_NAME_ANY)) {
|
if (!unit_name_is_valid(dst, UNIT_NAME_ANY)) {
|
||||||
r = -EINVAL;
|
unit_file_changes_add(changes, n_changes, -EUCLEAN, dst, NULL);
|
||||||
|
r = -EUCLEAN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue