Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Check external storage directory for 'open' restriction
Browse files Browse the repository at this point in the history
Refs #1757
  • Loading branch information
M66B committed Dec 14, 2014
1 parent 51aa918 commit 674cc94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Changelog
* Added restriction *Srv_startActivityAsCaller* ([issue](/../../issues/1757))
* Added restriction *Srv_getAccountsForPackage*
* Added account type parameter for *Srv_getAccounts* and *Srv_getAccountsAsUser*
* Check external storage directory for *open* restriction ([issue](/../../issues/1757))

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)

Expand Down
9 changes: 7 additions & 2 deletions src/biz/bokhorst/xprivacy/XIoBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class XIoBridge extends XHook {
private static String mEmulatedSource = null;
private static String mEmulatedTarget = null;
private static String mMediaStorage = null;
private static String mSecondaryStorage = null;

private XIoBridge(Methods method, String restrictionName) {
super(restrictionName, method.name(), null);
Expand All @@ -44,6 +45,7 @@ public String getClassName() {
// public static FileDescriptor open(String path, int flags) throws FileNotFoundException
// public static FileDescriptor socket(boolean stream) throws SocketException
// libcore/luni/src/main/java/libcore/io/IoBridge.java
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/Environment.java

// @formatter:on

Expand Down Expand Up @@ -97,15 +99,18 @@ protected void before(XParam param) throws Throwable {
mEmulatedSource = System.getenv("EMULATED_STORAGE_SOURCE");
mEmulatedTarget = System.getenv("EMULATED_STORAGE_TARGET");
mMediaStorage = System.getenv("MEDIA_STORAGE");
mSecondaryStorage = System.getenv("SECONDARY_STORAGE");
if (TextUtils.isEmpty(mMediaStorage))
mMediaStorage = "/data/media";
}

// Check storage folders
if (fileName.startsWith("/sdcard") || (mMediaStorage != null && fileName.startsWith(mMediaStorage))
if (fileName.startsWith("/sdcard")
|| (mExternalStorage != null && fileName.startsWith(mExternalStorage))
|| (mEmulatedSource != null && fileName.startsWith(mEmulatedSource))
|| (mEmulatedTarget != null && fileName.startsWith(mEmulatedTarget)))
|| (mEmulatedTarget != null && fileName.startsWith(mEmulatedTarget))
|| (mMediaStorage != null && fileName.startsWith(mMediaStorage))
|| (mSecondaryStorage != null && fileName.startsWith(mSecondaryStorage)))
if (isRestrictedExtra(param, fileName))
param.setThrowable(new FileNotFoundException("XPrivacy"));

Expand Down

0 comments on commit 674cc94

Please sign in to comment.