blob: 61f9ae5ddbb2fa1daee085663a1b62525f9da473 [file] [log] [blame]
Inseob Kimdc2af862021-02-17 15:51:56 +09001# Copyright (C) 2021 The Android Open Source Project
2#
3# init.rc for microdroid. This contains a minimal script plus basic service definitions (e.g. apexd)
4# needed for microdroid to run.
5# TODO(b/179340780): support APEX init scripts
6#
7# IMPORTANT: Do not create world writable files or directories.
8# This is a common source of Android security bugs.
9#
10
11import /init.environ.rc
12
13# Cgroups are mounted right before early-init using list from /etc/cgroups.json
14on early-init
Inseob Kimdc2af862021-02-17 15:51:56 +090015
Jooyung Hanc36b18a2021-04-20 03:33:36 +090016 # TODO(b/185991357) eliminate bootstrap mount namespace
17 # Set up linker config subdirectories based on mount namespaces
18 mkdir /linkerconfig/bootstrap 0755
19 mkdir /linkerconfig/default 0755
20
21 # Generate ld.config.txt for early executed processes
22 exec -- /system/bin/bootstrap/linkerconfig --target /linkerconfig/bootstrap
23 chmod 644 /linkerconfig/bootstrap/ld.config.txt
24 copy /linkerconfig/bootstrap/ld.config.txt /linkerconfig/default/ld.config.txt
25 chmod 644 /linkerconfig/default/ld.config.txt
26
27 # Mount bootstrap linker configuration as current
28 mount none /linkerconfig/bootstrap /linkerconfig bind rec
29
30 start ueventd
Inseob Kim870e76b2021-02-25 17:38:32 +090031
Inseob Kimdc2af862021-02-17 15:51:56 +090032 # Run apexd-bootstrap so that APEXes that provide critical libraries
33 # become available. Note that this is executed as exec_start to ensure that
34 # the libraries are available to the processes started after this statement.
35 exec_start apexd-bootstrap
36
Inseob Kim870e76b2021-02-25 17:38:32 +090037 # Generate linker config based on apex mounted in bootstrap namespace
38 update_linker_config
39
Inseob Kimdc2af862021-02-17 15:51:56 +090040on init
41 # Mount binderfs
42 mkdir /dev/binderfs
43 mount binder binder /dev/binderfs stats=global
44 chmod 0755 /dev/binderfs
45
46 symlink /dev/binderfs/binder /dev/binder
47 symlink /dev/binderfs/hwbinder /dev/hwbinder
48 symlink /dev/binderfs/vndbinder /dev/vndbinder
49
50 chmod 0666 /dev/binderfs/hwbinder
51 chmod 0666 /dev/binderfs/binder
52 chmod 0666 /dev/binderfs/vndbinder
53
54 # Start logd before any other services run to ensure we capture all of their logs.
55 start logd
56
57 start servicemanager
58
59on load_persist_props_action
60 start logd
61 start logd-reinit
62
63# Mount filesystems and start core system services.
64on late-init
65 trigger early-fs
66
67 # Mount fstab in init.{$device}.rc by mount_all command. Optional parameter
68 # '--early' can be specified to skip entries with 'latemount'.
69 # /system and /vendor must be mounted by the end of the fs stage,
70 # while /data is optional.
71 trigger fs
72 trigger post-fs
73
74 # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter
75 # to only mount entries with 'latemount'. This is needed if '--early' is
76 # specified in the previous mount_all command on the fs stage.
77 # With /system mounted and properties form /system + /factory available,
78 # some services can be started.
79 trigger late-fs
80
81 # Load persist properties and override properties (if enabled) from /data.
82 trigger load_persist_props_action
83
84 # Should be before netd, but after apex, properties and logging is available.
85 trigger load_bpf_programs
86
87 # Now we can start zygote for devices with file based encryption
88 trigger zygote-start
89
90 # Remove a file to wake up anything waiting for firmware.
91 trigger firmware_mounts_complete
92
93 trigger early-boot
94 trigger boot
95
96on post-fs
97 # Once everything is setup, no need to modify /.
98 # The bind+remount combination allows this to work in containers.
99 mount rootfs rootfs / remount bind ro nodev
100
Jooyung Hanc36b18a2021-04-20 03:33:36 +0900101 enter_default_mount_ns
102
103 # Start apexd in the VM mode to avoid unnecessary overhead of session management.
104 exec - root system -- /system/bin/apexd --vm
105
106 perform_apex_config
Inseob Kimdc2af862021-02-17 15:51:56 +0900107
Jooyung Han017916b2021-04-20 03:57:19 +0900108 exec_start derive_sdk
109
Inseob Kimdc2af862021-02-17 15:51:56 +0900110 start adbd
111
112service ueventd /system/bin/ueventd
113 class core
114 critical
115 seclabel u:r:ueventd:s0
116 shutdown critical
117
118service console /system/bin/sh
119 class core
120 console
121 disabled
122 user shell
123 group shell log readproc
124 seclabel u:r:shell:s0
125 setenv HOSTNAME console
126
Inseob Kimdc2af862021-02-17 15:51:56 +0900127on fs
128 write /dev/event-log-tags "# content owned by logd
129"
130 chown logd logd /dev/event-log-tags
131 chmod 0644 /dev/event-log-tags
132
133on property:sys.boot_completed=1
134 start logd-auditctl
135