History log of /system/core/init/service.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3ac3c02b258ac9f9fb794506b519c1beed075bd5 01-May-2017 Tom Cherry <tomcherry@google.com> init: add an initializer for keychord_id_

Add unit test to ensure all POD types of Service are initialized.

Bug: 37855222
Test: Ensure bugreport is triggered via keychord properly.
Test: New unit tests
Merged-In: If2cfea15a74ab417a7b909a60c264cb8eb990de7
Change-Id: If2cfea15a74ab417a7b909a60c264cb8eb990de7
(cherry picked from commit 7da548578c25683fe0082283303e16961df312da)
/system/core/init/service.h
2d80467165f831f86a01e7970d67840a264e2bd8 28-Mar-2017 Tom Cherry <tomcherry@google.com> init: add exec_start command

Exec services may also want to set other service flags such as
priority. Instead of expanding the exec syntax to handle this, create
a new command, exec_start, that will treat an existing service
definition as an exec service. The new exec_start command will start
the service then halt init from executing further commands until the
service has exited.

This change additionally encapsulates the waiting_for_exec logic into
ServiceManager and removes the ambiguous 'bool' return value from
Reap() which previously indicated if a Reaped service was an exec
service or not.

Bug: 36511808
Bug: 36102163
Test: Bullhead boots, services run with exec_start as they do exec.

Change-Id: I44f775cf1c1dd81d5c715f44fdc150c651a2c80a
(cherry picked from commit b27004aa05039b5196f1e878169dca41b68aadd6)
/system/core/init/service.h
641ff0a4d8d05349d9c22f726a035a2936a2a94d 27-Mar-2017 Wei Wang <wvw@google.com> init: add support of multiple class names

Add support of multiple class names in service, so that related services
can be grouped together. By doing this, we can start/stop some services
for special purpose. For example, early zygote, early boot animation
and etc.

Bug: 36535312
Test: marlin boots with defined classes
Change-Id: Ifeaaf034fd836816e24f3775bece53ea83faada6
/system/core/init/service.h
8d01f63f50fb001f41835a0dab636981f2ba76dd 13-Mar-2017 Keun-young Park <keunyoung@google.com> remove emergency shutdown and improve init's reboot logic

- Emergency shutdown just marks the fs as clean while leaving fs
in the middle of any state. Do not use it anymore.

- Changed android_reboot to set sys.powerctl property so that
all shutdown can be done by init.

- Normal reboot sequence changed to
1. Terminate processes (give time to clean up). And wait for
completion based on ro.build.shutdown_timeout.
Default value (when not set) is changed to 3 secs. If it is 0, do not
terminate processes.
2. Kill all remaining services except critical services for shutdown.
3. Shutdown vold using "vdc volume shutdown"
4. umount all emulated partitions. If it fails, just detach.
Wait in step 5 can handle it.
5. Try umounting R/W block devices for up to max timeout.
If it fails, try DETACH.
If umount fails to complete before reboot, it can be detected when
system reboots.
6. Reboot

- Log shutdown time and umount stat to log so that it can be collected after reboot

- To umount emulated partitions, all pending writes inside kernel should
be completed.
- To umount /data partition, all emulated partitions on top of /data should
be umounted and all pending writes should be completed.
- umount retry will only wait up to timeout. If there are too many pending
writes, reboot will discard them and e2fsck after reboot will fix any file system
issues.

bug: 36004738
bug: 32246772

Test: many reboots combining reboot from UI and adb reboot. Check last_kmsg and
fs_stat after reboot.

Change-Id: I6e74d6c68a21e76e08cc0438573d1586fd9aaee2
/system/core/init/service.h
c8ac0677734270f0b12d85ecf23b1de49054890c 14-Feb-2017 James Hawkins <jhawkins@google.com> Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."

This reverts commit 7c92e484503f239000ef97ef5b067907fbeaa4a6.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
/system/core/init/service.h
7c92e484503f239000ef97ef5b067907fbeaa4a6 14-Feb-2017 James Hawkins <jhawkins@google.com> bootstat: Refactor init/utils/boot_clock into base/chrono_utils.

Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
/system/core/init/service.h
0e3167e203ae89817cc30ba4a5a2d328716b4826 08-Feb-2017 James Hawkins <jhawkins@google.com> Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."

