]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #26458 from yuwata/core-network-namespace-remount-sysfs
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Feb 2023 08:44:06 +0000 (09:44 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Feb 2023 08:44:06 +0000 (09:44 +0100)
core: remount sysfs when network and mount namespace are enabled

src/libsystemd/sd-event/sd-event.c

index 5303a14cd69f94550c060cbf6e75498f91f47964..46292da2a1f3e5c7ecd7b83fcb0a015494eb33d0 100644 (file)
@@ -1269,7 +1269,7 @@ static void initialize_perturb(sd_event *e) {
         if (_likely_(e->perturb != USEC_INFINITY))
                 return;
 
-        if (sd_id128_get_boot(&id) >= 0 || sd_id128_get_machine(&id) > 0)
+        if (sd_id128_get_boot(&id) >= 0 || sd_id128_get_machine(&id) >= 0)
                 e->perturb = (id.qwords[0] ^ id.qwords[1]) % USEC_PER_MINUTE;
         else
                 e->perturb = 0; /* This is a super early process without /proc and /etc ?? */
@@ -1917,7 +1917,7 @@ _public_ int sd_event_add_memory_pressure(
         _cleanup_(source_freep) sd_event_source *s = NULL;
         _cleanup_close_ int path_fd = -1, fd = -1;
         _cleanup_free_ void *write_buffer = NULL;
-        const char *watch, *watch_fallback, *env;
+        const char *watch, *watch_fallback = NULL, *env;
         size_t write_buffer_size = 0;
         struct stat st;
         uint32_t events;
@@ -2028,10 +2028,11 @@ _public_ int sd_event_add_memory_pressure(
                         return locked ? -ENOENT : -EOPNOTSUPP;
 
                 path_fd = open(watch_fallback, O_PATH|O_CLOEXEC);
-                if (errno == ENOENT) /* PSI is not available in the kernel even under the fallback path? */
-                        return -EOPNOTSUPP;
-                if (errno < 0)
+                if (path_fd < 0) {
+                        if (errno == ENOENT) /* PSI is not available in the kernel even under the fallback path? */
+                                return -EOPNOTSUPP;
                         return -errno;
+                }
         }
 
         if (fstat(path_fd, &st) < 0)