am 523a2090: Merge "adb: Use 64 bit capabilities."
* commit '523a20901b2afce7ad02c0011d70ed57f8bbb997': adb: Use 64 bit capabilities.
This commit is contained in:
commit
e149855a81
1 changed files with 8 additions and 5 deletions
13
adb/adb.c
13
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 */
|
/* don't run as root if we are running in secure mode */
|
||||||
if (should_drop_privileges()) {
|
if (should_drop_privileges()) {
|
||||||
struct __user_cap_header_struct header;
|
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) {
|
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
@ -1271,12 +1271,15 @@ int adb_main(int is_daemon, int server_port)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
|
memset(cap, 0, sizeof(cap));
|
||||||
|
|
||||||
/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
|
/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
|
||||||
header.version = _LINUX_CAPABILITY_VERSION;
|
header.version = _LINUX_CAPABILITY_VERSION_3;
|
||||||
header.pid = 0;
|
header.pid = 0;
|
||||||
cap.effective = cap.permitted = (1 << CAP_SYS_BOOT);
|
cap[CAP_TO_INDEX(CAP_SYS_BOOT)].effective |= CAP_TO_MASK(CAP_SYS_BOOT);
|
||||||
cap.inheritable = 0;
|
cap[CAP_TO_INDEX(CAP_SYS_BOOT)].permitted |= CAP_TO_MASK(CAP_SYS_BOOT);
|
||||||
capset(&header, &cap);
|
capset(&header, cap);
|
||||||
|
|
||||||
D("Local port disabled\n");
|
D("Local port disabled\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue