summaryrefslogtreecommitdiffstats
path: root/models/publickey.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-02 18:54:47 -0500
committerUnknwon <u@gogs.io>2015-11-02 18:54:47 -0500
commit8eb4c3121abb890a176de895093e8bab6e113a9d (patch)
tree578af5e8073495bf3d7fb9d63d273b5b6ccae172 /models/publickey.go
parent75aab86a8dcc008f7da5fa76e4637c1839263fc2 (diff)
downloadgitea-8eb4c3121abb890a176de895093e8bab6e113a9d.tar.gz
gitea-8eb4c3121abb890a176de895093e8bab6e113a9d.zip
work on #1880
Diffstat (limited to 'models/publickey.go')
-rw-r--r--models/publickey.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/models/publickey.go b/models/publickey.go
index 68e078ac85..59a9f13ea3 100644
--- a/models/publickey.go
+++ b/models/publickey.go
@@ -218,9 +218,9 @@ func CheckPublicKeyString(content string) (_ string, err error) {
tmpFile.Close()
// Check if ssh-keygen recognizes its contents.
- stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-l", "-f", tmpPath)
+ stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-lf", tmpPath)
if err != nil {
- return "", errors.New("ssh-keygen -l -f: " + stderr)
+ return "", errors.New("ssh-keygen -lf: " + stderr)
} else if len(stdout) < 2 {
return "", errors.New("ssh-keygen returned not enough output to evaluate the key: " + stdout)
}
@@ -241,7 +241,8 @@ func CheckPublicKeyString(content string) (_ string, err error) {
if keySize == 0 {
return "", errors.New("cannot get key size of the given key")
}
- keyType := strings.Trim(sshKeygenOutput[len(sshKeygenOutput)-1], " ()")
+
+ keyType := strings.Trim(sshKeygenOutput[len(sshKeygenOutput)-1], " ()\n")
if minimumKeySize := setting.Service.MinimumKeySizes[keyType]; minimumKeySize == 0 {
return "", fmt.Errorf("unrecognized public key type: %s", keyType)
} else if keySize < minimumKeySize {
@@ -311,9 +312,9 @@ func addKey(e Engine, key *PublicKey) (err error) {
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
return err
}
- stdout, stderr, err := process.Exec("AddPublicKey", "ssh-keygen", "-l", "-f", tmpPath)
+ stdout, stderr, err := process.Exec("AddPublicKey", "ssh-keygen", "-lf", tmpPath)
if err != nil {
- return errors.New("ssh-keygen -l -f: " + stderr)
+ return errors.New("ssh-keygen -lf: " + stderr)
} else if len(stdout) < 2 {
return errors.New("not enough output for calculating fingerprint: " + stdout)
}