podman-container-tools/podman · error

stat %s: %m

Error message

stat %s: %m

What it means

Before executing a candidate hook, do_preexec_hooks_dir() stats '<dir>/<file>' (pkg/rootless/rootless_linux.c:468). Files deleted between readdir and stat (ENOENT) are skipped, so this fatal message means stat failed with another errno - typically EACCES (search permission denied on a path component), ELOOP (symlink loop), ESTALE (NFS stale handle), or EIO.

Source

Thrown at pkg/rootless/rootless_linux.c:475

      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;

      exec_binary (path, argv, argc);
      errno = 0;
    }

  if (errno)
    {
      fprintf (stderr, "readdir %s: %m\n", dir);
      exit (EXIT_FAILURE);
    }
}

View on GitHub (pinned to a2409076ef)

Solutions

  1. Reproduce manually: 'stat <path-from-message>' to see the errno
  2. Fix permissions on the file and every parent ('chmod a+rx' on dirs, 'chmod a+r' on the file) or relabel with restorecon
  3. Remove dangling/looping symlinks from the hooks dir
  4. If on NFS, move the hooks to local storage or remount with appropriate options

Example fix

# before
$ stat /etc/containers/pre-exec-hooks/broken-link
stat: cannot statx '/etc/containers/pre-exec-hooks/broken-link': Too many levels of symbolic links

# after
$ rm /etc/containers/pre-exec-hooks/broken-link
$ podman version
Defensive patterns

Strategy: validation

Validate before calling

# Pre-stat every hook exactly like the C helper will
for d in /etc/containers/pre-exec-hooks "${PODMAN_PREEXEC_HOOKS_DIR:-}"; do
  [ -z "$d" ] || [ ! -d "$d" ] && continue
  for f in "$d"/*; do
    [ -e "$f" ] || continue
    stat "$f" >/dev/null || { echo "hook not stat-able: $f" >&2; exit 1; }
  done
done

Prevention

When it happens

Trigger: A hook entry is a symlink chain forming a loop; the hooks dir sits on NFS and the file handle went stale; a parent directory of the hook lacks execute permission for the invoking user; concurrent repackaging of the hooks dir changes permissions mid-scan.

Common situations: Hooks on NFS with root_squash; SELinux denials on hook files; hook RPM updated while podman was starting; broken symlinks left by an uninstall script.

Related errors


AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15). Data as JSON: /api/errors/0fc63b6ae13a4490. Report an issue: GitHub.