You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by ka...@apache.org on 2023/03/12 11:50:50 UTC
[james-project] 02/07: JAMES-3881 Ignore error generating JMX password
This is an automated email from the ASF dual-hosted git repository.
kao pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c8ea7c484d5d88f79dc3e2d66ac2bc1d534fe24e
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Feb 15 21:58:38 2023 +0700
JAMES-3881 Ignore error generating JMX password
Log a warning
(cherry picked from commit a08b34c7971d90824fd174b8c91d54921a62f312)
---
.../org/apache/james/modules/server/JMXServer.java | 40 ++++++++++++----------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
index badd87f9b3..6aa801314a 100644
--- a/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
+++ b/server/container/guice/jmx/src/main/java/org/apache/james/modules/server/JMXServer.java
@@ -166,27 +166,31 @@ public class JMXServer implements Startable {
}
private void generateJMXPasswordFile() {
- File passwordFile = new File(jmxPasswordFilePath);
- if (!passwordFile.exists()) {
- try (OutputStream outputStream = new FileOutputStream(passwordFile)) {
- String randomPassword = RandomStringUtils.random(10, true, true);
- IOUtils.write(JmxConfiguration.JAMES_ADMIN_USER_DEFAULT + " " + randomPassword + "\n", outputStream, StandardCharsets.UTF_8);
- setPermissionOwnerOnly(passwordFile);
- LOGGER.info("Generated JMX password file: " + passwordFile.getPath());
- } catch (IOException e) {
- throw new RuntimeException("Error when creating JMX password file: " + passwordFile.getPath(), e);
+ try {
+ File passwordFile = new File(jmxPasswordFilePath);
+ if (!passwordFile.exists()) {
+ try (OutputStream outputStream = new FileOutputStream(passwordFile)) {
+ String randomPassword = RandomStringUtils.random(10, true, true);
+ IOUtils.write(JmxConfiguration.JAMES_ADMIN_USER_DEFAULT + " " + randomPassword + "\n", outputStream, StandardCharsets.UTF_8);
+ setPermissionOwnerOnly(passwordFile);
+ LOGGER.info("Generated JMX password file: " + passwordFile.getPath());
+ } catch (IOException e) {
+ throw new RuntimeException("Error when creating JMX password file: " + passwordFile.getPath(), e);
+ }
}
- }
- File accessFile = new File(jmxAccessFilePath);
- if (!accessFile.exists()) {
- try (OutputStream outputStream = new FileOutputStream(accessFile)) {
- IOUtils.write(JmxConfiguration.JAMES_ADMIN_USER_DEFAULT + " readwrite\n", outputStream, StandardCharsets.UTF_8);
- setPermissionOwnerOnly(accessFile);
- LOGGER.info("Generated JMX access file: " + accessFile.getPath());
- } catch (IOException e) {
- throw new RuntimeException("Error when creating JMX access file: " + accessFile.getPath(), e);
+ File accessFile = new File(jmxAccessFilePath);
+ if (!accessFile.exists()) {
+ try (OutputStream outputStream = new FileOutputStream(accessFile)) {
+ IOUtils.write(JmxConfiguration.JAMES_ADMIN_USER_DEFAULT + " readwrite\n", outputStream, StandardCharsets.UTF_8);
+ setPermissionOwnerOnly(accessFile);
+ LOGGER.info("Generated JMX access file: " + accessFile.getPath());
+ } catch (IOException e) {
+ throw new RuntimeException("Error when creating JMX access file: " + accessFile.getPath(), e);
+ }
}
+ } catch (Exception e) {
+ LOGGER.warn("Failure to auto-generate JMX password, fallback to unsecure JMX", e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org