# Copyright (C) 2021 The Android Open Source Project # # init.rc for microdroid. This contains a minimal script plus basic service definitions (e.g. apexd) # needed for microdroid to run. # TODO(b/179340780): support APEX init scripts # # IMPORTANT: Do not create world writable files or directories. # This is a common source of Android security bugs. # import /init.environ.rc # Cgroups are mounted right before early-init using list from /etc/cgroups.json on early-init start ueventd setprop ro.apex.updatable true setprop ro.debuggable 1 setprop ro.adb.secure 0 # Generate ld.config.txt exec -- /system/bin/bootstrap/linkerconfig --target /linkerconfig chmod 644 /linkerconfig/ld.config.txt # Run apexd-bootstrap so that APEXes that provide critical libraries # become available. Note that this is executed as exec_start to ensure that # the libraries are available to the processes started after this statement. exec_start apexd-bootstrap # Generate linker config based on apex mounted in bootstrap namespace update_linker_config on init # Mount binderfs mkdir /dev/binderfs mount binder binder /dev/binderfs stats=global chmod 0755 /dev/binderfs symlink /dev/binderfs/binder /dev/binder symlink /dev/binderfs/hwbinder /dev/hwbinder symlink /dev/binderfs/vndbinder /dev/vndbinder chmod 0666 /dev/binderfs/hwbinder chmod 0666 /dev/binderfs/binder chmod 0666 /dev/binderfs/vndbinder # Start logd before any other services run to ensure we capture all of their logs. start logd start servicemanager on load_persist_props_action start logd start logd-reinit # Mount filesystems and start core system services. on late-init trigger early-fs # Mount fstab in init.{$device}.rc by mount_all command. Optional parameter # '--early' can be specified to skip entries with 'latemount'. # /system and /vendor must be mounted by the end of the fs stage, # while /data is optional. trigger fs trigger post-fs # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter # to only mount entries with 'latemount'. This is needed if '--early' is # specified in the previous mount_all command on the fs stage. # With /system mounted and properties form /system + /factory available, # some services can be started. trigger late-fs # Load persist properties and override properties (if enabled) from /data. trigger load_persist_props_action # Should be before netd, but after apex, properties and logging is available. trigger load_bpf_programs # Now we can start zygote for devices with file based encryption trigger zygote-start # Remove a file to wake up anything waiting for firmware. trigger firmware_mounts_complete trigger early-boot trigger boot on post-fs # Once everything is setup, no need to modify /. # The bind+remount combination allows this to work in containers. mount rootfs rootfs / remount bind ro nodev # Currently, exec_start apexd-bootstrap is enough to run adb. # TODO(b/179342589): uncomment after turning off APEX session on microdroid # start apexd # Wait for apexd to finish activating APEXes before starting more processes. # wait_for_prop apexd.status activated start adbd service ueventd /system/bin/ueventd class core critical seclabel u:r:ueventd:s0 shutdown critical service console /system/bin/sh class core console disabled user shell group shell log readproc seclabel u:r:shell:s0 setenv HOSTNAME console service servicemanager /system/bin/servicemanager class core animation user system group system readproc critical # TODO(b/179342589): uncomment after turning off APEX session on microdroid # onrestart restart apexd onrestart class_restart main shutdown critical service logd /system/bin/logd socket logd stream 0666 logd logd socket logdr seqpacket 0666 logd logd socket logdw dgram+passcred 0222 logd logd file /proc/kmsg r file /dev/kmsg w user logd group logd system package_info readproc capabilities SYSLOG AUDIT_CONTROL priority 10 service logd-reinit /system/bin/logd --reinit oneshot disabled user logd group logd # Limit SELinux denial generation to 5/second service logd-auditctl /system/bin/auditctl -r 5 oneshot disabled user logd group logd capabilities AUDIT_CONTROL on fs write /dev/event-log-tags "# content owned by logd " chown logd logd /dev/event-log-tags chmod 0644 /dev/event-log-tags on property:sys.boot_completed=1 start logd-auditctl service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 class core socket adbd seqpacket 660 system system disabled seclabel u:r:adbd:s0 #TODO(b/179342589): uncomment after turning off APEX session on microdroid #service apexd /system/bin/apexd # interface aidl apexservice # class core # user root # group system # oneshot # disabled # does not start with the core class # reboot_on_failure reboot,apexd-failed service apexd-bootstrap /system/bin/apexd --bootstrap user root group system oneshot disabled reboot_on_failure reboot,bootloader,bootstrap-apexd-failed