Exemplo n.º 1
0
def modify_init_rc(directory):
  lines = fileio.all_lines('init.rc', directory = directory)

  f = fileio.open_file('init.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if 'export ANDROID_ROOT' in line:
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "export ANDROID_CACHE /cache\n")

    elif re.search(r"mkdir /system(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/system", "/raw-system", line))

    elif re.search(r"mkdir /data(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/data", "/raw-data", line))

    elif re.search(r"mkdir /cache(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/cache", "/raw-cache", line))

    elif 'yaffs2' in line:
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    else:
      fileio.write(f, line)

  f.close()
Exemplo n.º 2
0
def modify_init_target_rc(directory):
  lines = fileio.all_lines('init.target.rc', directory = directory)

  previous_line = ""

  f = fileio.open_file('init.target.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount_all\s+fstab.qcom.*$", line) and \
        re.search(r"^on\s+fs_selinux.*$", previous_line):
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    else:
      fileio.write(f, line)

    previous_line = line

  f.close()
Exemplo n.º 3
0
def modify_init_rc(cpiofile):
    cpioentry = cpiofile.get_file('init.rc')
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    in_mediaserver = False

    for line in lines:
        if re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif 'check_icd' in line:
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif version == 'kk44' and \
                line.startswith('service'):
            in_mediaserver = '/system/bin/mediaserver' in line
            buf += fileio.encode(line)

        elif in_mediaserver and re.search(r'^\s*user', line):
            buf += fileio.encode(fileio.whitespace(line) + 'user root\n')

        else:
            buf += fileio.encode(line)

    cpioentry.content = buf
Exemplo n.º 4
0
def modify_init_rc(cpiofile):
    cpioentry = cpiofile.get_file('init.rc')
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    in_mediaserver = False

    for line in lines:
        if re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif 'check_icd' in line:
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif version == 'kk44' and \
                line.startswith('service'):
            in_mediaserver = '/system/bin/mediaserver' in line
            buf += fileio.encode(line)

        elif in_mediaserver and re.search(r'^\s*user', line):
            buf += fileio.encode(fileio.whitespace(line) + 'user root\n')

        else:
            buf += fileio.encode(line)

    cpioentry.content = buf
Exemplo n.º 5
0
def modify_init_target_rc(cpiofile):
    cpioentry = cpiofile.get_file("init.target.rc")
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    previous_line = ""

    for line in lines:
        if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+mount_all\s+fstab.jgedlte.*$", line) and re.search(
            r"^on\s+fs(_selinux)?.*$", previous_line
        ):
            buf += fileio.encode(line)
            buf += fileio.encode(fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

        else:
            buf += fileio.encode(line)

        previous_line = line

    cpioentry.set_content(buf)
Exemplo n.º 6
0
def modify_init_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  for line in lines:
    if 'export ANDROID_ROOT' in line:
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "export ANDROID_CACHE /cache\n")

    elif re.search(r"mkdir /system(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/system", "/raw-system", line))

    elif re.search(r"mkdir /data(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/data", "/raw-data", line))

    elif re.search(r"mkdir /cache(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/cache", "/raw-cache", line))

    elif 'yaffs2' in line:
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    else:
      buf += fileio.encode(line)

  cpioentry.set_content(buf)
