Skip to content

Commit c2fd9da

Browse files
PnkcahtMarkEWaitekrissternCopilot
authored
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>
1 parent bcbe631 commit c2fd9da

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,14 @@ private String getErrorMessages(SignupInfo si) {
363363
* This can be run by anyone, but only to create the very first user account.
364364
*/
365365
@RequirePOST
366-
public void doCreateFirstAccount(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
366+
public synchronized void doCreateFirstAccount(StaplerRequest2 req, StaplerResponse2 rsp)
367+
throws IOException, ServletException {
368+
367369
if (hasSomeUser()) {
368370
rsp.sendError(SC_UNAUTHORIZED, "First user was already created");
369371
return;
370372
}
373+
371374
User u = createAccount(req, rsp, false, "firstUser.jelly");
372375
if (u != null) {
373376
tryToMakeAdmin(u);

0 commit comments

Comments
 (0)