Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 4199)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 4200)
@@ -25,8 +25,8 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import java.util.Map.Entry;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.regex.Matcher;
@@ -35,6 +35,6 @@
 import javax.swing.JOptionPane;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.io.XmlWriter;
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.tools.ColorHelper;
 import org.openstreetmap.josm.tools.Utils;
@@ -365,9 +365,11 @@
         if(Main.applet)
             return;
-        File prefFile = new File(getPreferencesDirFile(), "preferences");
+
+        File prefFile = getPreferenceFile();
+        File backupFile = new File(prefFile + "_backup");
 
         // Backup old preferences if there are old preferences
         if(prefFile.exists()) {
-            copyFile(prefFile, new File(prefFile + "_backup"));
+            copyFile(prefFile, backupFile);
         }
 
@@ -386,4 +388,16 @@
         copyFile(tmpFile, prefFile);
         tmpFile.delete();
+
+        setCorrectPermissions(prefFile);
+        setCorrectPermissions(backupFile);
+    }
+
+
+    private void setCorrectPermissions(File file) {
+        file.setReadable(false, false);
+        file.setWritable(false, false);
+        file.setExecutable(false, false);
+        file.setReadable(true, true);
+        file.setWritable(true, true);
     }
 
@@ -560,6 +574,7 @@
     synchronized public Color getColor(String colName, String specName, Color def) {
         String colKey = colName.toLowerCase().replaceAll("[^a-z0-9]+",".");
-        if(!colKey.equals(colName))
+        if(!colKey.equals(colName)) {
             colornames.put(colKey, colName);
+        }
         putDefault("color."+colKey, ColorHelper.color2html(def));
         String colStr = specName != null ? get("color."+specName) : "";
@@ -709,10 +724,11 @@
      * Used to read a 2-dimensional array of strings from the preference file.
      * If not a single entry could be found, def is returned.
-     */ 
+     */
     synchronized public Collection<Collection<String>> getArray(String key,
             Collection<Collection<String>> def)
-    {
-        if(def != null)
+            {
+        if(def != null) {
             putArrayDefault(key, def);
+        }
         key += ".";
         int num = 0;
@@ -722,6 +738,6 @@
         }
         return num == 0 ? def : col;
-    }
-    
+            }
+
     synchronized public boolean putArray(String key, Collection<Collection<String>> val) {
         boolean changed = false;
@@ -796,5 +812,5 @@
     public <T> List<T> getListOfStructs(String key, Collection<T> def, Class<T> klass) {
         Collection<Collection<String>> array =
-                getArray(key, def == null ? null : serializeListOfStructs(def, klass));
+            getArray(key, def == null ? null : serializeListOfStructs(def, klass));
         if (array == null)
             return def == null ? null : new ArrayList<T>(def);
@@ -829,6 +845,7 @@
         Collection<Collection<String>> vals = new ArrayList<Collection<String>>();
         for (T struct : l) {
-            if (struct == null)
+            if (struct == null) {
                 continue;
+            }
             vals.add(serializeStruct(struct, klass));
         }
@@ -937,5 +954,5 @@
      */
     private final static String[] DEFAULT_PLUGIN_SITE = {
-        "http://josm.openstreetmap.de/plugin%<?plugins=>"};
+    "http://josm.openstreetmap.de/plugin%<?plugins=>"};
 
     /**
@@ -973,5 +990,5 @@
         parser.map("collection", XMLCollection.class);
         parser.startWithValidation(in,
-        "http://josm.openstreetmap.de/preferences-1.0", "resource://data/preferences.xsd");
+                "http://josm.openstreetmap.de/preferences-1.0", "resource://data/preferences.xsd");
         LinkedList<String> vals = new LinkedList<String>();
         while(parser.hasNext()) {
@@ -990,5 +1007,5 @@
     public String toXML(boolean nopass) {
         StringBuilder b = new StringBuilder(
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<preferences xmlns=\"http://josm.openstreetmap.de/preferences-1.0\">\n");
         for (Entry<String, String> p : properties.entrySet()) {
