{"record":{"id":"0c3f692aabc514ac","repo":"podman-container-tools/podman","slug":"opendir-s-m","errorCode":null,"errorMessage":"opendir %s: %m\n","messagePattern":"opendir (.+?): %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":428,"sourceCode":"  if (WIFSTOPPED (status))\n      exit (EXIT_FAILURE);\n}\n\nstatic void\ndo_preexec_hooks_dir (const char *dir, char **argv, int argc)\n{\n  cleanup_free char *buffer = NULL;\n  cleanup_dir DIR *d = NULL;\n  size_t i, nfiles = 0;\n  struct dirent *de;\n\n  /* Store how many FDs were open before the Go runtime kicked in.  */\n  d = opendir (dir);\n  if (!d)\n    {\n      if (errno != ENOENT)\n        {\n          fprintf (stderr, \"opendir %s: %m\\n\", dir);\n          exit (EXIT_FAILURE);\n        }\n      return;\n    }\n\n  errno = 0;\n\n  for (de = readdir (d); de; de = readdir (d))\n    {\n      buffer = realloc (buffer, (nfiles + 1) * (NAME_MAX + 1));\n      if (buffer == NULL)\n        {\n          fprintf (stderr, \"realloc buffer: %m\\n\");\n          exit (EXIT_FAILURE);\n        }\n\n      if (de->d_type != DT_REG)\n        continue;","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L410-L446","documentation":"do_preexec_hooks_dir() scans a preexec-hooks directory with opendir() (pkg/rootless/rootless_linux.c:423). A missing directory (ENOENT) is silently ignored, so this fatal message means opendir failed with a different errno - most commonly EACCES (no read/execute permission on the directory), ENOTDIR (a path component is a plain file), or ELOOP (symlink loop).","triggerScenarios":"The hooks dir exists but mode/ownership denies access to the invoking (often rootless) user; /etc/containers/pre-exec-hooks or $PODMAN_PREEXEC_HOOKS_DIR points at a file instead of a directory; SELinux denial on the directory; hooks dir on an NFS mount with root squashing and restrictive perms.","commonSituations":"Hook packages installed as root with mode 0700 while podman runs rootless; a custom PODMAN_PREEXEC_HOOKS_DIR typo pointing to a file; SELinux mislabeling after copying hooks with cp -a from another host.","solutions":["Check the failing dir reported in the message: 'ls -ld <dir>' and fix permissions with 'chmod a+rx <dir>' or adjust ownership","If SELinux is enforcing, check 'ausearch -m avc -ts recent' and relabel with 'restorecon -Rv <dir>'","Verify the path is really a directory ('test -d <dir>') and fix $PODMAN_PREEXEC_HOOKS_DIR if it is wrong","Disable the hooks mechanism by removing /etc/containers/podman_preexec_hooks.txt to confirm or work around"],"exampleFix":"# before\n$ ls -ld /etc/containers/pre-exec-hooks\ndrwx------ 2 root root ... /etc/containers/pre-exec-hooks\n$ podman version\nopendir /etc/containers/pre-exec-hooks: Permission denied\n\n# after\n$ sudo chmod 0755 /etc/containers/pre-exec-hooks\n$ podman version\n","handlingStrategy":"validation","validationCode":"# Verify every hooks dir podman will scan is a readable directory\nfor d in /etc/containers/pre-exec-hooks \"${PODMAN_PREEXEC_HOOKS_DIR:-}\"; do\n  [ -z \"$d\" ] && continue\n  if [ -e \"$d\" ] && { [ ! -d \"$d\" ] || [ ! -r \"$d\" ] || [ ! -x \"$d\" ]; }; then\n    echo \"unusable preexec hooks dir: $d\" >&2\n    exit 1\n  fi\ndone\npodman \"$@\"\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install hook packages with mode 0755 directories and readable entries","Point PODMAN_PREEXEC_HOOKS_DIR only at dedicated, curated directories","After copying hooks between hosts, run restorecon on SELinux systems"],"tags":["preexec-hooks","permissions","filesystem","rootless","selinux"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}