From: <ka...@us...> - 2010-04-22 18:32:53
|
Revision: 3333 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3333&view=rev Author: kappa1 Date: 2010-04-22 18:32:46 +0000 (Thu, 22 Apr 2010) Log Message: ----------- Remove extra permissions from XRandR and just allow minimal permissions needed by the LinuxDisplay. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-04-20 18:21:05 UTC (rev 3332) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-04-22 18:32:46 UTC (rev 3333) @@ -48,6 +48,9 @@ import org.lwjgl.LWJGLUtil; import org.lwjgl.opengl.XRandR.Screen; +import java.security.AccessController; +import java.security.PrivilegedAction; + final class LinuxDisplay implements DisplayImplementation { /* X11 constants */ public final static int CurrentTime = 0; @@ -524,7 +527,12 @@ try { if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) { - XRandR.setConfiguration( savedXrandrConfig ); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + XRandR.setConfiguration( savedXrandrConfig ); + return null; + } + }); } else { @@ -615,7 +623,11 @@ throw new LWJGLException("No modes available"); switch (current_displaymode_extension) { case XRANDR: - savedXrandrConfig = XRandR.getConfiguration(); + savedXrandrConfig = (Screen[])AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return XRandR.getConfiguration(); + } + }); saved_mode = getCurrentXRandrMode(); break; case XF86VIDMODE: @@ -890,7 +902,12 @@ try { if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 ) { - XRandR.setConfiguration( savedXrandrConfig ); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + XRandR.setConfiguration( savedXrandrConfig ); + return null; + } + }); } else { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java 2010-04-20 18:21:05 UTC (rev 3332) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java 2010-04-22 18:32:46 UTC (rev 3333) @@ -40,8 +40,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; -import java.security.AccessController; -import java.security.PrivilegedAction; /** * Utility for working with the xrandr commmand-line utility. Assumes @@ -105,12 +103,7 @@ * xrandr is not supported */ public static Screen[] getConfiguration() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - populate(); - return null; - } - }); + populate(); return (Screen[]) current.clone(); } @@ -119,20 +112,11 @@ * @param screens * The desired screen set, may not be <code>null</code> */ - public static void setConfiguration(final Screen[]/* ... */screens) { + public static void setConfiguration(Screen[]/* ... */screens) { if (screens.length == 0) { throw new IllegalArgumentException("Must specify at least one screen"); } - - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - setScreen(screens); - return null; - } - }); - } - - private static void setScreen(Screen[] screens) { + List/* <String> */cmd = new ArrayList/* <String> */(); cmd.add("xrandr"); @@ -173,6 +157,7 @@ } catch (IOException e) { e.printStackTrace(); } + } /** @@ -180,13 +165,7 @@ * xrandr is not supported */ public static String[] getScreenNames() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - populate(); - return null; - } - }); - + populate(); return (String[]) screens.keySet().toArray(new String[screens.size()]); } @@ -196,13 +175,7 @@ * <code>null</code> if there is no such screen */ public static Screen[] getResolutions(String name) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - populate(); - return null; - } - }); - + populate(); // clone the array to prevent held copies being altered return (Screen[]) ((Screen[]) screens.get(name)).clone(); } @@ -274,4 +247,4 @@ return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos; } } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |