mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-26 19:15:09 +00:00
Fix race condition during initial admin account creation (#26036)
* Update README.md * Update README.md * Update README.md * Remove link to non-existent newsletter Also format with `yarn lint:fix` as noted in the contributing guide. * Update README.md * Update good first issues query * Fix race condition during initial admin account creation * Update core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Use synchronized method for initial admin account creation --------- Co-authored-by: Mark Waite <mark.earl.waite@gmail.com> Co-authored-by: Kris Stern <krisstern@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
1 file changed
+4
-1
@@ -363,11 +363,14 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
|
||||
* This can be run by anyone, but only to create the very first user account.
|
||||
*/
|
||||
@RequirePOST
|
||||
public void doCreateFirstAccount(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
|
||||
public synchronized void doCreateFirstAccount(StaplerRequest2 req, StaplerResponse2 rsp)
|
||||
throws IOException, ServletException {
|
||||
|
||||
if (hasSomeUser()) {
|
||||
rsp.sendError(SC_UNAUTHORIZED, "First user was already created");
|
||||
return;
|
||||
}
|
||||
|
||||
User u = createAccount(req, rsp, false, "firstUser.jelly");
|
||||
if (u != null) {
|
||||
tryToMakeAdmin(u);
|
||||
|
||||
Reference in new issue
Block a user