android adb shell 权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10973886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:36:45  来源:igfitidea点击:

android adb shell permission denied

androidshelladb

提问by Joonsung Kim

I've suffered in using adb.exe.

我在使用adb.exe.

I wanted to use adb.exeshell prompt same as bash, so I decided change the default bash binary (of course binary was cross compiled, and everything was perfect)

我想使用adb.exe与 bash 相同的 shell 提示符,所以我决定更改默认的 bash 二进制文件(当然二进制文件是交叉编译的,一切都很完美)

change bash binary is followed below order

更改 bash 二进制文件遵循以下顺序

  1. adb remount
  2. adb push bash /system/bin/

  3. adb shell

  4. cd /system/bin
  5. chmod 777 bash
  6. mv sh sh.bak
  7. ln -s bash sh
  1. adb remount
  2. adb push bash /system/bin/

  3. adb shell

  4. cd /system/bin
  5. chmod 777 bash
  6. mv sh sh.bak
  7. ln -s bash sh

first change was successful, but problem is occurred when second try.

第一次更改成功,但第二次尝试时出现问题。

I push new bash binary, but I missed change bash's permission 777, and disconnect adb shell.

我推送了新的 bash 二进制文件,但我错过了更改 bash 的权限 777,并断开了adb shell.

after

C:\Program Files (x86)\Android\android-sdk\platform-tools>adb.exe shell
- exec '/system/bin/sh' failed: Permission denied (13) -

C:\Program Files (x86)\Android\android-sdk\platform-tools>

Is there any smart idea to fix this permission problem?

有什么聪明的想法可以解决这个权限问题吗?

please help me...

请帮我...

采纳答案by Chris Stratton

If the device hasn't crashed completely (/system/bin/sh is a dependency for a lot of things - rebooting may not get very far!) and the system partition is still writable, you might be able to adb push a new copy of bash, where you have set the permission bits as desired on the host system before pushing it (you may have to use cygwin or even linux in order to havepermission bits locally)

如果设备没有完全崩溃(/system/bin/sh 是很多事情的依赖项 - 重启可能不会很远!)并且系统分区仍然可写,您可能能够 adb push 一个新副本bash,在推送之前,您已在主机系统上根据需要设置了权限位(您可能必须使用 cygwin 甚至 linux 才能在本地拥有权限位)

It sounds like the device is rooted, so you might be able to configure or customize a terminal emulator app to give you a session using the backup sh, run the backup sh again as root using some escalation tool, and then fix the problem.

听起来设备已获得 root 权限,因此您可以配置或自定义终端模拟器应用程序,以便使用备份 sh 为您提供会话,使用某些升级工具以 root 身份再次运行备份 sh,然后解决问题。

If you have a modified recovery with adb, you could probably fix it from there by mounting the (normal) system partition manually.

如果您使用 adb 修改了恢复,您可能可以通过手动安装(正常)系统分区来修复它。

Last resort would restoring from a vendor-signed vanilla image.

最后的手段是从供应商签名的 vanilla 映像中恢复。

Hopefully you get un-stuck, but perhaps you've learned from this experience- changing the default shell is probably not a good idea. It would be better to load your custom shell under a different name and run it manually.

希望你不会被卡住,但也许你已经从这次经历中学到了- 更改默认 shell 可能不是一个好主意。最好以不同的名称加载自定义 shell 并手动运行它。

回答by Ankit Jain

A general solution for doing such things:removing system app and all.

执行此类操作的通用解决方案:删除系统应用程序等。

adb shell
mount -o rw,remount -t yaffs2 /dev/block/mtdblk4 /system
cd /system/app/
rm maps.apk
mount -o ro,remount -t yaffs2 /dev/block/mtdblk4 /system
sync
reboot

回答by Arun Murthy

If you have recent versions of CWM installed you can be saved

如果您安装了最新版本的 CWM,则可以保存

a) adb reboot recovery (boot your phone into recovery)

a) adb reboot recovery(启动你的手机进入recovery)

b) in CWM recover mount /system partition ( using your phone ).

b) 在 CWM 中恢复挂载 /system 分区(使用您的手机)。

c) adb kill-server

c) adb kill-server

d) sudo adb start-server

d) 须藤 adb 启动服务器

e) adb shell

e) adb 外壳

f) Do your thing set your permission correctly

f) 做你的事,正确设置你的权限

I was influenced by the answer here https://android.stackexchange.com/questions/38085/is-it-a-hard-brick/113507#113507?newreg=6e0c0c0be98349058d3e1668532cd7dc

我受到这里答案的影响https://android.stackexchange.com/questions/38085/is-it-a-hard-brick/113507#113507?newreg=6e0c0c0be98349058d3e1668532cd7dc