This reverts commit 26f40c04c3ad80e2bc449990010d39d1c1b9a5f0.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
/system/core/init/service.h
26f40c04c3ad80e2bc449990010d39d1c1b9a5f0 06-Feb-2017 James Hawkins <jhawkins@google.com> bootstat: Remove custom uptime parser in favor of elapsedRealtime.

Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
/system/core/init/service.h
9605a945f7a497c0307b512b9cd762f2d23973ca 11-Nov-2016 Elliott Hughes <enh@google.com> init start time tracking.

With this change, init sets a property "init.start" to show the
CLOCK_BOOTTIME time at which init itself started, and for each service
an "init.svc.<name>.start" property to show the CLOCK_BOOTTIME time at
which that service was most recently started.

These times can be used by tools like bootstat to track boot time.

As part of this change, move init over to std::chrono. Also, rather than
make the command-line argument handling more complex, I've switched to
using an environment variable for communication between first- and
second-stage init, and added another environment variable to pass the
start time of the first stage through to the second stage.

Bug: http://b/32780225
Test: manual
Change-Id: Ia65a623e1866ea688b9a5433d6507926ce301dfe
/system/core/init/service.h
62767fe29f8aaf62470781a3cf419ba11187d178 27-Oct-2016 Mark Salyzyn <salyzyn@google.com> init: service file keyword

Solve one more issue where privilege is required to open a file and
we do not want to grant such to the service. This is the service side
of the picture, android_get_control_file() in libcutils is the client.
The file's descriptor is placed into the environment as
"ANDROID_FILE_<path>". For socket and files where non-alpha and
non-numeric characters in the <name/path> are replaced with _. There
was an accompanying change in android_get_control_socket() to match
in commit 'libcutils: add android_get_control_socket() test'

Add a gTest unit test for this that tests create_file and
android_get_control_file().

Test: gTest init_tests --gtest_filter=util.create_file
Bug: 32450474
Change-Id: I96eb970c707db6d51a9885873329ba1cb1f23140
/system/core/init/service.h
24b29132a017f7fbfd009c3e6aec499d1b815dbf 27-Oct-2016 Jorge Lucangeli Obes <jorgelo@google.com> init: Add support for ambient capabilities.

Ambient capabilities are inherited in a straightforward way across
execve(2):

"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"

This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.

Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.

