diff options
author | Bwko <bouwko@gmail.com> | 2016-12-01 00:56:15 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-02 07:41:19 +0100 |
commit | 4ff0db0246fa8a2add1032220024975203b93d72 (patch) | |
tree | 6395dd608ba47cc6429bc12d9595f09ebb915f02 /modules/ssh | |
parent | 5ab85372da74bd95f7143fd59c2c600d4c9894d0 (diff) | |
download | gitea-4ff0db0246fa8a2add1032220024975203b93d72.tar.gz gitea-4ff0db0246fa8a2add1032220024975203b93d72.zip |
Catch os... errors
Diffstat (limited to 'modules/ssh')
-rw-r--r-- | modules/ssh/ssh.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 0781073f59..b35973cc32 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -162,7 +162,12 @@ func Listen(port int) { keyPath := filepath.Join(setting.AppDataPath, "ssh/gogs.rsa") if !com.IsExist(keyPath) { - os.MkdirAll(filepath.Dir(keyPath), os.ModePerm) + filePath := filepath.Dir(keyPath) + + if err := os.MkdirAll(filePath, os.ModePerm); err != nil { + log.Error(4, "Fail to create dir %s: %v", filePath, err) + } + _, stderr, err := com.ExecCmd("ssh-keygen", "-f", keyPath, "-t", "rsa", "-N", "") if err != nil { panic(fmt.Sprintf("Fail to generate private key: %v - %s", err, stderr)) |