mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Setting preferences.txt permissions to 600 on linux and mac
This commit is contained in:
parent
4db6c737be
commit
fe85083f0b
@ -64,8 +64,6 @@ import static processing.app.I18n._;
|
|||||||
*/
|
*/
|
||||||
public class Preferences {
|
public class Preferences {
|
||||||
|
|
||||||
static final String PREFS_FILE = PreferencesData.PREFS_FILE;
|
|
||||||
|
|
||||||
class Language {
|
class Language {
|
||||||
Language(String _name, String _originalName, String _isoCode) {
|
Language(String _name, String _originalName, String _isoCode) {
|
||||||
name = _name;
|
name = _name;
|
||||||
|
@ -21,15 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
import static processing.app.I18n._;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
|
|
||||||
import cc.arduino.packages.BoardPort;
|
import cc.arduino.packages.BoardPort;
|
||||||
import com.sun.jna.Library;
|
import com.sun.jna.Library;
|
||||||
@ -39,6 +30,12 @@ import processing.app.debug.TargetPackage;
|
|||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
import processing.app.legacy.PConstants;
|
import processing.app.legacy.PConstants;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by Base for platform-specific tweaking, for instance finding the
|
* Used by Base for platform-specific tweaking, for instance finding the
|
||||||
@ -227,4 +224,9 @@ public class Platform {
|
|||||||
public List<BoardPort> filterPorts(List<BoardPort> ports, boolean aBoolean) {
|
public List<BoardPort> filterPorts(List<BoardPort> ports, boolean aBoolean) {
|
||||||
return new LinkedList<BoardPort>(ports);
|
return new LinkedList<BoardPort>(ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fixPrefsFilePermissions(File prefsFile) throws IOException, InterruptedException {
|
||||||
|
Process process = Runtime.getRuntime().exec(new String[]{"chmod", "600", prefsFile.getAbsolutePath()}, null, null);
|
||||||
|
process.waitFor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import processing.app.legacy.PConstants;
|
|||||||
|
|
||||||
public class PreferencesData {
|
public class PreferencesData {
|
||||||
|
|
||||||
static final String PREFS_FILE = "preferences.txt";
|
private static final String PREFS_FILE = "preferences.txt";
|
||||||
|
|
||||||
// data model
|
// data model
|
||||||
|
|
||||||
@ -30,18 +30,25 @@ public class PreferencesData {
|
|||||||
|
|
||||||
|
|
||||||
static public void init(File file) {
|
static public void init(File file) {
|
||||||
if (file != null)
|
if (file != null) {
|
||||||
preferencesFile = file;
|
preferencesFile = file;
|
||||||
else
|
} else {
|
||||||
preferencesFile = BaseNoGui.getSettingsFile(PREFS_FILE);
|
preferencesFile = BaseNoGui.getSettingsFile(PREFS_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
BaseNoGui.getPlatform().fixPrefsFilePermissions(preferencesFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
// start by loading the defaults, in case something
|
// start by loading the defaults, in case something
|
||||||
// important was deleted from the user prefs
|
// important was deleted from the user prefs
|
||||||
try {
|
try {
|
||||||
prefs.load(BaseNoGui.getLibStream("preferences.txt"));
|
prefs.load(BaseNoGui.getLibStream(PREFS_FILE));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
BaseNoGui.showError(null, _("Could not read default settings.\n" +
|
BaseNoGui.showError(null, _("Could not read default settings.\n" +
|
||||||
"You'll need to reinstall Arduino."), e);
|
"You'll need to reinstall Arduino."), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set some runtime constants (not saved on preferences file)
|
// set some runtime constants (not saved on preferences file)
|
||||||
@ -144,6 +151,12 @@ public class PreferencesData {
|
|||||||
|
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
BaseNoGui.getPlatform().fixPrefsFilePermissions(preferencesFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,10 +24,8 @@ package processing.app.windows;
|
|||||||
|
|
||||||
import com.sun.jna.Library;
|
import com.sun.jna.Library;
|
||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
||||||
|
|
||||||
import org.apache.commons.exec.CommandLine;
|
import org.apache.commons.exec.CommandLine;
|
||||||
import org.apache.commons.exec.Executor;
|
import org.apache.commons.exec.Executor;
|
||||||
|
|
||||||
import processing.app.PreferencesData;
|
import processing.app.PreferencesData;
|
||||||
import processing.app.debug.TargetPackage;
|
import processing.app.debug.TargetPackage;
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
@ -351,4 +349,9 @@ public class Platform extends processing.app.Platform {
|
|||||||
return super.preListAllCandidateDevices();
|
return super.preListAllCandidateDevices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fixPrefsFilePermissions(File prefsFile) throws IOException {
|
||||||
|
//noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user