Exemplo n.º 7
0
def modify_init_target_rc(cpiofile, filename='init.target.rc',
                          insert_apnhlos=False, insert_mdm=False):
    cpioentry = cpiofile.get_file(filename)
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    for line in lines:
        if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif re.search(r"^\s+mount_all\s+(\./)?fstab\..*$", line):
            buf += fileio.encode(line)
            buf += fileio.encode(fileio.whitespace(line) + common.EXEC_MOUNT)

        elif re.search(r"/data/media(\s|$)", line):
            buf += fileio.encode(
                re.sub('/data/media', '/raw-data/media', line))

        elif re.search(r"^\s+setprop\s+ro.crypto.fuse_sdcard\s+true", line):
            buf += fileio.encode(line)

            voldargs = 'shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337'

            if insert_apnhlos:
                buf += fileio.encode(fileio.whitespace(line) +
                                     "wait %s\n" % APNHLOS_PART)
                buf += fileio.encode(fileio.whitespace(line) +
                                     "mount vfat %s /firmware ro %s\n" %
                                     (APNHLOS_PART, voldargs))

            if insert_mdm:
                buf += fileio.encode(fileio.whitespace(line) +
                                     "wait %s\n" % MDM_PART)
                buf += fileio.encode(fileio.whitespace(line) +
                                     "mount vfat %s /firmware-mdm ro %s\n" %
                                     (MDM_PART, voldargs))

        else:
            buf += fileio.encode(line)

    cpioentry.content = buf
Exemplo n.º 8
0
def modify_init_target_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.target.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  previous_line = ""

  for line in lines:
    if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount_all\s+fstab.qcom.*$", line) and \
        re.search(r"^on\s+fs\s*$", previous_line):
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    elif re.search(r"^\s+setprop\s+ro.crypto.fuse_sdcard\s+true", line):
      buf += fileio.encode(line)

      if move_apnhlos_mount:
        buf += fileio.encode(fileio.whitespace(line) + "wait /dev/block/platform/msm_sdcc.1/by-name/apnhlos\n")
        buf += fileio.encode(fileio.whitespace(line) + "mount vfat /dev/block/platform/msm_sdcc.1/by-name/apnhlos /firmware ro shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337\n")

      if move_mdm_mount:
        buf += fileio.encode(fileio.whitespace(line) + "wait /dev/block/platform/msm_sdcc.1/by-name/mdm\n")
        buf += fileio.encode(fileio.whitespace(line) + "mount vfat /dev/block/platform/msm_sdcc.1/by-name/mdm /firmware-mdm ro shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337\n")

    else:
      buf += fileio.encode(line)

    previous_line = line

  cpioentry.set_content(buf)
Exemplo n.º 9
0
def modify_init_target_rc(cpiofile):
    cpioentry = cpiofile.get_file('init.target.rc')
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    in_qcam = False

    for line in lines:
        if version == 'kk44' and \
                re.search(r"^on\s+fs_selinux\s*$", line):
            buf += fileio.encode(line)
            buf += fileio.encode("    mount_all fstab.qcom\n")
            buf += fileio.encode("    " + common.EXEC_MOUNT)

        elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif version == 'kk44' and \
                line.startswith('service'):
            in_qcam = 'qcamerasvr' in line
            buf += fileio.encode(line)

        # This is not exactly safe, but it's the best we can do. TouchWiz is
        # doing some funny business where a process running under a certain
        # user or group (confirmed by /proc/<pid>/status) cannot access files
        # by that group. Not only that, mm-qcamera-daemon doesn't work if the
        # process has multiple groups and root is not the primary group. Oh
        # well, I'm done debugging proprietary binaries.
        elif in_qcam and re.search(r'^\s*user', line):
            buf += fileio.encode(fileio.whitespace(line) + 'user root\n')

        elif in_qcam and re.search(r'^\s*group', line):
            buf += fileio.encode(fileio.whitespace(line) + 'group root\n')

        else:
            buf += fileio.encode(line)

    cpioentry.content = buf
