out of band keyring transfer is not necessary, since repo is cloned securely
This commit is contained in:
parent
eb90a409d5
commit
a5b739af6d
2
Makefile
2
Makefile
|
@ -11,7 +11,7 @@ build: deps dist/setup-config
|
||||||
ln -sf dist/build/propellor/propellor
|
ln -sf dist/build/propellor/propellor
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
@if [ $$(whoami) = root ]; then apt-get -y install gnupg ghc cabal-install libghc-missingh-dev libghc-ansi-terminal-dev libghc-ifelse-dev libghc-unix-compat-dev libghc-hslogger-dev libghc-base64-bytestring-dev; fi || true
|
@if [ $$(whoami) = root ]; then apt-get -y install gnupg ghc cabal-install libghc-missingh-dev libghc-ansi-terminal-dev libghc-ifelse-dev libghc-unix-compat-dev libghc-hslogger-dev; fi || true
|
||||||
|
|
||||||
dist/setup-config: propellor.cabal
|
dist/setup-config: propellor.cabal
|
||||||
cabal configure
|
cabal configure
|
||||||
|
|
|
@ -3,14 +3,10 @@ module Propellor.CmdLine where
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import Data.List
|
import Data.List
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import qualified Data.ByteString.Lazy as BL
|
|
||||||
import qualified Data.ByteString.Base64.Lazy as B64
|
|
||||||
import Data.Bits.Utils
|
|
||||||
|
|
||||||
import Propellor
|
import Propellor
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.SafeCommand
|
import Utility.SafeCommand
|
||||||
import Utility.Data
|
|
||||||
|
|
||||||
data CmdLine
|
data CmdLine
|
||||||
= Run HostName
|
= Run HostName
|
||||||
|
@ -83,12 +79,7 @@ spin host = do
|
||||||
hClose fromh
|
hClose fromh
|
||||||
status <- getstatus fromh `catchIO` error "protocol error"
|
status <- getstatus fromh `catchIO` error "protocol error"
|
||||||
case status of
|
case status of
|
||||||
HaveKeyRing -> finish
|
Ready -> finish
|
||||||
NeedKeyRing -> do
|
|
||||||
d <- w82s . BL.unpack . B64.encode
|
|
||||||
<$> BL.readFile keyring
|
|
||||||
senddata toh keyring keyringMarker d
|
|
||||||
finish
|
|
||||||
NeedGitClone -> do
|
NeedGitClone -> do
|
||||||
hClose toh
|
hClose toh
|
||||||
hClose fromh
|
hClose fromh
|
||||||
|
@ -148,7 +139,7 @@ sendGitClone host url = do
|
||||||
, "rm -f " ++ remotebundle
|
, "rm -f " ++ remotebundle
|
||||||
]
|
]
|
||||||
|
|
||||||
data BootStrapStatus = HaveKeyRing | NeedKeyRing | NeedGitClone
|
data BootStrapStatus = Ready | NeedGitClone
|
||||||
deriving (Read, Show, Eq)
|
deriving (Read, Show, Eq)
|
||||||
|
|
||||||
type Marker = String
|
type Marker = String
|
||||||
|
@ -157,9 +148,6 @@ type Marked = String
|
||||||
statusMarker :: Marker
|
statusMarker :: Marker
|
||||||
statusMarker = "STATUS"
|
statusMarker = "STATUS"
|
||||||
|
|
||||||
keyringMarker :: Marker
|
|
||||||
keyringMarker = "KEYRING"
|
|
||||||
|
|
||||||
privDataMarker :: String
|
privDataMarker :: String
|
||||||
privDataMarker = "PRIVDATA "
|
privDataMarker = "PRIVDATA "
|
||||||
|
|
||||||
|
@ -177,19 +165,13 @@ fromMarked marker s
|
||||||
|
|
||||||
boot :: [Property] -> IO ()
|
boot :: [Property] -> IO ()
|
||||||
boot props = do
|
boot props = do
|
||||||
havering <- doesFileExist keyring
|
putStrLn $ toMarked statusMarker $ show Ready
|
||||||
putStrLn $ toMarked statusMarker $ show $ if havering then HaveKeyRing else NeedKeyRing
|
|
||||||
hFlush stdout
|
hFlush stdout
|
||||||
reply <- hGetContentsStrict stdin
|
reply <- hGetContentsStrict stdin
|
||||||
|
|
||||||
makePrivDataDir
|
makePrivDataDir
|
||||||
maybe noop (writeFileProtected privDataLocal) $
|
maybe noop (writeFileProtected privDataLocal) $
|
||||||
fromMarked privDataMarker reply
|
fromMarked privDataMarker reply
|
||||||
case eitherToMaybe . B64.decode . BL.pack . s2w8 =<< fromMarked keyringMarker reply of
|
|
||||||
Nothing -> noop
|
|
||||||
Just d -> do
|
|
||||||
writeFileProtected keyring ""
|
|
||||||
BL.writeFile keyring d
|
|
||||||
ensureProperties props
|
ensureProperties props
|
||||||
|
|
||||||
addKey :: String -> IO ()
|
addKey :: String -> IO ()
|
||||||
|
|
6
README
6
README
|
@ -54,7 +54,7 @@ for available fields.
|
||||||
|
|
||||||
It's often easiest for a remote host to use a git:// or http://
|
It's often easiest for a remote host to use a git:// or http://
|
||||||
url to its origin repository, rather than ssh://. So, to avoid a MITM
|
url to its origin repository, rather than ssh://. So, to avoid a MITM
|
||||||
attack, propellor checks that the top commit in the git repository is gpg
|
attack, propellor checks that any commit it fetched from origin is gpg
|
||||||
signed by a trusted gpg key, and refuses to deploy it otherwise.
|
signed by a trusted gpg key, and refuses to deploy it otherwise.
|
||||||
|
|
||||||
This is only done when privdata/keyring.gpg exists. To set it up:
|
This is only done when privdata/keyring.gpg exists. To set it up:
|
||||||
|
@ -62,8 +62,4 @@ This is only done when privdata/keyring.gpg exists. To set it up:
|
||||||
gpg --gen-key # only if you don't already have a gpg key
|
gpg --gen-key # only if you don't already have a gpg key
|
||||||
propellor --add-key $MYKEYID
|
propellor --add-key $MYKEYID
|
||||||
|
|
||||||
The keyring.gpg can be checked into git, but to ensure that it's
|
|
||||||
used from the beginning when bootstrapping, propellor --spin
|
|
||||||
transfers it to the host using ssh.
|
|
||||||
|
|
||||||
[1] http://reclass.pantsfullofunix.net/
|
[1] http://reclass.pantsfullofunix.net/
|
||||||
|
|
|
@ -26,7 +26,6 @@ Description:
|
||||||
Executable propellor
|
Executable propellor
|
||||||
Main-Is: config.hs
|
Main-Is: config.hs
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
Extensions: PackageImports
|
|
||||||
Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
|
Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
|
||||||
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
|
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
|
||||||
containers, base64-bytestring
|
containers, base64-bytestring
|
||||||
|
@ -36,7 +35,6 @@ Executable propellor
|
||||||
|
|
||||||
Library
|
Library
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
Extensions: PackageImports
|
|
||||||
Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
|
Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5,
|
||||||
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
|
IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal,
|
||||||
containers, dataenc
|
containers, dataenc
|
||||||
|
|
Loading…
Reference in New Issue