diff options
Diffstat (limited to 'lib/Kiki.hs')
-rw-r--r-- | lib/Kiki.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Kiki.hs b/lib/Kiki.hs index 222c1bb..a0e2d07 100644 --- a/lib/Kiki.hs +++ b/lib/Kiki.hs | |||
@@ -152,6 +152,7 @@ minimalOp isHomeless cap = op | |||
152 | return $ PassphraseSpec Nothing Nothing pfile | 152 | return $ PassphraseSpec Nothing Nothing pfile |
153 | , opTransforms = [] | 153 | , opTransforms = [] |
154 | , opHome = cap_homespec cap | 154 | , opHome = cap_homespec cap |
155 | , preferredPGPVersion = 4 | ||
155 | } | 156 | } |
156 | 157 | ||
157 | run :: [String] -> Args (IO ()) -> IO () | 158 | run :: [String] -> Args (IO ()) -> IO () |
@@ -203,8 +204,8 @@ peminfo bits usage = StreamInfo | |||
203 | , transforms = [] | 204 | , transforms = [] |
204 | } | 205 | } |
205 | 206 | ||
206 | importAndRefresh :: (FilePath -> FilePath) -> CommonArgsParsed -> SymmetricAlgorithm -> IO () | 207 | importAndRefresh :: Word8 -> (FilePath -> FilePath) -> CommonArgsParsed -> SymmetricAlgorithm -> IO () |
207 | importAndRefresh root cmn cipher = do | 208 | importAndRefresh pgpver root cmn cipher = do |
208 | let rootdir = do guard (root "x" /= "x") | 209 | let rootdir = do guard (root "x" /= "x") |
209 | Just $ root "" | 210 | Just $ root "" |
210 | me <- getEffectiveUserID | 211 | me <- getEffectiveUserID |
@@ -214,7 +215,6 @@ importAndRefresh root cmn cipher = do | |||
214 | let homespec = mplus (slash <$> rootdir <*> cap_homespec cmn) | 215 | let homespec = mplus (slash <$> rootdir <*> cap_homespec cmn) |
215 | (fmap (++"/root/.gnupg") rootdir) | 216 | (fmap (++"/root/.gnupg") rootdir) |
216 | passfd = cap_passfd cmn | 217 | passfd = cap_passfd cmn |
217 | pgpver = preferredPGPVersion $ minimalOp False cmn | ||
218 | (home,secring,pubring,mbwk) <- unconditionally $ getHomeDir homespec | 218 | (home,secring,pubring,mbwk) <- unconditionally $ getHomeDir homespec |
219 | osHomeDir <- if bUnprivileged then getHomeDirectory else return "/root" | 219 | osHomeDir <- if bUnprivileged then getHomeDirectory else return "/root" |
220 | 220 | ||
@@ -326,6 +326,7 @@ importAndRefresh root cmn cipher = do | |||
326 | return $ PassphraseSpec Nothing Nothing pfd | 326 | return $ PassphraseSpec Nothing Nothing pfd |
327 | , opHome = homespec | 327 | , opHome = homespec |
328 | , opTransforms = [] | 328 | , opTransforms = [] |
329 | , preferredPGPVersion = pgpver | ||
329 | } | 330 | } |
330 | nop = | 331 | nop = |
331 | KeyRingOperation | 332 | KeyRingOperation |
@@ -340,6 +341,7 @@ importAndRefresh root cmn cipher = do | |||
340 | return $ PassphraseSpec Nothing Nothing pfd | 341 | return $ PassphraseSpec Nothing Nothing pfd |
341 | , opHome=homespec | 342 | , opHome=homespec |
342 | , opTransforms = [] | 343 | , opTransforms = [] |
344 | , preferredPGPVersion = pgpver | ||
343 | } | 345 | } |
344 | when bUnprivileged $ do | 346 | when bUnprivileged $ do |
345 | hPutStrLn stderr "Insufficient privilege generating system service keys." | 347 | hPutStrLn stderr "Insufficient privilege generating system service keys." |
@@ -473,6 +475,7 @@ generateHostsFile fw rt = do | |||
473 | , opPassphrases = [] | 475 | , opPassphrases = [] |
474 | , opHome = Just $ takeDirectory (rtPubring rt) | 476 | , opHome = Just $ takeDirectory (rtPubring rt) |
475 | , opTransforms = [] | 477 | , opTransforms = [] |
478 | , preferredPGPVersion = 4 -- Does not matter (no fill of pgp files). | ||
476 | } | 479 | } |
477 | KikiResult _ report <- runKeyRing op | 480 | KikiResult _ report <- runKeyRing op |
478 | outputReport report | 481 | outputReport report |
@@ -723,6 +726,12 @@ slash "" ('/':xs) = '/':xs | |||
723 | slash "" xs = '/':xs | 726 | slash "" xs = '/':xs |
724 | slash (y:ys) xs = y:slash ys xs | 727 | slash (y:ys) xs = y:slash ys xs |
725 | 728 | ||
729 | dashdashPGPVersion :: Args Word8 | ||
730 | dashdashPGPVersion = liftA2 (\is4 is5 -> if is5 then 5 else if is4 then 4 else defaultV) (flag "-4") (flag "-5") | ||
731 | where | ||
732 | defaultV = 4 -- Use v4 packets by default for now. | ||
733 | |||
734 | |||
726 | dashdashChroot :: Args (FilePath -> FilePath) | 735 | dashdashChroot :: Args (FilePath -> FilePath) |
727 | dashdashChroot = pure (\r a -> slash r a) <*> arg "--chroot" <|> pure id | 736 | dashdashChroot = pure (\r a -> slash r a) <*> arg "--chroot" <|> pure id |
728 | 737 | ||