diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/KeyRing.hs | 3 | ||||
-rw-r--r-- | lib/KeyRing/BuildKeyDB.hs | 3 | ||||
-rw-r--r-- | lib/KeyRing/Types.hs | 9 | ||||
-rw-r--r-- | lib/Kiki.hs | 15 |
4 files changed, 19 insertions, 11 deletions
diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs index 5b51a93..9669430 100644 --- a/lib/KeyRing.hs +++ b/lib/KeyRing.hs | |||
@@ -87,8 +87,7 @@ import KeyRing.BuildKeyDB (allNames', Hostnames, | |||
87 | readSecretPEMFile, | 87 | readSecretPEMFile, |
88 | secp256k1_id, | 88 | secp256k1_id, |
89 | selectPublicKey, | 89 | selectPublicKey, |
90 | usageFromFilter, | 90 | usageFromFilter) |
91 | preferredPGPVersion) | ||
92 | 91 | ||
93 | import KeyRing.Types | 92 | import KeyRing.Types |
94 | import KeyDB | 93 | import KeyDB |
diff --git a/lib/KeyRing/BuildKeyDB.hs b/lib/KeyRing/BuildKeyDB.hs index c2b2703..3993c66 100644 --- a/lib/KeyRing/BuildKeyDB.hs +++ b/lib/KeyRing/BuildKeyDB.hs | |||
@@ -79,9 +79,6 @@ import GnuPGAgent | |||
79 | import ByteStringUtil | 79 | import ByteStringUtil |
80 | import Text.XXD | 80 | import Text.XXD |
81 | 81 | ||
82 | preferredPGPVersion :: KeyRingOperation -> Word8 | ||
83 | preferredPGPVersion _ = 4 -- TODO: v5 | ||
84 | |||
85 | newtype IPsToWriteToHostsFile = IPsToWriteToHostsFile [SockAddr] | 82 | newtype IPsToWriteToHostsFile = IPsToWriteToHostsFile [SockAddr] |
86 | -- | buildKeyDB | 83 | -- | buildKeyDB |
87 | -- | 84 | -- |
diff --git a/lib/KeyRing/Types.hs b/lib/KeyRing/Types.hs index dbcc22c..c272efc 100644 --- a/lib/KeyRing/Types.hs +++ b/lib/KeyRing/Types.hs | |||
@@ -32,13 +32,16 @@ data KeyRingOperation = KeyRingOperation | |||
32 | -- ^ If provided, this is the directory where the 'HomeSec' and 'HomePub' | 32 | -- ^ If provided, this is the directory where the 'HomeSec' and 'HomePub' |
33 | -- files reside. Otherwise, the evironment variable $GNUPGHOME is consulted | 33 | -- files reside. Otherwise, the evironment variable $GNUPGHOME is consulted |
34 | -- and if that is not set, it falls back to $HOME/.gnupg. | 34 | -- and if that is not set, it falls back to $HOME/.gnupg. |
35 | , preferredPGPVersion :: Word8 | ||
36 | -- ^ Newly created PGP key packets will use this version. It should be set | ||
37 | -- to either 4 or 5. | ||
35 | } | 38 | } |
36 | deriving (Eq,Show) | 39 | deriving (Eq,Show) |
37 | instance Semigroup KeyRingOperation where | 40 | instance Semigroup KeyRingOperation where |
38 | KeyRingOperation f p t h <> KeyRingOperation f' p' t' h' = | 41 | KeyRingOperation f p t h v <> KeyRingOperation f' p' t' h' v' = |
39 | KeyRingOperation (f <> f') (p <> p') (t <> t') (h <> h') | 42 | KeyRingOperation (f <> f') (p <> p') (t <> t') (h <> h') (max v v') |
40 | instance Monoid KeyRingOperation where | 43 | instance Monoid KeyRingOperation where |
41 | mempty = KeyRingOperation Map.empty [] [] Nothing | 44 | mempty = KeyRingOperation Map.empty [] [] Nothing 4 |
42 | 45 | ||
43 | data InputFile = HomeSec | 46 | data InputFile = HomeSec |
44 | -- ^ A file named secring.gpg located in the home directory. | 47 | -- ^ A file named secring.gpg located in the home directory. |
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 | ||