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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 22.05.23 um 23:13 schrieb rsbecker@xxxxxxxxxxxxx:
> 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é







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux