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

Commit

Permalink
Database file/folder permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jan 25, 2014
1 parent c6b6290 commit 2588989
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ private static File getDbFile() {
}

public static void setupDatebase() {
// This is run from Zygote with root permissions
try {
// Move database from experimental location
File folder = new File(Environment.getDataDirectory() + File.separator + "xprivacy");
Expand All @@ -780,11 +781,20 @@ public static void setupDatebase() {
folder.delete();
}

// Set file permission
Util.setPermission(getDbFile().getParentFile().getAbsolutePath(), 0771, -1, PrivacyManager.cAndroidUid);
if (getDbFile().exists())
Util.setPermission(getDbFile().getAbsolutePath(), 0770, -1, PrivacyManager.cAndroidUid);
File journal = new File(getDbFile() + "-journal");
// Set application folder permission
// Owner: rwx (untouched)
// Group: rwx (set to system)
// World: --x
File dbFile = getDbFile();
Util.setPermission(dbFile.getParentFile().getAbsolutePath(), 0771, -1, PrivacyManager.cAndroidUid);

// Set database file permissions
// Owner: rwx (untouched)
// Group: rwx (set to system)
// World: ---
if (dbFile.exists())
Util.setPermission(dbFile.getAbsolutePath(), 0770, -1, PrivacyManager.cAndroidUid);
File journal = new File(dbFile + "-journal");
if (journal.exists())
Util.setPermission(journal.getAbsolutePath(), 0770, -1, PrivacyManager.cAndroidUid);
} catch (Throwable ex) {
Expand Down Expand Up @@ -831,9 +841,6 @@ private static SQLiteDatabase getDatabase() {
}
}

if (dbFile.exists())
Util.setPermission(dbFile.getAbsolutePath(), 0775, -1, PrivacyManager.cAndroidUid);

Util.log(null, Log.WARN, "Database version=" + db.getVersion());
mDatabase = db;
}
Expand Down

0 comments on commit 2588989

Please sign in to comment.