Make getKeychain parametric

This commit is contained in:
rnhmjoj 2015-07-07 22:09:46 +02:00
parent 948cf41665
commit fc67f3938b

View File

@ -39,13 +39,12 @@ keychainList :: IO [FilePath]
keychainList = do keychainList = do
raw <- readProcess "security" ["list-keychains"] "" raw <- readProcess "security" ["list-keychains"] ""
case runParser parseKeychainList raw of case runParser parseKeychainList raw of
Just list -> return list Just list -> return $ filter ((/="System") . takeBaseName) list
Nothing -> error "failed to parse active keychains list" Nothing -> error "failed to parse active keychains list"
getKeychain :: IO Keychain getKeychain :: [FilePath] -> IO Keychain
getKeychain = do getKeychain paths = do
paths <- filter ((/="System") . takeBaseName) <$> keychainList raw <- readProcess "security" ("dump-keychain" : "-d" : paths) ""
raw <- readProcess "security" ("dump-keychain" : "-d" : paths) ""
case runParser parseKeychain raw of case runParser parseKeychain raw of
Just items -> return items Just items -> return items
Nothing -> error "failed to parse keychain" Nothing -> error "failed to parse keychain"