Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type=1400 audit(0.0:6364): avc: denied { open } for name="database.db" dev="mmcblk0p28" ino=171293 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=0
- os_unix.c:31278: (13) open(/data/user/0/com.testapp/databases/database.db)
- // Define in and out filepaths
- String DB_INPUT = "/data/data/com.package.name/databases/database.db";
- String DB_OUTPUT = activity.getDatabasePath("database.db").getPath();
- try {
- // Request superuser permissions
- Process suProcess = Runtime.getRuntime().exec("su");
- DataOutputStream suOutputStream = new DataOutputStream(suProcess.getOutputStream());
- // Copy database
- suOutputStream.writeBytes("cat " + DB_INPUT + " > " + DB_OUTPUT + "n");
- // Fix permissions
- int appUID = getApplication().getApplicationInfo().uid;
- suOutputStream.writeBytes("chmod 600 " + DB_OUTPUT + "n"); // rw- --- ---
- suOutputStream.writeBytes("chown " + appUID + "." + appUID + " " + DB_OUTPUT + "n");
- suOutputStream.writeBytes("exitn");
- suProcess.waitFor();
- suOutputStream.close();
- // Test
- SQLiteDatabase.openDatabase(DB_OUTPUT, null, SQLiteDatabase.OPEN_READWRITE);
- } catch(Exception e) {
- Log.e(LOGTAG, "Something went terrible wrong: " + e.getMessage());
- }
- // Define in and out filepaths
- String DB_INPUT = "/data/data/com.package.name/databases/database.db";
- String DB_OUTPUT = activity.getDatabasePath("database.db").getPath();
- // Create empty database to grant permissions
- SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DB_OUTPUT, null);
- db.close();
- try {
- // Request superuser permissions
- Process suProcess = Runtime.getRuntime().exec("su");
- DataOutputStream suOutputStream = new DataOutputStream(suProcess.getOutputStream());
- // Copy database
- suOutputStream.writeBytes("cat " + DB_INPUT + " > " + DB_OUTPUT + "n");
- // Close terminal
- suOutputStream.writeBytes("exitn");
- suProcess.waitFor();
- suOutputStream.close();
- } catch(Exception e) {
- Log.e(LOGTAG, "Something went terrible wrong: " + e.getMessage());
- }
Add Comment
Please, Sign In to add comment