I chose to not use Minijail here (though I'm still using libcap) for
two reasons:

1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.

2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.

Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
/system/core/init/service.h
310f6704d0dfe9ca4cfb153ce8e4212cc7596190 22-Jul-2016 Marco Nelissen <marcone@google.com> Allow setting oom_score_adj for services spawned from init

(cherry picked from commit f7adf8e4739812a2a4f194b17f84f4b9df42d04b)

Bug: 29831602
Change-Id: I4d24264bb6e879935a0b2adbb2e49ddf458980cf
/system/core/init/service.h
8f7b9e3d39cdae8363816aa7bcbab0d79fd70cea 28-Jul-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy performance warnings in syste/core.

* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
/system/core/init/service.h
344d01f99f6049565e4342b4c4202bd9ab96340b 08-Jul-2016 Jorge Lucangeli Obes <jorgelo@google.com> Refactor Service::Start method.

This CL extracts code from Service::Start into four helper functions,
bringing Service::Start down to 134 lines vs 212 lines originally. This
makes the method a lot easier to follow. There is no change in behaviour.

Also, make error messages consistent (start with lowercase) and
format Service::Start to fit in 100 cols.

Bug: 30035168

Change-Id: If979976fba4d339a336d030f802ca9f169fd012c
/system/core/init/service.h
177b27d4f5bfa498cc46aad24d9375d65630bea0 29-Jun-2016 Jorge Lucangeli Obes <jorgelo@google.com> Rename "Handle(r)" to "Parse(r)" in Android init.

The code in question parses config files, so use the right terminology.

Bug: 29872991
Change-Id: Id9644d9a98c1d702d2990f62b3020a27d073141e
/system/core/init/service.h
1b3fa3d6506d04570aab60147b0ec743e38c8796 22-Apr-2016 Jorge Lucangeli Obes <jorgelo@google.com> init: Add option to run a service in a new PID/mount namespace.

Namespaces are a more consistent isolation primitive than e.g. hiding
/proc.

Bug: 29635190

Change-Id: I7c39975813fb13b3d06be35a24c0854f16549c0a
/system/core/init/service.h
ad8e94e017173471e90c704eb7d8de5a14712aa7 15-Jun-2016 Elliott Hughes <enh@google.com> init: report createProcessGroup failure.

Also directly kill the initial pid for safety, like other libprocessgroup
users.

Change-Id: Ib28936aea19cceaeaa54734759d5ae0c252c7905
/system/core/init/service.h
081705c258efbe938d71c2022528d809fa6d42c5 19-May-2016 Vitalii Tomkiv <vitalit@google.com> Add process priority to service definition.

This change allows to set prioirrity of the process to be set through
*.rc file.

Bug: 28866384
Change-Id: If0108ef05c8a151749c43d2d7de1187653255ce8
/system/core/init/service.h
bdeac39a42c1b9c7195ada1c30fe12f94314490f 13-Apr-2016 Elliott Hughes <enh@google.com> Remove undocumented functionality from init.

(cherry-pick of a3cc6026301db08285028c760af2665a66b3cc44.)

Bug: http://b/28151340
Change-Id: I5360502c79d9113a13055bf017b39c099033e947
/system/core/init/service.h
70daa67062c016eea1a30be2e1de0dcba1d23a13 21-Mar-2016 Viorel Suman <viorel.suman@intel.com> Multiple consoles

This CL allows enabling of multiple consoles. A service can be
mapped to a specific console by providing the optional argument,
IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
class core
console tty0
disabled
user shell
group shell log readproc
seclabel u:r:shell:s0

Bug: None
Change-Id: I3b24e7f6848bbe5c6475f11334c04ec536e6af88
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
/system/core/init/service.h
efc72751729a5ade9e05aba264791bb44e65e7ab 21-Mar-2016 Viorel Suman <viorel.suman@intel.com> Revert "Enable multiple consoles"

This reverts commit caafe5c6204bc2066e6201a67ecd7cd1b3f8d015.

Bug: None
Change-Id: Iea2a80003d996ce542393242f87dc658ac6d01c9
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
/system/core/init/service.h
caafe5c6204bc2066e6201a67ecd7cd1b3f8d015 09-Mar-2016 Viorel Suman <viorel.suman@intel.com> Enable multiple consoles

This CL allows enabling of multiple consoles. The expected format
of "androidboot.console" kernel parameter is a list of available
consoles, as follows:

androidboot.console=tty0:ttyS0

A service can be mapped to a specific console by providing the
optional argument, IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
class core
console tty0
disabled
user shell
group shell log readproc
seclabel u:r:shell:s0

Bug: None
Change-Id: I3f8556425c8651bd121995869700f18b23365d55
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
/system/core/init/service.h
b7e03e82b89a30b09fea88eaf2a5638df1017cf6 18-Dec-2015 Bertrand SIMONNET <bsimonnet@google.com> init: Allows shutting down cleanly.

When ro.build.shutdown_timeout is set, init will send a SIGTERM signal to
all services on reboot. The normal shutdown process will continue once
all services have exited or after the shutdown timeout
(ro.build.shutdown_timeout).

If ro.build.shutdown_timeout is not set, we assume a 0s timeout.

Bug: 26216447
Test: manual: Ask to reboot. All services exit cleanly.

Change-Id: If921f6e8d87211e500ac9fa86f3e1eabe02d18cf
/system/core/init/service.h
b7349902a945903f9e36a569051f5131beb0bc24 26-Aug-2015 Tom Cherry <tomcherry@google.com> init: Use classes for parsing and clean up memory allocations

Create a Parser class that uses multiple SectionParser interfaces to
handle parsing the different sections of an init rc.

Create an ActionParser and ServiceParser that implement SectionParser
and parse the sections corresponding to Action and Service
classes.

Remove the legacy keyword structure and replace it with std::map's
that map keyword -> (minimum args, maximum args, function pointer) for
Commands and Service Options.

Create an ImportParser that implements SectionParser and handles the
import 'section'.

Clean up the unsafe memory handling of the Action class by using
std::unique_ptr.

Change-Id: Ic5ea5510cb956dbc3f78745a35096ca7d6da7085
/system/core/init/service.h
bac3299720623f4226bca103b26260052732ad30 31-Jul-2015 Tom Cherry <tomcherry@google.com> Create Service and ServiceManager classes

Change-Id: I363a5e4751ad83d2f4096882a6fbbeddca03acfe
/system/core/init/service.h