stub out POSIX stuff
This commit is contained in:
parent
e5f1ca7b4b
commit
6c74a42cc6
17 changed files with 128 additions and 0 deletions
2
Annex/Branch.hs
Normal file → Executable file
2
Annex/Branch.hs
Normal file → Executable file
|
@ -24,7 +24,9 @@ module Annex.Branch (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L
|
import qualified Data.ByteString.Lazy.Char8 as L
|
||||||
|
#if 0
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Annex.BranchState
|
import Annex.BranchState
|
||||||
|
|
0
Annex/Content.hs
Normal file → Executable file
0
Annex/Content.hs
Normal file → Executable file
2
Annex/Environment.hs
Normal file → Executable file
2
Annex/Environment.hs
Normal file → Executable file
|
@ -13,7 +13,9 @@ import Common.Annex
|
||||||
import Utility.UserInfo
|
import Utility.UserInfo
|
||||||
import qualified Git.Config
|
import qualified Git.Config
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
#endif
|
||||||
import Network.BSD
|
import Network.BSD
|
||||||
|
|
||||||
{- Checks that the system's environment allows git to function.
|
{- Checks that the system's environment allows git to function.
|
||||||
|
|
2
Annex/Ssh.hs
Normal file → Executable file
2
Annex/Ssh.hs
Normal file → Executable file
|
@ -14,7 +14,9 @@ module Annex.Ssh (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
#if 0
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Annex.LockPool
|
import Annex.LockPool
|
||||||
|
|
4
CmdLine.hs
Normal file → Executable file
4
CmdLine.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module CmdLine (
|
module CmdLine (
|
||||||
dispatch,
|
dispatch,
|
||||||
usage,
|
usage,
|
||||||
|
@ -15,7 +17,9 @@ import qualified Control.Exception as E
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Control.Exception (throw)
|
import Control.Exception (throw)
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
|
#if 0
|
||||||
import System.Posix.Signals
|
import System.Posix.Signals
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
|
4
Command/Fsck.hs
Normal file → Executable file
4
Command/Fsck.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Command.Fsck where
|
module Command.Fsck where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -28,7 +30,9 @@ import qualified Option
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Utility.HumanTime
|
import Utility.HumanTime
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.Process (getProcessID)
|
import System.Posix.Process (getProcessID)
|
||||||
|
#endif
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import Data.Time
|
import Data.Time
|
||||||
import System.Posix.Types (EpochTime)
|
import System.Posix.Types (EpochTime)
|
||||||
|
|
4
Creds.hs
Normal file → Executable file
4
Creds.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Creds where
|
module Creds where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -15,7 +17,9 @@ import Types.Remote (RemoteConfig, RemoteConfigKey)
|
||||||
import Remote.Helper.Encryptable (remoteCipher, embedCreds)
|
import Remote.Helper.Encryptable (remoteCipher, embedCreds)
|
||||||
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
#if 0
|
||||||
import System.Posix.Env (setEnv)
|
import System.Posix.Env (setEnv)
|
||||||
|
#endif
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L
|
import qualified Data.ByteString.Lazy.Char8 as L
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Utility.Base64
|
import Utility.Base64
|
||||||
|
|
8
Git.hs
Normal file → Executable file
8
Git.hs
Normal file → Executable file
|
@ -8,6 +8,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Git (
|
module Git (
|
||||||
Repo(..),
|
Repo(..),
|
||||||
Ref(..),
|
Ref(..),
|
||||||
|
@ -30,7 +32,9 @@ module Git (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Network.URI (uriPath, uriScheme, unEscapeString)
|
import Network.URI (uriPath, uriScheme, unEscapeString)
|
||||||
|
#if 0
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Git.Types
|
import Git.Types
|
||||||
|
@ -127,4 +131,8 @@ hookPath script repo = do
|
||||||
ifM (catchBoolIO $ isexecutable hook)
|
ifM (catchBoolIO $ isexecutable hook)
|
||||||
( return $ Just hook , return Nothing )
|
( return $ Just hook , return Nothing )
|
||||||
where
|
where
|
||||||
|
#if __WINDOWS__
|
||||||
|
isexecutable f = doesFileExist f
|
||||||
|
#else
|
||||||
isexecutable f = isExecutable . fileMode <$> getFileStatus f
|
isexecutable f = isExecutable . fileMode <$> getFileStatus f
|
||||||
|
#endif
|
||||||
|
|
4
Git/Construct.hs
Normal file → Executable file
4
Git/Construct.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Git.Construct (
|
module Git.Construct (
|
||||||
fromCwd,
|
fromCwd,
|
||||||
fromAbsPath,
|
fromAbsPath,
|
||||||
|
@ -21,7 +23,9 @@ module Git.Construct (
|
||||||
checkForRepo,
|
checkForRepo,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.User
|
import System.Posix.User
|
||||||
|
#endif
|
||||||
import qualified Data.Map as M hiding (map, split)
|
import qualified Data.Map as M hiding (map, split)
|
||||||
import Network.URI
|
import Network.URI
|
||||||
|
|
||||||
|
|
4
Git/CurrentRepo.hs
Normal file → Executable file
4
Git/CurrentRepo.hs
Normal file → Executable file
|
@ -5,10 +5,14 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Git.CurrentRepo where
|
module Git.CurrentRepo where
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
import System.Posix.Directory (changeWorkingDirectory)
|
||||||
import System.Posix.Env (getEnv, unsetEnv)
|
import System.Posix.Env (getEnv, unsetEnv)
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Git.Types
|
import Git.Types
|
||||||
|
|
4
GitAnnexShell.hs
Normal file → Executable file
4
GitAnnexShell.hs
Normal file → Executable file
|
@ -5,9 +5,13 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module GitAnnexShell where
|
module GitAnnexShell where
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
#endif
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
|
4
Remote/Rsync.hs
Normal file → Executable file
4
Remote/Rsync.hs
Normal file → Executable file
|
@ -5,11 +5,15 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Remote.Rsync (remote) where
|
module Remote.Rsync (remote) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
#if 0
|
||||||
import System.Posix.Process (getProcessID)
|
import System.Posix.Process (getProcessID)
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
|
|
4
Test.hs
Normal file → Executable file
4
Test.hs
Normal file → Executable file
|
@ -5,15 +5,19 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Test where
|
module Test where
|
||||||
|
|
||||||
import Test.HUnit
|
import Test.HUnit
|
||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
import Test.QuickCheck.Test
|
import Test.QuickCheck.Test
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
import System.Posix.Directory (changeWorkingDirectory)
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import System.Posix.Env
|
import System.Posix.Env
|
||||||
|
#endif
|
||||||
import Control.Exception.Extensible
|
import Control.Exception.Extensible
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import System.IO.HVFS (SystemFS(..))
|
import System.IO.HVFS (SystemFS(..))
|
||||||
|
|
4
Utility/Daemon.hs
Normal file → Executable file
4
Utility/Daemon.hs
Normal file → Executable file
|
@ -5,12 +5,16 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.Daemon where
|
module Utility.Daemon where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Utility.LogFile
|
import Utility.LogFile
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix
|
import System.Posix
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Run an action as a daemon, with all output sent to a file descriptor.
|
{- Run an action as a daemon, with all output sent to a file descriptor.
|
||||||
-
|
-
|
||||||
|
|
60
Utility/FileMode.hs
Normal file → Executable file
60
Utility/FileMode.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.FileMode where
|
module Utility.FileMode where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
@ -17,6 +19,7 @@ import Foreign (complement)
|
||||||
{- Applies a conversion function to a file's mode. -}
|
{- Applies a conversion function to a file's mode. -}
|
||||||
modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO ()
|
modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO ()
|
||||||
modifyFileMode f convert = void $ modifyFileMode' f convert
|
modifyFileMode f convert = void $ modifyFileMode' f convert
|
||||||
|
#if 0
|
||||||
modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode
|
modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode
|
||||||
modifyFileMode' f convert = do
|
modifyFileMode' f convert = do
|
||||||
s <- getFileStatus f
|
s <- getFileStatus f
|
||||||
|
@ -25,6 +28,9 @@ modifyFileMode' f convert = do
|
||||||
when (new /= old) $
|
when (new /= old) $
|
||||||
setFileMode f new
|
setFileMode f new
|
||||||
return old
|
return old
|
||||||
|
#else
|
||||||
|
modifyFileMode' = error "modifyFileMode' TODO"
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Adds the specified FileModes to the input mode, leaving the rest
|
{- Adds the specified FileModes to the input mode, leaving the rest
|
||||||
- unchanged. -}
|
- unchanged. -}
|
||||||
|
@ -33,7 +39,11 @@ addModes ms m = combineModes (m:ms)
|
||||||
|
|
||||||
{- Removes the specified FileModes from the input mode. -}
|
{- Removes the specified FileModes from the input mode. -}
|
||||||
removeModes :: [FileMode] -> FileMode -> FileMode
|
removeModes :: [FileMode] -> FileMode -> FileMode
|
||||||
|
#if 0
|
||||||
removeModes ms m = m `intersectFileModes` complement (combineModes ms)
|
removeModes ms m = m `intersectFileModes` complement (combineModes ms)
|
||||||
|
#else
|
||||||
|
removeModes = error "removeModes TODO"
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Runs an action after changing a file's mode, then restores the old mode. -}
|
{- Runs an action after changing a file's mode, then restores the old mode. -}
|
||||||
withModifiedFileMode :: FilePath -> (FileMode -> FileMode) -> IO a -> IO a
|
withModifiedFileMode :: FilePath -> (FileMode -> FileMode) -> IO a -> IO a
|
||||||
|
@ -44,43 +54,78 @@ withModifiedFileMode file convert a = bracket setup cleanup go
|
||||||
go _ = a
|
go _ = a
|
||||||
|
|
||||||
writeModes :: [FileMode]
|
writeModes :: [FileMode]
|
||||||
|
#if 0
|
||||||
writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode]
|
writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode]
|
||||||
|
#else
|
||||||
|
writeModes = []
|
||||||
|
#endif
|
||||||
|
|
||||||
readModes :: [FileMode]
|
readModes :: [FileMode]
|
||||||
|
#if 0
|
||||||
readModes = [ownerReadMode, groupReadMode, otherReadMode]
|
readModes = [ownerReadMode, groupReadMode, otherReadMode]
|
||||||
|
#else
|
||||||
|
readModes = []
|
||||||
|
#endif
|
||||||
|
|
||||||
executeModes :: [FileMode]
|
executeModes :: [FileMode]
|
||||||
|
#if 0
|
||||||
executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode]
|
executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode]
|
||||||
|
#else
|
||||||
|
executeModes = []
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Removes the write bits from a file. -}
|
{- Removes the write bits from a file. -}
|
||||||
preventWrite :: FilePath -> IO ()
|
preventWrite :: FilePath -> IO ()
|
||||||
|
#if 0
|
||||||
preventWrite f = modifyFileMode f $ removeModes writeModes
|
preventWrite f = modifyFileMode f $ removeModes writeModes
|
||||||
|
#else
|
||||||
|
preventWrite _ = return ()
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Turns a file's owner write bit back on. -}
|
{- Turns a file's owner write bit back on. -}
|
||||||
allowWrite :: FilePath -> IO ()
|
allowWrite :: FilePath -> IO ()
|
||||||
|
#if 0
|
||||||
allowWrite f = modifyFileMode f $ addModes [ownerWriteMode]
|
allowWrite f = modifyFileMode f $ addModes [ownerWriteMode]
|
||||||
|
#else
|
||||||
|
allowWrite _ = return ()
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Allows owner and group to read and write to a file. -}
|
{- Allows owner and group to read and write to a file. -}
|
||||||
groupWriteRead :: FilePath -> IO ()
|
groupWriteRead :: FilePath -> IO ()
|
||||||
|
#if 0
|
||||||
groupWriteRead f = modifyFileMode f $ addModes
|
groupWriteRead f = modifyFileMode f $ addModes
|
||||||
[ ownerWriteMode, groupWriteMode
|
[ ownerWriteMode, groupWriteMode
|
||||||
, ownerReadMode, groupReadMode
|
, ownerReadMode, groupReadMode
|
||||||
]
|
]
|
||||||
|
#else
|
||||||
|
groupWriteRead _ = return ()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
checkMode :: FileMode -> FileMode -> Bool
|
checkMode :: FileMode -> FileMode -> Bool
|
||||||
checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor
|
checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Checks if a file mode indicates it's a symlink. -}
|
{- Checks if a file mode indicates it's a symlink. -}
|
||||||
isSymLink :: FileMode -> Bool
|
isSymLink :: FileMode -> Bool
|
||||||
|
#if 0
|
||||||
isSymLink = checkMode symbolicLinkMode
|
isSymLink = checkMode symbolicLinkMode
|
||||||
|
#else
|
||||||
|
isSymLink _ = False
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Checks if a file has any executable bits set. -}
|
{- Checks if a file has any executable bits set. -}
|
||||||
isExecutable :: FileMode -> Bool
|
isExecutable :: FileMode -> Bool
|
||||||
|
#if 0
|
||||||
isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0
|
isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0
|
||||||
|
#else
|
||||||
|
isExecutable _ = False
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Runs an action without that pesky umask influencing it, unless the
|
{- Runs an action without that pesky umask influencing it, unless the
|
||||||
- passed FileMode is the standard one. -}
|
- passed FileMode is the standard one. -}
|
||||||
noUmask :: FileMode -> IO a -> IO a
|
noUmask :: FileMode -> IO a -> IO a
|
||||||
|
#if 0
|
||||||
noUmask mode a
|
noUmask mode a
|
||||||
| mode == stdFileMode = a
|
| mode == stdFileMode = a
|
||||||
| otherwise = bracket setup cleanup go
|
| otherwise = bracket setup cleanup go
|
||||||
|
@ -88,17 +133,28 @@ noUmask mode a
|
||||||
setup = setFileCreationMask nullFileMode
|
setup = setFileCreationMask nullFileMode
|
||||||
cleanup = setFileCreationMask
|
cleanup = setFileCreationMask
|
||||||
go _ = a
|
go _ = a
|
||||||
|
#else
|
||||||
|
noUmask _ a = a
|
||||||
|
#endif
|
||||||
|
|
||||||
combineModes :: [FileMode] -> FileMode
|
combineModes :: [FileMode] -> FileMode
|
||||||
|
#if 0
|
||||||
combineModes [] = undefined
|
combineModes [] = undefined
|
||||||
combineModes [m] = m
|
combineModes [m] = m
|
||||||
combineModes (m:ms) = foldl unionFileModes m ms
|
combineModes (m:ms) = foldl unionFileModes m ms
|
||||||
|
#else
|
||||||
|
combineModes _ = error "combineModes TODO"
|
||||||
|
#endif
|
||||||
|
|
||||||
stickyMode :: FileMode
|
stickyMode :: FileMode
|
||||||
stickyMode = 512
|
stickyMode = 512
|
||||||
|
|
||||||
isSticky :: FileMode -> Bool
|
isSticky :: FileMode -> Bool
|
||||||
|
#if 0
|
||||||
isSticky = checkMode stickyMode
|
isSticky = checkMode stickyMode
|
||||||
|
#else
|
||||||
|
isSticky _ = False
|
||||||
|
#endif
|
||||||
|
|
||||||
setSticky :: FilePath -> IO ()
|
setSticky :: FilePath -> IO ()
|
||||||
setSticky f = modifyFileMode f $ addModes [stickyMode]
|
setSticky f = modifyFileMode f $ addModes [stickyMode]
|
||||||
|
@ -110,6 +166,7 @@ setSticky f = modifyFileMode f $ addModes [stickyMode]
|
||||||
- as writeFile.
|
- as writeFile.
|
||||||
-}
|
-}
|
||||||
writeFileProtected :: FilePath -> String -> IO ()
|
writeFileProtected :: FilePath -> String -> IO ()
|
||||||
|
#if 0
|
||||||
writeFileProtected file content = do
|
writeFileProtected file content = do
|
||||||
h <- openFile file WriteMode
|
h <- openFile file WriteMode
|
||||||
void $ tryIO $
|
void $ tryIO $
|
||||||
|
@ -117,3 +174,6 @@ writeFileProtected file content = do
|
||||||
removeModes [groupReadMode, otherReadMode]
|
removeModes [groupReadMode, otherReadMode]
|
||||||
hPutStr h content
|
hPutStr h content
|
||||||
hClose h
|
hClose h
|
||||||
|
#else
|
||||||
|
writeFileProtected = writeFile
|
||||||
|
#endif
|
||||||
|
|
14
Utility/Gpg.hs
Normal file → Executable file
14
Utility/Gpg.hs
Normal file → Executable file
|
@ -5,13 +5,17 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.Gpg where
|
module Utility.Gpg where
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
|
#if 0
|
||||||
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
|
@ -20,6 +24,7 @@ newtype KeyIds = KeyIds [String]
|
||||||
|
|
||||||
stdParams :: [CommandParam] -> IO [String]
|
stdParams :: [CommandParam] -> IO [String]
|
||||||
stdParams params = do
|
stdParams params = do
|
||||||
|
#ifndef __WINDOWS__
|
||||||
-- Enable batch mode if GPG_AGENT_INFO is set, to avoid extraneous
|
-- Enable batch mode if GPG_AGENT_INFO is set, to avoid extraneous
|
||||||
-- gpg output about password prompts. GPG_BATCH is set by the test
|
-- gpg output about password prompts. GPG_BATCH is set by the test
|
||||||
-- suite for a similar reason.
|
-- suite for a similar reason.
|
||||||
|
@ -29,6 +34,9 @@ stdParams params = do
|
||||||
then []
|
then []
|
||||||
else ["--batch", "--no-tty", "--use-agent"]
|
else ["--batch", "--no-tty", "--use-agent"]
|
||||||
return $ batch ++ defaults ++ toCommand params
|
return $ batch ++ defaults ++ toCommand params
|
||||||
|
#else
|
||||||
|
return $ defaults ++ toCommand params
|
||||||
|
#endif
|
||||||
where
|
where
|
||||||
-- be quiet, even about checking the trustdb
|
-- be quiet, even about checking the trustdb
|
||||||
defaults = ["--quiet", "--trust-model", "always"]
|
defaults = ["--quiet", "--trust-model", "always"]
|
||||||
|
@ -64,6 +72,7 @@ pipeStrict params input = do
|
||||||
- Note that to avoid deadlock with the cleanup stage,
|
- Note that to avoid deadlock with the cleanup stage,
|
||||||
- the reader must fully consume gpg's input before returning. -}
|
- the reader must fully consume gpg's input before returning. -}
|
||||||
feedRead :: [CommandParam] -> String -> (Handle -> IO ()) -> (Handle -> IO a) -> IO a
|
feedRead :: [CommandParam] -> String -> (Handle -> IO ()) -> (Handle -> IO a) -> IO a
|
||||||
|
#ifndef __WINDOWS__
|
||||||
feedRead params passphrase feeder reader = do
|
feedRead params passphrase feeder reader = do
|
||||||
-- pipe the passphrase into gpg on a fd
|
-- pipe the passphrase into gpg on a fd
|
||||||
(frompipe, topipe) <- createPipe
|
(frompipe, topipe) <- createPipe
|
||||||
|
@ -83,6 +92,9 @@ feedRead params passphrase feeder reader = do
|
||||||
feeder to
|
feeder to
|
||||||
hClose to
|
hClose to
|
||||||
reader from
|
reader from
|
||||||
|
#else
|
||||||
|
feedRead = error "feedRead TODO"
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Finds gpg public keys matching some string. (Could be an email address,
|
{- Finds gpg public keys matching some string. (Could be an email address,
|
||||||
- a key id, or a name; See the section 'HOW TO SPECIFY A USER ID' of
|
- a key id, or a name; See the section 'HOW TO SPECIFY A USER ID' of
|
||||||
|
@ -204,6 +216,7 @@ keyBlock public ls = unlines
|
||||||
| public = "PUBLIC"
|
| public = "PUBLIC"
|
||||||
| otherwise = "PRIVATE"
|
| otherwise = "PRIVATE"
|
||||||
|
|
||||||
|
#if 0
|
||||||
{- Runs an action using gpg in a test harness, in which gpg does
|
{- Runs an action using gpg in a test harness, in which gpg does
|
||||||
- not use ~/.gpg/, but a directory with the test key set up to be used. -}
|
- not use ~/.gpg/, but a directory with the test key set up to be used. -}
|
||||||
testHarness :: IO a -> IO a
|
testHarness :: IO a -> IO a
|
||||||
|
@ -230,3 +243,4 @@ testTestHarness :: IO Bool
|
||||||
testTestHarness = do
|
testTestHarness = do
|
||||||
keys <- testHarness $ findPubKeys testKeyId
|
keys <- testHarness $ findPubKeys testKeyId
|
||||||
return $ KeyIds [testKeyId] == keys
|
return $ KeyIds [testKeyId] == keys
|
||||||
|
#endif
|
||||||
|
|
4
Utility/LogFile.hs
Normal file → Executable file
4
Utility/LogFile.hs
Normal file → Executable file
|
@ -5,11 +5,15 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.LogFile where
|
module Utility.LogFile where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
|
#if 0
|
||||||
import System.Posix
|
import System.Posix
|
||||||
|
#endif
|
||||||
|
|
||||||
openLog :: FilePath -> IO Fd
|
openLog :: FilePath -> IO Fd
|
||||||
openLog logfile = do
|
openLog logfile = do
|
||||||
|
|
Loading…
Add table
Reference in a new issue