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, subcmdDeleteRepositoryArchives,
subcmdDeleteMissingRepositories, subcmdDeleteMissingRepositories,
subcmdGitGcRepos, subcmdGitGcRepos,
subcmdRewriteAllPublicKeys, subcmdRewriteAuthorizedKeys,
subcmdSyncRepositoryHooks, subcmdSyncRepositoryHooks,
subcmdReinitMissingRepositories, subcmdReinitMissingRepositories,
}, },
@ -94,11 +94,11 @@ to make automatic initialization process more smoothly`,
}, },
} }
subcmdRewriteAllPublicKeys = cli.Command{ subcmdRewriteAuthorizedKeys = cli.Command{
Name: "rewrite-public-keys", Name: "rewrite-authorized-keys",
Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)", Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)",
Action: adminDashboardOperation( Action: adminDashboardOperation(
models.RewriteAllPublicKeys, models.RewriteAuthorizedKeys,
"All public keys have been rewritten successfully", "All public keys have been rewritten successfully",
), ),
Flags: []cli.Flag{ Flags: []cli.Flag{

8
models/ssh_key.go

@ -512,16 +512,18 @@ func DeletePublicKey(doer *User, id int64) (err error) {
return err 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 // Note: x.Iterate does not get latest data after insert/delete, so we have to call this function
// outsite any session scope independently. // outsite any session scope independently.
func RewriteAllPublicKeys() error { func RewriteAuthorizedKeys() error {
sshOpLocker.Lock() sshOpLocker.Lock()
defer sshOpLocker.Unlock() defer sshOpLocker.Unlock()
log.Trace("Doing: RewriteAuthorizedKeys")
os.MkdirAll(setting.SSH.RootPath, os.ModePerm) os.MkdirAll(setting.SSH.RootPath, os.ModePerm)
fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys") fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
tmpPath := fpath + ".tmp" tmpPath := fpath + ".tmp"

2
models/user.go

@ -853,7 +853,7 @@ func DeleteUser(u *User) (err error) {
return err return err
} }
return RewriteAllPublicKeys() return RewriteAuthorizedKeys()
} }
// DeleteInactivateUsers deletes all inactivate users and email addresses. // 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() err = models.GitGcRepos()
case SYNC_SSH_AUTHORIZED_KEY: case SYNC_SSH_AUTHORIZED_KEY:
success = c.Tr("admin.dashboard.resync_all_sshkeys_success") success = c.Tr("admin.dashboard.resync_all_sshkeys_success")
err = models.RewriteAllPublicKeys() err = models.RewriteAuthorizedKeys()
case SYNC_REPOSITORY_HOOKS: case SYNC_REPOSITORY_HOOKS:
success = c.Tr("admin.dashboard.resync_all_hooks_success") success = c.Tr("admin.dashboard.resync_all_hooks_success")
err = models.SyncRepositoryHooks() err = models.SyncRepositoryHooks()

Loading…
Cancel
Save