diff options
author | Joe Crayne <joe@jerkface.net> | 2019-07-05 23:11:24 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-07-05 23:11:24 -0400 |
commit | 1da6145352f403a880890266ca79b57c992cb0dc (patch) | |
tree | 7879d929c86ef84fcd30be0772a87a525c2e3e2e | |
parent | b6ea6fcee16c3ef65adff62d532346a3dee1f4fa (diff) |
Give useful error when kiki init is non-root.
-rw-r--r-- | kiki.hs | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -53,6 +53,7 @@ import qualified Data.Map as Map | |||
53 | import Control.Arrow (first,second) | 53 | import Control.Arrow (first,second) |
54 | import Data.Monoid ( (<>) ) | 54 | import Data.Monoid ( (<>) ) |
55 | import Data.Binary.Put | 55 | import Data.Binary.Put |
56 | import System.Posix.User | ||
56 | 57 | ||
57 | import CommandLine | 58 | import CommandLine |
58 | import Data.OpenPGP.Util (verify, fingerprint, GenerateKeyParams(..)) | 59 | import 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 | ||
1560 | kiki "init" args = run args $ importAndRefresh <$> dashdashChroot <*> dashdashHomedir <*> dashdashCipher | 1563 | kiki "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 | ||
1561 | kiki "spawn" args | "--help" `elem` args = | 1573 | kiki "spawn" args | "--help" `elem` args = |
1562 | putStr . unlines $ | 1574 | putStr . unlines $ |
1563 | [ "kiki spawn [ --passphrase-fd=FD" | 1575 | [ "kiki spawn [ --passphrase-fd=FD" |