review feedback

Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
This commit is contained in:
Nathan McCauley 2015-07-20 10:55:52 -07:00
parent 75ae5b65df
commit 6b23e7d249
3 changed files with 8 additions and 14 deletions

View File

@ -2,7 +2,6 @@ package main
import (
"bufio"
"bytes"
"crypto/sha256"
"crypto/tls"
"errors"
@ -17,6 +16,7 @@ import (
"github.com/docker/notary/trustmanager"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"strings"
)
// FIXME: This should not be hardcoded
@ -314,10 +314,10 @@ func getNotaryPassphraseRetriever() trustmanager.PassphraseRetriever {
if err != nil {
return "", false, err
}
passphrase = passphrase[0 : len(passphrase)-1]
retPass := strings.TrimSpace(string(passphrase))
if !createNew {
retPass := string(passphrase)
if alias == "snapshot" || alias == "targets" {
userEnteredTargetsSnapshotsPass = true
targetsSnapshotsPass = retPass
@ -326,10 +326,10 @@ func getNotaryPassphraseRetriever() trustmanager.PassphraseRetriever {
userEnteredRootsPass = true
rootsPass = retPass
}
return string(passphrase), false, nil
return retPass, false, nil
}
if len(passphrase) < 8 {
if len(retPass) < 8 {
fmt.Println("Please use a password manager to generate and store a good random passphrase.")
return "", false, errors.New("Passphrase too short")
}
@ -340,12 +340,11 @@ func getNotaryPassphraseRetriever() trustmanager.PassphraseRetriever {
if err != nil {
return "", false, err
}
confirmation = confirmation[0 : len(confirmation)-1]
confirmationStr := strings.TrimSpace(string(confirmation))
if !bytes.Equal(passphrase, confirmation) {
if retPass != confirmationStr {
return "", false, errors.New("The entered passphrases do not match")
}
retPass := string(passphrase)
if alias == "snapshot" || alias == "targets" {
userEnteredTargetsSnapshotsPass = true

View File

@ -24,10 +24,6 @@ var (
// unencrypted
ErrRootKeyNotEncrypted = errors.New("only encrypted root keys may be imported")
// ErrNonRootKeyEncrypted is returned if a non-root key is found to
// be encrypted while exporting
ErrNonRootKeyEncrypted = errors.New("found encrypted non-root key")
// ErrNoKeysFoundForGUN is returned if no keys are found for the
// specified GUN during export
ErrNoKeysFoundForGUN = errors.New("no keys found for specified GUN")

View File

@ -153,8 +153,7 @@ func getKeyAlias(s LimitedFileStore, keyID string) (string, error) {
name := strings.TrimSpace(strings.TrimSuffix(filepath.Base(keyID), filepath.Ext(keyID)))
for _, file := range files {
lastPathSeparator := strings.LastIndexAny(file, "/\\")
filename := file[lastPathSeparator+1:]
filename := filepath.Base(file)
if strings.HasPrefix(filename, name) {
aliasPlusDotKey := strings.TrimPrefix(filename, name+"_")