add publickey list

This commit is contained in:
Lunny Xiao 2014-03-07 11:34:41 +08:00
parent e246f2188e
commit 8e821c75d7
6 changed files with 45 additions and 6 deletions

View file

@ -77,6 +77,12 @@ func AddPublicKey(key *PublicKey) error {
return nil
}
func ListPublicKey(userId int64) ([]PublicKey, error) {
keys := make([]PublicKey, 0)
err := orm.Find(&keys, &PublicKey{OwnerId: userId})
return keys, err
}
func SaveAuthorizedKeyFile(key *PublicKey) error {
p := filepath.Join(sshPath, "authorized_keys")
f, err := os.OpenFile(p, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)