Nothing -> pure Nothing
Just (Right f'') -> liftIO $
Just <$> relPathDirToFile subdir f''
- Just (Left gitsha) -> do
- liftIO . F.writeFile (subdir </> f')
- =<< catObject gitsha
- return (Just f')
+ Just (Left gitsha) ->
+ Just <$> (liftIO . relPathDirToFile subdir
+ =<< populategitsha gitsha tmpdir)
liftIO $ hPutStrLn (stdinHandle p) $
maybe "" fromOsPath mp
liftIO $ hFlush (stdinHandle p)
calcduration (MonotonicTimestamp starttime) (MonotonicTimestamp endtime) =
fromIntegral (endtime - starttime) :: NominalDiffTime
+ -- Writes to a .git/objects/ file in the tmpdir, rather than
+ -- using the input filename, to avoid exposing the input filename
+ -- to the program as a parameter, which could parse it as a dashed
+ -- option or other special parameter.
+ populategitsha gitsha tmpdir = do
+ let f = tmpdir </> ".git" </> "objects"
+ </> toOsPath (Git.fromRef' gitsha)
+ liftIO $ createDirectoryIfMissing True $ takeDirectory f
+ liftIO . F.writeFile f =<< catObject gitsha
+ return f
+
computationBehaviorChangeError :: ComputeProgram -> String -> OsPath -> Annex a
computationBehaviorChangeError (ComputeProgram program) requestdesc p =
giveup $ program ++ " is not behaving the same way it used to, now " ++ requestdesc ++ ": " ++ fromOsPath p
being set, eg `ANNEX_COMPUTE_passes=10` or `ANNEX_COMPUTE_--level=9`.
For security, the program should avoid exposing user input to the shell
-unprotected, or otherwise executing it.
+unprotected, or otherwise executing it. And when running a command, make
+sure that whatever user input is passed to it can result in only safe and
+expected behavior.
The program is run in a temporary directory, which will be cleaned up after
it exits. Note that it may be run in a subdirectory of a temporary