]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamectl: gracefully handle old hostnamed replies to GetHardwareSerial() 31615/head
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2024 12:04:20 +0000 (13:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2024 12:05:39 +0000 (13:05 +0100)
Old versions of hostnamed used to propagate ENODEV/ENOENT as-is. Bad
idea. This was fixed in 171ddae1a122e9c97b4ef12ccb2d29e1ba7a318a, but
let's handle this gracefully in hostnamectl.

src/hostname/hostnamectl.c

index 5e1cbd373d6de730d4897df311042a53fab7ba0e..d1c4d476f66b907f440afb2bc4a601d427354d30 100644 (file)
@@ -454,7 +454,8 @@ static int show_all_names(sd_bus *bus) {
                                                &error,
                                                BUS_ERROR_NO_HARDWARE_SERIAL,
                                                SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED,
-                                               SD_BUS_ERROR_UNKNOWN_METHOD) ? LOG_DEBUG : LOG_WARNING,
+                                               SD_BUS_ERROR_UNKNOWN_METHOD) ||
+                               ERRNO_IS_DEVICE_ABSENT(r) ? LOG_DEBUG : LOG_WARNING, /* old hostnamed used to send ENOENT/ENODEV back to client as is, handle that gracefully */
                                r, "Failed to query hardware serial, ignoring: %s", bus_error_message(&error, r));
         else {
                 r = sd_bus_message_read_basic(hardware_serial_reply, 's', &info.hardware_serial);