Skip to content

Commit

Permalink
JENKINS-33800 - fileNotFound exception if jenkins 1 installed, security
Browse files Browse the repository at this point in the history
settings saved but global config is not - show normal login in this case
  • Loading branch information
kzantow committed Mar 29, 2016
1 parent 6219c8f commit da3bb81
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
48 changes: 31 additions & 17 deletions core/src/main/java/jenkins/install/SetupWizard.java
Expand Up @@ -107,30 +107,44 @@ public SetupWizard(Jenkins j) throws IOException, InterruptedException {
}
}

String setupKey = iapf.readToString().trim();
String ls = System.lineSeparator();
LOGGER.info(ls + ls + "*************************************************************" + ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls
+ ls
+ "Jenkins initial setup is required. An admin user has been created and "
+ "a password generated." + ls
+ "Please use the following password to proceed to installation:" + ls
+ ls
+ setupKey + ls
+ ls
+ "This may also be found at: " + iapf.getRemote() + ls
+ ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls);
if(iapf.exists()) {
String setupKey = iapf.readToString().trim();
String ls = System.lineSeparator();
LOGGER.info(ls + ls + "*************************************************************" + ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls
+ ls
+ "Jenkins initial setup is required. An admin user has been created and "
+ "a password generated." + ls
+ "Please use the following password to proceed to installation:" + ls
+ ls
+ setupKey + ls
+ ls
+ "This may also be found at: " + iapf.getRemote() + ls
+ ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls
+ "*************************************************************" + ls);
}

try {
PluginServletFilter.addFilter(FORCE_SETUP_WIZARD_FILTER);
} catch (ServletException e) {
throw new AssertionError(e);
}
}

/**
* Indicates a generated password should be used - e.g. this is a new install, no security realm set up
*/
public boolean useGeneratedPassword() {
try {
return getInitialAdminPasswordFile().exists();
} catch (Exception e) {
// ignore
}
return false;
}

/**
* Gets the file used to store the initial admin password
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/resources/jenkins/model/Jenkins/login.jelly
Expand Up @@ -24,10 +24,11 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:if test="${it.setupWizard != null}">
<j:choose>
<j:when test="${it.setupWizard.useGeneratedPassword()}">
<st:include it="${it.setupWizard}" page="authenticate-security-token"/>
</j:if>
<j:if test="${it.setupWizard == null}">
</j:when>
<j:otherwise>
<l:layout norefresh="true">
<l:hasPermission permission="${app.READ}">
<st:include page="sidepanel.jelly" />
Expand Down Expand Up @@ -74,5 +75,6 @@ THE SOFTWARE.
</div>
</l:main-panel>
</l:layout>
</j:if>
</j:otherwise>
</j:choose>
</j:jelly>

0 comments on commit da3bb81

Please sign in to comment.