The standalone builds now unset their special path and library path variables before running the system web browser.
Should fix a crash reported on OSX.
This commit is contained in:
parent
6a9ba6ad06
commit
2525fefbb9
6 changed files with 49 additions and 4 deletions
|
@ -21,6 +21,7 @@ import Utility.OSX
|
||||||
import Utility.FreeDesktop
|
import Utility.FreeDesktop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
import Data.AssocList
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
|
||||||
standaloneAppBase :: IO (Maybe FilePath)
|
standaloneAppBase :: IO (Maybe FilePath)
|
||||||
|
@ -68,3 +69,24 @@ ensureInstalled = go =<< standaloneAppBase
|
||||||
createDirectoryIfMissing True (parentDir shim)
|
createDirectoryIfMissing True (parentDir shim)
|
||||||
writeFile shim content
|
writeFile shim content
|
||||||
modifyFileMode shim $ addModes [ownerExecuteMode]
|
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
|
||||||
|
|
|
@ -137,9 +137,10 @@ openBrowser cmd htmlshim = go $ maybe runBrowser runCustomBrowser cmd
|
||||||
go a = do
|
go a = do
|
||||||
putStrLn ""
|
putStrLn ""
|
||||||
putStrLn $ "Launching web browser on " ++ url
|
putStrLn $ "Launching web browser on " ++ url
|
||||||
unlessM (a url) $
|
env <- cleanEnvironment
|
||||||
|
unlessM (a url env) $
|
||||||
error $ "failed to start web browser"
|
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 -}
|
{- web.browser is a generic git config setting for a web browser program -}
|
||||||
webBrowser :: Git.Repo -> Maybe FilePath
|
webBrowser :: Git.Repo -> Maybe FilePath
|
||||||
|
|
|
@ -41,8 +41,8 @@ localhost = "localhost"
|
||||||
{- Runs a web browser on a given url.
|
{- Runs a web browser on a given url.
|
||||||
-
|
-
|
||||||
- Note: The url *will* be visible to an attacker. -}
|
- Note: The url *will* be visible to an attacker. -}
|
||||||
runBrowser :: String -> IO Bool
|
runBrowser :: String -> (Maybe [(String, String)]) -> IO Bool
|
||||||
runBrowser url = boolSystem cmd [Param url]
|
runBrowser url env = boolSystemEnv cmd [Param url] env
|
||||||
where
|
where
|
||||||
#ifdef darwin_HOST_OS
|
#ifdef darwin_HOST_OS
|
||||||
cmd = "open"
|
cmd = "open"
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -4,6 +4,8 @@ git-annex (3.20121127) UNRELEASED; urgency=low
|
||||||
subdirectories. Could affect various parts of git-annex.
|
subdirectories. Could affect various parts of git-annex.
|
||||||
* rsync: Fix bug introduced in last release that broke encrypted rsync
|
* rsync: Fix bug introduced in last release that broke encrypted rsync
|
||||||
special remotes.
|
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
|
-- Joey Hess <joeyh@debian.org> Mon, 26 Nov 2012 16:45:19 -0400
|
||||||
|
|
||||||
|
|
|
@ -41,17 +41,27 @@ fi
|
||||||
|
|
||||||
# Put our binaries first, to avoid issues with out of date or incompatable
|
# Put our binaries first, to avoid issues with out of date or incompatable
|
||||||
# system binaries.
|
# system binaries.
|
||||||
|
ORIG_PATH="$PATH"
|
||||||
|
export ORIG_PATH
|
||||||
PATH=$base/bin:$PATH
|
PATH=$base/bin:$PATH
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
ORIG_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
|
||||||
|
export ORIG_LD_LIBRARY_PATH
|
||||||
for lib in $(cat $base/libdirs); do
|
for lib in $(cat $base/libdirs); do
|
||||||
LD_LIBRARY_PATH="$base/$lib:$LD_LIBRARY_PATH"
|
LD_LIBRARY_PATH="$base/$lib:$LD_LIBRARY_PATH"
|
||||||
done
|
done
|
||||||
export LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
|
||||||
|
export ORIG_GIT_EXEC_PATH
|
||||||
GIT_EXEC_PATH=$base/git-core
|
GIT_EXEC_PATH=$base/git-core
|
||||||
export GIT_EXEC_PATH
|
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
|
if [ "$1" ]; then
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
shift 1
|
shift 1
|
||||||
|
|
|
@ -41,6 +41,8 @@ fi
|
||||||
|
|
||||||
# Put our binaries first, to avoid issues with out of date or incompatable
|
# Put our binaries first, to avoid issues with out of date or incompatable
|
||||||
# system binaries.
|
# system binaries.
|
||||||
|
ORIG_PATH="$PATH"
|
||||||
|
export ORIG_PATH
|
||||||
PATH=$base/bin:$PATH
|
PATH=$base/bin:$PATH
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
@ -53,12 +55,20 @@ export PATH
|
||||||
# different versions of a single library. And it seems to work better
|
# different versions of a single library. And it seems to work better
|
||||||
# than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system
|
# than DYLD_FALLBACK_LIBRARY_PATH, which fails to override old system
|
||||||
# versions of libraries when a program in the app needs a newer version.
|
# 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
|
DYLD_ROOT_PATH=$base
|
||||||
export DYLD_ROOT_PATH
|
export DYLD_ROOT_PATH
|
||||||
|
|
||||||
|
ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
|
||||||
|
export ORIG_GIT_EXEC_PATH
|
||||||
GIT_EXEC_PATH=$base/git-core
|
GIT_EXEC_PATH=$base/git-core
|
||||||
export GIT_EXEC_PATH
|
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
|
if [ "$1" ]; then
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
shift 1
|
shift 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue