]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fallback to XDG_RUNTIME_DIR when /run not found 4620/head
authorHong YANG <hong.yang3@nio.com>
Thu, 4 Dec 2025 03:43:37 +0000 (11:43 +0800)
committerHong YANG <hong.yang3@nio.com>
Thu, 4 Dec 2025 04:56:22 +0000 (12:56 +0800)
Instead of return null immediately when RUNTIME_PATH
not found, fallback to XDG_RUNTIME_DIR or HOME.

Signed-off-by: Hong YANG <hong.yang3@nio.com>
src/lxc/utils.c

index af276a3b551695120194ca304cb220db626e28f5..1e41d642a1ae1cb6dc0e7eea418da7e2e92992ec 100644 (file)
@@ -253,10 +253,8 @@ char *get_rundir(void)
        const char *homedir;
        struct stat sb;
 
-       if (stat(RUNTIME_PATH, &sb) < 0)
-               return NULL;
-
-       if (geteuid() == sb.st_uid || getegid() == sb.st_gid)
+       if ((stat(RUNTIME_PATH, &sb) == 0) &&
+           (geteuid() == sb.st_uid || getegid() == sb.st_gid))
                return strdup(RUNTIME_PATH);
 
        static_rundir = getenv("XDG_RUNTIME_DIR");