]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-id128: make sd_id128_get_boot() and friend return -ENOSYS when /proc/ is not mounted
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 12 Dec 2022 13:03:52 +0000 (22:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 12 Dec 2022 13:04:53 +0000 (22:04 +0900)
src/libsystemd/sd-id128/sd-id128.c

index 70b1a10c748ddd30aa46b19e8582c4323a7d7eaf..8f9801ae37a3c00c013e241308d410aa6b402716 100644 (file)
@@ -15,6 +15,7 @@
 #include "macro.h"
 #include "missing_syscall.h"
 #include "random-util.h"
+#include "stat-util.h"
 #include "user-util.h"
 
 _public_ char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]) {
@@ -146,6 +147,8 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) {
 
         if (sd_id128_is_null(saved_boot_id)) {
                 r = id128_read("/proc/sys/kernel/random/boot_id", ID128_FORMAT_UUID, &saved_boot_id);
+                if (r == -ENOENT && proc_mounted() == 0)
+                        return -ENOSYS;
                 if (r < 0)
                         return r;