blob: 14238a4af351719b9920ddbf254331d43250cf1a [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
15 start ueventd
16
Inseob Kim870e76b2021-02-25 17:38:32 +090017 # Generate ld.config.txt
18 exec -- /system/bin/bootstrap/linkerconfig --target /linkerconfig
19 chmod 644 /linkerconfig/ld.config.txt
20
Inseob Kimdc2af862021-02-17 15:51:56 +090021 # Run apexd-bootstrap so that APEXes that provide critical libraries
22 # become available. Note that this is executed as exec_start to ensure that
23 # the libraries are available to the processes started after this statement.
24 exec_start apexd-bootstrap
25
Inseob Kim870e76b2021-02-25 17:38:32 +090026 # Generate linker config based on apex mounted in bootstrap namespace
27 update_linker_config
28
Inseob Kimdc2af862021-02-17 15:51:56 +090029on init
30 # Mount binderfs
31 mkdir /dev/binderfs
32 mount binder binder /dev/binderfs stats=global
33 chmod 0755 /dev/binderfs
34
35 symlink /dev/binderfs/binder /dev/binder
36 symlink /dev/binderfs/hwbinder /dev/hwbinder
37 symlink /dev/binderfs/vndbinder /dev/vndbinder
38
39 chmod 0666 /dev/binderfs/hwbinder
40 chmod 0666 /dev/binderfs/binder
41 chmod 0666 /dev/binderfs/vndbinder
42
43 # Start logd before any other services run to ensure we capture all of their logs.
44 start logd
45
46 start servicemanager
47
48on load_persist_props_action
49 start logd
50 start logd-reinit
51
52# Mount filesystems and start core system services.
53on late-init
54 trigger early-fs
55
56 # Mount fstab in init.{$device}.rc by mount_all command. Optional parameter
57 # '--early' can be specified to skip entries with 'latemount'.
58 # /system and /vendor must be mounted by the end of the fs stage,
59 # while /data is optional.
60 trigger fs
61 trigger post-fs
62
63 # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter
64 # to only mount entries with 'latemount'. This is needed if '--early' is
65 # specified in the previous mount_all command on the fs stage.
66 # With /system mounted and properties form /system + /factory available,
67 # some services can be started.
68 trigger late-fs
69
70 # Load persist properties and override properties (if enabled) from /data.
71 trigger load_persist_props_action
72
73 # Should be before netd, but after apex, properties and logging is available.
74 trigger load_bpf_programs
75
76 # Now we can start zygote for devices with file based encryption
77 trigger zygote-start
78
79 # Remove a file to wake up anything waiting for firmware.
80 trigger firmware_mounts_complete
81
82 trigger early-boot
83 trigger boot
84
85on post-fs
86 # Once everything is setup, no need to modify /.
87 # The bind+remount combination allows this to work in containers.
88 mount rootfs rootfs / remount bind ro nodev
89
90 # Currently, exec_start apexd-bootstrap is enough to run adb.
91 # TODO(b/179342589): uncomment after turning off APEX session on microdroid
92 # start apexd
93 # Wait for apexd to finish activating APEXes before starting more processes.
94 # wait_for_prop apexd.status activated
95
96 start adbd
97
98service ueventd /system/bin/ueventd
99 class core
100 critical
101 seclabel u:r:ueventd:s0
102 shutdown critical
103
104service console /system/bin/sh
105 class core
106 console
107 disabled
108 user shell
109 group shell log readproc
110 seclabel u:r:shell:s0
111 setenv HOSTNAME console
112
Inseob Kim95d620c2021-03-11 14:20:24 +0900113# TODO(b/181093750): remove these after adding apex support
114service adbd /system/bin/adbd --root_seclabel=u:r:su:s0
115 class core
116 socket adbd seqpacket 660 system system
Inseob Kimdc2af862021-02-17 15:51:56 +0900117 disabled
Inseob Kim95d620c2021-03-11 14:20:24 +0900118 seclabel u:r:adbd:s0
Inseob Kimdc2af862021-02-17 15:51:56 +0900119
120on fs
121 write /dev/event-log-tags "# content owned by logd
122"
123 chown logd logd /dev/event-log-tags
124 chmod 0644 /dev/event-log-tags
125
126on property:sys.boot_completed=1
127 start logd-auditctl
128