要求具有超级用户权限来编辑文件 [英] Request superuser rights to edit file

查看:121
本文介绍了要求具有超级用户权限来编辑文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刨一个应用程序,我需要编辑一个系统文件。

I'm planing an app where i need to edit a system file.

我只能编辑具有root权限的文件。我安装了一个根深蒂固开发手机Superuser.apk。需要超级其他应用程序做的第一个开始要求root访问权限。 我想这样做,但我无法找到如何申请超级用户权限我的应用程序的任何线索。

I can only edit that file with root rights. I have a rooted dev phone with Superuser.apk installed. Other apps that require root do request root access on first start. I want to do the same but I can't find any hints on how to request superuser rights for my app.

我发现了一些有关意向android.intent.action.superuser但是当我尝试推出的活动为目的的行动,我得到一个 ActivityNotFoundException

I found something about an intent android.intent.action.superuser but when I try to launch an activity for that intent action I get an ActivityNotFoundException.

任何想法?

推荐答案

这样做的目的实际上并没有得到你的超级用户权限,它只是交互与超级用户应用程序的权限授予机制。

The intent does not actually get you superuser rights, it just interacts with the superuser app's permission granting mechanism.

真正的关键是要明白,Android的底层Linux不支持用户权限升级。相反,它支持(/已被修改,以支持)用于一个用户请求来作为超级用户运行_some_other_process_。

The real key is to understand that android's underlying linux does not support escalation of a user's privileges. Instead, it supports (/has been modified to support) a mechanism for a user to request to run _some_other_process_ as the superuser.

这句话的意思是,实际的根权限的任务将不得不通过不同的可执行文件,可能是原生命令行一,你将在代表团推出的su命令或任何特定修改的Andr​​oid版本支持完成。这将是最简单的,如果你能弄清楚如何做到使用内置的工具箱中的命令行程序中的一个任务 - 例如,写文件,在其他地方,然后MV(也许CHOWN)到所需的位置。同时牢记/系统通常安装只读的,你将不得不重新安装它RW之前,你可以写在那里。

What this means is that the actual root-rights task will have to be done by a different executable, probably a native 'command line' one which you will launch under delegation by the su command or whatever your particular modified android build supports. It will be easiest if you can figure out how to do the task using one of the built-in toolbox command line programs - for example, write the file somewhere else and then mv (and maybe chown) it to where you want. Also bear in mind that /system is typically mounted read-only, and you would have to remount it rw before you can write there.

放了很多心思做任何事,你尝试做超级用户...它很容易使一个烂摊子,或留下问题。如果要部署的应用程序给别人,也想想你将要创建的安全漏洞。

Put a lot of thought into anything you try to do as the superuser... it's easy to make a mess or leave problems behind. If you are deploying the app to others, also think about security holes you will be creating.

这篇关于要求具有超级用户权限来编辑文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