• 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;
               }

        }
  • 相关阅读:
    tp3中子查询 逻辑条件是or
    数据量大的情况用布隆过滤器判断是否已存在
    pip 通过pqi切换源到国内镜像
    php先响应后处理
    selenium登录网银,密码控件输入
    mysql 查询a表在b表中不存在的记录
    下列java代码中的变量a、b、c分别在内存的______存储区存放。
    关于选中的磁盘具有MBR分区表。在EFI系统上,Windows只能安装到GPT磁盘。问题解决
    VBOX不能为虚拟电脑打开一个新任务解决方法
    解决虚拟机似乎正在使用的问题
  • 原文地址:https://www.cnblogs.com/muhuacat/p/7146039.html
Copyright © 2020-2023  润新知