postfork: Also check shebang/interpreter for EACCESS

This happens e.g. with a shebang of "#!/bin/" - we would complain
about EACCESS, even tho accessing *the file to run* worked.
This commit is contained in:
Fabian Boehm 2022-12-30 11:41:18 +01:00
parent afd242b14d
commit ead0b03108

View file

@ -453,6 +453,7 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
break;
}
case EACCES:
case ENOENT: {
// ENOENT is returned by exec() when the path fails, but also returned by posix_spawn if
// an open file action fails. These cases appear to be impossible to distinguish. We
@ -481,24 +482,21 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
"Failed to execute process '%s': The file exists and is executable. "
"Check the interpreter or linker?",
actual_cmd);
} else {
} else if (err == ENOENT) {
FLOGF_SAFE(exec,
"Failed to execute process '%s': The file does not exist or could not "
"be executed.",
actual_cmd);
} else {
FLOGF_SAFE(exec, "Failed to execute process '%s': The file could not be accessed.",
actual_cmd);
}
break;
}
case ENOMEM: {
FLOGF_SAFE(exec, "Out of memory");
break;
}
case EACCES: {
FLOGF_SAFE(exec, "Failed to execute process '%s': The file could not be accessed.",
actual_cmd);
break;
}
case ETXTBSY: {
FLOGF_SAFE(exec, "Failed to execute process '%s': File is currently open for writing.",
actual_cmd);