From: <ls...@us...> - 2009-08-16 11:35:52
|
Revision: 5650 http://jnode.svn.sourceforge.net/jnode/?rev=5650&view=rev Author: lsantha Date: 2009-08-16 11:35:45 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Replaced DoPrivileged pragma with PrivilegedAction. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java Modified: trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java 2009-08-16 09:56:10 UTC (rev 5649) +++ trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java 2009-08-16 11:35:45 UTC (rev 5650) @@ -29,9 +29,7 @@ import org.jnode.fs.jifs.JIFSDirectory; import org.jnode.fs.jifs.JIFSFile; import org.jnode.fs.jifs.files.JIFSFthread; -import org.jnode.annotation.DoPrivileged; - /** * Directory containing one file for each java.lang.thread. Based on the thread * command. @@ -50,14 +48,19 @@ setParent(parent); } - @DoPrivileged public void refresh() { super.clear(); - ThreadGroup grp = Thread.currentThread().getThreadGroup(); - while (grp.getParent() != null) { - grp = grp.getParent(); - } - addGroup(grp); + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + ThreadGroup grp = Thread.currentThread().getThreadGroup(); + while (grp.getParent() != null) { + grp = grp.getParent(); + } + addGroup(grp); + return null; + } + }); } private void addGroup(final ThreadGroup grp) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-08-16 09:56:10 UTC (rev 5649) +++ trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-08-16 11:35:45 UTC (rev 5650) @@ -23,10 +23,11 @@ import java.io.File; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.CommandLine.Token; -import org.jnode.annotation.DoPrivileged; import sun.security.action.GetPropertyAction; /** @@ -80,34 +81,48 @@ } @Override - @DoPrivileged - protected File doAccept(Token token, int flags) throws CommandSyntaxException { + protected File doAccept(final Token token, final int flags) throws CommandSyntaxException { if (token.text.length() > 0) { - File file = new File(token.text); - if ((flags & HYPHEN_IS_SPECIAL) == 0 || !file.getPath().equals("-")) { - if (isExisting(flags) && !file.exists()) { - throw new CommandSyntaxException("this file or directory does not exist"); - } - if (isNonexistent(flags) && file.exists()) { - throw new CommandSyntaxException("this file or directory already exist"); - } - if ((flags & ALLOW_DODGY_NAMES) == 0) { - File f = file; - do { - // This assumes that option names start with '-'. - if (f.getName().startsWith("-")) { - if (f == file && !file.isAbsolute() && f.getParent() == null) { - // The user most likely meant this to be an option name ... - throw new CommandSyntaxException("unexpected or unknown option"); - } else { - throw new CommandSyntaxException("file or directory name starts with a '-'"); + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() { + @Override + public File run() throws Exception { + File file = new File(token.text); + if ((flags & HYPHEN_IS_SPECIAL) == 0 || !file.getPath().equals("-")) { + if (isExisting(flags) && !file.exists()) { + throw new CommandSyntaxException("this file or directory does not exist"); } + if (isNonexistent(flags) && file.exists()) { + throw new CommandSyntaxException("this file or directory already exist"); + } + if ((flags & ALLOW_DODGY_NAMES) == 0) { + File f = file; + do { + // This assumes that option names start with '-'. + if (f.getName().startsWith("-")) { + if (f == file && !file.isAbsolute() && f.getParent() == null) { + // The user most likely meant this to be an option name ... + throw new CommandSyntaxException("unexpected or unknown option"); + } else { + throw new CommandSyntaxException( + "file or directory name starts with a '-'"); + } + } + f = f.getParentFile(); + } while (f != null); + } } - f = f.getParentFile(); - } while (f != null); + return file; + } + }); + } catch (PrivilegedActionException x) { + Exception e = x.getException(); + if (e instanceof CommandSyntaxException) { + throw (CommandSyntaxException) e; + } else { + throw new RuntimeException(e); } } - return file; } else { throw new CommandSyntaxException("invalid file name"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |