]> git.ipfire.org Git - thirdparty/public-inbox.git/commit
fix git permission denied in certain configs
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Thu, 29 May 2025 15:23:21 +0000 (11:23 -0400)
committerEric Wong <e@80x24.org>
Wed, 4 Jun 2025 11:37:25 +0000 (11:37 +0000)
commit4cca3dcfe2342b2dfa41fb0b272c18626ae03196
tree0a89630678ce9279e0b28312aa1bb8c892cafd6d
parent27a0289343a0e8d7ad23a60461e3466c35d85927
fix git permission denied in certain configs

The problem is the which() sub in Spawn.pm only checks if the path
fragment is executable, but this may be true of a directory as well.

In particular, a lot of people have a git directory in their $HOME
(where they store their git repos) and if $PATH contains '.' then
SpawnPP.pm will try to execute this directory leading to this failure
on a lot of lei commands:

exec ./git var GIT_PAGER failed: Permission denied at /usr/share/perl5/PublicInbox/SpawnPP.pm line 62.
fork_exec git var GIT_PAGER failed: Permission denied

As you can see what's happened is it's tried to execute my ./git
directory, which obviously fails.  The fix is simple, skip executable
files which are also directories when doing $PATH based lookup

[ew: use `_' bareword to avoid 2nd stat, spelling fix in commit message]

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
lib/PublicInbox/Spawn.pm