This article was reproduced from: http://blog.csdn.net/liyongming1982/article/details/14108111
Some user version of the log is not complete, and push/pull some files or properties file
Often encounter insufficient permissions, to debug a lot of things:
For the user version of the ADB shell to open or shell permissions, rather than root permissions,
If you need root privileges, you need to change the SYSTEM/CORE/ADB/ADB.C inside the Should_drop_privileges ()
This function, return 0 at #ifndef Allow_adbd_root; instead of return 1; Can.
To determine whether to lower permissions:
[CPP]View PlainCopy
- static int should_drop_privileges () {
- #ifndef Allow_adbd_root
- return 1;
- #else/* Allow_adbd_root */
- int secure = 0;
- Char Value[property_value_max];
- / * Run ADBD in secure mode if Ro.secure is set and
- * * We is not in the emulator
- */
- Property_get ("Ro.kernel.qemu", Value, "");
- if (strcmp (Value, "1")! = 0) {
- Property_get ("Ro.secure", Value, "1");
- if (strcmp (Value, "1") = = 0) {
- //don ' t run as root if Ro.secure is set ...
- secure = 1;
- //... except we allow running as root in Userdebug builds if the
- //Service.adb.root property had been set by the "ADB root" command
- Property_get ("ro.debuggable", Value, "");
- if (strcmp (Value, "1") = = 0) {
- Property_get ("Service.adb.root", Value, "");
- if (strcmp (Value, "1") = = 0) {
- secure = 0;
- }
- }
- }
- }
- return secure;
- #endif/* Allow_adbd_root */
- }
Specifically how to reduce permissions:
[CPP]View PlainCopy
- if (Should_drop_privileges ()) {
- struct __user_cap_header_struct header;
- struct __user_cap_data_struct cap;
- if (Prctl (pr_set_keepcaps, 1, 0, 0, 0)! = 0) {
- Exit (1);
- }
- /* Add extra Groups:
- * * AID_ADB to access the USB driver
- * * Aid_log to read system logs (ADB logcat)
- * * Aid_input to diagnose INPUT issues (getevent)
- * * Aid_inet to diagnose network issues (netcfg, ping)
- * * Aid_graphics to access the frame buffer
- * * AID_NET_BT and aid_net_bt_admin to diagnose Bluetooth (hcidump)
- * * Aid_sdcard_r to allow reading from the SD card
- * * AID_SDCARD_RW to allow writing to the SD card
- * * Aid_mount to allow unmounting the SD card before rebooting
- * * Aid_net_bw_stats to read out Qtaguid statistics
- */
- gid_t groups[] = {aid_adb, aid_log, Aid_input, Aid_inet, Aid_graphics,
- AID_NET_BT, Aid_net_bt_admin, Aid_sdcard_r, AID_SDCARD_RW,
- Aid_mount, aid_net_bw_stats};
- if (setgroups (sizeof (groups)/sizeof (Groups[0]), groups)! = 0) {
- Exit (1);
- }
- / * Then switch the user and group to "Shell" * /
- if (setgid (aid_shell)! = 0) {
- Exit (1);
- }
- if (setuid (aid_shell)! = 0) {
- Exit (1);
- }
- / * Set cap_sys_boot capability, so "adb reboot" would succeed * /
- Header.version = _linux_capability_version;
- header.pid = 0;
- cap.effective = cap.permitted = (1 << cap_sys_boot);
- cap.inheritable = 0;
- Capset (&header, &cap);
- D ("Local Port disabled\n");
- }
Android User version increases ADB privilege "go"