summaryrefslogtreecommitdiffstats
path: root/partition.cpp
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2014-02-28 18:24:43 +0100
committerDees Troy <dees_troy@teamw.in>2014-02-28 18:59:04 +0100
commit4159aedfaa35e9a41ba9478b7bb00f661c6646d3 (patch)
treecdc9caa6ba475f7bf520c19161b6d872c3b38631 /partition.cpp
parentMerge "Check crypto footer before offering to decrypt" into android-4.4 (diff)
downloadandroid_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar.gz
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar.bz2
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar.lz
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar.xz
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.tar.zst
android_bootable_recovery-4159aedfaa35e9a41ba9478b7bb00f661c6646d3.zip
Diffstat (limited to 'partition.cpp')
-rw-r--r--partition.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/partition.cpp b/partition.cpp
index 57a692349..172633c07 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -63,6 +63,11 @@ extern "C" {
#include "selinux/selinux.h"
#include <selinux/label.h>
#endif
+#ifdef HAVE_CAPABILITIES
+#include <sys/capability.h>
+#include <sys/xattr.h>
+#include <linux/xattr.h>
+#endif
using namespace std;
@@ -1699,6 +1704,7 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System)
string Full_FileName, Command;
int index = 0;
char split_index[5];
+ bool ret = false;
if (Has_Android_Secure) {
if (!Wipe_AndSec())
@@ -1726,8 +1732,29 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System)
tar.setpassword(Password);
#endif
if (tar.extractTarFork() != 0)
- return false;
- return true;
+ ret = false;
+ else
+ ret = true;
+#ifdef HAVE_CAPABILITIES
+ // Restore capabilities to the run-as binary
+ if (Mount_Point == "/system" && Mount(true) && TWFunc::Path_Exists("/system/bin/run-as")) {
+ struct vfs_cap_data cap_data;
+ uint64_t capabilities = (1 << CAP_SETUID) | (1 << CAP_SETGID);
+
+ memset(&cap_data, 0, sizeof(cap_data));
+ cap_data.magic_etc = VFS_CAP_REVISION | VFS_CAP_FLAGS_EFFECTIVE;
+ cap_data.data[0].permitted = (uint32_t) (capabilities & 0xffffffff);
+ cap_data.data[0].inheritable = 0;
+ cap_data.data[1].permitted = (uint32_t) (capabilities >> 32);
+ cap_data.data[1].inheritable = 0;
+ if (setxattr("/system/bin/run-as", XATTR_NAME_CAPS, &cap_data, sizeof(cap_data), 0) < 0) {
+ LOGINFO("Failed to reset capabilities of /system/bin/run-as binary.\n");
+ } else {
+ LOGINFO("Reset capabilities of /system/bin/run-as binary successful.\n");
+ }
+ }
+#endif
+ return ret;
}
bool TWPartition::Restore_DD(string restore_folder) {