summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Bowman <don.waterloo@gmail.com>2015-08-12 22:00:43 +0000
committerDon Bowman <don.waterloo@gmail.com>2015-08-12 22:00:43 +0000
commitab0247b4dc0b968a68bbb75c97d5fe022cca427a (patch)
tree58638f7f200f6b128de20abb63ba75477016832b
parent1cb46ede1acf4f8527e64fcae7e92672cad764b2 (diff)
downloadgitea-ab0247b4dc0b968a68bbb75c97d5fe022cca427a.tar.gz
gitea-ab0247b4dc0b968a68bbb75c97d5fe022cca427a.zip
race condition on keydelete
-rw-r--r--models/publickey.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/models/publickey.go b/models/publickey.go
index 70da8057ce..3ef84b9c70 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