am 44db990d: Fix bug 2950316. Check return values.
Merge commit '44db990d3a4ce0edbdd16fa7ac20693ef601b723' into gingerbread-plus-aosp * commit '44db990d3a4ce0edbdd16fa7ac20693ef601b723': Fix bug 2950316. Check return values.
This commit is contained in:
commit
4692599cf7
1 changed files with 12 additions and 4 deletions
16
adb/adb.c
16
adb/adb.c
|
|
@ -893,7 +893,9 @@ int adb_main(int is_daemon, int server_port)
|
||||||
struct __user_cap_header_struct header;
|
struct __user_cap_header_struct header;
|
||||||
struct __user_cap_data_struct cap;
|
struct __user_cap_data_struct cap;
|
||||||
|
|
||||||
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
|
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* add extra groups:
|
/* add extra groups:
|
||||||
** AID_ADB to access the USB driver
|
** AID_ADB to access the USB driver
|
||||||
|
|
@ -907,11 +909,17 @@ int adb_main(int is_daemon, int server_port)
|
||||||
*/
|
*/
|
||||||
gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
|
gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
|
||||||
AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT };
|
AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT };
|
||||||
setgroups(sizeof(groups)/sizeof(groups[0]), groups);
|
if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* then switch user and group to "shell" */
|
/* then switch user and group to "shell" */
|
||||||
setgid(AID_SHELL);
|
if (setgid(AID_SHELL) != 0) {
|
||||||
setuid(AID_SHELL);
|
exit(1);
|
||||||
|
}
|
||||||
|
if (setuid(AID_SHELL) != 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue