summaryrefslogtreecommitdiff
path: root/lib/Kiki.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kiki.hs')
-rw-r--r--lib/Kiki.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Kiki.hs b/lib/Kiki.hs
index 575cf26..be99ed8 100644
--- a/lib/Kiki.hs
+++ b/lib/Kiki.hs
@@ -39,6 +39,15 @@ refresh root homepass = do
39 39
40data CommonArgsParsed = CommonArgsParsed { cap_homespec :: Maybe String, cap_passfd :: Maybe InputFile } 40data CommonArgsParsed = CommonArgsParsed { cap_homespec :: Maybe String, cap_passfd :: Maybe InputFile }
41 41
42streaminfo :: StreamInfo
43streaminfo = StreamInfo
44 { fill = KF_None
45 , spill = KF_None
46 , typ = KeyRingFile
47 , initializer = NoCreate
48 , access = AutoAccess
49 , transforms = []
50 }
42 51
43minimalOp :: CommonArgsParsed -> KeyRingOperation 52minimalOp :: CommonArgsParsed -> KeyRingOperation
44minimalOp cap = op 53minimalOp cap = op
@@ -167,3 +176,20 @@ sshblobFromPacket k = blob
167 <$> optional (arg "--homedir") 176 <$> optional (arg "--homedir")
168 <*> optional (FileDesc <$> read <$> arg "--passphrase-fd") 177 <*> optional (FileDesc <$> read <$> arg "--passphrase-fd")
169 178
179replaceSshServerKeys root cmn = do
180 let homepass' = cmn { cap_homespec = fmap root (cap_homespec cmn) }
181 replaceSSH op = op { opFiles = files }
182 where
183 files = Map.adjust delssh HomeSec
184 $ Map.adjust delssh HomePub
185 $ Map.insert (ArgFile $ root "/etc/ssh/ssh_host_rsa_key") strm $ opFiles op
186 strm = streaminfo { typ = PEMFile, spill = KF_Match "ssh-server", access = Sec }
187 delssh strm = strm { transforms = DeleteSubkeyByUsage "ssh-server" : transforms strm
188 , fill = KF_All }
189 KikiResult r report <- runKeyRing $ minimalOp homepass'
190 case r of
191 KikiSuccess rt -> Kiki.refreshCache rt $ case root "" of
192 "/" -> Nothing
193 "" -> Nothing
194 pth -> Just pth
195 err -> hPutStrLn stderr $ errorString err