Exemplo n.º 10
0
def modify_init_target_rc(cpiofile):
    cpioentry = cpiofile.get_file('init.target.rc')
    lines = fileio.bytes_to_lines(cpioentry.content)
    buf = bytes()

    in_qcam = False

    for line in lines:
        if version == 'kk44' and \
                re.search(r"^on\s+fs_selinux\s*$", line):
            buf += fileio.encode(line)
            buf += fileio.encode("    mount_all fstab.qcom\n")
            buf += fileio.encode("    " + common.EXEC_MOUNT)

        elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
            buf += fileio.encode(re.sub(r"^", "#", line))

        elif version == 'kk44' and \
                line.startswith('service'):
            in_qcam = 'qcamerasvr' in line
            buf += fileio.encode(line)

        # This is not exactly safe, but it's the best we can do. TouchWiz is
        # doing some funny business where a process running under a certain
        # user or group (confirmed by /proc/<pid>/status) cannot access files
        # by that group. Not only that, mm-qcamera-daemon doesn't work if the
        # process has multiple groups and root is not the primary group. Oh
        # well, I'm done debugging proprietary binaries.
        elif in_qcam and re.search(r'^\s*user', line):
            buf += fileio.encode(fileio.whitespace(line) + 'user root\n')

        elif in_qcam and re.search(r'^\s*group', line):
            buf += fileio.encode(fileio.whitespace(line) + 'group root\n')

        else:
            buf += fileio.encode(line)

    cpioentry.content = buf
