Make git-annex enable-tor work when using the linux standalone build

Clean the standalone environment before running the su command
to run "sh". Otherwise, PATH leaked through, causing it to run
git-annex.linux/bin/sh, but GIT_ANNEX_DIR was not set,
which caused that script to not work:

[2022-10-26 15:07:02.145466106] (Utility.Process) process [938146] call: pkexec ["sh","-c","cd '/home/joey/tmp/git-annex.linux/r' && '/home/joey/tmp/git-annex.linux/git-annex' 'enable-tor' '1000'"]
/home/joey/tmp/git-annex.linux/bin/sh: 4: exec: /exe/sh: not found

Changed programPath to not use GIT_ANNEX_PROGRAMPATH,
but instead run the scripts at the top of GIT_ANNEX_DIR.
That works both when the standalone environment is set up, and when it's
not.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2022-10-26 15:44:06 -04:00
parent a8ce8ac75d
commit 14f7a386f0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 48 additions and 35 deletions

View file

@ -57,9 +57,9 @@ describePasswordPrompt' :: Maybe SuCommand -> Maybe String
describePasswordPrompt' (Just (SuCommand p _ _)) = describePasswordPrompt p
describePasswordPrompt' Nothing = Nothing
runSuCommand :: (Maybe SuCommand) -> IO Bool
runSuCommand (Just (SuCommand _ cmd ps)) = boolSystem cmd ps
runSuCommand Nothing = return False
runSuCommand :: (Maybe SuCommand) -> Maybe [(String, String)] -> IO Bool
runSuCommand (Just (SuCommand _ cmd ps)) env = boolSystemEnv cmd ps env
runSuCommand Nothing _ = return False
-- Generates a SuCommand that runs a command as root, fairly portably.
--