]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamed: add explicit BUS_ERROR_NO_HARDWARE_SERIAL error
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Mar 2024 13:46:27 +0000 (14:46 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Mar 2024 21:37:38 +0000 (22:37 +0100)
For the very similar case of the product UUID we have its own error
BUS_ERROR_NO_PRODUCT_UUID if we have no UUID. Let's mirror this for the
hardware serial, and expose the same, to keep things nicely symmteric.

src/hostname/hostnamed.c
src/libsystemd/sd-bus/bus-common-errors.c
src/libsystemd/sd-bus/bus-common-errors.h

index 87662e209128aedb8248e01c1c2d0116b74bb37e..e5679ab93156ace0d6b0d8ffda4e2ac5abdf5b26 100644 (file)
@@ -1365,7 +1365,8 @@ static int method_get_hardware_serial(sd_bus_message *m, void *userdata, sd_bus_
 
         r = get_hardware_serial(&serial);
         if (r < 0)
-                return r;
+                return sd_bus_error_set(error, BUS_ERROR_NO_HARDWARE_SERIAL,
+                                        "Failed to read hardware serial from firmware.");
 
         r = sd_bus_message_new_method_return(m, &reply);
         if (r < 0)
index e44795b1d3033f1ca035f17ba8ceb2197ad77ca8..de12ec5e9eb382d01d38fe8248ccac723a6a2d83 100644 (file)
@@ -105,6 +105,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
         SD_BUS_ERROR_MAP(BUS_ERROR_TRANSFER_IN_PROGRESS,         EBUSY),
 
         SD_BUS_ERROR_MAP(BUS_ERROR_NO_PRODUCT_UUID,              EOPNOTSUPP),
+        SD_BUS_ERROR_MAP(BUS_ERROR_NO_HARDWARE_SERIAL,           EOPNOTSUPP),
         SD_BUS_ERROR_MAP(BUS_ERROR_FILE_IS_PROTECTED,            EACCES),
         SD_BUS_ERROR_MAP(BUS_ERROR_READ_ONLY_FILESYSTEM,         EROFS),
 
index 36f53dbde14b75dac7652eb443d67e614a83b019..94dc85d30123f12693169b112630abe9ead41eaf 100644 (file)
 #define BUS_ERROR_TRANSFER_IN_PROGRESS         "org.freedesktop.import1.TransferInProgress"
 
 #define BUS_ERROR_NO_PRODUCT_UUID              "org.freedesktop.hostname1.NoProductUUID"
+#define BUS_ERROR_NO_HARDWARE_SERIAL           "org.freedesktop.hostname1.NoHardwareSerial"
 #define BUS_ERROR_FILE_IS_PROTECTED            "org.freedesktop.hostname1.FileIsProtected"
 #define BUS_ERROR_READ_ONLY_FILESYSTEM         "org.freedesktop.hostname1.ReadOnlyFilesystem"