Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: rsbecker@nexbridge.com, git@vger.kernel.org
Subject: Re: [BUG] Git 2.38.0-rc1 t1800 message text comparison
Date: Sun, 4 Jun 2023 14:13:06 +0200	[thread overview]
Message-ID: <f5519f93-bca7-ecbc-9da3-b25ce8aef618@web.de> (raw)
In-Reply-To: <013601d98cf2$392153c0$ab63fb40$@nexbridge.com>

Am 22.05.23 um 23:13 schrieb rsbecker@nexbridge.com:
> 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.

> 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é




  reply	other threads:[~2023-06-04 12:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 19:01 [BUG] Git 2.28.0-rc1 t1800 message text comparison rsbecker
2022-09-22 19:02 ` [BUG] Git 2.38.0-rc1 " rsbecker
2022-09-23 20:43 ` rsbecker
2022-12-14  5:53   ` rsbecker
2023-05-22 20:39     ` René Scharfe
2023-05-22 20:49       ` rsbecker
2023-05-22 21:13         ` rsbecker
2023-06-04 12:13           ` René Scharfe [this message]
2023-06-04 20:55             ` René Scharfe
2023-06-06  0:31               ` Junio C Hamano
2023-06-10 14:51                 ` [PATCH 1/2] t1800: loosen matching of error message for bad shebang René Scharfe
2023-06-12 18:01                   ` Junio C Hamano
2023-06-10 14:51                 ` [PATCH 2/2] run-command: report exec error even on ENOENT René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5519f93-bca7-ecbc-9da3-b25ce8aef618@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=rsbecker@nexbridge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).