summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-02-15 18:07:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-02-15 18:07:46 +0000
commit523a20901b2afce7ad02c0011d70ed57f8bbb997 (patch)
tree7125366666ac9be42503b6159e5bcf68b5a3361c
parent17361134180b178531979897f9c9867346a57f10 (diff)
parent109f4e16cb22e2ae915a4c16d8c8a5e46a749d27 (diff)
downloadsystem_core-523a20901b2afce7ad02c0011d70ed57f8bbb997.zip
system_core-523a20901b2afce7ad02c0011d70ed57f8bbb997.tar.gz
system_core-523a20901b2afce7ad02c0011d70ed57f8bbb997.tar.bz2
Merge "adb: Use 64 bit capabilities."
-rw-r--r--adb/adb.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 92436da..399d43a 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -1238,7 +1238,7 @@ int adb_main(int is_daemon, int server_port)
/* don't run as root if we are running in secure mode */
if (should_drop_privileges()) {
struct __user_cap_header_struct header;
- struct __user_cap_data_struct cap;
+ struct __user_cap_data_struct cap[2];
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0) {
exit(1);
@@ -1271,12 +1271,15 @@ int adb_main(int is_daemon, int server_port)
exit(1);
}
+ memset(&header, 0, sizeof(header));
+ memset(cap, 0, sizeof(cap));
+
/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
- header.version = _LINUX_CAPABILITY_VERSION;
+ header.version = _LINUX_CAPABILITY_VERSION_3;
header.pid = 0;
- cap.effective = cap.permitted = (1 << CAP_SYS_BOOT);
- cap.inheritable = 0;
- capset(&header, &cap);
+ cap[CAP_TO_INDEX(CAP_SYS_BOOT)].effective |= CAP_TO_MASK(CAP_SYS_BOOT);
+ cap[CAP_TO_INDEX(CAP_SYS_BOOT)].permitted |= CAP_TO_MASK(CAP_SYS_BOOT);
+ capset(&header, cap);
D("Local port disabled\n");
} else {