Nick Kralevich | f3ef127 | 2012-03-14 15:22:54 -0700 | [diff] [blame] | 1 | # Copyright (C) 2012 The Android Open Source Project |
| 2 | # |
| 3 | # IMPORTANT: Do not create world writable files or directories. |
| 4 | # This is a common source of Android security bugs. |
| 5 | # |
| 6 | |
Ying Wang | 5748ee9 | 2013-07-23 18:03:37 -0700 | [diff] [blame] | 7 | import /init.environ.rc |
Mike Lockwood | 4f5d517 | 2012-04-04 11:26:59 -0700 | [diff] [blame] | 8 | import /init.usb.rc |
Mike Lockwood | 35ea5e4 | 2012-08-28 10:25:13 -0700 | [diff] [blame] | 9 | import /init.${ro.hardware}.rc |
Narayan Kamath | 4456a55 | 2014-03-31 11:08:02 +0100 | [diff] [blame] | 10 | import /init.${ro.zygote}.rc |
Todd Poynor | f1c50bf | 2012-09-20 20:10:53 -0700 | [diff] [blame] | 11 | import /init.trace.rc |
Dima Zavin | 7634bf8 | 2011-12-16 14:23:22 -0800 | [diff] [blame] | 12 | |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 13 | on early-init |
Dima Zavin | 4a25390 | 2011-11-04 12:45:52 -0700 | [diff] [blame] | 14 | # Set init and its forked children's oom_adj. |
Todd Poynor | 4676550 | 2013-09-16 19:32:03 -0700 | [diff] [blame] | 15 | write /proc/1/oom_score_adj -1000 |
Dima Zavin | 4a25390 | 2011-11-04 12:45:52 -0700 | [diff] [blame] | 16 | |
Stephen Smalley | deb41e5 | 2013-10-01 09:21:47 -0400 | [diff] [blame] | 17 | # Set the security context of /adb_keys if present. |
| 18 | restorecon /adb_keys |
| 19 | |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 20 | start ueventd |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 21 | |
| 22 | on init |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 23 | sysclktz 0 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 24 | |
Elliott Hughes | 3a5d71a | 2015-02-13 16:47:02 -0800 | [diff] [blame] | 25 | # Backward compatibility. |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | symlink /system/etc /etc |
Brian Swetland | bb6f68c | 2009-09-18 15:31:23 -0700 | [diff] [blame] | 27 | symlink /sys/kernel/debug /d |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | 3a5d71a | 2015-02-13 16:47:02 -0800 | [diff] [blame] | 29 | # Link /vendor to /system/vendor for devices without a vendor partition. |
Daniel Rosenberg | f67d6bd | 2014-06-26 14:55:04 -0700 | [diff] [blame] | 30 | symlink /system/vendor /vendor |
| 31 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 32 | # Create cgroup mount point for cpu accounting |
Mike Chan | 89f235c | 2010-03-01 11:36:10 -0800 | [diff] [blame] | 33 | mkdir /acct |
| 34 | mount cgroup none /acct cpuacct |
| 35 | mkdir /acct/uid |
| 36 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 37 | # Create cgroup mount point for memory |
Rom Lemarchand | 67b00d8 | 2013-09-10 17:39:30 -0700 | [diff] [blame] | 38 | mount tmpfs none /sys/fs/cgroup mode=0750,uid=0,gid=1000 |
| 39 | mkdir /sys/fs/cgroup/memory 0750 root system |
Rom Lemarchand | 435a52e | 2013-07-10 13:00:42 -0700 | [diff] [blame] | 40 | mount cgroup none /sys/fs/cgroup/memory memory |
| 41 | write /sys/fs/cgroup/memory/memory.move_charge_at_immigrate 1 |
| 42 | chown root system /sys/fs/cgroup/memory/tasks |
| 43 | chmod 0660 /sys/fs/cgroup/memory/tasks |
Rom Lemarchand | 67b00d8 | 2013-09-10 17:39:30 -0700 | [diff] [blame] | 44 | mkdir /sys/fs/cgroup/memory/sw 0750 root system |
Rom Lemarchand | 435a52e | 2013-07-10 13:00:42 -0700 | [diff] [blame] | 45 | write /sys/fs/cgroup/memory/sw/memory.swappiness 100 |
| 46 | write /sys/fs/cgroup/memory/sw/memory.move_charge_at_immigrate 1 |
| 47 | chown root system /sys/fs/cgroup/memory/sw/tasks |
| 48 | chmod 0660 /sys/fs/cgroup/memory/sw/tasks |
| 49 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 50 | mkdir /system |
| 51 | mkdir /data 0771 system system |
| 52 | mkdir /cache 0770 system cache |
Dmitry Shmidt | 720f08f | 2009-06-09 14:38:56 -0700 | [diff] [blame] | 53 | mkdir /config 0500 root root |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 54 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 55 | # Mount staging areas for devices managed by vold |
Jeff Sharkey | bfcd810 | 2012-08-22 13:57:25 -0700 | [diff] [blame] | 56 | # See storage config details at http://source.android.com/tech/storage/ |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 57 | mkdir /mnt 0755 root system |
| 58 | mount tmpfs tmpfs /mnt mode=0755,uid=0,gid=1000 |
| 59 | restorecon_recursive /mnt |
Jeff Sharkey | 5dd0f86 | 2012-08-17 16:01:16 -0700 | [diff] [blame] | 60 | |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 61 | mkdir /mnt/secure 0700 root root |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 62 | mkdir /mnt/secure/asec 0700 root root |
| 63 | mkdir /mnt/asec 0755 root system |
| 64 | mkdir /mnt/obb 0755 root system |
| 65 | mkdir /mnt/media_rw 0750 root media_rw |
| 66 | mkdir /mnt/user 0755 root root |
| 67 | mkdir /mnt/user/0 0755 root root |
Jeff Sharkey | ae0a5ac | 2015-04-06 14:08:54 -0700 | [diff] [blame] | 68 | mkdir /mnt/expand 0771 system system |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 69 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 70 | # sdcard_r is GID 1028 |
| 71 | mkdir /storage 0751 root sdcard_r |
| 72 | mount tmpfs tmpfs /storage mode=0751,uid=0,gid=1028 |
| 73 | restorecon_recursive /storage |
San Mehat | 6ea3cc6 | 2010-02-19 18:25:22 -0800 | [diff] [blame] | 74 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 75 | # Symlink to keep legacy apps working in multi-user world |
| 76 | mkdir /storage/self 0751 root sdcard_r |
| 77 | symlink /storage/self/primary /sdcard |
| 78 | symlink /mnt/user/0/primary /storage/self/primary |
Kenny Root | c7858a3 | 2010-07-15 12:14:44 -0700 | [diff] [blame] | 79 | |
Todd Poynor | aacded7 | 2013-07-10 15:19:44 -0700 | [diff] [blame] | 80 | # memory control cgroup |
| 81 | mkdir /dev/memcg 0700 root system |
| 82 | mount cgroup none /dev/memcg memory |
| 83 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 84 | write /proc/sys/kernel/panic_on_oops 1 |
| 85 | write /proc/sys/kernel/hung_task_timeout_secs 0 |
| 86 | write /proc/cpu/alignment 4 |
| 87 | write /proc/sys/kernel/sched_latency_ns 10000000 |
| 88 | write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 |
San Mehat | 4322f2d | 2009-06-29 08:47:43 -0700 | [diff] [blame] | 89 | write /proc/sys/kernel/sched_compat_yield 1 |
San Mehat | 7baff71 | 2009-09-16 13:32:23 -0700 | [diff] [blame] | 90 | write /proc/sys/kernel/sched_child_runs_first 0 |
Nick Kralevich | d707fb3 | 2011-10-06 11:47:11 -0700 | [diff] [blame] | 91 | write /proc/sys/kernel/randomize_va_space 2 |
Nick Kralevich | 2e7c833 | 2011-11-02 08:51:37 -0700 | [diff] [blame] | 92 | write /proc/sys/kernel/kptr_restrict 2 |
Nick Kralevich | 27cca21 | 2011-12-05 14:48:08 -0800 | [diff] [blame] | 93 | write /proc/sys/vm/mmap_min_addr 32768 |
Nick Kralevich | be341cc | 2013-02-21 18:36:43 -0800 | [diff] [blame] | 94 | write /proc/sys/net/ipv4/ping_group_range "0 2147483647" |
Mark Salyzyn | 581edc1 | 2013-11-20 13:38:52 -0800 | [diff] [blame] | 95 | write /proc/sys/net/unix/max_dgram_qlen 300 |
Glenn Kasten | b91bd9f | 2012-04-19 16:18:37 -0700 | [diff] [blame] | 96 | write /proc/sys/kernel/sched_rt_runtime_us 950000 |
| 97 | write /proc/sys/kernel/sched_rt_period_us 1000000 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 98 | |
Sreeram Ramachandran | fd94922 | 2014-04-09 17:44:56 -0700 | [diff] [blame] | 99 | # reflect fwmark from incoming packets onto generated replies |
| 100 | write /proc/sys/net/ipv4/fwmark_reflect 1 |
| 101 | write /proc/sys/net/ipv6/fwmark_reflect 1 |
| 102 | |
| 103 | # set fwmark on accepted sockets |
| 104 | write /proc/sys/net/ipv4/tcp_fwmark_accept 1 |
| 105 | |
Greg Hackmann | f3fd122 | 2014-12-03 09:57:00 -0800 | [diff] [blame] | 106 | # disable icmp redirects |
| 107 | write /proc/sys/net/ipv4/conf/all/accept_redirects 0 |
| 108 | write /proc/sys/net/ipv6/conf/all/accept_redirects 0 |
| 109 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 110 | # Create cgroup mount points for process groups |
San Mehat | 529520e | 2009-10-06 11:22:55 -0700 | [diff] [blame] | 111 | mkdir /dev/cpuctl |
San Mehat | b91bf4b | 2010-02-27 08:20:11 -0800 | [diff] [blame] | 112 | mount cgroup none /dev/cpuctl cpu |
San Mehat | 92175e0 | 2010-01-17 12:21:42 -0800 | [diff] [blame] | 113 | chown system system /dev/cpuctl |
San Mehat | 529520e | 2009-10-06 11:22:55 -0700 | [diff] [blame] | 114 | chown system system /dev/cpuctl/tasks |
Riley Andrews | 522d72b | 2014-10-03 17:02:53 -0700 | [diff] [blame] | 115 | chmod 0666 /dev/cpuctl/tasks |
San Mehat | 529520e | 2009-10-06 11:22:55 -0700 | [diff] [blame] | 116 | write /dev/cpuctl/cpu.shares 1024 |
Riley Andrews | 522d72b | 2014-10-03 17:02:53 -0700 | [diff] [blame] | 117 | write /dev/cpuctl/cpu.rt_runtime_us 800000 |
Glenn Kasten | b91bd9f | 2012-04-19 16:18:37 -0700 | [diff] [blame] | 118 | write /dev/cpuctl/cpu.rt_period_us 1000000 |
San Mehat | 529520e | 2009-10-06 11:22:55 -0700 | [diff] [blame] | 119 | |
Riley Andrews | 522d72b | 2014-10-03 17:02:53 -0700 | [diff] [blame] | 120 | mkdir /dev/cpuctl/bg_non_interactive |
| 121 | chown system system /dev/cpuctl/bg_non_interactive/tasks |
| 122 | chmod 0666 /dev/cpuctl/bg_non_interactive/tasks |
San Mehat | 529520e | 2009-10-06 11:22:55 -0700 | [diff] [blame] | 123 | # 5.0 % |
Riley Andrews | 522d72b | 2014-10-03 17:02:53 -0700 | [diff] [blame] | 124 | write /dev/cpuctl/bg_non_interactive/cpu.shares 52 |
| 125 | write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 700000 |
| 126 | write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000 |
Glenn Kasten | b91bd9f | 2012-04-19 16:18:37 -0700 | [diff] [blame] | 127 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 128 | # qtaguid will limit access to specific data based on group memberships. |
| 129 | # net_bw_acct grants impersonation of socket owners. |
| 130 | # net_bw_stats grants access to other apps' detailed tagged-socket stats. |
JP Abgrall | 3e54aab | 2013-01-04 14:34:58 -0800 | [diff] [blame] | 131 | chown root net_bw_acct /proc/net/xt_qtaguid/ctrl |
| 132 | chown root net_bw_stats /proc/net/xt_qtaguid/stats |
| 133 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 134 | # Allow everybody to read the xt_qtaguid resource tracking misc dev. |
| 135 | # This is needed by any process that uses socket tagging. |
JP Abgrall | 8e3ff70 | 2011-09-11 16:12:27 -0700 | [diff] [blame] | 136 | chmod 0644 /dev/xt_qtaguid |
| 137 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 138 | # Create location for fs_mgr to store abbreviated output from filesystem |
| 139 | # checker programs. |
Ken Sumrall | 4eaf905 | 2013-09-18 17:49:21 -0700 | [diff] [blame] | 140 | mkdir /dev/fscklogs 0770 root system |
| 141 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 142 | # pstore/ramoops previous console log |
Todd Poynor | 479efb5 | 2013-11-21 20:23:54 -0800 | [diff] [blame] | 143 | mount pstore pstore /sys/fs/pstore |
| 144 | chown system log /sys/fs/pstore/console-ramoops |
| 145 | chmod 0440 /sys/fs/pstore/console-ramoops |
Mark Salyzyn | 4b0313e | 2014-12-15 07:52:19 -0800 | [diff] [blame] | 146 | chown system log /sys/fs/pstore/pmsg-ramoops-0 |
| 147 | chmod 0440 /sys/fs/pstore/pmsg-ramoops-0 |
Todd Poynor | 479efb5 | 2013-11-21 20:23:54 -0800 | [diff] [blame] | 148 | |
Greg Hackmann | cee8757 | 2015-01-26 10:40:29 -0800 | [diff] [blame] | 149 | # enable armv8_deprecated instruction hooks |
| 150 | write /proc/sys/abi/swp 1 |
| 151 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 152 | # Healthd can trigger a full boot from charger mode by signaling this |
| 153 | # property when the power button is held. |
| 154 | on property:sys.boot_from_charger_mode=1 |
| 155 | class_stop charger |
| 156 | trigger late-init |
| 157 | |
| 158 | # Load properties from /system/ + /factory after fs mount. |
| 159 | on load_all_props_action |
| 160 | load_all_props |
Mark Salyzyn | 5c39e0a | 2015-04-20 08:55:02 -0700 | [diff] [blame] | 161 | start logd |
Mark Salyzyn | 48d0606 | 2015-03-11 14:45:05 -0700 | [diff] [blame] | 162 | start logd-reinit |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 163 | |
Riley Andrews | 80c7a5e | 2014-07-11 15:05:23 -0700 | [diff] [blame] | 164 | # Indicate to fw loaders that the relevant mounts are up. |
| 165 | on firmware_mounts_complete |
| 166 | rm /dev/.booting |
| 167 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 168 | # Mount filesystems and start core system services. |
| 169 | on late-init |
| 170 | trigger early-fs |
| 171 | trigger fs |
| 172 | trigger post-fs |
| 173 | trigger post-fs-data |
| 174 | |
| 175 | # Load properties from /system/ + /factory after fs mount. Place |
| 176 | # this in another action so that the load will be scheduled after the prior |
| 177 | # issued fs triggers have completed. |
| 178 | trigger load_all_props_action |
| 179 | |
Riley Andrews | 67cb1ae | 2014-07-15 20:39:41 -0700 | [diff] [blame] | 180 | # Remove a file to wake up anything waiting for firmware. |
| 181 | trigger firmware_mounts_complete |
| 182 | |
Riley Andrews | e4b7b29 | 2014-06-16 15:06:21 -0700 | [diff] [blame] | 183 | trigger early-boot |
| 184 | trigger boot |
| 185 | |
Riley Andrews | 80c7a5e | 2014-07-11 15:05:23 -0700 | [diff] [blame] | 186 | |
Colin Cross | 31712be | 2010-04-09 12:26:06 -0700 | [diff] [blame] | 187 | on post-fs |
Mark Salyzyn | 124ff15 | 2015-04-07 15:32:12 -0700 | [diff] [blame] | 188 | start logd |
Brian Swetland | 56de7a1 | 2010-09-08 15:06:45 -0700 | [diff] [blame] | 189 | # once everything is setup, no need to modify / |
| 190 | mount rootfs rootfs / ro remount |
Jeff Sharkey | 885342a | 2012-08-14 21:00:22 -0700 | [diff] [blame] | 191 | # mount shared so changes propagate into child namespaces |
| 192 | mount rootfs rootfs / shared rec |
Brian Swetland | 56de7a1 | 2010-09-08 15:06:45 -0700 | [diff] [blame] | 193 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 194 | # We chown/chmod /cache again so because mount is run as root + defaults |
| 195 | chown system cache /cache |
| 196 | chmod 0770 /cache |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 197 | # We restorecon /cache in case the cache partition has been reset. |
Nick Kralevich | e169591 | 2014-07-09 12:39:21 -0700 | [diff] [blame] | 198 | restorecon_recursive /cache |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 199 | |
Tao Bao | e48aed0 | 2015-05-11 14:08:18 -0700 | [diff] [blame] | 200 | # Create /cache/recovery in case it's not there. It'll also fix the odd |
| 201 | # permissions if created by the recovery system. |
| 202 | mkdir /cache/recovery 0770 system cache |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 203 | |
| 204 | #change permissions on vmallocinfo so we can grab it from bugreports |
| 205 | chown root log /proc/vmallocinfo |
| 206 | chmod 0440 /proc/vmallocinfo |
| 207 | |
Dima Zavin | 9481266 | 2012-09-25 14:22:02 -0700 | [diff] [blame] | 208 | chown root log /proc/slabinfo |
| 209 | chmod 0440 /proc/slabinfo |
| 210 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 211 | #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks |
| 212 | chown root system /proc/kmsg |
| 213 | chmod 0440 /proc/kmsg |
| 214 | chown root system /proc/sysrq-trigger |
| 215 | chmod 0220 /proc/sysrq-trigger |
Colin Cross | b35e36e | 2012-08-02 18:14:33 -0700 | [diff] [blame] | 216 | chown system log /proc/last_kmsg |
| 217 | chmod 0440 /proc/last_kmsg |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 218 | |
dcashman | 5822a4a | 2014-03-25 16:31:07 -0700 | [diff] [blame] | 219 | # make the selinux kernel policy world-readable |
| 220 | chmod 0444 /sys/fs/selinux/policy |
| 221 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 222 | # create the lost+found directories, so as to enforce our permissions |
Chia-chi Yeh | ea74414 | 2011-07-08 16:52:18 -0700 | [diff] [blame] | 223 | mkdir /cache/lost+found 0770 root root |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 224 | |
| 225 | on post-fs-data |
Colin Cross | 31712be | 2010-04-09 12:26:06 -0700 | [diff] [blame] | 226 | # We chown/chmod /data again so because mount is run as root + defaults |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 227 | chown system system /data |
| 228 | chmod 0771 /data |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 229 | # We restorecon /data in case the userdata partition has been reset. |
| 230 | restorecon /data |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 231 | |
Jeff Sharkey | fc00048 | 2015-03-16 10:17:47 -0700 | [diff] [blame] | 232 | # Emulated internal storage area |
| 233 | mkdir /data/media 0770 media_rw media_rw |
| 234 | |
Paul Lawrence | 0a423d9 | 2015-04-28 22:07:10 +0000 | [diff] [blame] | 235 | # Make sure we have the device encryption key |
| 236 | start logd |
| 237 | start vold |
| 238 | installkey /data |
| 239 | |
Yongqin Liu | a197ff1 | 2014-12-05 13:45:02 +0800 | [diff] [blame] | 240 | # Start bootcharting as soon as possible after the data partition is |
| 241 | # mounted to collect more data. |
| 242 | mkdir /data/bootchart 0755 shell shell |
| 243 | bootchart_init |
| 244 | |
Nick Kralevich | b410eb1 | 2013-09-17 16:18:23 -0700 | [diff] [blame] | 245 | # Avoid predictable entropy pool. Carry over entropy from previous boot. |
| 246 | copy /data/system/entropy.dat /dev/urandom |
| 247 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 248 | # create basic filesystem structure |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 249 | mkdir /data/misc 01771 system misc |
Benoit Goby | 0245e15 | 2012-05-09 17:27:53 -0700 | [diff] [blame] | 250 | mkdir /data/misc/adb 02750 system shell |
Matthew Xie | 971153a | 2012-10-04 12:35:27 -0700 | [diff] [blame] | 251 | mkdir /data/misc/bluedroid 0770 bluetooth net_bt_stack |
Jaikumar Ganesh | eafdd86 | 2010-01-07 20:24:55 -0800 | [diff] [blame] | 252 | mkdir /data/misc/bluetooth 0770 system system |
Chia-chi Yeh | 9b4f1ff | 2009-09-18 10:35:26 +0800 | [diff] [blame] | 253 | mkdir /data/misc/keystore 0700 keystore keystore |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 254 | mkdir /data/misc/gatekeeper 0700 system system |
Brian Carlstrom | 0491893 | 2011-06-30 22:50:29 -0700 | [diff] [blame] | 255 | mkdir /data/misc/keychain 0771 system system |
Sreeram Ramachandran | b46efdb | 2014-07-07 22:09:54 -0700 | [diff] [blame] | 256 | mkdir /data/misc/net 0750 root shell |
Robert Greenwalt | 2aa33a3 | 2013-07-16 09:46:17 -0700 | [diff] [blame] | 257 | mkdir /data/misc/radio 0770 system radio |
Robert Greenwalt | d6d4780 | 2012-09-26 16:04:27 -0700 | [diff] [blame] | 258 | mkdir /data/misc/sms 0770 system radio |
Elliott Hughes | f820e85 | 2012-10-19 18:10:05 -0700 | [diff] [blame] | 259 | mkdir /data/misc/zoneinfo 0775 system system |
Chia-chi Yeh | 9bb4d41 | 2011-07-08 20:03:03 -0700 | [diff] [blame] | 260 | mkdir /data/misc/vpn 0770 system vpn |
Torne (Richard Coles) | 234f696 | 2014-05-22 18:40:21 +0100 | [diff] [blame] | 261 | mkdir /data/misc/shared_relro 0771 shared_relro shared_relro |
Oscar Montemayor | d0aa32c | 2010-01-06 13:18:12 -0800 | [diff] [blame] | 262 | mkdir /data/misc/systemkeys 0700 system system |
Mike Lockwood | 48d116e | 2009-07-08 18:42:08 -0400 | [diff] [blame] | 263 | mkdir /data/misc/wifi 0770 wifi wifi |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 264 | mkdir /data/misc/wifi/sockets 0770 wifi wifi |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 265 | mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi |
Jaewan Kim | 373d9fa | 2014-03-10 17:13:07 +0900 | [diff] [blame] | 266 | mkdir /data/misc/ethernet 0770 system system |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 267 | mkdir /data/misc/dhcp 0770 dhcp dhcp |
Robin Lee | 3094f82 | 2014-04-25 15:21:35 +0100 | [diff] [blame] | 268 | mkdir /data/misc/user 0771 root root |
Dehao Chen | ac725c1 | 2015-05-05 15:05:39 -0700 | [diff] [blame] | 269 | mkdir /data/misc/perfprofd 0775 root root |
Stephen Smalley | 82e87ed | 2014-01-29 13:53:03 -0500 | [diff] [blame] | 270 | # give system access to wpa_supplicant.conf for backup and restore |
Amith Yamasani | eefef32 | 2009-07-02 12:08:13 -0700 | [diff] [blame] | 271 | chmod 0660 /data/misc/wifi/wpa_supplicant.conf |
Chia-chi Yeh | 5ebced3 | 2012-03-07 14:52:10 -0800 | [diff] [blame] | 272 | mkdir /data/local 0751 root root |
Glenn Kasten | b0f908a | 2013-02-22 14:54:45 -0800 | [diff] [blame] | 273 | mkdir /data/misc/media 0700 media media |
Jeff Sharkey | 25775e8 | 2015-03-31 15:03:29 -0700 | [diff] [blame] | 274 | mkdir /data/misc/vold 0700 root root |
Stephen Smalley | deb41e5 | 2013-10-01 09:21:47 -0400 | [diff] [blame] | 275 | |
Nick Kralevich | f3ef127 | 2012-03-14 15:22:54 -0700 | [diff] [blame] | 276 | # For security reasons, /data/local/tmp should always be empty. |
| 277 | # Do not place files or directories in /data/local/tmp |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 278 | mkdir /data/local/tmp 0771 shell shell |
| 279 | mkdir /data/data 0771 system system |
| 280 | mkdir /data/app-private 0771 system system |
Kenny Root | f8bbaba | 2012-04-12 15:01:52 -0700 | [diff] [blame] | 281 | mkdir /data/app-asec 0700 root root |
Kenny Root | 5054417 | 2012-09-08 22:39:25 -0700 | [diff] [blame] | 282 | mkdir /data/app-lib 0771 system system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 283 | mkdir /data/app 0771 system system |
| 284 | mkdir /data/property 0700 root root |
Nick Kralevich | 0359d77 | 2015-01-30 17:38:06 -0800 | [diff] [blame] | 285 | mkdir /data/tombstones 0771 system system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 286 | |
Chia-chi Yeh | ea74414 | 2011-07-08 16:52:18 -0700 | [diff] [blame] | 287 | # create dalvik-cache, so as to enforce our permissions |
Alex Light | 3878ebd | 2014-08-27 15:40:05 -0700 | [diff] [blame] | 288 | mkdir /data/dalvik-cache 0771 root root |
Nick Kralevich | 347ee51 | 2014-06-11 18:32:15 -0700 | [diff] [blame] | 289 | mkdir /data/dalvik-cache/profiles 0711 system system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 290 | |
MÃ¥rten Kongstad | b45280d | 2011-05-30 10:24:54 +0200 | [diff] [blame] | 291 | # create resource-cache and double-check the perms |
| 292 | mkdir /data/resource-cache 0771 system system |
| 293 | chown system system /data/resource-cache |
| 294 | chmod 0771 /data/resource-cache |
| 295 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 296 | # create the lost+found directories, so as to enforce our permissions |
Chia-chi Yeh | ea74414 | 2011-07-08 16:52:18 -0700 | [diff] [blame] | 297 | mkdir /data/lost+found 0770 root root |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 298 | |
James Dong | 09cdc0e | 2012-01-06 15:19:26 -0800 | [diff] [blame] | 299 | # create directory for DRM plug-ins - give drm the read/write access to |
| 300 | # the following directory. |
| 301 | mkdir /data/drm 0770 drm drm |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 302 | |
Jeff Tinker | 08d6430 | 2013-04-23 19:54:17 -0700 | [diff] [blame] | 303 | # create directory for MediaDrm plug-ins - give drm the read/write access to |
| 304 | # the following directory. |
| 305 | mkdir /data/mediadrm 0770 mediadrm mediadrm |
| 306 | |
Nick Kralevich | 89252ce | 2014-10-20 21:53:56 -0700 | [diff] [blame] | 307 | mkdir /data/adb 0700 root root |
| 308 | |
Jeff Sharkey | fb4f7ac | 2013-03-14 14:27:38 -0700 | [diff] [blame] | 309 | # symlink to bugreport storage location |
| 310 | symlink /data/data/com.android.shell/files/bugreports /data/bugreports |
| 311 | |
William Roberts | bfd71b4 | 2013-01-23 14:05:04 -0800 | [diff] [blame] | 312 | # Separate location for storing security policy files on data |
William Roberts | d43bab7 | 2013-04-15 13:56:22 -0700 | [diff] [blame] | 313 | mkdir /data/security 0711 system system |
William Roberts | bfd71b4 | 2013-01-23 14:05:04 -0800 | [diff] [blame] | 314 | |
Paul Lawrence | c410b3b | 2015-03-26 15:49:42 +0000 | [diff] [blame] | 315 | # Create all remaining /data root dirs so that they are made through init |
| 316 | # and get proper encryption policy installed |
| 317 | mkdir /data/backup 0700 system system |
| 318 | mkdir /data/media 0770 media_rw media_rw |
| 319 | mkdir /data/ss 0700 system system |
| 320 | mkdir /data/system 0775 system system |
Nick Kralevich | 9c0437f | 2015-04-07 16:44:08 -0700 | [diff] [blame] | 321 | mkdir /data/system/heapdump 0700 system system |
Paul Lawrence | c410b3b | 2015-03-26 15:49:42 +0000 | [diff] [blame] | 322 | mkdir /data/user 0711 system system |
| 323 | |
Stephen Smalley | 6552f68 | 2013-08-26 10:45:05 -0400 | [diff] [blame] | 324 | # Reload policy from /data/security if present. |
| 325 | setprop selinux.reload_policy 1 |
| 326 | |
Stephen Smalley | f2b7ee7 | 2014-02-06 13:52:52 -0500 | [diff] [blame] | 327 | # Set SELinux security contexts on upgrade or policy update. |
| 328 | restorecon_recursive /data |
| 329 | |
Neil Fuller | 0891322 | 2015-03-31 18:24:29 +0100 | [diff] [blame] | 330 | # Check any timezone data in /data is newer than the copy in /system, delete if not. |
Nick Kralevich | 32512e7 | 2015-06-03 13:05:28 -0700 | [diff] [blame] | 331 | exec - system system -- /system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo |
Neil Fuller | 0891322 | 2015-03-31 18:24:29 +0100 | [diff] [blame] | 332 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 333 | # If there is no fs-post-data action in the init.<device>.rc file, you |
| 334 | # must uncomment this line, otherwise encrypted filesystems |
| 335 | # won't work. |
| 336 | # Set indication (checked by vold) that we have finished this action |
| 337 | #setprop vold.post_fs_data_done 1 |
| 338 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 339 | on boot |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 340 | # basic network init |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 341 | ifup lo |
| 342 | hostname localhost |
| 343 | domainname localdomain |
| 344 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 345 | # set RLIMIT_NICE to allow priorities from 19 to -20 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 346 | setrlimit 13 40 40 |
| 347 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 348 | # Memory management. Basic kernel parameters, and allow the high |
| 349 | # level system server to be able to adjust the kernel OOM driver |
| 350 | # parameters to match how it is managing things. |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 351 | write /proc/sys/vm/overcommit_memory 1 |
The Android Open Source Project | e037fd7 | 2009-03-13 13:04:37 -0700 | [diff] [blame] | 352 | write /proc/sys/vm/min_free_order_shift 4 |
Dianne Hackborn | 06787f4 | 2011-08-07 16:30:24 -0700 | [diff] [blame] | 353 | chown root system /sys/module/lowmemorykiller/parameters/adj |
Daniel Cardenas | 429e742 | 2015-03-20 00:07:57 +0000 | [diff] [blame] | 354 | chmod 0664 /sys/module/lowmemorykiller/parameters/adj |
Dianne Hackborn | 06787f4 | 2011-08-07 16:30:24 -0700 | [diff] [blame] | 355 | chown root system /sys/module/lowmemorykiller/parameters/minfree |
Daniel Cardenas | 429e742 | 2015-03-20 00:07:57 +0000 | [diff] [blame] | 356 | chmod 0664 /sys/module/lowmemorykiller/parameters/minfree |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 357 | |
San Mehat | 831d8e1 | 2009-10-13 12:24:47 -0700 | [diff] [blame] | 358 | # Tweak background writeout |
| 359 | write /proc/sys/vm/dirty_expire_centisecs 200 |
| 360 | write /proc/sys/vm/dirty_background_ratio 5 |
| 361 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 362 | # Permissions for System Server and daemons. |
| 363 | chown radio system /sys/android_power/state |
| 364 | chown radio system /sys/android_power/request_state |
| 365 | chown radio system /sys/android_power/acquire_full_wake_lock |
| 366 | chown radio system /sys/android_power/acquire_partial_wake_lock |
| 367 | chown radio system /sys/android_power/release_wake_lock |
Arve Hjønnevåg | 70a163f | 2012-05-02 17:57:50 -0700 | [diff] [blame] | 368 | chown system system /sys/power/autosleep |
Arve Hjønnevåg | 1670f83 | 2012-03-20 20:33:09 -0700 | [diff] [blame] | 369 | chown system system /sys/power/state |
| 370 | chown system system /sys/power/wakeup_count |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 371 | chown radio system /sys/power/wake_lock |
| 372 | chown radio system /sys/power/wake_unlock |
| 373 | chmod 0660 /sys/power/state |
| 374 | chmod 0660 /sys/power/wake_lock |
| 375 | chmod 0660 /sys/power/wake_unlock |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 376 | |
| 377 | chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate |
| 378 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate |
Todd Poynor | 2b5b3bb | 2012-12-20 18:52:03 -0800 | [diff] [blame] | 379 | chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack |
| 380 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 381 | chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time |
| 382 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time |
| 383 | chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq |
| 384 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq |
Todd Poynor | 2b5b3bb | 2012-12-20 18:52:03 -0800 | [diff] [blame] | 385 | chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads |
| 386 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 387 | chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load |
| 388 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load |
Todd Poynor | f35c203 | 2012-04-19 13:17:24 -0700 | [diff] [blame] | 389 | chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay |
| 390 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay |
Todd Poynor | 8d3ea1d | 2012-04-24 15:37:13 -0700 | [diff] [blame] | 391 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boost |
| 392 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost |
Todd Poynor | 4ff10e6 | 2012-05-03 15:20:48 -0700 | [diff] [blame] | 393 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse |
Todd Poynor | 33045a6 | 2012-04-27 20:21:18 -0700 | [diff] [blame] | 394 | chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost |
| 395 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost |
Todd Poynor | 4f247d7 | 2012-12-19 17:43:06 -0800 | [diff] [blame] | 396 | chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration |
| 397 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration |
Todd Poynor | 6b5de1c | 2013-03-25 13:17:13 -0700 | [diff] [blame] | 398 | chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy |
| 399 | chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy |
Todd Poynor | 0653b97 | 2012-04-11 14:48:51 -0700 | [diff] [blame] | 400 | |
| 401 | # Assume SMP uses shared cpufreq policy for all CPUs |
| 402 | chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq |
| 403 | chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq |
| 404 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 405 | chown system system /sys/class/timed_output/vibrator/enable |
| 406 | chown system system /sys/class/leds/keyboard-backlight/brightness |
| 407 | chown system system /sys/class/leds/lcd-backlight/brightness |
| 408 | chown system system /sys/class/leds/button-backlight/brightness |
The Android Open Source Project | f614d64 | 2009-03-18 17:39:49 -0700 | [diff] [blame] | 409 | chown system system /sys/class/leds/jogball-backlight/brightness |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 410 | chown system system /sys/class/leds/red/brightness |
| 411 | chown system system /sys/class/leds/green/brightness |
| 412 | chown system system /sys/class/leds/blue/brightness |
| 413 | chown system system /sys/class/leds/red/device/grpfreq |
| 414 | chown system system /sys/class/leds/red/device/grppwm |
| 415 | chown system system /sys/class/leds/red/device/blink |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 416 | chown system system /sys/class/timed_output/vibrator/enable |
| 417 | chown system system /sys/module/sco/parameters/disable_esco |
| 418 | chown system system /sys/kernel/ipv4/tcp_wmem_min |
| 419 | chown system system /sys/kernel/ipv4/tcp_wmem_def |
| 420 | chown system system /sys/kernel/ipv4/tcp_wmem_max |
| 421 | chown system system /sys/kernel/ipv4/tcp_rmem_min |
| 422 | chown system system /sys/kernel/ipv4/tcp_rmem_def |
| 423 | chown system system /sys/kernel/ipv4/tcp_rmem_max |
| 424 | chown root radio /proc/cmdline |
| 425 | |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 426 | # Define default initial receive window size in segments. |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 427 | setprop net.tcp.default_init_rwnd 60 |
| 428 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 429 | class_start core |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 430 | |
| 431 | on nonencrypted |
Paul Lawrence | 13d5bb4 | 2014-01-30 10:43:52 -0800 | [diff] [blame] | 432 | class_start main |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 433 | class_start late_start |
| 434 | |
Paul Lawrence | 13d5bb4 | 2014-01-30 10:43:52 -0800 | [diff] [blame] | 435 | on property:vold.decrypt=trigger_default_encryption |
Paul Lawrence | 13d5bb4 | 2014-01-30 10:43:52 -0800 | [diff] [blame] | 436 | start defaultcrypto |
| 437 | |
Paul Lawrence | 166fa3d | 2014-02-03 13:27:49 -0800 | [diff] [blame] | 438 | on property:vold.decrypt=trigger_encryption |
| 439 | start surfaceflinger |
| 440 | start encrypt |
Paul Lawrence | 166fa3d | 2014-02-03 13:27:49 -0800 | [diff] [blame] | 441 | |
Riley Andrews | 1bbef88 | 2014-06-26 13:55:03 -0700 | [diff] [blame] | 442 | on property:sys.init_log_level=* |
| 443 | loglevel ${sys.init_log_level} |
| 444 | |
Dima Zavin | ca47cef | 2011-08-24 15:28:23 -0700 | [diff] [blame] | 445 | on charger |
| 446 | class_start charger |
| 447 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 448 | on property:vold.decrypt=trigger_reset_main |
| 449 | class_reset main |
| 450 | |
Ken Sumrall | c5c5103 | 2011-03-08 17:01:29 -0800 | [diff] [blame] | 451 | on property:vold.decrypt=trigger_load_persist_props |
| 452 | load_persist_props |
Mark Salyzyn | 5c39e0a | 2015-04-20 08:55:02 -0700 | [diff] [blame] | 453 | start logd |
Mark Salyzyn | 48d0606 | 2015-03-11 14:45:05 -0700 | [diff] [blame] | 454 | start logd-reinit |
Ken Sumrall | c5c5103 | 2011-03-08 17:01:29 -0800 | [diff] [blame] | 455 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 456 | on property:vold.decrypt=trigger_post_fs_data |
| 457 | trigger post-fs-data |
| 458 | |
Ken Sumrall | e434915 | 2011-01-17 14:26:34 -0800 | [diff] [blame] | 459 | on property:vold.decrypt=trigger_restart_min_framework |
| 460 | class_start main |
| 461 | |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 462 | on property:vold.decrypt=trigger_restart_framework |
| 463 | class_start main |
| 464 | class_start late_start |
| 465 | |
| 466 | on property:vold.decrypt=trigger_shutdown_framework |
| 467 | class_reset late_start |
| 468 | class_reset main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 469 | |
Nick Kralevich | ca8e66a | 2013-04-18 12:20:02 -0700 | [diff] [blame] | 470 | on property:sys.powerctl=* |
| 471 | powerctl ${sys.powerctl} |
| 472 | |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 473 | # system server cannot write to /proc/sys files, |
| 474 | # and chown/chmod does not work for /proc/sys/ entries. |
| 475 | # So proxy writes through init. |
Colin Cross | 57fdb5c | 2013-07-25 10:34:30 -0700 | [diff] [blame] | 476 | on property:sys.sysctl.extra_free_kbytes=* |
| 477 | write /proc/sys/vm/extra_free_kbytes ${sys.sysctl.extra_free_kbytes} |
Riley Andrews | 6dfdc7c | 2014-06-18 20:35:40 -0700 | [diff] [blame] | 478 | |
JP Abgrall | 7c862c8 | 2014-02-21 12:05:01 -0800 | [diff] [blame] | 479 | # "tcp_default_init_rwnd" Is too long! |
| 480 | on property:sys.sysctl.tcp_def_init_rwnd=* |
| 481 | write /proc/sys/net/ipv4/tcp_default_init_rwnd ${sys.sysctl.tcp_def_init_rwnd} |
| 482 | |
Colin Cross | 57fdb5c | 2013-07-25 10:34:30 -0700 | [diff] [blame] | 483 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 484 | ## Daemon processes to be run by init. |
| 485 | ## |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 486 | service ueventd /sbin/ueventd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 487 | class core |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 488 | critical |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 489 | seclabel u:r:ueventd:s0 |
Colin Cross | f83d0b9 | 2010-04-21 12:04:20 -0700 | [diff] [blame] | 490 | |
Mark Salyzyn | 3c253dc | 2014-03-21 16:06:54 -0700 | [diff] [blame] | 491 | service logd /system/bin/logd |
| 492 | class core |
| 493 | socket logd stream 0666 logd logd |
| 494 | socket logdr seqpacket 0666 logd logd |
| 495 | socket logdw dgram 0222 logd logd |
Mark Salyzyn | 3c253dc | 2014-03-21 16:06:54 -0700 | [diff] [blame] | 496 | |
Mark Salyzyn | 48d0606 | 2015-03-11 14:45:05 -0700 | [diff] [blame] | 497 | service logd-reinit /system/bin/logd --reinit |
| 498 | oneshot |
| 499 | disabled |
| 500 | |
Todd Poynor | 13f4c9f | 2013-06-19 15:09:35 -0700 | [diff] [blame] | 501 | service healthd /sbin/healthd |
| 502 | class core |
| 503 | critical |
| 504 | seclabel u:r:healthd:s0 |
| 505 | |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 506 | service console /system/bin/sh |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 507 | class core |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 508 | console |
| 509 | disabled |
| 510 | user shell |
Nick Kralevich | f2cb352 | 2014-06-12 12:33:21 -0700 | [diff] [blame] | 511 | group shell log |
Stephen Smalley | 610653f | 2013-12-23 14:11:02 -0500 | [diff] [blame] | 512 | seclabel u:r:shell:s0 |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 513 | |
Mike Lockwood | d49b4ef | 2010-11-19 09:12:27 -0500 | [diff] [blame] | 514 | on property:ro.debuggable=1 |
Brian Swetland | b4d6539 | 2010-10-27 15:40:23 -0700 | [diff] [blame] | 515 | start console |
| 516 | |
Mike Lockwood | 352dfdf | 2011-06-08 17:40:00 -0700 | [diff] [blame] | 517 | # adbd is controlled via property triggers in init.<platform>.usb.rc |
Nick Kralevich | d49aa25 | 2014-01-18 09:25:04 -0800 | [diff] [blame] | 518 | service adbd /sbin/adbd --root_seclabel=u:r:su:s0 |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 519 | class core |
Benoit Goby | 0574d6b | 2012-04-24 15:07:12 -0700 | [diff] [blame] | 520 | socket adbd stream 660 system system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 521 | disabled |
Stephen Smalley | 1eee419 | 2012-01-13 08:54:34 -0500 | [diff] [blame] | 522 | seclabel u:r:adbd:s0 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 523 | |
| 524 | # adbd on at boot in emulator |
| 525 | on property:ro.kernel.qemu=1 |
| 526 | start adbd |
| 527 | |
Mark Salyzyn | 0a0cc71 | 2014-03-21 17:41:52 -0700 | [diff] [blame] | 528 | service lmkd /system/bin/lmkd |
| 529 | class core |
| 530 | critical |
| 531 | socket lmkd seqpacket 0660 system system |
| 532 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 533 | service servicemanager /system/bin/servicemanager |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 534 | class core |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 535 | user system |
Nick Kralevich | 333f24b | 2010-12-10 14:10:16 -0800 | [diff] [blame] | 536 | group system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 537 | critical |
Todd Poynor | 13f4c9f | 2013-06-19 15:09:35 -0700 | [diff] [blame] | 538 | onrestart restart healthd |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 539 | onrestart restart zygote |
| 540 | onrestart restart media |
Mathias Agopian | 04a8759 | 2011-10-31 14:27:36 -0700 | [diff] [blame] | 541 | onrestart restart surfaceflinger |
| 542 | onrestart restart drm |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 543 | |
Jeff Sharkey | 25775e8 | 2015-03-31 15:03:29 -0700 | [diff] [blame] | 544 | service vold /system/bin/vold \ |
| 545 | --blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 \ |
| 546 | --fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0 |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 547 | class core |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 548 | socket vold stream 0660 root mount |
Paul Lawrence | 37fcc5d | 2015-06-03 14:19:29 -0700 | [diff] [blame] | 549 | socket cryptd stream 0660 root mount |
San Mehat | f0cb74e | 2010-02-26 10:01:14 -0800 | [diff] [blame] | 550 | ioprio be 2 |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 551 | |
San Mehat | 192277c | 2010-01-15 07:48:35 -0800 | [diff] [blame] | 552 | service netd /system/bin/netd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 553 | class main |
San Mehat | 192277c | 2010-01-15 07:48:35 -0800 | [diff] [blame] | 554 | socket netd stream 0660 root system |
Brad Fitzpatrick | 8c5669f | 2010-10-27 10:23:16 -0700 | [diff] [blame] | 555 | socket dnsproxyd stream 0660 root inet |
Robert Greenwalt | 1d91fcf | 2012-03-27 16:59:27 -0700 | [diff] [blame] | 556 | socket mdns stream 0660 root system |
Sreeram Ramachandran | 76202a2 | 2014-05-11 07:27:34 -0700 | [diff] [blame] | 557 | socket fwmarkd stream 0660 root inet |
San Mehat | 192277c | 2010-01-15 07:48:35 -0800 | [diff] [blame] | 558 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 559 | service debuggerd /system/bin/debuggerd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 560 | class main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 561 | |
Dan Willemsen | 78ef91a | 2014-02-16 11:30:27 -0800 | [diff] [blame] | 562 | service debuggerd64 /system/bin/debuggerd64 |
| 563 | class main |
| 564 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 565 | service ril-daemon /system/bin/rild |
vidya rao | 04cf629 | 2011-06-24 12:15:20 -0700 | [diff] [blame] | 566 | class main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 567 | socket rild stream 660 root radio |
Dheeraj Shetty | b4ef85c | 2015-04-10 10:31:21 -0700 | [diff] [blame] | 568 | socket sap_uim_socket1 stream 660 bluetooth bluetooth |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 569 | socket rild-debug stream 660 radio system |
| 570 | user root |
Jeff Sharkey | 61f1359 | 2012-08-20 14:31:47 -0700 | [diff] [blame] | 571 | group radio cache inet misc audio log |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 572 | |
Mathias Agopian | a40481b | 2011-03-03 18:48:30 -0800 | [diff] [blame] | 573 | service surfaceflinger /system/bin/surfaceflinger |
Andres Morales | 314313a | 2014-08-26 12:57:46 -0700 | [diff] [blame] | 574 | class core |
Mathias Agopian | a40481b | 2011-03-03 18:48:30 -0800 | [diff] [blame] | 575 | user system |
Dima Zavin | ece565c | 2012-10-04 17:02:26 -0700 | [diff] [blame] | 576 | group graphics drmrpc |
Mathias Agopian | a40481b | 2011-03-03 18:48:30 -0800 | [diff] [blame] | 577 | onrestart restart zygote |
| 578 | |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 579 | service drm /system/bin/drmserver |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 580 | class main |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 581 | user drm |
Jeff Sharkey | 61f1359 | 2012-08-20 14:31:47 -0700 | [diff] [blame] | 582 | group drm system inet drmrpc |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 583 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 584 | service media /system/bin/mediaserver |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 585 | class main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 586 | user media |
Jeff Tinker | 08d6430 | 2013-04-23 19:54:17 -0700 | [diff] [blame] | 587 | group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm |
San Mehat | f0cb74e | 2010-02-26 10:01:14 -0800 | [diff] [blame] | 588 | ioprio rt 4 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 589 | |
Paul Lawrence | 13d5bb4 | 2014-01-30 10:43:52 -0800 | [diff] [blame] | 590 | # One shot invocation to deal with encrypted volume. |
| 591 | service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted |
| 592 | disabled |
| 593 | oneshot |
| 594 | # vold will set vold.decrypt to trigger_restart_framework (default |
| 595 | # encryption) or trigger_restart_min_framework (other encryption) |
| 596 | |
Paul Lawrence | 166fa3d | 2014-02-03 13:27:49 -0800 | [diff] [blame] | 597 | # One shot invocation to encrypt unencrypted volumes |
Paul Lawrence | 317b402 | 2015-02-06 17:18:19 +0000 | [diff] [blame] | 598 | service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default |
Paul Lawrence | 166fa3d | 2014-02-03 13:27:49 -0800 | [diff] [blame] | 599 | disabled |
| 600 | oneshot |
| 601 | # vold will set vold.decrypt to trigger_restart_framework (default |
| 602 | # encryption) |
| 603 | |
Mathias Agopian | 8b2cf9f | 2009-05-20 18:09:51 -0700 | [diff] [blame] | 604 | service bootanim /system/bin/bootanimation |
Andres Morales | 314313a | 2014-08-26 12:57:46 -0700 | [diff] [blame] | 605 | class core |
Mathias Agopian | 8b2cf9f | 2009-05-20 18:09:51 -0700 | [diff] [blame] | 606 | user graphics |
Mike Lockwood | 7e58899 | 2014-09-29 06:17:10 -0700 | [diff] [blame] | 607 | group graphics audio |
Mathias Agopian | 8b2cf9f | 2009-05-20 18:09:51 -0700 | [diff] [blame] | 608 | disabled |
| 609 | oneshot |
| 610 | |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 611 | service gatekeeperd /system/bin/gatekeeperd /data/misc/gatekeeper |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 612 | class main |
| 613 | user system |
| 614 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 615 | service installd /system/bin/installd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 616 | class main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 617 | socket installd stream 600 system system |
| 618 | |
Doug Zongker | 9526202 | 2014-02-04 12:15:14 -0800 | [diff] [blame] | 619 | service flash_recovery /system/bin/install-recovery.sh |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 620 | class main |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 621 | oneshot |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 622 | |
Chia-chi Yeh | 51afbf5 | 2009-07-01 07:06:47 +0800 | [diff] [blame] | 623 | service racoon /system/bin/racoon |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 624 | class main |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 625 | socket racoon stream 600 system system |
Chia-chi Yeh | 9bb4d41 | 2011-07-08 20:03:03 -0700 | [diff] [blame] | 626 | # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port. |
Chia-chi Yeh | a246871 | 2011-08-08 10:11:40 -0700 | [diff] [blame] | 627 | group vpn net_admin inet |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 628 | disabled |
| 629 | oneshot |
| 630 | |
| 631 | service mtpd /system/bin/mtpd |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 632 | class main |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 633 | socket mtpd stream 600 system system |
Chia-chi Yeh | 51afbf5 | 2009-07-01 07:06:47 +0800 | [diff] [blame] | 634 | user vpn |
Chia-chi Yeh | a246871 | 2011-08-08 10:11:40 -0700 | [diff] [blame] | 635 | group vpn net_admin inet net_raw |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 636 | disabled |
| 637 | oneshot |
| 638 | |
Chia-chi Yeh | 9b4f1ff | 2009-09-18 10:35:26 +0800 | [diff] [blame] | 639 | service keystore /system/bin/keystore /data/misc/keystore |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 640 | class main |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 641 | user keystore |
Kenny Root | ad5b9c7 | 2012-02-23 16:31:10 -0800 | [diff] [blame] | 642 | group keystore drmrpc |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 643 | |
Mike Lockwood | abe3a9c | 2009-09-02 18:09:26 -0400 | [diff] [blame] | 644 | service dumpstate /system/bin/dumpstate -s |
Ken Sumrall | 752923c | 2010-12-03 16:33:31 -0800 | [diff] [blame] | 645 | class main |
Mike Lockwood | abe3a9c | 2009-09-02 18:09:26 -0400 | [diff] [blame] | 646 | socket dumpstate stream 0660 shell log |
| 647 | disabled |
| 648 | oneshot |
Mike Lockwood | 9dd2eef | 2011-12-11 20:25:16 -0800 | [diff] [blame] | 649 | |
Robert Greenwalt | 1d91fcf | 2012-03-27 16:59:27 -0700 | [diff] [blame] | 650 | service mdnsd /system/bin/mdnsd |
| 651 | class main |
| 652 | user mdnsr |
| 653 | group inet net_raw |
| 654 | socket mdnsd stream 0660 mdnsr inet |
| 655 | disabled |
| 656 | oneshot |
Doug Zongker | 7baebf1 | 2014-01-14 12:30:40 -0800 | [diff] [blame] | 657 | |
Tao Bao | e48aed0 | 2015-05-11 14:08:18 -0700 | [diff] [blame] | 658 | service uncrypt /system/bin/uncrypt |
| 659 | class main |
| 660 | disabled |
| 661 | oneshot |
| 662 | |
| 663 | service pre-recovery /system/bin/uncrypt --reboot |
Doug Zongker | 7baebf1 | 2014-01-14 12:30:40 -0800 | [diff] [blame] | 664 | class main |
| 665 | disabled |
| 666 | oneshot |
Than McIntosh | 7d678d8 | 2015-04-28 14:32:35 -0400 | [diff] [blame] | 667 | |
Than McIntosh | 7d678d8 | 2015-04-28 14:32:35 -0400 | [diff] [blame] | 668 | service perfprofd /system/xbin/perfprofd |
Than McIntosh | b37c45e | 2015-05-27 14:02:11 -0400 | [diff] [blame] | 669 | class late_start |
Than McIntosh | 7d678d8 | 2015-04-28 14:32:35 -0400 | [diff] [blame] | 670 | user root |
| 671 | oneshot |
Mark Salyzyn | 49ed105 | 2015-05-26 14:57:13 -0700 | [diff] [blame] | 672 | |
| 673 | on property:persist.logd.logpersistd=logcatd |
| 674 | # all exec/services are called with umask(077), so no gain beyond 0700 |
| 675 | mkdir /data/misc/logd 0700 logd log |
| 676 | # logd for write to /data/misc/logd, log group for read from pstore (-L) |
| 677 | exec - logd log -- /system/bin/logcat -L -b all -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 64 -n 256 |
| 678 | start logcatd |
| 679 | |
| 680 | service logcatd /system/bin/logcat -b all -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 64 -n 256 |
| 681 | class late_start |
| 682 | disabled |
| 683 | # logd for write to /data/misc/logd, log group for read from log daemon |
| 684 | user logd |
| 685 | group log |