From c89d0c3b0567eb8fdf0b06a27f46c64245d2f0a4 Mon Sep 17 00:00:00 2001 From: Jacek Migacz Date: Sun, 18 Sep 2022 15:41:38 +0200 Subject: [PATCH] core: give a nicer error message on invalid aliases --- src/core/dbus-manager.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 633873da27..919aa58cde 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -2176,6 +2176,16 @@ static int install_error( "File %s is under the systemd unit hierarchy already.", changes[i].path); 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: r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING, "\"%s\" is not a valid unit name.", @@ -2188,11 +2198,26 @@ static int install_error( changes[i].path); 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: r = sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit file %s does not exist.", changes[i].path); 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: assert(changes[i].type < 0); /* other errors */ r = sd_bus_error_set_errnof(error, changes[i].type, "File %s: %m", changes[i].path);