启动的shell时,属于root用户
来源:互联网 发布:f35机动知乎 编辑:程序博客网 时间:2024/06/05 15:16
如果要调试的时候信息打印到超级终端,添加console,像sh一样直接输出到console
service console /system/bin/sh
console
我们的console交互程序shell -- /system/bin/sh处理来自console开发板的串口输入了,并且会将结果output输出到console开发板的串口上。
如果在超级终端执行一些命令不成功,比如mkdir,这样的基础命令,是没有取得root权限,只需在启动的shell时,指定该程序(shell 程序)属于root用户即可,修改init.rc文件如下:(临时的:目录/myandroid/out/target/product/XXXx/root/ 。永久的:/myandroid/system/core/rootdir/ 。其中xxxx为板子相应软件)
init.rc设置由:
service console /system/bin/sh
console
disabled
user sh
group log
修改为下面设置:
service console /system/bin/sh
console
disabled
user root
group root
控制台中可以执行root权限
Android adb root权限
方法:
修改./default.prop
把ro.secure设为0,persist.service.adb.enable设为1,adbd进程就会以root用户的身份启动。
原理:
可以看一下Android系统根目录下的/init.rc的片段:
… …
# adbd is controlled by the persist.service.adb.enable system property
service adbd /sbin/adbd
disabled
# adbd on at boot in emulator
on property:ro.kernel.qemu=1
start adbd
on property:persist.service.adb.enable=1
start adbd
on property:persist.service.adb.enable=0
stop adbd
… …
这里定义了一个触发器,只要persist.service.adb.enable值被置为1,就会启动/sbin/adbd。
在build目录下搜索一下,发现了main.mk中有这样的代码片段
## user/userdebug ##
user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
enable_target_debugging := true
ifneq (,$(user_variant))
# Target is secure in user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
tags_to_install := user
ifeq ($(user_variant),userdebug)
# Pick up some extra useful tools
tags_to_install += debug
else
# Disable debugging in plain user builds.
enable_target_debugging :=
endif
# TODO: Always set WITH_DEXPREOPT (for user builds) once it works on OSX.
# Also, remove the corresponding block in config/product_config.make.
ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
WITH_DEXPREOPT := true
endif
# Disallow mock locations by default for user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
else # !user_variant
# Turn on checkjni for non-user builds.
ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
# Set device insecure for non-user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
# Allow mock locations by default for non user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
endif # !user_variant
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
endif # !enable_target_debugging
这段代码我大致解释一下:
主要通过判断当前的编译模式来给几个属性赋予不同的值,然后把属性存储在ADDITIONAL_DEFAULT_PROPERTIES这个变量中, 这个变量在后面是要写到根目录下的/default.prop中去,在系统启动时被属性服务加载的。也就是说我们在/default.prop中看到的几 个属性的值是在这里设置的。
只看两个属性ro.secure,persist.service.adb.enable。当前是user模式的话,编译系统会把 ro.secure置为1,把persist.service.adb.enable置为0.也就是说,用user模式编译出来的系统运行在安全模式 下,adbd默认关闭。即使通过设置属性的方式打开,adbd进程的用户也是shell,不具有root权限。这样,普通用户或者开发者拿到一个机器后, 通过PC运行adb shell时,是以shell用户登录机器的。
好了,现在把ro.secure置为0,再重新编译,只要设置属性persist.service.adb.enable的值为1,adbd进程就会以root用户的身份启动。
- 启动的shell时,属于root用户
- 启动的shell时,指定该程序(shell 程序)属于root用户
- 启动的shell时,指定该程序(shell 程序)属于root用户
- Ubuntu root用户启动
- linux的shell脚本判断当前是否为root用户
- 用户管理(二):使用shell脚本批量删除除root用户以外的其它用户
- Ubuntu下root用户启动
- 非root用户启动tomcat
- 非root用户启动tomcat
- 使用root用户启动php
- 非root用户启动tomcat
- elasticsearch使用root用户启动
- 非root用户启动tomcat遇到的环境变量问题
- lunix:进入root进入非root用户的shell bash环境[用于权限测试]
- root后adb shell默认不是root用户时,如何将文件放入手机系统中
- root后adb shell默认不是root用户时,如何将文件放入手机系统中
- root后adb shell默认不是root用户时,如何将文件放入手机系统中
- Ubuntu的root用户
- 伸展树——自顶向下
- 《计算机网络》之网络层
- 《盗墓笔记》解谜!
- 9个offer,12家公司,35场面试,从微软到谷歌,应届计算机毕业生的2012求职之路
- Proxy动态代理(二)
- 启动的shell时,属于root用户
- super(true) destroyApp(true) 部分英文缩写
- C函数与汇编函数之间参数及返回值传递方法
- Centos6.3安装OpenStack的Folsom版本(2)
- 2012年工作总结
- RTP:实时传输协议详解(转)
- [ javascript ] Closures ( 闭包 )!
- 分类问题
- Linux内存管理