summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-05 23:11:24 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-05 23:11:24 -0400
commit1da6145352f403a880890266ca79b57c992cb0dc (patch)
tree7879d929c86ef84fcd30be0772a87a525c2e3e2e /kiki.hs
parentb6ea6fcee16c3ef65adff62d532346a3dee1f4fa (diff)
Give useful error when kiki init is non-root.
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/kiki.hs b/kiki.hs
index 11f9fb4..bca3ca5 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -53,6 +53,7 @@ import qualified Data.Map as Map
53import Control.Arrow (first,second) 53import Control.Arrow (first,second)
54import Data.Monoid ( (<>) ) 54import Data.Monoid ( (<>) )
55import Data.Binary.Put 55import Data.Binary.Put
56import System.Posix.User
56 57
57import CommandLine 58import CommandLine
58import Data.OpenPGP.Util (verify, fingerprint, GenerateKeyParams(..)) 59import Data.OpenPGP.Util (verify, fingerprint, GenerateKeyParams(..))
@@ -1335,6 +1336,8 @@ kiki "merge" [] = do
1335 , " don't write)." 1336 , " don't write)."
1336 , "" 1337 , ""
1337 , " --create=(rsa:SIZE|cmd:CMD)" 1338 , " --create=(rsa:SIZE|cmd:CMD)"
1339 , " Note: With --flow=spill, a dummy file name must still be"
1340 , " provided so that the command line can be parsed."
1338 , "" 1341 , ""
1339 , " --autosign[=no]" 1342 , " --autosign[=no]"
1340 , "" 1343 , ""
@@ -1557,7 +1560,16 @@ kiki "init" args | "--help" `elem` args = do
1557 , "" 1560 , ""
1558 ] ++ documentHomeDir ++ [""] ++ documentPassphraseFDFlag True True True 1561 ] ++ documentHomeDir ++ [""] ++ documentPassphraseFDFlag True True True
1559 1562
1560kiki "init" args = run args $ importAndRefresh <$> dashdashChroot <*> dashdashHomedir <*> dashdashCipher 1563kiki "init" args = do
1564 rootOK <- case runArgs ([],args) dashdashChroot of
1565 Left e -> hPutStrLn stderr (usageErrorMessage e) >> return False
1566 Right root -> if root "x" /= root "x"
1567 then return True
1568 else fmap (==0) $ getEffectiveUserID
1569 if rootOK
1570 then run args $ importAndRefresh <$> dashdashChroot <*> dashdashHomedir <*> dashdashCipher
1571 else do hPutStrLn stderr "Missing --chroot option. Permision denied."
1572 exitFailure
1561kiki "spawn" args | "--help" `elem` args = 1573kiki "spawn" args | "--help" `elem` args =
1562 putStr . unlines $ 1574 putStr . unlines $
1563 [ "kiki spawn [ --passphrase-fd=FD" 1575 [ "kiki spawn [ --passphrase-fd=FD"