Exemplo n.º 11
0
def modify_init_target_rc(directory):
  lines = fileio.all_lines('init.target.rc', directory = directory)

  previous_line = ""

  f = fileio.open_file('init.target.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
      fileio.write(f, re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount_all\s+fstab.qcom.*$", line) and \
        re.search(r"^on\s+fs\s*$", previous_line):
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    elif re.search(r"^\s+setprop\s+ro.crypto.fuse_sdcard\s+true", line):
      fileio.write(f, line)

      if move_apnhlos_mount:
        fileio.write(f, fileio.whitespace(line) + "wait /dev/block/platform/msm_sdcc.1/by-name/apnhlos\n")
        fileio.write(f, fileio.whitespace(line) + "mount vfat /dev/block/platform/msm_sdcc.1/by-name/apnhlos /firmware ro shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337\n")

      if move_mdm_mount:
        fileio.write(f, fileio.whitespace(line) + "wait /dev/block/platform/msm_sdcc.1/by-name/mdm\n")
        fileio.write(f, fileio.whitespace(line) + "mount vfat /dev/block/platform/msm_sdcc.1/by-name/mdm /firmware-mdm ro shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337\n")

    else:
      fileio.write(f, line)

    previous_line = line

  f.close()
Exemplo n.º 12
0
def modify_init_qcom_rc(directory):
  lines = fileio.all_lines('init.qcom.rc', directory = directory)

  f = fileio.open_file('init.qcom.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if 'export EMULATED_STORAGE_TARGET' in line:
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "export EXTERNAL_SD /storage/sdcard1\n")

    # Change /data/media to /raw-data/media
    elif re.search(r"/data/media(\s|$)", line):
      fileio.write(f, re.sub('/data/media', '/raw-data/media', line))

    else:
      fileio.write(f, line)

  f.close()
Exemplo n.º 13
0
def modify_init_qcom_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.qcom.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  for line in lines:
    if 'export EMULATED_STORAGE_TARGET' in line:
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "export EXTERNAL_SD /storage/sdcard1\n")

    # Change /data/media to /raw-data/media
    elif re.search(r"/data/media(\s|$)", line):
      buf += fileio.encode(re.sub('/data/media', '/raw-data/media', line))

    else:
      buf += fileio.encode(line)

  cpioentry.set_content(buf)
Exemplo n.º 14
0
def modify_init_hammerhead_rc(directory):
  lines = fileio.all_lines('init.hammerhead.rc', directory = directory)

  previous_line = ""

  f = fileio.open_file('init.hammerhead.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if re.search(r"^\s+mount_all\s+./fstab.hammerhead.*$", line) and \
        re.search(r"^on\s+fs\s*$", previous_line):
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    # Change /data/media to /raw-data/media
    elif re.search(r"/data/media(\s|$)", line):
      fileio.write(f, re.sub('/data/media', '/raw-data/media', line))

    else:
      fileio.write(f, line)

    previous_line = line

  f.close()
Exemplo n.º 15
0
def modify_init_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  previous_line = ""

  for line in lines:
    if 'export ANDROID_ROOT' in line:
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "export ANDROID_CACHE /cache\n")

    elif re.search(r"mkdir /system(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/system", "/raw-system", line))

    elif re.search(r"mkdir /data(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/data", "/raw-data", line))

    elif re.search(r"mkdir /cache(\s|$)", line):
      buf += fileio.encode(line)
      buf += fileio.encode(re.sub("/cache", "/raw-cache", line))

    elif 'yaffs2' in line:
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif version == 'kk44' \
        and re.search(r"mount.*/system", line) \
        and re.search(r"on\s+charger", previous_line):
      buf += fileio.encode("    mount_all fstab.jgedlte\n")
      buf += fileio.encode("    exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    else:
      buf += fileio.encode(line)

    previous_line = line

  cpioentry.set_content(buf)
Exemplo n.º 16
0
def modify_init_rc(directory):
  lines = fileio.all_lines('init.rc', directory = directory)

  previous_line = ""

  f = fileio.open_file('init.rc', fileio.WRITE, directory = directory)
  for line in lines:
    if 'export ANDROID_ROOT' in line:
      fileio.write(f, line)
      fileio.write(f, fileio.whitespace(line) + "export ANDROID_CACHE /cache\n")

    elif re.search(r"mkdir /system(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/system", "/raw-system", line))

    elif re.search(r"mkdir /data(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/data", "/raw-data", line))

    elif re.search(r"mkdir /cache(\s|$)", line):
      fileio.write(f, line)
      fileio.write(f, re.sub("/cache", "/raw-cache", line))

    elif 'yaffs2' in line:
      fileio.write(f, re.sub(r"^", "#", line))

    elif version == 'kk44' \
        and re.search(r"mount.*/system", line) \
        and re.search(r"on\s+charger", previous_line):
      fileio.write(f, "    mount_all fstab.jgedlte\n")
      fileio.write(f, "    exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    else:
      fileio.write(f, line)

    previous_line = line

  f.close()
Exemplo n.º 17
0
def modify_init_g2_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.g2.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  previous_line = ""

  for line in lines:
    if re.search(r"^\s+mount_all\s+./fstab.g2.*$", line) and \
        re.search(r"^on\s+fs\s*$", previous_line):
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    # Change /data/media to /raw-data/media
    elif re.search(r"/data/media(\s|$)", line):
      buf += fileio.encode(re.sub('/data/media', '/raw-data/media', line))

    else:
      buf += fileio.encode(line)

    previous_line = line

  cpioentry.set_content(buf)
Exemplo n.º 18
0
def modify_init_target_rc(cpiofile):
  cpioentry = cpiofile.get_file('init.target.rc')
  lines = fileio.bytes_to_lines(cpioentry.content)
  buf = bytes()

  previous_line = ""

  for line in lines:
    if re.search(r"^\s+wait\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^\s+check_fs\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif re.search(r"^\s+mount\s+ext4\s+/dev/.*/cache.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    elif version == 'kk44' and \
        re.search(r"^on\s+fs_selinux\s*$", line):
      buf += fileio.encode(line)
      buf += fileio.encode("    mount_all fstab.qcom\n")
      buf += fileio.encode("    exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    elif re.search(r"^\s+mount_all\s+fstab.qcom.*$", line) and \
        re.search(r"^on\s+fs(_selinux)?.*$", previous_line):
      buf += fileio.encode(line)
      buf += fileio.encode(fileio.whitespace(line) + "exec /sbin/busybox-static sh /init.multiboot.mounting.sh\n")

    elif re.search(r"^.*setprop.*selinux.reload_policy.*$", line):
      buf += fileio.encode(re.sub(r"^", "#", line))

    else:
      buf += fileio.encode(line)

    previous_line = line

  cpioentry.set_content(buf)