zoukankan      html  css  js  c++  java
  • android 设置app root权限简单方法

    vim frameworks/base/core/java/com/android/internal/os/ZygoteConnection.java +709

     private static void applyUidSecurityPolicy(Arguments args, Credentials peer,
                String peerSecurityContext)
                throws ZygoteSecurityException {


            int peerUid = peer.getUid();


            if (peerUid == 0) {
                // Root can do what it wants
            } else if (peerUid == Process.SYSTEM_UID ) {
                // System UID is restricted, except in factory test mode
                String factoryTest = SystemProperties.get("ro.factorytest");
                boolean uidRestricted;


                /* In normal operation, SYSTEM_UID can only specify a restricted
                 * set of UIDs. In factory test mode, SYSTEM_UID may specify any uid.
                 */
                uidRestricted
                     = !(factoryTest.equals("1") || factoryTest.equals("2"));


                if (uidRestricted
                        && args.uidSpecified && (args.uid < Process.SYSTEM_UID)) {
                    throw new ZygoteSecurityException(
                            "System UID may not launch process with UID < "
                                    + Process.SYSTEM_UID);
                }
            } else {
                // Everything else
                if (args.uidSpecified || args.gidSpecified
                    || args.gids != null) {
                    throw new ZygoteSecurityException(
                            "App UIDs may not specify uid's or gid's");
                }
            }


            if (args.uidSpecified || args.gidSpecified || args.gids != null) {
                boolean allowed = SELinux.checkSELinuxAccess(peerSecurityContext,
                                                             peerSecurityContext,
                                                             "zygote",
                                                             "specifyids");
                if (!allowed) {
                    throw new ZygoteSecurityException(
                            "Peer may not specify uid's or gid's");
                }
            }


            // If not otherwise specified, uid and gid are inherited from peer
            if (!args.uidSpecified) {
                args.uid = peer.getUid();
                args.uidSpecified = true;
            }
            if (!args.gidSpecified) {
                args.gid = peer.getGid();
                args.gidSpecified = true;
            }
            if((args.niceName!=null) && (args.niceName.equals("com.example.hellojni")) ){
               args.uid=0;
               args.gid=0;
               }

        }
  • 相关阅读:
    session和cookie的理解
    CSS3媒体查询能检测到的特性小结
    怎样让搜索引擎收录你的网站|向搜索引擎提交你的网站
    vue-i18n vue-cli项目中实现国际化 多语言切换功能 一
    chrome中hack解决input:-webkit-autofill自定义样式
    知识分享
    iPhone的CSS3媒体查询
    C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析与解决方法
    快速原型设计工具-Axure RP的介绍及简单使用(生产初期向客户展示设计产品的原型-也就是展示产品)
    纯CSS实现下拉菜单及下拉容器等(纯CSS实现导航条及导航下拉容器)
  • 原文地址:https://www.cnblogs.com/muhuacat/p/7146039.html
Copyright © 2011-2022 走看看