[PATCH] posix findexe function returns non-executable files
Matt Mackall
mpm at selenic.com
Fri Aug 26 15:59:28 CDT 2011
On Fri, 2011-08-26 at 00:48 -0400, Robert Jones wrote:
> opener: posix findexe function returns non-executable files
>
> Make the Posix version of the findexe() function check the file's executable
> bits before returning the file. If the executable bits are not set then the
> file is skipped.
>
> The Posix findexe() function claims to do command searching like
> which does, but which only returns executable files. The Posix findexe
> function will return any file found in the path, regardless of the file's
> permission bits. This causes problems in other tools, like TortoiseHg,
> that expect findexe to return an executable file.
>
> This patch adds a permissions check to the Posix findexe function. If the
> executable bit is not set for any of user, group or other, then the function
> continues searching the path. The patch does not check files that have
> path separators in the name. It is assumed the user added an explicit path
> for a reason. findexe() should not break that assumption.
>
>
> # HG changeset patch
> # User Robert Jones <rob at redshirtsoftware.com>
> # Date 1314178961 14400
> # Node ID ddb494a4ae579edcb7a3de94a9ccfab39489fc92
> # Parent f1c54569975b1db26667e07649cc95adf4de347c
> add check for executable bits on files identified by posix findexe function
>
> diff -r f1c54569975b -r ddb494a4ae57 mercurial/posix.py
> --- a/mercurial/posix.py Wed Aug 24 05:41:31 2011 -0400
> +++ b/mercurial/posix.py Wed Aug 24 05:42:41 2011 -0400
> @@ -256,7 +256,9 @@
> for path in os.environ.get('PATH', '').split(os.pathsep):
> executable = findexisting(os.path.join(path, command))
> if executable is not None:
> - return executable
> + st = os.stat(executable)
> + if (st.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)):
> + return executable
> return None
>
> def setsignalhandler():
There's something messed up with whitespace in your patch. I've fixed
that up and queued it with a more standard summary, thanks.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list