[libbluray-devel] Use doPrivileged() when creating cache dirs from Xlet context

hpi1 git at videolan.org
Fri Feb 27 11:53:27 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Feb 27 11:36:56 2015 +0200| [0f8f2c2798716fcdb8df97aefb312ae286676b48] | committer: hpi1

Use doPrivileged() when creating cache dirs from Xlet context

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=0f8f2c2798716fcdb8df97aefb312ae286676b48
---

 src/libbluray/bdj/java/org/videolan/VFSCache.java |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/VFSCache.java b/src/libbluray/bdj/java/org/videolan/VFSCache.java
index d85ad04..f076abc 100644
--- a/src/libbluray/bdj/java/org/videolan/VFSCache.java
+++ b/src/libbluray/bdj/java/org/videolan/VFSCache.java
@@ -25,6 +25,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import java.io.BDFileSystem;
 import org.videolan.bdjo.AppCache;
@@ -277,6 +279,17 @@ class VFSCache {
         inAccessFile = false;
     }
 
+    private void mkdirs_xletCode(String path) {
+        final File file = new File(path);
+        AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run() {
+                    file.mkdirs();
+                    return null;
+                }
+            });
+    }
+
     private void accessFileImp(String absPath) {
 
         if (BDFileSystem.nativeFileExists(absPath)) {
@@ -290,7 +303,7 @@ class VFSCache {
             /* this is regular file */
         } else {
             /* this is directory, make sure it exists */
-            new File(absPath).mkdirs();
+            mkdirs_xletCode(absPath);
             return;
         }
 
@@ -303,7 +316,7 @@ class VFSCache {
         int sepPos = relPath.lastIndexOf(File.separatorChar);
         if (sepPos > 0) {
             String absDir = cacheRoot + relPath.substring(0, sepPos);
-            new File(absDir).mkdirs();
+            mkdirs_xletCode(absDir);
         }
 
         /* finally, copy the file to cache */



More information about the libbluray-devel mailing list