[jboss-as] [AS7-4536] add-user.sh mangles permissions of mgmt-users.properties

Marek Goldmann goldmann at fedoraproject.org
Tue Apr 24 15:01:14 UTC 2012


commit 9c502da202840e13f076bb1c98bbe851583580fc
Author: Marek Goldmann <mgoldman at redhat.com>
Date:   Fri Apr 20 14:19:02 2012 +0200

    [AS7-4536] add-user.sh mangles permissions of mgmt-users.properties

 ...d-user.sh-mangles-permissions-of-mgmt-use.patch |   99 ++++++++++++++++++++
 jboss-as.spec                                      |   12 ++-
 2 files changed, 108 insertions(+), 3 deletions(-)
---
diff --git a/0054-AS7-4536-add-user.sh-mangles-permissions-of-mgmt-use.patch b/0054-AS7-4536-add-user.sh-mangles-permissions-of-mgmt-use.patch
new file mode 100644
index 0000000..ce74339
--- /dev/null
+++ b/0054-AS7-4536-add-user.sh-mangles-permissions-of-mgmt-use.patch
@@ -0,0 +1,99 @@
+From fc26329b5109c158a2689b8aca147dbf63bdfc4a Mon Sep 17 00:00:00 2001
+From: Marek Goldmann <mgoldman at redhat.com>
+Date: Tue, 17 Apr 2012 13:56:43 +0200
+Subject: [PATCH 54/54] [AS7-4536] add-user.sh mangles permissions of
+ mgmt-users.properties
+
+---
+ .../management/security/PropertiesFileLoader.java  |   42 ++++++++++++--------
+ 1 files changed, 25 insertions(+), 17 deletions(-)
+
+diff --git a/domain-management/src/main/java/org/jboss/as/domain/management/security/PropertiesFileLoader.java b/domain-management/src/main/java/org/jboss/as/domain/management/security/PropertiesFileLoader.java
+index 38737cb..9c4bad9 100644
+--- a/domain-management/src/main/java/org/jboss/as/domain/management/security/PropertiesFileLoader.java
++++ b/domain-management/src/main/java/org/jboss/as/domain/management/security/PropertiesFileLoader.java
+@@ -38,7 +38,9 @@ import java.io.IOException;
+ import java.io.InputStreamReader;
+ import java.io.OutputStreamWriter;
+ import java.nio.charset.Charset;
++import java.util.ArrayList;
+ import java.util.Arrays;
++import java.util.List;
+ import java.util.Properties;
+ 
+ import static org.jboss.as.domain.management.DomainManagementLogger.ROOT_LOGGER;
+@@ -122,28 +124,36 @@ public abstract class PropertiesFileLoader {
+         return properties;
+     }
+ 
++    /**
++     * Saves changes in properties file. It reads the property file into memory,
++     * modifies it and saves it back to the file.
++     *
++     * @throws IOException
++     */
+     public synchronized void persistProperties() throws IOException {
+         Properties toSave = (Properties) properties.clone();
+ 
+-        File backup = new File(propertiesFile.getCanonicalPath() + ".bak");
+-        if (backup.exists()) {
+-            if (backup.delete() == false) {
+-                throw new IllegalStateException("Unable to delete backup properties file.");
+-            }
+-        }
++        List<String> content = new ArrayList<String>();
++        FileReader fileReader = new FileReader(propertiesFile);
++        BufferedReader bufferedFileReader = new BufferedReader(fileReader);
+ 
+-        if (propertiesFile.renameTo(backup) == false) {
+-            throw new IllegalStateException("Unable to backup properties file.");
++        // Read the properties file into memory
++        // Shouldn't be so bad - it's a small file
++        try {
++            String line = null;
++            int i = 0;
++            while ((line = bufferedFileReader.readLine()) != null) {
++                content.add(line);
++            }
++        } finally {
++            safeClose(bufferedFileReader);
++            safeClose(fileReader);
+         }
+ 
+-        FileReader fr = new FileReader(backup);
+-        BufferedReader br = new BufferedReader(fr);
+-
+-        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(propertiesFile),"UTF8"));
++        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(propertiesFile), "UTF8"));
+ 
+         try {
+-            String line;
+-            while ((line = br.readLine()) != null) {
++            for (String line : content) {
+                 String trimmed = line.trim();
+                 if (trimmed.startsWith("#")) {
+                     bw.append(line);
+@@ -172,12 +182,9 @@ public abstract class PropertiesFileLoader {
+             }
+         } finally {
+             safeClose(bw);
+-            safeClose(br);
+-            safeClose(fr);
+         }
+     }
+ 
+-
+     public static String escapeString(String name, char[] escapeArray) {
+         Arrays.sort(escapeArray);
+         for(int i = 0; i < name.length(); ++i) {
+@@ -198,6 +205,7 @@ public abstract class PropertiesFileLoader {
+         }
+         return name;
+     }
++
+     private void safeClose(final Closeable c) {
+         try {
+             c.close();
+-- 
+1.7.7.6
+
diff --git a/jboss-as.spec b/jboss-as.spec
index 14768c4..11c56fa 100644
--- a/jboss-as.spec
+++ b/jboss-as.spec
@@ -15,7 +15,7 @@
 
 Name:             jboss-as
 Version:          7.1.0
-Release:          3%{?dist}
+Release:          4%{?dist}
 Summary:          JBoss Application Server
 Group:            System Environment/Daemons
 License:          LGPLv2 and ASL 2.0
@@ -84,6 +84,7 @@ Patch49:          0050-Discard-logs-from-systemd-service-we-don-t-need-dupl.patc
 Patch50:          0051-Changed-the-systemd-config-file-location-we-want-to-.patch
 Patch51:          0052-Remove-activation-module.patch
 Patch52:          0053-Use-properties-in-add-user-AS7-module.patch
+Patch53:          0054-AS7-4536-add-user.sh-mangles-permissions-of-mgmt-use.patch
 
 BuildArch:        noarch
 
@@ -169,6 +170,7 @@ BuildRequires:    maven-jar-plugin
 BuildRequires:    maven-checkstyle-plugin
 BuildRequires:    maven-resources-plugin
 BuildRequires:    maven-surefire-plugin
+BuildRequires:    maven-dependency-plugin
 BuildRequires:    mojarra
 BuildRequires:    picketbox
 BuildRequires:    picketbox-commons
@@ -339,6 +341,7 @@ This package contains the API documentation for %{name}.
 %patch50 -p1
 %patch51 -p1
 %patch52 -p1
+%patch53 -p1
 
 %build
 # We don't have packaged all test dependencies (jboss-test for example)
@@ -658,9 +661,9 @@ exit 0
 %attr(0775,root,jboss-as) %dir %{confdir}/standalone
 %attr(0775,root,jboss-as) %dir %{confdir}/domain
 %attr(0700,jboss-as,jboss-as) %dir %{cachedir}/auth
-%attr(0664,jboss-as,jboss-as) %config(noreplace) %{confdir}/standalone/*.properties
+%attr(0600,jboss-as,jboss-as) %config(noreplace) %{confdir}/standalone/*.properties
 %attr(0664,jboss-as,jboss-as) %config(noreplace) %{confdir}/standalone/*.xml
-%attr(0664,jboss-as,jboss-as) %config(noreplace) %{confdir}/domain/*.properties
+%attr(0600,jboss-as,jboss-as) %config(noreplace) %{confdir}/domain/*.properties
 %attr(0664,jboss-as,jboss-as) %config(noreplace) %{confdir}/domain/*.xml
 %config(noreplace) %{confdir}/%{name}.conf
 %{_unitdir}/%{name}.service
@@ -678,6 +681,9 @@ exit 0
 %doc %{homedir}/LICENSE.txt
 
 %changelog
+* Tue Apr 17 2012 Marek Goldmann <mgoldman at redhat.com> 7.1.0-4
+- [AS7-4536] add-user.sh mangles permissions of mgmt-users.properties
+
 * Mon Apr 16 2012 Marek Goldmann <mgoldman at redhat.com> 7.1.0-3
 - Simplified systemd files
 - Added jboss-as-cli module


More information about the scm-commits mailing list