mirror of https://github.com/gogs/gogs.git
models: rename RewriteAllPublicKeys -> RewriteAuthorizedKeys
parent
0d2398aaff
commit
a855abf8c0
|
@ -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{
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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…
Reference in New Issue