diff options
-rw-r--r-- | Assistant/Install.hs | 22 | ||||
-rw-r--r-- | Command/WebApp.hs | 5 | ||||
-rw-r--r-- | Utility/WebApp.hs | 4 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rwxr-xr-x | standalone/linux/runshell | 10 | ||||
-rwxr-xr-x | standalone/osx/git-annex.app/Contents/MacOS/runshell | 10 |
6 files changed, 49 insertions, 4 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs index 635c265f4..475161c63 100644 --- a/Assistant/Install.hs +++ b/Assistant/Install.hs @@ -21,6 +21,7 @@ import Utility.OSX import Utility.FreeDesktop #endif +import Data.AssocList import System.Posix.Env standaloneAppBase :: IO (Maybe FilePath) @@ -68,3 +69,24 @@ ensureInstalled = go =<< standaloneAppBase createDirectoryIfMissing True (parentDir shim) writeFile shim content modifyFileMode shim $ addModes [ownerExecuteMode] + +{- Returns a cleaned up environment that lacks settings used to make the + - standalone builds use their bundled libraries and programs. + - Useful when calling programs not included in the standalone builds. + - + - For a non-standalone build, returns Nothing. + -} +cleanEnvironment :: IO (Maybe [(String, String)]) +cleanEnvironment = clean <$> getEnvironment + where + clean env + | null vars = Nothing + | otherwise = Just $ catMaybes $ map (restoreorig env) env + | otherwise = Nothing + where + vars = words $ lookup1 "GIT_ANNEX_STANDLONE_ENV" env + restoreorig oldenv p@(k, v) + | k `elem` vars = case lookup1 ("ORIG_" ++ k) oldenv of + "" -> Nothing + v' -> Just (k, v') + | otherwise = Just p diff --git a/Command/WebApp.hs b/Command/WebApp.hs index a0bd2e7f7..1d97eb304 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -137,9 +137,10 @@ openBrowser cmd htmlshim = go $ maybe runBrowser runCustomBrowser cmd go a = do putStrLn "" putStrLn $ "Launching web browser on " ++ url - unlessM (a url) $ + env <- cleanEnvironment + unlessM (a url env) $ error $ "failed to start web browser" - runCustomBrowser c u = boolSystem c [Param u] + runCustomBrowser c u = boolSystemEnv c [Param u] {- web.browser is a generic git config setting for a web browser program -} webBrowser :: Git.Repo -> Maybe FilePath diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs index cbc4ce906..0c3f6040d 100644 --- a/Utility/WebApp.hs +++ b/Utility/WebApp.hs @@ -41,8 +41,8 @@ localhost = "localhost" {- Runs a web browser on a given url. - - Note: The url *will* be visible to an attacker. -} -runBrowser :: String -> IO Bool -runBrowser url = boolSystem cmd [Param url] +runBrowser :: String -> (Maybe [(String, String)]) -> IO Bool +runBrowser url env = boolSystemEnv cmd [Param url] env where #ifdef darwin_HOST_OS cmd = "open" diff --git a/debian/changelog b/debian/changelog index a9fdd1b07..3f503013f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ git-annex (3.20121127) UNRELEASED; urgency=low subdirectories. Could affect various parts of git-annex. * rsync: Fix bug introduced in last release that broke encrypted rsync special remotes. + * The standalone builds now unset their special path and library path + variables before running the system web browser. -- Joey Hess <joeyh@debian.org> Mon, 26 Nov 2012 16:45:19 -0400 diff --git a/standalone/linux/runshell b/standalone/linux/runshell index 82d3ce2c5..816c3036e 100755 --- a/standalone/linux/runshell +++ b/standalone/linux/runshell @@ -41,17 +41,27 @@ fi # Put our binaries first, to avoid issues with out of date or incompatable # system binaries. +ORIG_PATH="$PATH" +export ORIG_PATH PATH=$base/bin:$PATH export PATH +ORIG_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" +export ORIG_LD_LIBRARY_PATH for lib in $(cat $base/libdirs); do LD_LIBRARY_PATH="$base/$lib:$LD_LIBRARY_PATH" done export LD_LIBRARY_PATH +ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH" +export ORIG_GIT_EXEC_PATH GIT_EXEC_PATH=$base/git-core export GIT_EXEC_PATH +# Indicate which variables were exported above. +GIT_ANNEX_STANDLONE_ENV="PATH LD_LIBRARY_PATH GIT_EXEC_PATH" +export GIT_ANNEX_STANDLONE_ENV + if [ "$1" ]; then cmd="$1" shift 1 diff --git a/standalone/osx/git-annex.app/Contents/MacOS/runshell b/standalone/osx/git-annex.app/Contents/MacOS/runshell index c409d814b..51748285a 100755 --- a/standalone/osx/git-annex.app/Contents/MacOS/runshell +++ b/standalone/osx/git-annex.app/Contents/MacOS/runshell @@ -41,6 +41,8 @@ fi # Put our binaries first, to avoid issues with out of date or incompatable # system binaries. +ORIG_PATH="$PATH" +export ORIG_PATH PATH=$base/bin:$PATH export PATH @@ -53,12 +55,20 @@ export PATH # different versions of a single library. And it seems to work better # than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system # versions of libraries when a program in the app needs a newer version. +ORIG_DYLD_ROOT_PATH="$DYLD_ROOT_PATH" +export ORIG_DYLD_ROOT_PATH DYLD_ROOT_PATH=$base export DYLD_ROOT_PATH +ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH" +export ORIG_GIT_EXEC_PATH GIT_EXEC_PATH=$base/git-core export GIT_EXEC_PATH +# Indicate which variables were exported above. +GIT_ANNEX_STANDLONE_ENV="PATH DYLD_ROOT_PATH GIT_EXEC_PATH" +export GIT_ANNEX_STANDLONE_ENV + if [ "$1" ]; then cmd="$1" shift 1 |