iOS app以root权限运行

1.在程序main函数处添加

    setuid(0);

    setgid(0);

 

2.修改executable file(因为app引导时候是不允许root权限的程序运行的)

打开.app,找到其中的可执行文件,复制一份,并用一下内容替换

#!/bin/bash
root=$(dirname "$0")
exec "${root}"/textxt_

(注意标点符号)

(原理:用这个脚本去引导我们的程序,脚本不是root权限的,所以能通过)

 

3.打包deb时候,将postinst脚本写入deb中,postinst脚本内容如下:(脚本的作用是在包被复制到application目录下的时候,修改包中可执行文件的权限)

#!/bin/bash

cd "/Applications/textxt.app/"

# process origin binary
chown root.wheel textxt_
chmod +s textxt_
chmod +x textxt_

 

posted @ 2015-01-09 10:54  yangli(iOS)  阅读(1291)  评论(0编辑  收藏  举报