1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

core: give a nicer error message on invalid aliases

This commit is contained in:
Jacek Migacz 2022-09-18 15:41:38 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 0cdb1a2fa3
commit c89d0c3b05

View File

@ -2176,6 +2176,16 @@ static int install_error(
"File %s is under the systemd unit hierarchy already.", changes[i].path); "File %s is under the systemd unit hierarchy already.", changes[i].path);
goto found; goto found;
case -EBADSLT:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"Invalid specifier in %s.", changes[i].path);
goto found;
case -EIDRM:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"Destination unit %s is a non-template unit.", changes[i].path);
goto found;
case -EUCLEAN: case -EUCLEAN:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING, r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"\"%s\" is not a valid unit name.", "\"%s\" is not a valid unit name.",
@ -2188,11 +2198,26 @@ static int install_error(
changes[i].path); changes[i].path);
goto found; goto found;
case -EXDEV:
if (changes[i].source)
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"Cannot alias %s as %s.",
changes[i].source, changes[i].path);
else
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"Invalid unit reference %s.", changes[i].path);
goto found;
case -ENOENT: case -ENOENT:
r = sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, r = sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT,
"Unit file %s does not exist.", changes[i].path); "Unit file %s does not exist.", changes[i].path);
goto found; goto found;
case -EUNATCH:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"Cannot resolve specifiers in %s.", changes[i].path);
goto found;
default: default:
assert(changes[i].type < 0); /* other errors */ assert(changes[i].type < 0); /* other errors */
r = sd_bus_error_set_errnof(error, changes[i].type, "File %s: %m", changes[i].path); r = sd_bus_error_set_errnof(error, changes[i].type, "File %s: %m", changes[i].path);