summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-21 18:41:52 -0400
committerjoe <joe@jerkface.net>2014-04-21 18:41:52 -0400
commit768eef43fc1e19175a3b3f6820f96910d3f2a4b7 (patch)
tree0e88b9b2c5b937d57ec6e0e79ee28b4f13f15cee /kiki.hs
parent687c7db8bbdf42b57a252e5bc6dbd01d4dd5593e (diff)
autosign support
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs20
1 files changed, 18 insertions, 2 deletions
diff --git a/kiki.hs b/kiki.hs
index 0d87b90..d1d8bb3 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -1157,7 +1157,7 @@ main = do
1157 ++ hosts 1157 ++ hosts
1158 , kImports = Map.fromList $ 1158 , kImports = Map.fromList $
1159 [ ( HomePub, importStyle ) ] 1159 [ ( HomePub, importStyle ) ]
1160 , kManip = noManip 1160 , kManip = maybe noManip (const doAutosign) $ Map.lookup "--autosign" margs
1161 , homeSpec = homespec 1161 , homeSpec = homespec
1162 } 1162 }
1163 1163
@@ -1183,6 +1183,22 @@ main = do
1183 return() 1183 return()
1184 where 1184 where
1185 1185
1186 doAutosign rt kd@(KeyData k ksigs umap submap) = ops
1187 where
1188 ops = map (\u -> InducerSignature u []) us
1189 us = filter torStyle $ Map.keys umap
1190 torbindings = getTorKeys (map packet $ flattenTop "" True kd)
1191 torStyle str = and [ uid_topdomain parsed == "onion"
1192 , uid_realname parsed `elem` ["","Anonymous"]
1193 , uid_user parsed == "root"
1194 , fmap (match . fst) (lookup (packet k) torbindings)
1195 == Just True ]
1196 where parsed = parseUID str
1197 match = ( (==subdom) . take (fromIntegral len))
1198 subdom0 = L.fromChunks [encodeUtf8 (uid_subdomain parsed)]
1199 subdom = Char8.unpack subdom0
1200 len = T.length (uid_subdomain parsed)
1201
1186 getTorKeys pub = do 1202 getTorKeys pub = do
1187 xs <- groupBindings pub 1203 xs <- groupBindings pub
1188 (_,(top,sub),us,_,_) <- xs 1204 (_,(top,sub),us,_,_) <- xs
@@ -1244,7 +1260,7 @@ main = do
1244 o <- overs sig 1260 o <- overs sig
1245 k <- keys 1261 k <- keys
1246 let ov = verify (Message [k]) $ o 1262 let ov = verify (Message [k]) $ o
1247 signatures_over ov 1263 take 1 $ signatures_over ov
1248 return (sig,Just ov,k) 1264 return (sig,Just ov,k)
1249 selfsigs = filter (\(sig,v,whosign) -> isJust (v >> selfkey >>= guard 1265 selfsigs = filter (\(sig,v,whosign) -> isJust (v >> selfkey >>= guard
1250 . (== keykey whosign) 1266 . (== keykey whosign)