From: Lennart Poettering Date: Tue, 7 Jan 2025 09:55:29 +0000 (+0100) Subject: namespace-util: slightly tweak proc_mounted() handling in namespace_is_init() X-Git-Tag: v258-rc1~1673^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b14690a3982a884f26d2f860943c54b7c5fc471;p=thirdparty%2Fsystemd.git namespace-util: slightly tweak proc_mounted() handling in namespace_is_init() Let's not sloppily eat up errors here. --- diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c index 88d122ea6c5..d45d4d33c5d 100644 --- a/src/basic/namespace-util.c +++ b/src/basic/namespace-util.c @@ -307,9 +307,14 @@ int namespace_is_init(NamespaceType type) { struct stat st; r = RET_NERRNO(stat(p, &st)); - if (r == -ENOENT) + if (r == -ENOENT) { /* If the /proc/ns/ API is not around in /proc/ then ns is off in the kernel and we are in the init ns */ - return proc_mounted() == 0 ? -ENOSYS : true; + r = proc_mounted(); + if (r < 0) + return -ENOENT; /* If we can't determine if /proc/ is mounted propagate original error */ + + return r ? true : -ENOSYS; + } if (r < 0) return r;