diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-02-25 18:30:48 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-02-25 18:30:48 +0800 |
commit | 52984f85d5afc2a74bb3ca04487da7fb277437d6 (patch) | |
tree | be3843f3270c679a01432b86f36b7887d1906398 /models | |
parent | d42c194aadd349ebb2e87d64d764a370fb3f54dc (diff) | |
download | gitea-52984f85d5afc2a74bb3ca04487da7fb277437d6.tar.gz gitea-52984f85d5afc2a74bb3ca04487da7fb277437d6.zip |
add publickey
Diffstat (limited to 'models')
-rw-r--r-- | models/publickey.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/models/publickey.go b/models/publickey.go index 1e58ba0574..2fd1895d6c 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -47,7 +47,7 @@ func GenAuthorizedKey(keyId int64, key string) string { return fmt.Sprintf(tmplPublicKey, appPath, keyId, key) } -func AddPublicKey(key *PublicKey, user string) error { +func AddPublicKey(key *PublicKey) error { _, err := orm.Insert(key) if err != nil { return err @@ -67,11 +67,11 @@ func AddPublicKey(key *PublicKey, user string) error { func SaveAuthorizedKeyFile(key *PublicKey) error { p := filepath.Join(sshPath, "authorized_keys") - f, err := os.Create(p) + f, err := os.OpenFile(p, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) if err != nil { return err } - os.Chmod(p, 0600) + //os.Chmod(p, 0600) _, err = f.WriteString(GenAuthorizedKey(key.Id, key.Content)) return err } |