1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-15 14:44:41 +00:00

Mirror fix on public key

This commit is contained in:
Unknown 2014-04-27 17:01:39 -04:00
parent 62240b6bc1
commit 41b0a7b97c
2 changed files with 9 additions and 8 deletions

View File

@ -77,12 +77,12 @@ func init() {
// PublicKey represents a SSH key of user. // PublicKey represents a SSH key of user.
type PublicKey struct { type PublicKey struct {
Id int64 Id int64
OwnerId int64 `xorm:"unique(s) index not null"` OwnerId int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"unique(s) not null"` Name string `xorm:"UNIQUE(s) NOT NULL"`
Fingerprint string Fingerprint string
Content string `xorm:"TEXT not null"` Content string `xorm:"TEXT NOT NULL"`
Created time.Time `xorm:"created"` Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"updated"` Updated time.Time `xorm:"UPDATED"`
} }
// GenAuthorizedKey returns formatted public key string. // GenAuthorizedKey returns formatted public key string.
@ -107,9 +107,9 @@ func AddPublicKey(key *PublicKey) (err error) {
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), os.ModePerm); err != nil { if err = ioutil.WriteFile(tmpPath, []byte(key.Content), os.ModePerm); err != nil {
return err return err
} }
stdout, _, err := com.ExecCmd("ssh-keygen", "-l", "-f", tmpPath) stdout, stderr, err := com.ExecCmd("ssh-keygen", "-l", "-f", tmpPath)
if err != nil { if err != nil {
return err return errors.New("ssh-keygen -l -f: " + stderr)
} else if len(stdout) < 2 { } else if len(stdout) < 2 {
return errors.New("Not enough output for calculating fingerprint") return errors.New("Not enough output for calculating fingerprint")
} }

View File

@ -166,7 +166,8 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
return return
} }
k := &models.PublicKey{OwnerId: ctx.User.Id, k := &models.PublicKey{
OwnerId: ctx.User.Id,
Name: form.KeyName, Name: form.KeyName,
Content: form.KeyContent, Content: form.KeyContent,
} }