Browse Source

models: rename RewriteAllPublicKeys -> RewriteAuthorizedKeys

pull/4985/merge
Unknwon 7 years ago
parent
commit
a855abf8c0
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 8
      cmd/admin.go
  2. 8
      models/ssh_key.go
  3. 2
      models/user.go
  4. 2
      routes/admin/admin.go

8
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{

8
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"

2
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.

2
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()

Loading…
Cancel
Save