git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] Git 2.38.0-rc1 t1800 message text comparison

From
René Scharfe <l.s.r@web.de>
Date
Jun 4, 2023, 12:13 UTC
Message-ID
<f5519f93-bca7-ecbc-9da3-b25ce8aef618@web.de>
In-Reply-To
<013601d98cf2$392153c0$ab63fb40$@nexbridge.com>
Am 22.05.23 um 23:13 schrieb rsbecker@nexbridge.com:
Show 17 quoted lines
> On Monday, May 22, 2023 4:49 PM, I wrote:
>> On Monday, May 22, 2023 4:39 PM, René Scharfe wrote:
>>> So trying to execute an executable file consisting only of the line
>>> "#!/bad/path/no/spaces" causes NonStop to report "Permission denied"?
>>> That message text belongs to error code EACCES, not to EPERM
>>> ("Operation not permitted"), right?
>>
>> That should be correct, although the OS Devs I spoke to about this said "EPERM". I
>> am experimenting.
>>
>>> POSIX allows execve to return EACCES if the file to execute is not a
>>> regular file and executing that file type is not supported or if
>>> permissions are missing to one of its path components.
>>
>> Part of the OS Dev's response was that POSIX is actually ambiguous on this point.
>> Linux made the decision to use ENOENT. NonStop decided to use EPERM (although it
>> may actually be EACCESS - I will report back.

In https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html I don't see how EACCES would be a valid response in this case. And it makes no intuitive sense -- which permission is missing in this situation?

That doesn't change the fact that this issue needs to be dealt with in Git somehow.

> NonStop actually does report EACCES, not EPERM. The comment at the
> front of run-command.c does describe the situation.

Do you mean the one about EACCES being reported if a directory in $PATH is inaccessible in sane_execvp()? That does not apply here because "#!/bad/path/no/spaces" specifies an absolute path, so $PATH is not searched.

Show 17 quoted lines
> The following is a potential fix:
>
> diff --git a/run-command.c b/run-command.c
> index 60c9419866..b76e117d35 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -846,7 +846,7 @@ int start_command(struct child_process *cmd)
>                         execve(argv.v[0], (char *const *) argv.v,
>                                (char *const *) childenv);
>
> -               if (errno == ENOENT) {
> +               if (errno == ENOENT || errno == EACCES) {
>                         if (cmd->silent_exec_failure)
>                                 child_die(CHILD_ERR_SILENT);
>                         child_die(CHILD_ERR_ENOENT);
>
> This does pass and should cover all POSIX interpretations.

That would misreport execution failures due to missing permissions (think e.g. "chmod 0 file") as "No such file or directory". So this should be only done if really needed, perhaps guarded by an access(2) check for verifying that EACCES is bogus, and only on affected platforms.

René
Previous: rsbecker@nexbridge.comNext: René Scharfe
Message 8 of 13 in “[BUG] Git 2.28.0-rc1 t1800 message text comparison”
  1. rsbecker@nexbridge.comSep 22, 2022
  2. rsbecker@nexbridge.comSep 22, 2022
  3. rsbecker@nexbridge.comSep 23, 2022
  4. rsbecker@nexbridge.comDec 14, 2022
  5. René ScharfeMay 22, 2023
  6. rsbecker@nexbridge.comMay 22, 2023
  7. rsbecker@nexbridge.comMay 22, 2023
  8. René ScharfeJun 4, 2023
  9. René ScharfeJun 4, 2023
  10. Junio C HamanoJun 6, 2023
  11. 1/2 t1800: loosen matching of error message for bad shebangRené Scharfe, Jun 10, 2023
  12. Junio C HamanoJun 12, 2023
  13. 2/2 run-command: report exec error even on ENOENTRené Scharfe, Jun 10, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.