diff options
author | lunnyxiao <xiaolunwen@gmail.com> | 2014-09-17 12:04:18 +0800 |
---|---|---|
committer | lunnyxiao <xiaolunwen@gmail.com> | 2014-09-17 12:04:18 +0800 |
commit | 061a879cea39a1cce56dcb394b912fad50d7b77a (patch) | |
tree | 26e8c3d25da1b9d785421a6a02b7564798b2e8c4 /models | |
parent | ed84adb679f3de70b2bffaead20a87711c38ee3a (diff) | |
parent | 9f015b4c73806e65d3ca085b76723dc8cf41eb02 (diff) | |
download | gitea-061a879cea39a1cce56dcb394b912fad50d7b77a.tar.gz gitea-061a879cea39a1cce56dcb394b912fad50d7b77a.zip |
Merge branch 'dev' of github.com:gogits/gogs into dev
Conflicts:
conf/app.ini
Diffstat (limited to 'models')
-rw-r--r-- | models/publickey.go | 24 | ||||
-rw-r--r-- | models/repo.go | 9 |
2 files changed, 25 insertions, 8 deletions
diff --git a/models/publickey.go b/models/publickey.go index 1246cffc58..1824e88701 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -22,6 +22,7 @@ import ( "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/process" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -119,23 +120,30 @@ func CheckPublicKeyString(content string) (bool, error) { tmpFile.WriteString(content) tmpFile.Close() - // … see if ssh-keygen recognizes its contents + // Check if ssh-keygen recognizes its contents. stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-l", "-f", tmpPath) if err != nil { return false, errors.New("ssh-keygen -l -f: " + stderr) } else if len(stdout) < 2 { return false, errors.New("ssh-keygen returned not enough output to evaluate the key") } + + // The ssh-keygen in Windows does not print key type, so no need go further. + if setting.IsWindows { + return true, nil + } + sshKeygenOutput := strings.Split(stdout, " ") if len(sshKeygenOutput) < 4 { return false, errors.New("Not enough fields returned by ssh-keygen -l -f") } + + // Check if key type and key size match. keySize, err := com.StrTo(sshKeygenOutput[0]).Int() if err != nil { return false, errors.New("Cannot get key size of the given key") } keyType := strings.TrimSpace(sshKeygenOutput[len(sshKeygenOutput)-1]) - if minimumKeySize := MinimumKeySize[keyType]; minimumKeySize == 0 { return false, errors.New("Sorry, unrecognized public key type") } else if keySize < minimumKeySize { @@ -160,10 +168,14 @@ func saveAuthorizedKeyFile(key *PublicKey) error { if err != nil { return err } - if finfo.Mode().Perm() > 0600 { - log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String()) - if err = f.Chmod(0600); err != nil { - return err + + // FIXME: following command does not support in Windows. + if !setting.IsWindows { + if finfo.Mode().Perm() > 0600 { + log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String()) + if err = f.Chmod(0600); err != nil { + return err + } } } diff --git a/models/repo.go b/models/repo.go index 25876872eb..2e16270431 100644 --- a/models/repo.go +++ b/models/repo.go @@ -95,8 +95,13 @@ func NewRepoContext() { if err != nil { log.Fatal(4, "Fail to get Git version: %v", err) } - if ver.Major < 2 && ver.Minor < 8 { - log.Fatal(4, "Gogs requires Git version greater or equal to 1.8.0") + + reqVer, err := git.ParseVersion("1.7.1") + if err != nil { + log.Fatal(4, "Fail to parse required Git version: %v", err) + } + if ver.LessThan(reqVer) { + log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1") } // Check if server has basic git setting and set if not. |