podman-container-tools/podman · error
internal error: path too long
Error message
internal error: path too long
What it means
For each entry in a preexec-hooks dir, do_preexec_hooks_dir() composes '<dir>/<filename>' into a char path[PATH_MAX] with snprintf and treats a return of PATH_MAX as overflow (pkg/rootless/rootless_linux.c:461-465). Because filenames are capped at NAME_MAX (255), in practice the hooks directory path itself must be near PATH_MAX (4096) to trigger this. It is an internal sanity assertion, not an expected runtime error.
Source
Thrown at pkg/rootless/rootless_linux.c:464
continue;
strncpy (buffer + nfiles * (NAME_MAX + 1), de->d_name, NAME_MAX + 1);
nfiles++;
}
qsort (buffer, nfiles, NAME_MAX + 1, (int (*)(const void *, const void *)) strcmp);
for (i = 0; i < nfiles; i++)
{
const char *fname = buffer + i * (NAME_MAX + 1);
char path[PATH_MAX];
struct stat st;
int ret;
ret = snprintf (path, PATH_MAX, "%s/%s", dir, fname);
if (ret == PATH_MAX)
{
fprintf (stderr, "internal error: path too long\n");
exit (EXIT_FAILURE);
}
ret = stat (path, &st);
if (ret < 0)
{
/* Ignore the failure if the file was deleted. */
if (errno == ENOENT)
continue;
fprintf (stderr, "stat %s: %m\n", path);
exit (EXIT_FAILURE);
}
/* Not an executable. */
if ((st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
continue;
View on GitHub (pinned to a2409076ef)
Solutions
- Shorten the hooks dir path: keep hooks in the default locations (/etc/containers/pre-exec-hooks, LIBEXECPODMAN/pre-exec-hooks)
- Print ${#PODMAN_PREEXEC_HOOKS_DIR} and ensure it is well under 4096 - 256 characters
- Unset PODMAN_PREEXEC_HOOKS_DIR or remove /etc/containers/podman_preexec_hooks.txt to bypass hooks entirely
- If triggered without an obviously long path, report upstream - it indicates memory corruption or a patched build
Defensive patterns
Strategy: validation
Validate before calling
# Reject absurd hook dir paths before podman scans them
d="${PODMAN_PREEXEC_HOOKS_DIR:-}"
if [ -n "$d" ] && [ "${#d}" -ge 3800 ]; then
echo "preexec hooks dir path too long: ${#d} chars" >&2
exit 1
fi
Prevention
- Keep hook directories at the default shallow locations
- Validate exported path variables for sane lengths in env bootstrap scripts
When it happens
Trigger: A hooks directory (e.g. via PODMAN_PREEXEC_HOOKS_DIR) deployed at a path roughly 4090+ characters long, or a symlink-resolved dir path of that length; deliberate path fuzzing of the env var.
Common situations: Never seen in normal packaging; only with scripted generation of absurdly deep directory trees or hostile environment fuzzing. Note the upstream check is 'ret == PATH_MAX' where 'ret >= PATH_MAX' would be stricter, so it is marked 'internal error'.
Related errors
- internal error: namespace path too long
- invalid value for XDG_RUNTIME_DIR: %m
- malloc: %m
- waitpid: %m
- opendir %s: %m
AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15).
Data as JSON: /api/errors/5aed79859061dc67.
Report an issue: GitHub.