From ab0247b4dc0b968a68bbb75c97d5fe022cca427a Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Wed, 12 Aug 2015 22:00:43 +0000 Subject: [PATCH] race condition on keydelete --- models/publickey.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/publickey.go b/models/publickey.go index 70da8057..3ef84b9c 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -386,8 +386,6 @@ func ListPublicKeys(uid int64) ([]*PublicKey, error) { // rewriteAuthorizedKeys finds and deletes corresponding line in authorized_keys file. func rewriteAuthorizedKeys(key *PublicKey, p, tmpP string) error { - sshOpLocker.Lock() - defer sshOpLocker.Unlock() fr, err := os.Open(p) if err != nil { @@ -444,6 +442,9 @@ func UpdatePublicKey(key *PublicKey) error { } func deletePublicKey(e *xorm.Session, key *PublicKey) error { + sshOpLocker.Lock() + defer sshOpLocker.Unlock() + has, err := e.Get(key) if err != nil { return err