From 4cca3dcfe2342b2dfa41fb0b272c18626ae03196 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 29 May 2025 11:23:21 -0400 Subject: [PATCH] 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 --- lib/PublicInbox/Spawn.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index 1d9f9b76b..7d4671c36 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -350,7 +350,7 @@ sub which ($) { return $file if index($file, '/') >= 0; for my $p (split(/:/, $ENV{PATH})) { $p .= "/$file"; - return $p if -x $p; + return $p if (-x $p && ! -d _); } undef; } -- 2.47.3