Ticket #4667: preferences_chmod_600.patch

File preferences_chmod_600.patch, 1.3 KB (added by dpaleino, 11 years ago)

chmod preferences file to 600

  • src/org/openstreetmap/josm/data/Preferences.java

     
    393393        File tmpFile = new File(prefFile + "_tmp");
    394394        copyFile(tmpFile, prefFile);
    395395        tmpFile.delete();
     396
     397        setCorrectPermissions();
    396398    }
    397399
     400    public void setCorrectPermissions() throws IOException {
     401        // Make it owner-only-readable.
     402        // FIXME: newest versions will use JDK 1.6, it has set*() functions.
     403        Runtime.getRuntime().exec("/bin/chmod 600 " + getPreferenceFile().getAbsolutePath());
     404    }
     405
    398406    /**
    399407     * Simple file copy function that will overwrite the target file
    400408     * Taken from http://www.rgagnon.com/javadetails/java-0064.html (CC-NC-BY-SA)
     
    509517                System.err.println(tr("Warning: Failed to initialize preferences.Failed to reset preference file to default: {0}", getPreferenceFile()));
    510518            }
    511519        }
     520
     521        try {
     522            setCorrectPermissions();
     523        }
     524        catch (IOException e) {
     525            e.printStackTrace();
     526        }
    512527    }
    513528
    514529    public final void resetToDefault(){