diff --git a/CHANGELOG.md b/CHANGELOG.md index bcf0d1083..283a6310d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Test and beta releases will have experimental functions enabled by default. **Next release** * Show restrictions of system applications, even when disabled +* Moved database back due to permission problems ([issue](https://github.com/M66B/XPrivacy/issues/1129)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/PrivacyService.java b/src/biz/bokhorst/xprivacy/PrivacyService.java index bacc555b1..e904b1f19 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyService.java +++ b/src/biz/bokhorst/xprivacy/PrivacyService.java @@ -761,32 +761,33 @@ private static int getXUid() { } private static File getDbFile() { - return new File(Environment.getDataDirectory() + File.separator + "data" + File.separator - + PrivacyService.class.getPackage().getName() + File.separator + "xprivacy.db"); + return new File(Environment.getDataDirectory() + File.separator + "xprivacy" + File.separator + "xprivacy.db"); } 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"); - if (folder.exists()) { - File[] files = folder.listFiles(); - if (files != null) - for (File file : files) { - File target = new File(getDbFile().getParentFile() + File.separator + file.getName()); - Util.log(null, Log.WARN, "Moving " + file + " to " + target); - file.renameTo(target); - } - folder.delete(); - } - - // Set application folder permission + // Create base folder + getDbFile().getParentFile().mkdirs(); + + // Move existing database + File source = new File(Environment.getDataDirectory() + File.separator + "data" + File.separator + + PrivacyService.class.getPackage().getName() + File.separator + "xprivacy.db"); + File target = new File(getDbFile().getParentFile() + File.separator + "xprivacy.db"); + source.renameTo(target); + source = new File(source + "-journal"); + target = new File(target + "-journal"); + source.renameTo(target); + + // Create database, if needed + getDatabase(); + + // Set database folder permission // Owner: rwx (untouched) // Group: rwx (set to system) // World: --x File dbFile = getDbFile(); - Util.setPermission(dbFile.getParentFile().getAbsolutePath(), 0771, -1, PrivacyManager.cAndroidUid); + Util.setPermission(dbFile.getParentFile().getAbsolutePath(), 0770, -1, PrivacyManager.cAndroidUid); // Set database file permissions // Owner: rwx (untouched)