summaryrefslogtreecommitdiff
path: root/cokiki.hs
diff options
context:
space:
mode:
authorjoe <joe@blackbird>2016-04-25 23:36:21 -0400
committerjoe <joe@blackbird>2016-04-25 23:36:21 -0400
commitae4fa8395e6c87a81681a44b549b8cbbfe82e5e1 (patch)
tree4677f59d48fb30d0ea96fc96b44310b941e14d6b /cokiki.hs
parent769609c28931b01f9c2bdc8740b7553938775e43 (diff)
slash utility (for gluing file paths).
Diffstat (limited to 'cokiki.hs')
-rw-r--r--cokiki.hs11
1 files changed, 1 insertions, 10 deletions
diff --git a/cokiki.hs b/cokiki.hs
index 8874625..055be9b 100644
--- a/cokiki.hs
+++ b/cokiki.hs
@@ -29,15 +29,6 @@ usage = unlines
29 , " strongswan: TODO" 29 , " strongswan: TODO"
30 ] 30 ]
31 31
32ㄧchroot :: Args (FilePath -> FilePath)
33ㄧchroot = pure (\r a -> slash r a) <*> arg "--chroot" <|> pure id
34 where
35 slash :: String -> String -> String
36 slash "/" ('/':xs) = '/':xs
37 slash "" ('/':xs) = '/':xs
38 slash "" xs = '/':xs
39 slash (y:ys) xs = y:slash ys xs
40
41main = do 32main = do
42 (cmd,args) <- splitAt 1 <$> getArgs 33 (cmd,args) <- splitAt 1 <$> getArgs
43 uid <- getEffectiveUserID 34 uid <- getEffectiveUserID
@@ -45,7 +36,7 @@ main = do
45 | uid==0 = action 36 | uid==0 = action
46 | otherwise = hPutStrLn stderr "operation requires root." 37 | otherwise = hPutStrLn stderr "operation requires root."
47 let sel = case cmd of 38 let sel = case cmd of
48 ["ssh-client"] -> pure (sshClient uid) <*> ㄧchroot <*> Kiki.ㄧhomedir 39 ["ssh-client"] -> pure (sshClient uid) <*> Kiki.ㄧchroot <*> Kiki.ㄧhomedir
49 ["ssh-server"] -> pure (whenRoot sshServer) 40 ["ssh-server"] -> pure (whenRoot sshServer)
50 ["strongswan"] -> pure (whenRoot strongswan) 41 ["strongswan"] -> pure (whenRoot strongswan)
51 _ -> pure $ hPutStr stderr usage 42 _ -> pure $ hPutStr stderr usage