]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostname-setup: do not trigger assertion when uname() is prohibited by seccomp
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 Aug 2025 04:21:59 +0000 (13:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 16 Aug 2025 15:14:42 +0000 (00:14 +0900)
gethostname_full() is used in nss-myhostname, and hence random
application may indirectly call it. When an application with a too strict
seccomp filter loads the nss module, the application may trigger the
assertion.

Partially fixes #38582.

src/shared/hostname-setup.c

index 0d21e0482d16d95b564393320ca62c51534b56b9..ac13d06fb2345ef25263a709d9cc64b0bd4b4018 100644 (file)
@@ -316,7 +316,8 @@ int gethostname_full(GetHostnameFlags flags, char **ret) {
 
         assert(ret);
 
-        assert_se(uname(&u) >= 0);
+        if (uname(&u) < 0)
+                return -errno;
 
         s = u.nodename;
         if (isempty(s) || streq(s, "(none)") ||