Skip to content

Commit

Permalink
Pause summarizer prior to prompting for password
Browse files Browse the repository at this point in the history
Also, make password protected ssh key support opt-out, rather than
opt-in.

Resolves #578
  • Loading branch information
glinton committed Sep 15, 2017
1 parent 5e695d1 commit 53425f4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
10 changes: 8 additions & 2 deletions generators/hooks/build/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

// UserPayload returns a string for the user hook payload
func UserPayload() string {

configModel, _ := models.LoadConfig()
payload := map[string]interface{}{
"provider": configModel.Provider,
Expand Down Expand Up @@ -102,7 +101,14 @@ func getKey(keyFile string) ([]byte, error) {
buf := block.Bytes

if encryptedBlock(block) {
if x509.IsEncryptedPEMBlock(block) && configModel.SshEncryptedKeys {
if x509.IsEncryptedPEMBlock(block) {
if configModel.NoEncryptedKeys {
return nil, fmt.Errorf("Skipping encrypted ssh key")
}

display.PauseTask()
defer display.ResumeTask()

// prompt for password to decrypt key
fmt.Printf("Password protected key found!\nPlease enter the password for '%s'\n", keyFile)
for attempts := 0; attempts < 3; attempts++ {
Expand Down
4 changes: 2 additions & 2 deletions models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type Config struct {
DockerMachineNetworkSpace string `json:"docker-machine-network-space"`
NativeNetworkSpace string `json:"native-network-space"`

SshKey string `json:"ssh-key"`
SshEncryptedKeys bool `json:"ssh-encrypted-keys"`
SshKey string `json:"ssh-key"`
NoEncryptedKeys bool `json:"no-encrypted-keys"`

Anonymous bool `json:"anonymous"`
LockPort int `json:"lock-port"`
Expand Down
4 changes: 2 additions & 2 deletions processors/configure_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func ConfigureSet(key, val string) error {
config.NativeNetworkSpace = val
case "ssh_key", "ssh-key":
config.SshKey = val
case "ssh_encrypted_keys", "ssh-encrypted-keys":
config.SshEncryptedKeys = val == "true" || val == "t" || val == "1"
case "no_encrypted_keys", "no-encrypted-keys":
config.NoEncryptedKeys = val == "true" || val == "t" || val == "1"
case "lock_port", "lock-port":
config.LockPort, _ = strconv.Atoi(val)
case "ci-mode", "ci_mode":
Expand Down
8 changes: 6 additions & 2 deletions util/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func StartTask(format string, args ...interface{}) error {
return nil
}

// PauseTask ...
// PauseTask pauses the summarizer so you can print to stdout.
func PauseTask() {
// stop the task summarizer
if Summary && summarizer != nil {
Expand All @@ -151,7 +151,11 @@ func PauseTask() {
}
}

// ResumeTask ...
// todo: make a quiet pause/resume task. just disable the "summarizer" and don't
// print junk on resume. maybe just delete the previous line `* Paused Task` so
// it will be overwritten with the `⣷ Resumed Task` header.

// ResumeTask resumes the summarizer, so output is swallowed unless `-v` is passed.
func ResumeTask() {
// resume task
if Summary && summarizer != nil {
Expand Down

0 comments on commit 53425f4

Please sign in to comment.