{"record":{"id":"ff3636d71741ddae","repo":"podman-container-tools/podman","slug":"invalid-value-for-xdg-runtime-dir-m","errorCode":null,"errorMessage":"invalid value for XDG_RUNTIME_DIR: %m","messagePattern":"invalid value for XDG_RUNTIME_DIR: %m","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":845,"sourceCode":"      char gid_fmt[16];\n      size_t len;\n      int r;\n\n      cwd = getcwd (NULL, 0);\n      if (cwd == NULL)\n        {\n          fprintf (stderr, \"error getting current working directory: %m\\n\");\n          _exit (EXIT_FAILURE);\n        }\n\n      uid = geteuid ();\n      gid = getegid ();\n\n      len = snprintf (path, PATH_MAX, \"%s/libpod/tmp/ns_handles\", xdg_runtime_dir);\n      if (len >= PATH_MAX)\n        {\n          errno = ENAMETOOLONG;\n          fprintf (stderr, \"invalid value for XDG_RUNTIME_DIR: %m\");\n          exit (EXIT_FAILURE);\n        }\n\n      if (set_ns_handles (path) == 0)\n        goto joined;\n\n      /* If the handle is stale, give up with the shortcut.  */\n      if (errno == ESTALE)\n        return;\n\n      /* Fall back to pause.pid if:\n         - ENOENT ns_handles file doesn't exist\n         - EOPNOTSUPP kernel doesn't support open_by_handle_at\n         - ENOSYS syscall not available\n         - EPERM (could be seccomp when running in a container)\n       */\n      if (errno != ENOENT && errno != EOPNOTSUPP && errno != ENOSYS && errno != EPERM)\n        {","sourceCodeStart":827,"sourceCodeEnd":863,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L827-L863","documentation":"On the shortcut path the preamble formats '$XDG_RUNTIME_DIR/libpod/tmp/ns_handles' into a char path[PATH_MAX] (pkg/rootless/rootless_linux.c:842-847). If the formatted length reaches PATH_MAX, errno is set to ENAMETOOLONG and the message is printed (without a trailing newline) before exit. Since XDG_RUNTIME_DIR was already validated as set and non-empty, this means its value is absurdly long (~4000+ characters).","triggerScenarios":"A broken login/profile script, test harness, or fuzzing environment exporting an XDG_RUNTIME_DIR whose length plus the ~25-char suffix reaches 4096; any podman command from that environment as a non-root user.","commonSituations":"Almost never legitimate - normally XDG_RUNTIME_DIR is /run/user/<uid>. Seen with misconfigured CI env injection, corrupted env files, or deliberate stress tests of environment variables.","solutions":["Inspect the value: 'echo ${#XDG_RUNTIME_DIR}' - it should be small (e.g. /run/user/1000)","Fix the exporting script/config to the standard value: export XDG_RUNTIME_DIR=/run/user/$(id -u)","Log out and back in so systemd sets the variable correctly for the session","If a legitimate workflow needs long paths, report upstream - PATH_MAX limits apply"],"exampleFix":"# before\nexport XDG_RUNTIME_DIR=\"/tmp/$(printf 'a%.0s' {1..4200})\"\npodman ps   # invalid value for XDG_RUNTIME_DIR: File name too long\n\n# after\nexport XDG_RUNTIME_DIR=/run/user/$(id -u)\npodman ps\n","handlingStrategy":"validation","validationCode":"# Reject an over-long XDG_RUNTIME_DIR before podman builds paths from it\nif [ -n \"${XDG_RUNTIME_DIR:-}\" ] && [ \"${#XDG_RUNTIME_DIR}\" -gt 3800 ]; then\n  echo \"XDG_RUNTIME_DIR is too long (${#XDG_RUNTIME_DIR} chars)\" >&2\n  exit 1\nfi\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expect XDG_RUNTIME_DIR to be /run/user/<uid>; anything else deserves inspection","Audit env-generating scripts and CI secret/env injection for corrupted values"],"tags":["xdg-runtime-dir","environment","path","rootless","path-max"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}