The meaning of the INSTALLD process in Android

Source: Internet
Author: User

1. Why do I need installd

As you can see from the output below, System_server runs as the system user. We know that Packagemanager runs in System_server. In other words, Packagemanager's identity is also the system user.

[Email protected]:/$ busybox PS

Busyboxps

PID USER Time COMMAND

......

701 System 0:23 System_server

146 Install 0:00/system/bin/installd

However, the system user does not have permission to access the application directory. The output below shows that the current user is system and it cannot access the/data/data/com.xiaomi.shop directory (this directory should be a directory for Xiaomi App Store apps).

[Email protected]:/data/data$ ID

Id

uid=1000 (system) gid=1000 (System) CONTEXT=U:R:TOOLBOX:S0

[Email protected]:/data/data$ ls-l com.xiaomi.shop

Ls-lcom.xiaomi.shop

Opendir failed, Permission denied

This is the reason why INSTALLD exists.

2. Why can INSTALLD access the application's directory (such as/data/data/com.xiaomi.shop)?

The source program for INSTALLD is in the FRAMEWORKS\NATIVE\CMDS\INSTALLD directory.

The following code is in the Install.c file.

static void Drop_privileges () {

......

struct __user_cap_header_struct capheader;

struct __user_cap_data_struct capdata[2];

memset (&capheader, 0,sizeof (Capheader));

memset (&capdata, 0, sizeof (capdata));

Capheader.version =_linux_capability_version_3;

capheader.pid = 0;

Capdata[cap_to_index (cap_dac_override)].permitted |= cap_to_mask (cap_dac_override);

......

if (Capset (&capheader, &capdata[0]) < 0) {

Aloge ("Capset failed:%s\n", Strerror (errno));

Exit (1);

}

}

int main (const int argc__unused, const char *argv[] __unused) {

......

Drop_privileges ();

......

}

As you can see from the code above, the INSTALLD process has cap_dac_override privileges (Privilege). According to Http://linux.die.net/man/7/capabilities, for processes with cap_dac_override privileges, Linux skips the check of read, write, and execute permissions on the file. Therefore, INSTALLD can access files in any directory.

Cap_dac_override

Bypass file read, write, and executepermission checks. (DAC is an abbreviation of "discretionary AccessControl".)

The meaning of the INSTALLD process in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.