Browse Source

models/ssh_key: fix SSH_KEYGEN_PATH not working (#3770)

pull/4109/head
Unknwon 8 years ago
parent
commit
9b8fa69c15
No known key found for this signature in database
GPG Key ID: FB9F411CDD69BEC1
  1. 5
      models/ssh_key.go
  2. 4
      routers/repo/setting.go

5
models/ssh_key.go

@ -385,9 +385,10 @@ func addKey(e Engine, key *PublicKey) (err error) {
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil { if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
return err return err
} }
stdout, stderr, err := process.Exec("AddPublicKey", "ssh-keygen", "-lf", tmpPath)
stdout, stderr, err := process.Exec("AddPublicKey", setting.SSH.KeygenPath, "-lf", tmpPath)
if err != nil { if err != nil {
return fmt.Errorf("'ssh-keygen -lf %s' failed with error '%s': %s", tmpPath, err, stderr) return fmt.Errorf("fail to parse public key: %s - %s", err, stderr)
} else if len(stdout) < 2 { } else if len(stdout) < 2 {
return errors.New("not enough output for calculating fingerprint: " + stdout) return errors.New("not enough output for calculating fingerprint: " + stdout)
} }

4
routers/repo/setting.go

@ -378,7 +378,7 @@ func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository)
owner, err := models.GetUserByName(ctx.Params(":username")) owner, err := models.GetUserByName(ctx.Params(":username"))
if err != nil { if err != nil {
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
ctx.Handle(404, "GetUserByName", err) ctx.Handle(404, "GetUserByName", nil)
} else { } else {
ctx.Handle(500, "GetUserByName", err) ctx.Handle(500, "GetUserByName", err)
} }
@ -388,7 +388,7 @@ func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository)
repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame")) repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame"))
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Handle(404, "GetRepositoryByName", err) ctx.Handle(404, "GetRepositoryByName", nil)
} else { } else {
ctx.Handle(500, "GetRepositoryByName", err) ctx.Handle(500, "GetRepositoryByName", err)
} }

Loading…
Cancel
Save