git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Frans Klaver" <fransklaver@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] run-command.c: Accept EACCES as command not found
Date: Tue, 22 Nov 2011 00:06:46 +0100	[thread overview]
Message-ID: <op.v5bjtk1r0aolir@keputer> (raw)
In-Reply-To: <7vbos5f7ix.fsf@alter.siamese.dyndns.org>

On Mon, 21 Nov 2011 23:13:58 +0100, Junio C Hamano <gitster@pobox.com>  
wrote:

> Frans Klaver <fransklaver@gmail.com> writes:
>
>> execvp returns ENOENT if a command was not found after searching PATH.
>> If path contains a directory that current user has insufficient
>> privileges to, EACCES is returned. This may still mean the program
>> wasn't found.
>>
>> If the latter case is encountered, git errors out without giving aliases
>> a try,...
>
> Isn't that a *good* thing in general, though, so that the user can
> diagnose the breakage in the $PATH and fix it?

Actually I went through diagnosing and fixing it. After tracking it down,  
I did wonder about this question myself and I didn't come to a definitive  
conclusion on it. On one hand I do agree that it may be an incentive for  
the user to fix his path. On the other hand I found it an obscure one to  
track down; git's behavior doesn't match bash behavior:

$ git config --global alias.aliasedinit init &&
mkdir searchpath && chmod 400 searchpath && PATH=$(pwd)/searchpath:$PATH  
&& export PATH &&
mkdir someproject && cd someproject &&
git aliasedinit
fatal: cannot exec 'git-aliasedinit': Permission denied

$ git-aliasedinit
bash: git-aliasedinit: command not found

This isn't very intuitive to track down an incorrect PATH with, imo. You  
have to dig into git core code, learn about how git handles commands,  
learn about debugging forked processes, and find out that execvp uses  
EACCES for more than just "permission denied" _just_ to find out you've  
got a wrong environment variable lying about. That's a full day of work  
gone for a newbie. If bash would also tell me in natural language that  
permission was denied, I wouldn't even have considered doing this patch.

For my part the root of the problem lies with the use of EACCES by execvp  
here, not so much with how git uses it. For this particular case, EACCES  
doesn't just mean "it exists, but you cannot execute this", it may also  
mean "not found, but one of the paths could not be accessed". If git were  
to provide a really helpful message, we'd have to detect which paths got  
denied. Once we know that, we can even on the spot decide to error out or  
not. In other words, we'd have to figure out which meaning of EACCES is  
actually used. Based on that, git can error out, warn or ignore at will.

In any case, I thought it best to have other developers have a look at it.  
I can put a bit more of that information in the commit message, but I'd be  
just as happy to drop the patch and keep the exercise.

Frans

  reply	other threads:[~2011-11-21 23:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-21 21:53 [PATCH] run-command.c: Accept EACCES as command not found Frans Klaver
2011-11-21 22:13 ` Junio C Hamano
2011-11-21 23:06   ` Frans Klaver [this message]
2011-11-21 23:54     ` Junio C Hamano
2011-11-22  9:31       ` Frans Klaver
2011-11-23  8:17         ` Frans Klaver
2011-11-23 12:04           ` Nguyen Thai Ngoc Duy
2011-11-23 13:25             ` Frans Klaver
2011-11-23 22:55           ` Frans Klaver
2011-12-06 21:38             ` [PATCH 0/2] run-command: Add EACCES diagnostics Frans Klaver
2011-12-06 21:38               ` [PATCH 1/2] run-command: Add checks after execvp fails with EACCES Frans Klaver
2011-12-06 22:35                 ` Junio C Hamano
2011-12-07  8:31                   ` Frans Klaver
2011-12-08 21:44                   ` Frans Klaver
2011-12-09 17:23                     ` Junio C Hamano
2011-12-09 21:35                       ` Frans Klaver
2011-12-06 21:38               ` [PATCH 2/2] run-command: Add interpreter permissions check Frans Klaver
2011-12-06 22:47                 ` Junio C Hamano
2011-12-07  8:37                   ` Frans Klaver
2011-12-13 15:08             ` [PATCH 0/2 v2] run-command: Add eacces diagnostics Frans Klaver
2011-12-13 15:08               ` [PATCH 1/2] run-command: Add checks after execvp fails with EACCES Frans Klaver
2011-12-13 19:01                 ` Junio C Hamano
2011-12-14 14:31                   ` Frans Klaver
2011-12-14 22:06                     ` Frans Klaver
2011-12-13 15:08               ` [PATCH 2/2] run-command: Add interpreter permissions check Frans Klaver

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=op.v5bjtk1r0aolir@keputer \
    --to=fransklaver@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 NNTP newsgroup(s).