diff options
author | Unknwon <u@gogs.io> | 2018-03-30 01:26:36 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2018-03-30 01:26:36 -0400 |
commit | a855abf8c0de73fb3a9913000e1eb8d8ea9840ff (patch) | |
tree | cdf3bf423ad2104c1406cd9acb67d86511584e09 | |
parent | 0d2398aaff7f887adf79e8c40f4ad4584036e7f5 (diff) |
models: rename RewriteAllPublicKeys -> RewriteAuthorizedKeys
-rw-r--r-- | cmd/admin.go | 8 | ||||
-rw-r--r-- | models/ssh_key.go | 8 | ||||
-rw-r--r-- | models/user.go | 2 | ||||
-rw-r--r-- | routes/admin/admin.go | 2 |
4 files changed, 11 insertions, 9 deletions
diff --git a/cmd/admin.go b/cmd/admin.go index e9078caf..52c4496d 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -27,7 +27,7 @@ to make automatic initialization process more smoothly`, subcmdDeleteRepositoryArchives, subcmdDeleteMissingRepositories, subcmdGitGcRepos, - subcmdRewriteAllPublicKeys, + subcmdRewriteAuthorizedKeys, subcmdSyncRepositoryHooks, subcmdReinitMissingRepositories, }, @@ -94,11 +94,11 @@ to make automatic initialization process more smoothly`, }, } - subcmdRewriteAllPublicKeys = cli.Command{ - Name: "rewrite-public-keys", + subcmdRewriteAuthorizedKeys = cli.Command{ + Name: "rewrite-authorized-keys", Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)", Action: adminDashboardOperation( - models.RewriteAllPublicKeys, + models.RewriteAuthorizedKeys, "All public keys have been rewritten successfully", ), Flags: []cli.Flag{ diff --git a/models/ssh_key.go b/models/ssh_key.go index 6c35b70a..350c5f75 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -512,16 +512,18 @@ func DeletePublicKey(doer *User, id int64) (err error) { return err } - return RewriteAllPublicKeys() + return RewriteAuthorizedKeys() } -// RewriteAllPublicKeys removes any authorized key and rewrite all keys from database again. +// RewriteAuthorizedKeys removes any authorized key and rewrite all keys from database again. // Note: x.Iterate does not get latest data after insert/delete, so we have to call this function // outsite any session scope independently. -func RewriteAllPublicKeys() error { +func RewriteAuthorizedKeys() error { sshOpLocker.Lock() defer sshOpLocker.Unlock() + log.Trace("Doing: RewriteAuthorizedKeys") + os.MkdirAll(setting.SSH.RootPath, os.ModePerm) fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys") tmpPath := fpath + ".tmp" diff --git a/models/user.go b/models/user.go index 4b97e911..831ba3f4 100644 --- a/models/user.go +++ b/models/user.go @@ -853,7 +853,7 @@ func DeleteUser(u *User) (err error) { return err } - return RewriteAllPublicKeys() + return RewriteAuthorizedKeys() } // DeleteInactivateUsers deletes all inactivate users and email addresses. diff --git a/routes/admin/admin.go b/routes/admin/admin.go index 2ef83523..e3ac5bdf 100644 --- a/routes/admin/admin.go +++ b/routes/admin/admin.go @@ -151,7 +151,7 @@ func Dashboard(c *context.Context) { err = models.GitGcRepos() case SYNC_SSH_AUTHORIZED_KEY: success = c.Tr("admin.dashboard.resync_all_sshkeys_success") - err = models.RewriteAllPublicKeys() + err = models.RewriteAuthorizedKeys() case SYNC_REPOSITORY_HOOKS: success = c.Tr("admin.dashboard.resync_all_hooks_success") err = models.SyncRepositoryHooks() |