Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Daniel2014-01-25 21:10:19 +0000
committerThomas Watson2014-01-27 15:22:44 +0000
commit613853829fa5d79c7f760b4208c3d07e41ae243a (patch)
tree2089726de63c8e9348964b8c0d76c2697526f894
parent5e9ed65eafe8ba01bab4a16b9919b350cc4fcdcb (diff)
downloadrt.equinox.framework-613853829fa5d79c7f760b4208c3d07e41ae243a.tar.gz
rt.equinox.framework-613853829fa5d79c7f760b4208c3d07e41ae243a.tar.xz
rt.equinox.framework-613853829fa5d79c7f760b4208c3d07e41ae243a.zip
Bug 379102 - Prevent running Eclipse as root (optionally)I20140128-0800
Change-Id: I3f86470968e2b33a03a246c61950451caabe1884 Signed-off-by: Krzysztof Daniel <krzysztof.daniel@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
index 85417f637..f55835c14 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - bug 301226
- * Red Hat Inc. - bug 373640
+ * Red Hat Inc. - bug 373640, 379102
* Ericsson AB (Pascal Rapicault) - bug 304132
*******************************************************************************/
package org.eclipse.equinox.launcher;
@@ -140,6 +140,11 @@ public class Main {
private static final String EXITDATA = "-exitdata"; //$NON-NLS-1$
private static final String NAME = "-name"; //$NON-NLS-1$
private static final String LAUNCHER = "-launcher"; //$NON-NLS-1$
+
+ private static final String PROTECT = "-protect"; //$NON-NLS-1$
+ //currently the only level of protection we care about
+ private static final String MASTER = "master"; //$NON-NLS-1$
+
private static final String LIBRARY = "--launcher.library"; //$NON-NLS-1$
private static final String APPEND_VMARGS = "--launcher.appendVmargs"; //$NON-NLS-1$
private static final String OVERRIDE_VMARGS = "--launcher.overrideVmargs"; //$NON-NLS-1$
@@ -236,6 +241,8 @@ public class Main {
protected BufferedWriter log = null;
protected boolean newSession = true;
+ private boolean protectMaster;
+
// for variable substitution
public static final String VARIABLE_DELIM_STRING = "$"; //$NON-NLS-1$
public static final char VARIABLE_DELIM_CHAR = '$';
@@ -562,6 +569,11 @@ public class Main {
setupVMProperties();
processConfiguration();
+ if (protectMaster && (System.getProperty(PROP_SHARED_CONFIG_AREA) == null)) {
+ System.err.println("This application is configured to run in a cascaded mode only."); //$NON-NLS-1$
+ System.setProperty(PROP_EXITCODE, "" + 14); //$NON-NLS-1$
+ return;
+ }
// need to ensure that getInstallLocation is called at least once to initialize the value.
// Do this AFTER processing the configuration to allow the configuration to set
// the install location.
@@ -1566,6 +1578,16 @@ public class Main {
}
}
+ // look for the command to use to show the splash screen
+ if (args[i].equalsIgnoreCase(PROTECT)) {
+ found = true;
+ //consume next parameter
+ configArgs[configArgIndex++] = i++;
+ if (args[i].equalsIgnoreCase(MASTER)) {
+ protectMaster = true;
+ }
+ }
+
// done checking for args. Remember where an arg was found
if (found) {
configArgs[configArgIndex++] = i;

Back to the top