diff options
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -1401,7 +1401,7 @@ kiki "merge" args = do | |||
1401 | kiki "init" args | "--help" `elem` args = do | 1401 | kiki "init" args | "--help" `elem` args = do |
1402 | putStr . unlines $ | 1402 | putStr . unlines $ |
1403 | [ "kiki init [ --passphrase-fd=FD" | 1403 | [ "kiki init [ --passphrase-fd=FD" |
1404 | , " | --home[=HOMEDIR]" | 1404 | , " | --homedir[=HOMEDIR]" |
1405 | , " | --chroot=ROOTDIR ] ..." | 1405 | , " | --chroot=ROOTDIR ] ..." |
1406 | , "" | 1406 | , "" |
1407 | , "Initialize a GnuPG keyring for use with kiki. After completion, you" | 1407 | , "Initialize a GnuPG keyring for use with kiki. After completion, you" |
@@ -1417,6 +1417,9 @@ kiki "init" args | "--help" `elem` args = do | |||
1417 | , " --chroot=ROOTDIR" | 1417 | , " --chroot=ROOTDIR" |
1418 | , " Use ROOTDIR for input of ssh keys and export files to" | 1418 | , " Use ROOTDIR for input of ssh keys and export files to" |
1419 | , " ROOTDIR/var/cache/kiki instead of the current system path." | 1419 | , " ROOTDIR/var/cache/kiki instead of the current system path." |
1420 | , " When this option is specified, the GNUPGHOME environment" | ||
1421 | , " variable is ignored and you must use --homedir to specify" | ||
1422 | , " a value other than /root/.gnupg." | ||
1420 | , "" | 1423 | , "" |
1421 | ] ++ documentHomeDir ++ [""] ++ documentPassphraseFDFlag True True True | 1424 | ] ++ documentHomeDir ++ [""] ++ documentPassphraseFDFlag True True True |
1422 | kiki "init" args = do | 1425 | kiki "init" args = do |
@@ -1426,7 +1429,7 @@ kiki "init" args = do | |||
1426 | -} | 1429 | -} |
1427 | let as = lefts $ map splitArg args | 1430 | let as = lefts $ map splitArg args |
1428 | lefts = mapMaybe isLeft where { isLeft (Left x) = Just x; isLeft _ = Nothing } | 1431 | lefts = mapMaybe isLeft where { isLeft (Left x) = Just x; isLeft _ = Nothing } |
1429 | bads = map fst as \\ ["passphrase-fd","home","chroot"] | 1432 | bads = map fst as \\ ["passphrase-fd","homedir","chroot"] |
1430 | if not (null bads) then error ("Bad option: " ++ unwords bads) else do | 1433 | if not (null bads) then error ("Bad option: " ++ unwords bads) else do |
1431 | let rootdir = fmap (fromMaybe "") $ lookup "chroot" as | 1434 | let rootdir = fmap (fromMaybe "") $ lookup "chroot" as |
1432 | let noChrootArg = rootdir == Nothing | 1435 | let noChrootArg = rootdir == Nothing |
@@ -1435,7 +1438,7 @@ kiki "init" args = do | |||
1435 | -- maybe id fchroot rootdir $ do | 1438 | -- maybe id fchroot rootdir $ do |
1436 | args <- return $ map (second $ fromMaybe "") as | 1439 | args <- return $ map (second $ fromMaybe "") as |
1437 | 1440 | ||
1438 | let homespec = mplus ( (++) <$> rootdir <*> lookup "home" args ) | 1441 | let homespec = mplus (slash <$> rootdir <*> lookup "homedir" args ) |
1439 | (fmap (++"/root/.gnupg") rootdir) | 1442 | (fmap (++"/root/.gnupg") rootdir) |
1440 | sshkeygen size = Just $ concat [ "mkdir -p \"$(dirname $file)\" && " | 1443 | sshkeygen size = Just $ concat [ "mkdir -p \"$(dirname $file)\" && " |
1441 | , "ssh-keygen -P \"\" -q -f $file -b " | 1444 | , "ssh-keygen -P \"\" -q -f $file -b " |
@@ -1447,7 +1450,11 @@ kiki "init" args = do | |||
1447 | -- ssl = Just "mkdir -p \"$(dirname $file)\" && openssl genrsa -out $file 1024" | 1450 | -- ssl = Just "mkdir -p \"$(dirname $file)\" && openssl genrsa -out $file 1024" |
1448 | (home,secring,pubring,mbwk) <- unconditionally $ getHomeDir homespec | 1451 | (home,secring,pubring,mbwk) <- unconditionally $ getHomeDir homespec |
1449 | osHomeDir <- if bUnprivileged then getHomeDirectory else return "/root" | 1452 | osHomeDir <- if bUnprivileged then getHomeDirectory else return "/root" |
1450 | -- putStrLn $ "home = " ++ show (home,secring,pubring,mbwk) | 1453 | putStrLn $ "gnupg home = " ++ show (home,secring,pubring,mbwk) |
1454 | putStrLn $ "os home = " ++ show osHomeDir | ||
1455 | -- gnupg home = ("TESTS/tmpgh","TESTS/tmpgh/secring.gpg","TESTS/tmpgh/pubring.gpg",Nothing) | ||
1456 | -- os home = "/root" | ||
1457 | |||
1451 | 1458 | ||
1452 | -- Generate secring.gpg if it does not exist... | 1459 | -- Generate secring.gpg if it does not exist... |
1453 | gotsec <- doesFileExist secring | 1460 | gotsec <- doesFileExist secring |