History log of /system/core/init/builtins.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
5872cbdf02ee0a64f1a313f00eb1e635b452393b 17-Apr-2018 Paul Crowley <paulcrowley@google.com> Set property for metadata encryption on first boot

Bug: 77335096
Test: device boots twice with and without metadata encryption
Change-Id: Iaed78288cb37865ba23833721b73b11414e7e862
/system/core/init/builtins.cpp
dc97e3e091b404b23e7fe919b30e523565f3b1ce 13-Apr-2018 Paul Crowley <paulcrowley@google.com> Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."

An earlier such change was reverted in commit e242a97db547dc73efea1b5287536be66637dc33.

Bug: 70487538
Test: ensure that angler can boot
Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
/system/core/init/builtins.cpp
b9ee9abebe631b02f312f1d2517305cf6ead159a 02-Mar-2018 Treehugger Robot <treehugger-gerrit@google.com> Merge "Revert "If enablefilecrypto or init_user0 fails, reboot into recovery.""
e242a97db547dc73efea1b5287536be66637dc33 02-Mar-2018 Paul Crowley <paulcrowley@google.com> Revert "If enablefilecrypto or init_user0 fails, reboot into recovery."

This reverts commit 959b05553576ffc15da4334a5917ce763611ab82.

Reason for revert: b/73968735
Bug: 73968735
Test: b/73968735#comment5

Change-Id: Ifce4c029bab7380c60e20cc2b2885beb4a097456
/system/core/init/builtins.cpp
de6bd50d4238d19ec401127bcf2321dc679d908d 14-Feb-2018 Tom Cherry <tomcherry@google.com> init: add host side parser for init

Create a host side parser for init such that init rc files can be
verified for syntax correctness before being used on the device.

Bug: 36970783
Test: run the parser on init files on host

Change-Id: I7e8772e278ebaff727057308596ebacf28b6fdda
/system/core/init/builtins.cpp
851803d3cf3e874bb9305341a681a56cc73e7c57 15-Feb-2018 Treehugger Robot <treehugger-gerrit@google.com> Merge "If enablefilecrypto or init_user0 fails, reboot into recovery."
959b05553576ffc15da4334a5917ce763611ab82 14-Feb-2018 Paul Crowley <paulcrowley@google.com> If enablefilecrypto or init_user0 fails, reboot into recovery.

Test: Roll back PLATFORM_SECURITY_PATCH, ensure recovery dialog is seen
Bug: 70487538
Change-Id: Iceb6af3f9d6aea6bc646dbb4b5d29dffcb284736
/system/core/init/builtins.cpp
7fd3bc27eccdcb11de4886bdda05cd26a8d8af5c 14-Feb-2018 Tom Cherry <tomcherry@google.com> Move ActionManager to its own file

Bug: 36970783
Test: build
Change-Id: I08fa39052236b462249f79de1d02bf02bdbf4c84
/system/core/init/builtins.cpp
94e930551169f95593cd8732f8d9dcb452902ed0 05-Feb-2018 Treehugger Robot <treehugger-gerrit@google.com> Merge "init: add TODO for mount operations."
880d566400d38743e75be0ae88b142bc5ba27c57 05-Feb-2018 Tom Cherry <tomcherry@google.com> init: add TODO for mount operations.

mount operations should be done in vendor init context, but their
complexity currently limits this. Add a TODO to make this reason
clear to those viewing the code.

Bug: 72488820
Test: N/A
Change-Id: I8b6dd92aa79f31dc24603559ed6de0815facfcba
/system/core/init/builtins.cpp
c684696a96623054666952e1616d57335fc4192c 30-Jan-2018 Paul Crowley <paulcrowley@google.com> Use vold's mount with metadata encryption service.

Don't use the FDE flow to support metadata encryption; just use the
vold service which directly mounts the volume.

Bug: 63927601
Test: Boot Taimen to SUW with and without metadata encryption.
Change-Id: Idf9c27a69872cd7a9e2fb76df09a91d8e5ef4896
/system/core/init/builtins.cpp
32228485ffac6ff0b674210be448b121bbd6427c 19-Jan-2018 Tom Cherry <tomcherry@google.com> Make vendor_init check SELinux before setting properties

Finishing a TODO from vendor_init, check SELinux permissions before
setting properties in vendor_init.

Bug: 62875318
Test: N/A
Change-Id: I3cb6abadd2613ae083705cc6b9c970587b6c6b19
/system/core/init/builtins.cpp
4b591f1851d1708dc6416a09d78437ac1d7b416e 27-Nov-2017 Joel Galenson <jgalenson@google.com> Run restorecon after init creates a symlink or writes to a file.

Init currently sets the SELinux context on a mkdir but not on
other operations. This patch modifies it to do so when creating
symlinks, writing to a file, or copying a file.

Test: Built, flashed, and booted. Added fake init entries and
verified that they received the proper SELinux context.

Change-Id: I836b570fef81d74f3b6c8e7ce0274e94ca7b12d3
/system/core/init/builtins.cpp
cadc34fd9ad0c89f949e6ec5d5ebe72f78313d99 19-Oct-2017 Tom Cherry <tomcherry@google.com> Merge "init: wait_for_prop shouldn't run in a subcontext"
am: 6e52973623

Change-Id: I160bedcb91668ccf2b663c36835871d21be2db8b
fa3e52c64af181f9e701144949c91d9d035c69b4 17-Oct-2017 Tom Cherry <tomcherry@google.com> init: wait_for_prop shouldn't run in a subcontext

wait_for_prop sets a flag that prevents the action queue from
continuing while otherwise allowing init's main loop to continue
executing. This cannot be done from a subcontext, so it's moved to
normal init.

All property functions need work in any case, particularly once
property_service is moved out of init.

Bug: 62875318
Test: boot sailfish and see that the previous failure related to this
is fixed

Change-Id: Ib9e0d0bdbd0ff22ab0e5c3fe6db620700af266c6
/system/core/init/builtins.cpp
5c00898944e469e637acd8a092c21b0f823689ac 04-Oct-2017 Tom Cherry <tomcherry@google.com> Merge "init: log failures if a service cannot start during class_start"
am: 533fbd62ab

Change-Id: I7a05ae9f806a23d04d649fb230e2875633b2caee
20acdef8164d77b99f8abede198a03ac510a7a08 03-Oct-2017 Tom Cherry <tomcherry@google.com> init: log failures if a service cannot start during class_start

Test: boot system with this logging and see appropriate failures
Change-Id: I312dca89f6215afe05b10b2539258a212a0c1ae2
/system/core/init/builtins.cpp
821cb5e16ccd3b4566b11abe2621073a698662f9 02-Oct-2017 Tom Cherry <tomcherry@google.com> Merge "init: run vendor commands in a separate SELinux context"
am: 8e09b0b953

Change-Id: I7e0272f29bd8bab029a9f9c07aa413c9172f6f5a
cb0f9bbc855097e0c8248643015b837255fd569a 13-Sep-2017 Tom Cherry <tomcherry@google.com> init: run vendor commands in a separate SELinux context

One of the major aspects of treble is the compartmentalization of system
and vendor components, however init leaves a huge gap here, as vendor
init scripts run in the same context as system init scripts and thus can
access and modify the same properties, files, etc as the system can.

This change is meant to close that gap. It forks a separate 'subcontext'
init that runs in a different SELinux context with permissions that match
what vendors should have access to. Commands get sent over a socket to
this 'subcontext' init that then runs them in this SELinux context and
returns the result.

Note that not all commands run in the subcontext; some commands such as
those dealing with services only make sense in the context of the main
init process.

Bug: 62875318
Test: init unit tests, boot bullhead, boot sailfish

Change-Id: Idf4a4ebf98842d27b8627f901f961ab9eb412aee
/system/core/init/builtins.cpp
a6d75117e26337a22cf727fc66e0a189ff614d8d 18-Sep-2017 Tom Cherry <tomcherry@google.com> Merge "init: add exec_background command"
am: 424ed42fb4

Change-Id: I9529146ea9b29b2fb2e2c92f3533efc4e3106943
424ed42fb4382c7edbfe7239c9fde56ee87449c5 18-Sep-2017 Tom Cherry <tomcherry@google.com> Merge "init: add exec_background command"
3631c545b8e3256c5aba2269491912e3f568cd99 18-Sep-2017 Tom Cherry <tomcherry@google.com> init: add exec_background command

This command functions similarly to `exec` except that it does not
cause init to halt executing commands until the process has
terminated. It is useful for launching simple one time background
tasks.

Bug: 65736247
Test: create an exec_background service and see it function properly
Change-Id: I719c8b85479b65201770aedc0a13191303007c11
/system/core/init/builtins.cpp
171587d10ea2ceb89e6b727154b21db0f8e621fe 15-Sep-2017 Tom Cherry <tomcherry@google.com> Merge "init: fix crash when reboot is triggered by a builtin"
am: b92415cee2

Change-Id: I4137679d88e58c706f14adeeaf84b41426079de4
3633a4014a1a315000c3e6dee36b419473ab44b9 13-Sep-2017 Tom Cherry <tomcherry@google.com> init: fix crash when reboot is triggered by a builtin

Builtin commands may set the sys.powerctl property, which causes
reboot to be immediately processed. Unfortunately, part of the reboot
processing involves clearing the action queue, so when this scenario
happens, ActionManager::ExecuteOneCommand() can abort due to its state
being unexpectedly changed.

Longer term, the real fix here is to split init and property service.
In this case, the property sets will be sent to property service and
the reboot will only be processed once property service responds back
to init that the property has been set. Since that will not happen
within the action queue, there will be no risk of failure.

Short term, this change sets a flag in init to shutdown the device
before the next action is run, which defers the shutdown enough to fix
the crash, but continues to prevent any further commands from running.

Bug: 65374456
Test: force bullhead into the repro case and observe that it no longer
repros

Change-Id: I89c73dad8d7912a845d694b095cab061b8dcc05e
/system/core/init/builtins.cpp
721b2d6035b390f8601974174130d5976504eafd 07-Sep-2017 Luis Hector Chavez <lhchavez@google.com> Merge "init: Allow clean system shutdown upon SIGTERM"
am: 61cb88add2

Change-Id: If0a495fa067440f0b59969ac0dbc010b4687b52f
9f97f4794027d8143b7d4f2d3ad4f80ca72ca77a 06-Sep-2017 Luis Hector Chavez <lhchavez@google.com> init: Allow clean system shutdown upon SIGTERM

This allows Android to cleanly shutdown when running in a PID namespace
in a way that does not rely on adbd running. This is useful to allow
Android to be running in a container and its lifetime managed by an
OCI-compliant tool.

Bug: 65415372
Test: `kill -TERM 1` as root is correctly dropped.
Test: `kill -TERM 1` from the init PID namespace causes init to cleanly shutdown.
Change-Id: Ia66ebdb436221919081bc4723337c0c7f1e53b09
/system/core/init/builtins.cpp
df9ac65c75ba96dee95b884201e41404d9a2744b 02-Sep-2017 Wei Wang <wvw@google.com> Merge "init: add option to read file fully on readahead"
am: d97a1710b8

Change-Id: I2a49bd384b1fe621314916c1f325c03b7fa43162
02628f3b2323ea9cd2459f863a2ae0d0c59f90a4 16-Aug-2017 Wei Wang <wvw@google.com> init: add option to read file fully on readahead

Bug: 62413151
Test: boottime, dumpcache
Change-Id: I1a7b69f0619428e4db31c5a7639c5d895c89ecdb
/system/core/init/builtins.cpp
c39a5082dc65cbf7bda948c4bc466a40376d1683 28-Aug-2017 Tom Cherry <tomcherry@google.com> Merge "init: support setting rlimits per service"
am: 459aa1cac6

Change-Id: I4ef5abc3371ce52783bfb14669bcffe33febb73e
7ac013de7edc7ec6570ff6a5b6bd3bdce68b769c 25-Aug-2017 Tom Cherry <tomcherry@google.com> init: support setting rlimits per service

Add a new service option, `rlimit` that allows a given rlimit to be
set for a specific service instead of globally.

Use the same parsing, now allowing text such as 'cpu' or 'rtprio'
instead of relying on the enum value for the `setrlimit` builtin
command as well.

Bug: 63882119
Bug: 64894637

Test: boot bullhead, run a test app that attempts to set its rtprio to
95, see that the priority set fails normally but passes when
`rlimit rtprio 99 99` is used as its service option.
See that this fails when `rlimit rtprio 50 50` is used as well.
Test: new unit tests

Change-Id: I4a13ca20e8529937d8b4bc11718ffaaf77523a52
/system/core/init/builtins.cpp
e0db940e52799354149484fc04ef9eee7bd8455f 24-Aug-2017 Tom Cherry <tomcherry@google.com> Merge changes I316c13e3,I4d99744d,Id9614b72,I7c98a0b7
am: a78b5b300b

Change-Id: I0e4221611fb34489b2ecdd713933a2e4ba4e5055
68f2a4614518468f1320ad3e62a6db554e509fb1 23-Aug-2017 Tom Cherry <tomcherry@google.com> init: enable error reporting of builtin functions

Enable error reporting when builtin functions fail. These errors are
now reported with full context including the source file and line
number, e.g.

init: Command 'write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug}' action=early-boot (/init.bullhead.rc:84) took 0ms and failed: cannot expand '${persist.sys.ssr.enable_debug}'

There are two small caveats:
1) There are nearly 200 reports of builtins failure due to "No such
file or directory". Many of these are due to legacy paths included
in rootdir/init.rc. Until they are cleaned up, reporting of these
failures is disabled.
2) Similarly, symlink is often used to create backwards compatible
symlinks. By their very nature, these calls are expected to fail
on newer systems that do already use the new path. Due to this,
failures of symlink due to EEXIST are not reported.

Bug: 38038887
Test: boot bullhead, only see true errors reported from builtins.
Change-Id: I316c13e3adc992cacc6d79ffee987adc8738fca0
/system/core/init/builtins.cpp
76af7e6a0c4ce7759e6cc5994b5496ddb09035ee 23-Aug-2017 Tom Cherry <tomcherry@google.com> init: log Service failures via Result<T>

Log Service failures via Result<T> such that their context can be
captured when interacting with services through builtin functions.

Test: boot bullhead
Change-Id: I4d99744d64008d4a06a404e3c9817182c6e177bc
/system/core/init/builtins.cpp
6de21f11125941ea1b94fdeec754bacea3916fd5 23-Aug-2017 Tom Cherry <tomcherry@google.com> init: cleanup environment handling

Init keep its own copy of the environment that it uses for execve when
starting services. This is unnecessary however as libc already has
functions that mutate the environment and the environment that init
uses is clean for starting services. This change removes init's copy
of the environment and uses the libc functions instead.

This also makes small clean-up to the way the Service class stores
service specific environment variables.

Test: boot bullhead
Change-Id: I7c98a0b7aac9fa8f195ae33bd6a7515bb56faf78
/system/core/init/builtins.cpp
557946e57c375b05deb5ba07b739f27abc70697e 01-Aug-2017 Tom Cherry <tomcherry@google.com> init: use Result<T> for builtin functions

We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context. This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead
Merged-In: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
/system/core/init/builtins.cpp
11a3aeeae3dc887b889d4086d4d26d95c324c08d 03-Aug-2017 Tom Cherry <tomcherry@google.com> init: introduce Result<T> for return values and error handling

init tries to propagate error information up to build context before
logging errors. This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
U output;
std::string calculate_result_err;
if (!CalculateResult(input, &output, &calculate_result_err)) {
*err = "CalculateResult " + input + " failed: " +
calculate_result_err;
return false;
}
UseResult(output);
return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string. If the functional only returns success or a failure with
an error message, Result<Success> may be used. The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T. This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure. ErrnoError()
additionally appends ": " + strerror(errno) to the end of the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
auto output = CalculateResult(input);
if (!output) {
return Error() << "CalculateResult " << input << " failed: "
<< output.error();
}
UseResult(*output);
return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Merged-In: I1e7d3a8820a79362245041251057fbeed2f7979b
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
/system/core/init/builtins.cpp
7fa62c58d603dc1bc56d73a22bbf7f9a0dd3059e 01-Aug-2017 Tom Cherry <tomcherry@google.com> init: use Result<T> for builtin functions

We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context. This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead

Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
/system/core/init/builtins.cpp
62ca663475ff5284503cb82cae3e92e93d56bbea 03-Aug-2017 Tom Cherry <tomcherry@google.com> init: introduce Result<T> for return values and error handling

init tries to propagate error information up to build context before
logging errors. This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
U output;
std::string calculate_result_err;
if (!CalculateResult(input, &output, &calculate_result_err)) {
*err = "CalculateResult " + input + " failed: " +
calculate_result_err;
return false;
}
UseResult(output);
return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string. If the functional only returns success or a failure with
an error message, Result<Success> may be used. The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T. This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure. ErrnoError()
additionally appends ": " + strerror(errno) to the end of the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
auto output = CalculateResult(input);
if (!output) {
return Error() << "CalculateResult " << input << " failed: "
<< output.error();
}
UseResult(*output);
return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
/system/core/init/builtins.cpp
b6b9629f02175f6fe8b0a19645c21b117ffe673b 14-Aug-2017 Tom Cherry <tomcherry@google.com> Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp
am: 08228116a8

Change-Id: I3fc6288cf03cd1e262852ceb3fc9dbcedb32c7c3
08228116a88ecc3fccd2265054de5e2fc776b4d3 14-Aug-2017 Tom Cherry <tomcherry@google.com> Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp
0c8d6d27304d1d6e5f8f0a3feb1f60872ac278f2 10-Aug-2017 Tom Cherry <tomcherry@google.com> init: split security functions out of init.cpp

This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp. It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop. The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users. The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
/system/core/init/builtins.cpp
d8467415b08bd49ba36dd86939907056ad10e664 12-Aug-2017 Wei Wang <wvw@google.com> Merge "init: Add readahead built-in command" am: 12bd22badf am: 826bc7b507
am: 67eac4fa36

Change-Id: I852ee7278ec94e3b483a8ef61fe34477f73517fb
c3692b3ea9dffbb1e8c4a48ed780e472568a1064 10-Aug-2017 Tom Cherry <tomcherry@google.com> init: split security functions out of init.cpp

This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp. It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop. The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users. The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
(cherry picked from commit 9afb86b25d8675927cb37c86119a7ecf19f74819)
/system/core/init/builtins.cpp
542aae443fbb1ed336368692df949dfe2a6ba62b 04-Aug-2017 Wei Wang <wvw@google.com> init: Add readahead built-in command

Inspired by ag/2659809/, this CL add readahead built-in command in init
to let files be prefetched into pagecache for faster reading.
Readahead happens in background but due to filesystem limitation it
might take small amount of time in it reading the filesystem metadata
needed to locate the requested blocks. So the command is executed in a
forked process to not block init execution.

Bug: 62413151
Test: boottime, dumpcache
Change-Id: I56c86e2ebc20efda4aa509e6efb736bd1d92baa5
/system/core/init/builtins.cpp
99a538a4bb4358d4655d9a0ce45ce4dc87e2e00c 02-Aug-2017 Tom Cherry <tomcherry@google.com> Merge "init: use unique_fd in builtins.cpp" am: c34afb1cd5 am: 76756aa1dd
am: 54032d387a

Change-Id: I20865544dd1692979c8fbd21c05272a98c00eca4
7037991f04f8b8e99e72ddfa62b97055112b8039 01-Aug-2017 Tom Cherry <tomcherry@google.com> init: use unique_fd in builtins.cpp

Test: boot

Change-Id: I09295856dbd0de9436a95a2fe99ab6be156b995f
/system/core/init/builtins.cpp
c31c4d5c6d0b5aba845133a1bb55d3efc2863ac9 01-Aug-2017 Tom Cherry <tomcherry@google.com> Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe am: 2a2a8d9ec0 am: b1c18af247
am: 3d6b46a789

Change-Id: I704cb309efb106cff34c28b9c7fde3e86bb34cc0
911b9b1d6ead5f2e4c4158af0cd8787f4d458ddf 28-Jul-2017 Tom Cherry <tomcherry@google.com> init: rename ServiceManager to ServiceList and clean it up

ServiceManager is essentially just a list now that the rest of its
functionality has been moved elsewhere, so the class is renamed
appropriately.

The ServiceList::Find* functions have been cleaned up into a single
smaller interface.
The ServiceList::ForEach functions have been removed in favor of
ServiceList itself being directly iterable.

Test: boot bullhead
Change-Id: Ibd57c103338f03b83d81e8b48ea0e46cd48fd8f0
/system/core/init/builtins.cpp
3b81f2d623c6cba45ad07fa91338d346d9b96482 28-Jul-2017 Tom Cherry <tomcherry@google.com> init: move exec operations out of ServiceManager

These can be implemented without ServiceManager, so we remove them and
make ServiceManager slightly less of a God class.

Test: boot bullhead
Test: init unit tests
Change-Id: Ia6e546fe5292255412245256f7d230af4ece135f
/system/core/init/builtins.cpp
a78298e8a652a8ff67c730d2312dac66d66fbe66 28-Jul-2017 Tom Cherry <tomcherry@google.com> Merge "init: remove Parser singleton and related cleanup" am: 379123f9ab am: bf4afbb288
am: 1b74d14b7e

Change-Id: Ifaaeae8fb3f43235846207fa02a83edbc1e427d9
67dee626e0185096bbaf73042f1a891ce436f714 27-Jul-2017 Tom Cherry <tomcherry@google.com> init: remove Parser singleton and related cleanup

* Remove the Parser singleton (Hooray!)
* Rename parser.* to tokenizer.* as this is actually a tokenizer
* Rename init_parser.* to parser.* as this is a generic parser
* Move contents of init_parser_test.cpp to service_test.cpp as this
actually is a test of the parsing in MakeExecOneshotService() and
nothing related to (init_)parser.cpp

Test: boot bullhead
Test: bool sailfish
Test: init unit tests
Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
/system/core/init/builtins.cpp
c0a9cf648bef5a5760bf78806d78a3ee8b64477a 10-Jul-2017 Tom Cherry <tomcherry@google.com> Merge "Move Timer from init to libbase" am: 896297b2ef am: 7ff0b008f7
am: 4e5c4f18d8

Change-Id: Iffad0dcde94fce7dac627ebf0530420f9cfd38d1
ede0d538501dfc78c741fb3b0645406636d1d1fd 06-Jul-2017 Tom Cherry <tomcherry@google.com> Move Timer from init to libbase

Test: boot bullhead
Test: new libbase unit tests

Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
/system/core/init/builtins.cpp
2a38e6d11990caa40fba9572bbf65b7d0382be1d 06-Jul-2017 Wei Wang <wvw@google.com> Merge "init: Support custom shutdown actions" am: c1bc4241f8 am: 5b89535442
am: b39890048c

Change-Id: I57a0422f47094cc061163510138e9562648fdd98
eeab491efd8f456324f88e444f228b1016712e45 28-Jun-2017 Wei Wang <wvw@google.com> init: Support custom shutdown actions

We have been seeing panics and errors during shutdown sequence in
some vendor's platform, and it is required to disable error handling
during shutdown.

This CL separates the shutdown request to execute another "shutdown"
trigger at the beginning of shutdown stage. And vendor can use this
trigger to add custom commands needed for shutting down gracefully.

Bug: 38203024
Bug: 62084631
Test: device reboot/shutdown
Change-Id: I3fac4ed59f06667d86e477ee55ed391cf113717f
/system/core/init/builtins.cpp
99d93f4462f5c7496dad313de0acc67b04e545c3 24-Jun-2017 Tom Cherry <tomcherry@google.com> Merge "init: create android::init:: namespace" am: 040212706b am: d3d79b2196
am: b57e1180e3

Change-Id: Ic6d35273820d70136a6085bf49dcf3afcbb24f24
81f5d3ebef2c3789737bf718fc2a2cdd7b9e8b33 22-Jun-2017 Tom Cherry <tomcherry@google.com> init: create android::init:: namespace

With some small fixups along the way

Test: Boot bullhead
Test: init unit tests
Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
/system/core/init/builtins.cpp
1a23b2aef506f725501ee9b7bbb272a8b08faa63 23-Jun-2017 Tom Cherry <tomcherry@google.com> Merge "init: cleanup some string usage" am: 84c2eebbdd am: 77382acf42
am: 288fb7c2cc

Change-Id: I61e6ee578e55ebe343112c8114816ac4e18b9c7e
1c3a53f03ca3c2c647f83cd8b8ae7e18c5c7bc69 23-Jun-2017 Tom Cherry <tomcherry@google.com> init: cleanup some string usage

1) property_set() takes const std::string& for both of its arguments,
so stop using .c_str() with its parameters
2) Simplify a few places where StringPrintf() is used to concatenate strings
3) Use std::to_string() instead of StringPrintf() where it's better suited

Test: Boot bullhead
Test: init unit tests
Change-Id: I68ebda0e469f6230c8f9ad3c8d5f9444e0c4fdfd
/system/core/init/builtins.cpp
482f36cf74c0461bbad4a33df27d1b8e72ccc2d2 08-May-2017 Tom Cherry <tomcherry@google.com> init: remove restorecon() from util.cpp

restorecon() has become nothing more than a small wrapper around
selinux_android_restore(). This itself isn't super problematic, but
it is an obstacle for compiling util.cpp on the host as that function
is not available on the host.

Bug: 36970783
Test: Boot bullhead
Merged-In: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
Change-Id: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
/system/core/init/builtins.cpp
d71154268d79a19c51b7abc6f0e485408c0e07a3 09-May-2017 Tom Cherry <tomcherry@google.com> Merge "init: remove restorecon() from util.cpp" into oc-dev-plus-aosp
am: 2813d87484

Change-Id: Ib6619f696fb08b99410b3a33221fe8eacebf89d6
c2ef2f0d8d7b8b6c113e2fabb259209f9890f407 08-May-2017 Tom Cherry <tomcherry@google.com> init: remove restorecon() from util.cpp

restorecon() has become nothing more than a small wrapper around
selinux_android_restore(). This itself isn't super problematic, but
it is an obstacle for compiling util.cpp on the host as that function
is not available on the host.

Bug: 36970783
Test: Boot bullhead
Change-Id: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
/system/core/init/builtins.cpp
3decb98f75053b96d2401d43057322ac4ec995d4 08-May-2017 Tom Cherry <tomcherry@google.com> Merge changes I46690d1c,I84c11aa5 am: 0dda322d4a am: 18b23afa4b am: 3f9ba91d8f
am: 756ee8ded9

Change-Id: Ib005ef875bfc8116c320007acc10e7cf9accdc10
2cbbe9f7a35efdc94e8e34ef92eb6f70a85887fe 05-May-2017 Tom Cherry <tomcherry@google.com> init: do not log directly from read_file() and write_file()

Their callers may be able to add more context, so use an error string
to record the error.

Bug: 38038887
Test: boot bullhead
Test: Init unit tests
Change-Id: I46690d1c66e00a4b15cadc6fd0d6b50e990388c3
/system/core/init/builtins.cpp
517e1f17cfec2143d4d10a64b1496a550acf3ea2 05-May-2017 Tom Cherry <tomcherry@google.com> init: Check DecodeUid() result and use error string

Check the result of DecodeUid() and return failure when uids/gids are
unable to be decoded.

Also, use an error string instead of logging directly such that more
context can be added when decoding fails.

Bug: 38038887
Test: Boot bullhead
Test: Init unit tests
Change-Id: I84c11aa5a8041bf5d2f754ee9af748344b789b37
/system/core/init/builtins.cpp
fd9ffbb9175b41ac28b5a97cdde24c0219d0ae60 04-May-2017 Tom Cherry <tomcherry@google.com> Merge "init: use do_exec() for init_user0" am: 5ad06cbb1c am: 577c75e78c am: bc8a4ad7aa
am: 10cdd5bbf1

Change-Id: I3fa46dc57426738550beffb71932e06a0407c68c
5a86cb7694b31c7506ed5c42241f4e601efa65cb 03-May-2017 Tom Cherry <tomcherry@google.com> init: use do_exec() for init_user0

Similar to what installkey used to do, init_user0 forks and
synchronously waits for vdc to return. This is dangerous to do in
init however as init also processes properties from a single thread.

I'm not aware of any specific issues that this is currently causing,
but it's a good preventative measure to match what installkey does and
use do_exec().

Test: Boot bullhead, see that init_user0 still happens
Change-Id: I853c61594fe3d97e91bbb2319ebddf2bbe80d457
/system/core/init/builtins.cpp
d2c9acddd0b67075a61bf665a43bf50cf1536399 03-May-2017 Tom Cherry <tomcherry@google.com> Merge "ueventd: do not reference init's sehandle" am: 672dd970f4 am: e4988c9a34 am: 4c664d8c5c
am: 214e45a5a7

Change-Id: I9e73d1849df48dffd886f47c2b358f36309918c0
e7656b7200d934d6f77df422d6d3dee469230dea 02-May-2017 Tom Cherry <tomcherry@google.com> ueventd: do not reference init's sehandle

Init exposes a global 'sehandle' that ueventd references as part of
devices.cpp and util.cpp. This is particularly dangerous in
device_init() in which both uevent and init write to this global.

This change creates a separate local copy for devices.cpp and puts
restrictions on where init.h can be included to make sure the global
used by init is not reference by non-init code. Future changes to
init should remove this global.

Test: Boot bullhead

Change-Id: Ifefa9e1932e9d647d06cca2618f5c8e5a7a85460
/system/core/init/builtins.cpp
64b51491d3e4856fc7ef2dfa4442f9f063acf3af 24-Apr-2017 Tom Cherry <tomcherry@google.com> Merge changes Ic446c026,I86568a5b am: 51b7cb006f am: 41dbec9791 am: fea35fc7e4
am: d0ea8a98cd

Change-Id: I4f8fe713f768748e521ad4d6c18edf0e4b382591
ad54d094cde838d19034b8325705b22dca0e9af0 20-Apr-2017 Tom Cherry <tomcherry@google.com> init: create init_tests.cpp

Start a init_tests.cpp file for end-to-end tests that parse small init script
segments and verify that they act as expected.

The first tests ensure that the execution order of event triggers
happens appropriately.

Test: Boot bullhead, run unit tests

Change-Id: Ic446c02605ab796fd41e0596ce1fd381aee80ce0
/system/core/init/builtins.cpp
30a6f276fd8850b0a78689d7bff3cb06a18cb286 20-Apr-2017 Tom Cherry <tomcherry@google.com> init: clean up the SectionParser interface and Parser class

Remove the dependency on Action and Service from what should be a
generic Parser class.

Make ActionParser, ImportParser, and ServiceParser take a pointer to
their associated classes instead of accessing them through a
singleton.

Misc fixes to SectionParser Interface:
1) Make SectionParser::ParseLineSection() non-const as it always should
have been.
2) Use Rvalue references where appropriate
3) Remove extra std::string& filename in SectionParser::EndFile()
4) Only have SectionParser::ParseSection() as pure virtual

Document SectionParser.

Make ImportParser report the filename and line number of failed imports.

Make ServiceParser report the filename and line number of duplicated services.

Test: Boot bullhead

Change-Id: I86568a5b375fb4f27f4cb235ed1e37635f01d630
/system/core/init/builtins.cpp
9dbe97b4d502ef4b7e45775190875882fbaf42e2 21-Apr-2017 Paul Lawrence <paullawrence@google.com> Support metadata encryption

Bug: 29189559
Test: Angler, Marlin build and boot
Change-Id: Ia7b070781f5f16ff8bfd934569a2209c80c28385
/system/core/init/builtins.cpp
98ad32a967079be80a101458d8a29d7ecefbb547 18-Apr-2017 Tom Cherry <tomcherry@google.com> init: handle sys.powerctl immediately

Currently if a process sets the sys.powerctl property, init adds this
property change into the event queue, just like any other property.
The actual logic to shutdown the device is not executed until init
gets to the action associated with the property change.

This is bad for multiple reasons, but explicitly causes deadlock in
the follow scenario:

A service is started with `exec` or `exec_start`
The same service sets sys.powerctl indicating to the system to
shutdown
The same service then waits infinitely

In this case, init doesn't process any further commands until the exec
service completes, including the command to reboot the device.

This change causes init to immediately handle sys.powerctl and reboot
the device regardless of the state of the event queue, wait for exec,
or wait for property conditions.

Bug: 37209359
Bug: 37415192

Test: Init reboots normally
Test: Update verifier can reboot the system
Change-Id: Iff2295aed970840f47e56c4bacc93001b791fa35
/system/core/init/builtins.cpp
aaf70e77dc232fde152249bb6f66a227eab35a10 01-Mar-2017 Bowgo Tsai <bowgotsai@google.com> fs_mgr: support AVB in fs_mgr_update_verity_state()

fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
- [partition.system.verified]: [2]
- [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
- [partition.system.verified]: [0]
- [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
/system/core/init/builtins.cpp
00e1c4f330d0723dfe24267ccb5588c09ec9a12c 12-Apr-2017 Dmitri Plotnikov <dplotnikov@google.com> Passing additional parameter to powerctl

Test: adb reboot recovery,foo and verify that the parameter reaches bootloader
Change-Id: I9690cf96cf9730e5324b9f5310c3d0341fe25fe2
/system/core/init/builtins.cpp
f57c0bfab20b4fae10fc2e385d5e32fc93895670 07-Apr-2017 Tom Cherry <tomcherry@google.com> init: clean up more headers

We don't need everyone including <sys/system_properties.h>

Test: boot bullhead
Change-Id: I73d507e4f273678eaf15947725741e1e3b966cc6
/system/core/init/builtins.cpp
3f5eaae526413a29de899270714469c76dc91ec8 07-Apr-2017 Tom Cherry <tomcherry@google.com> init: more header cleanup

Remove includes of "log.h" that really want <android-base/logging.h>
Fix header include order
Remove headers included in .cpp files that their associated .h already includes
Remove some unused headers

Test: boot bullhead
Change-Id: I2b415adfe86a5c8bbe4fb1ebc53c7b0ee2253824
/system/core/init/builtins.cpp
dbe88e7953ed53961056c7f5531d91d229293462 28-Dec-2016 Yongqin Liu <yongqin.liu@linaro.org> init: use read_file and write_file to implement do_copy builtin

this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045
Merged-In: If3c30a2fff58cfece2fcd27e69c30382146e6808

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
/system/core/init/builtins.cpp
53089aa25ca9707e22e45e862f794bfc958d302a 01-Apr-2017 Tom Cherry <tomcherry@google.com> init: Use std::string for write_file()

The content parameter of write_file() previously took a char* that was
then converted to a std::string in WriteStringToFd(). One unfortunate
effect of this, is that it is impossible to write data that contains
'\0' within it, as the new string will only contain characters up
until the '\0'.

This changes write_file() to take an std::string, such that
std::string::size() is used to determine the length of the string,
allowing it to contain null characters.

Also change the path parameter of read_file() and write_file() for
consistency.

Lastly, add a test for handling strings with '\0' in them.

Bug: 36726045
Test: Boot bullhead, run unit tests
Change-Id: Idad60e4228ee2de741ab3ab6a4917065b5e63cd8
/system/core/init/builtins.cpp
cf29755e281a2027e79f8fbe5863ae37a8a72f62 31-Mar-2017 Tom Cherry <tomcherry@google.com> Merge "Make init builtin command installkey respect property updates"
3428d0c2c0b0056dadbc561d86b66ec83b960583 31-Mar-2017 Wonsik Kim <wonsik@google.com> Merge "Revert "init: use read_file and write_file to implement do_copy builtin""
395e29472fa012c4177d981d9ce699625b706f4f 31-Mar-2017 Wonsik Kim <wonsik@google.com> Revert "init: use read_file and write_file to implement do_copy builtin"

This reverts commit 82bac0de6d95bcdf45729516f6a4f29eb2681118.

Change-Id: Ibfdf453bd85ba4fcd1948b78bd22e639a883653e
/system/core/init/builtins.cpp
9cc51728af87d476de1b90e0f8dba62b3fc8711f 29-Mar-2017 Janis Danisevskis <jdanis@google.com> Make init builtin command installkey respect property updates

init used to block on installkey such that it was unable to
process property events. This lead to a deadlock by which
the Keymaster HAL would wait indefinitely for the
hwservicemanager.ready=true.

This fixes the issue by implementing the builtin in terms of
do_exec, which allows init to stay responsive to properties
while waiting for the child to terminate.

Bug: 36278706
Test: Add a 3s delay into hwservicemanager before it sets the property
hwservicemanager.ready and the device still boots.

Change-Id: Iaefd31156ca01f3a44b4f85a8bf78beee8dfe224
/system/core/init/builtins.cpp
8772b3686efad95dc53afca5004fcd62c2797638 29-Mar-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge changes from topic 'exec-start-update-verifier'

* changes:
init.rc: launch update_verifier with exec_start
init: add exec_start command
ccf23537eeacfa47e5f18dd3b75089886d177c1b 29-Mar-2017 Tom Cherry <tomcherry@google.com> init: replace property_get with its android::base equivalent

Slowly try to decouple property_service.cpp from the rest of init.

Test: Boot bullhead
Change-Id: I267ae0b057bca0bf657b97cb8bfbb18199282729
/system/core/init/builtins.cpp
20e43a2f2c5054d70f27b8de443ddb13a0d60bf9 29-Mar-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "init: remove unused cutils includes"
1ec1bd918ccebf64aaa40b5ef1c1a497c75aa85e 29-Mar-2017 Tom Cherry <tomcherry@google.com> init: remove unused cutils includes

Test: Boot bullhead
Change-Id: I629f9c3863f00fa38f87a68442c2380d28764718
/system/core/init/builtins.cpp
b27004aa05039b5196f1e878169dca41b68aadd6 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
/system/core/init/builtins.cpp
2b63d54af81b2d061b98799b97f01d771bfa6782 10-Mar-2017 Steven Moreland <smoreland@google.com> init: add class_restart

Bug: 34093663
Test: hwservicemanager `onrestart class_restart hal` works
Change-Id: Ie1e4daab2b7b4c6c714d4e3d05afa2d86d6233df
/system/core/init/builtins.cpp
7f0d15a6f23172657974ad94ba7bbb49cc5df79b 24-Mar-2017 Treehugger Robot <treehugger-gerrit@google.com> Merge "init: use read_file and write_file to implement do_copy builtin"
82bac0de6d95bcdf45729516f6a4f29eb2681118 28-Dec-2016 Yongqin Liu <yongqin.liu@linaro.org> init: use read_file and write_file to implement do_copy builtin

this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Test: manual with hikey

Change-Id: Ifc1086a20e85db6980b497b1150a8a7952e672d6
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
/system/core/init/builtins.cpp
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/builtins.cpp
16663a2aa45eff3df50df562abdf757fd09bbb7a 31-Jan-2017 Todd Poynor <toddpoynor@google.com> powerctl: add thermal-shutdown command

Add sys.powerctl property interface for initiating thermal shutdown.

Bug: 30994946
Test: Manual: setprop sys.powerctl thermal-shutdown
Change-Id: Iffce60bd3cb4b40a5859623d10b91bee5101f168
/system/core/init/builtins.cpp
d8a7257b14086a9070aa521b41118570ee4f4aaa 13-Mar-2017 Tom Cherry <tomcherry@google.com> init: fix DumpState() logging

Fix two formatting issues in Action::DumpState(),

Old:
on ro.crypto.state=encrypted ro.crypto.type=file zygote-start
New:
on ro.crypto.state=encrypted && ro.crypto.type=file && zygote-start

Old:
on boot
%sifup lo
%shostname localhost
%sdomainname localdomain
%swrite /proc/sys/vm/overcommit_memory 1
New:
on boot
ifup lo
hostname localhost
domainname localdomain
write /proc/sys/vm/overcommit_memory 1

Also, now that we're importing many small rc files, it no longer makes
sense to call Parser::DumpState() after each import. Therefore, move
the conditional to call Parser::DumpState() to after /init.rc and its
imports are parsed and after the late imports are parsed.

Test: Boot bullhead with DumpState() enabled and check the output
Change-Id: I0b81305b8938aa1a7133d7dd2055f34f47609cf9
/system/core/init/builtins.cpp
69fae7b3dcf15dadea477dd686bd11bc63c1d2e8 04-Mar-2017 Keun-young Park <keunyoung@google.com> add ro.boottime.init.mount_all.* for measuring mount time

- three properties: .early, .default, .late
- for tracking critical early boot times

bug: 35949600
Test: manual, getprop after boot

Change-Id: I851891518428e6e21cb43a2a6f982ab7db281d4c
/system/core/init/builtins.cpp
4ec72cc25fe889818977ea00d2e97c17a04818a5 22-Feb-2017 Jaekyun Seok <jaekyun@google.com> Treblize init.rc location

Treblization requires to locate partner-specific modules in its own
partition. So their own init.rc file could be located in /odm or
/vendor.
This CL is to support those locations for the init.rc.
Additionally thic CL modified import parser to support importing a
relative path.

Test: building succeeded and tested on sailfish with enabling early
mount.
Bug: 35269867

Change-Id: I1bce924a32c8a2b53fb5d981d35d758cf9ddd9a6
/system/core/init/builtins.cpp
2d0fdaaafc5d2925b8ef7708a950f6b599892b54 02-Feb-2017 Wei Wang <wvw@google.com> init: clean up exec command

Add wait time log for exec service execution time
Fix memory leak when exec service failed to start

Test: on marlin
Bug: 34518530
Change-Id: I01736bd9b1429414f3dc91dd5d02d88a681f0985
/system/core/init/builtins.cpp
132ac31b4738094e62cc1744e75f3756a035302c 26-Jan-2017 Wei Wang <wvw@google.com> init: add wait_for_prop builtin command

There are many use cases from vendors to exec service in background and then
use a shell scriprt to wait for the command done.

This CL is to add a wait_for_prop command to suppor those use cases.

Bug: 34746108
Test: on marlin
Change-Id: Ia81290b0928f9d375710d2daa546714f0cd65b72
/system/core/init/builtins.cpp
77f0e9fda8839a21a4d360f128fe9af820b8819c 28-Dec-2016 Jorge Lucangeli Obes <jorgelo@google.com> init: Make 'write_file' return bool to match 'read_file'.

The mismatch of return values makes reasoning about the correctness of
CLs like https://android-review.googlesource.com/317923 quite hard.

Bug: 33941660
Test: Init builds, HiKey boots.
Change-Id: Ia4b8a9af420682997b154a594892740181980921
/system/core/init/builtins.cpp
0b8b2303acbc244ed02234bf7a9ebba608832ad1 19-Dec-2016 Paul Crowley <paulcrowley@google.com> Ask the user before wiping if crypto policy fails.

If crypto policy fails, instruct recovery to prompt the user before
wiping all data.

Test: adb shell rmdir /data/ota && adb shell mkdir -p /data/ota/forcefail && adb reboot
Bug: 28693324
Change-Id: I4d09b35a20c513a76c9ba56fe826114449a9ad68
/system/core/init/builtins.cpp
4ee7861ee1665b74b491f267636d367bbfe11dd3 16-Dec-2016 Elliott Hughes <enh@google.com> Merge "Improve init bootcharting."
fdf1a54f4544867f7f4c983d06d48978db6b56a2 14-Dec-2016 Tao Bao <tbao@google.com> init: Specify the data wipe reason.

We should say that if the data wipe is triggered by fs_mgr_mount_all.

Test: mmma system/core/init
Change-Id: I3998d9493611ecc286de0913a95cf22fc41100b5
/system/core/init/builtins.cpp
a3641af22fdb0f1b3127e4d56e65c13ad108d74a 11-Nov-2016 Elliott Hughes <enh@google.com> Improve init bootcharting.

Most notably, there's no longer any need to guess an end time.

Bug: http://b/23478578
Bug: http://b/33450491
Test: rebooted with bootcharting on/off
Change-Id: Icb7d6859581da5526d77dfc5aa4d57c9bfbfd7e2
/system/core/init/builtins.cpp
8cf9d66486aad3c827b5b0a9eca75871e7444a6a 05-Dec-2016 Elliott Hughes <enh@google.com> Merge "Replace the "coldboot" timeout with a property."
am: e218fc673f

Change-Id: Ibaf1f7ad3a90e5216db04506288df51258e19f4b
331cf2fb7c16b5b25064f8d2f00284105a9b413f 29-Nov-2016 Elliott Hughes <enh@google.com> Replace the "coldboot" timeout with a property.

Also rename init's existing boot-time related properties so they're
all "ro.*" properties.

Example result:

# Three properties showing when init started...
[ro.boottime.init]: [5294587604]
# ...how long it waited for ueventd...
[ro.boottime.init.cold_boot_wait]: [646956470]
# ...and how long SELinux initialization took...
[ro.boottime.init.selinux]: [45742921]

# Plus one property for each service, showing when it first started.
[ro.boottime.InputEventFind]: [10278767840]
[ro.boottime.adbd]: [8359267180]
[ro.boottime.atfwd]: [10338554773]
[ro.boottime.audioserver]: [10298157478]
[ro.boottime.bootanim]: [9323670089]
[ro.boottime.cameraserver]: [10299402321]
[ro.boottime.cnd]: [10335931856]
[ro.boottime.debuggerd]: [7001352774]
[ro.boottime.debuggerd64]: [7002261785]
[ro.boottime.drm]: [10301082113]
[ro.boottime.fingerprintd]: [10331443314]
[ro.boottime.flash-nanohub-fw]: [6995265534]
[ro.boottime.gatekeeperd]: [10340355242]
[ro.boottime.healthd]: [7856893380]
[ro.boottime.hwservicemanager]: [7856051088]
[ro.boottime.imscmservice]: [10290530758]
[ro.boottime.imsdatadaemon]: [10358136702]
[ro.boottime.imsqmidaemon]: [10289084872]
[ro.boottime.installd]: [10303296020]
[ro.boottime.irsc_util]: [10279807632]
[ro.boottime.keystore]: [10305034093]
[ro.boottime.lmkd]: [7863506714]
[ro.boottime.loc_launcher]: [10324525241]
[ro.boottime.logd]: [6526221633]
[ro.boottime.logd-reinit]: [7850662702]
[ro.boottime.mcfg-sh]: [10337268315]
[ro.boottime.media]: [10312152687]
[ro.boottime.mediacodec]: [10306852530]
[ro.boottime.mediadrm]: [10308707999]
[ro.boottime.mediaextractor]: [10310681177]
[ro.boottime.msm_irqbalance]: [7862451974]
[ro.boottime.netd]: [10313523104]
[ro.boottime.netmgrd]: [10285009351]
[ro.boottime.oem_qmi_server]: [10293329092]
[ro.boottime.per_mgr]: [7857915776]
[ro.boottime.per_proxy]: [8335121605]
[ro.boottime.perfd]: [10283443101]
[ro.boottime.qcamerasvr]: [10329644772]
[ro.boottime.qmuxd]: [10282346643]
[ro.boottime.qseecomd]: [6855708593]
[ro.boottime.qti]: [10286196851]
[ro.boottime.ril-daemon]: [10314933677]
[ro.boottime.rmt_storage]: [7859105047]
[ro.boottime.servicemanager]: [7864555881]
[ro.boottime.ss_ramdump]: [8337634938]
[ro.boottime.ssr_setup]: [8336268324]
[ro.boottime.surfaceflinger]: [7866921402]
[ro.boottime.thermal-engine]: [10281249924]
[ro.boottime.time_daemon]: [10322006542]
[ro.boottime.ueventd]: [5618663938]
[ro.boottime.vold]: [7003493920]
[ro.boottime.wificond]: [10316641073]
[ro.boottime.wpa_supplicant]: [18959816881]
[ro.boottime.zygote]: [10295295029]
[ro.boottime.zygote_secondary]: [10296637269]

Bug: http://b/31800756
Test: boots
Change-Id: I094cce0c1bab9406d950ca94212689dc2e15dba5
/system/core/init/builtins.cpp
ffa3689107d0e9c944e5d877dd8e857e1d22cb65 17-Nov-2016 Paul Lawrence <paullawrence@google.com> Merge "Add flags to restorecon_recursive to traverse filesystems"
am: 5fbd1cfd34

Change-Id: I539d7e9d441c7bb3f5602b892408a85436b857e8
5fbd1cfd340e8b33ba308e5341dc07d82edfe9c0 17-Nov-2016 Treehugger Robot <treehugger-gerrit@google.com> Merge "Add flags to restorecon_recursive to traverse filesystems"
279f3d593fef224a25324800d03b61d256c1e4dd 17-Nov-2016 Wei Wang <wvw@google.com> init: fix undefined behavior in ExecuteCommand
am: d67a4abc64

Change-Id: I1ecbb1d083af62dd5e69b4cff19ec411016054f3
2369b1eb8095f42c16f05f553dd58683353ed65d 17-Nov-2016 Wei Wang <wvw@google.com> Merge changes from topic 'slow_log'

* changes:
init: fix undefined behavior in ExecuteCommand
Revert "Revert "init: warn slow action""
d67a4abc647d5ed7235ff7ee1695b31340e63a1c 16-Nov-2016 Wei Wang <wvw@google.com> init: fix undefined behavior in ExecuteCommand

ExecuteCommand may change command_ vector which leads undefined behavior
This bug is found when adding logs in ExecuteCommand printing our Command class fields

Bug: 32838381
Test: on emulator
Change-Id: I96468bd2192ca80013871a3a6ac4132149363fff
/system/core/init/builtins.cpp
a8d8434c42b27f0186be7ecd78c2acc9d459b068 15-Nov-2016 Paul Lawrence <paullawrence@google.com> Add flags to restorecon_recursive to traverse filesystems

Use to solve the problem of tracefs conditionally being mounted
under debugfs and needing restorecon'd without boot performance
penalty.

Also move skip-ce to a flag for consistency.

Test: Check that trace_mount has correct attributes after boot
Bug: 32849675
Change-Id: Ib6731f502b6afc393ea5ada96fa95b339f14da49
/system/core/init/builtins.cpp
d1d3bdd16fbaae87e0cfdb8d412f226e4aa390cf 16-Jul-2016 Jeff Sharkey <jsharkey@android.com> Only restorecon CE storage after unlocked.

On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed. This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories. vold will request a restorecon when the keys
are actually installed.

(cherrypicked from commit 1635afe83d1ebd6b5f1fac1e9c6c6b5cd1c93204)

Bug: 30126557
Test: Cherry-picked from master
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
/system/core/init/builtins.cpp
3ee9807554c85c1faa7ec70bf46f9e7f84b8c3b6 15-Nov-2016 Elliott Hughes <enh@google.com> Merge "Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for."
am: f3e731b3c5

Change-Id: I2028bb8835c5e55e1bf8c88c3395253ded9d66d3
290a228fdca935ab2e702db77516758314900c3a 15-Nov-2016 Elliott Hughes <enh@google.com> Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for.

Bug: http://b/32878766
Test: boots
Change-Id: Ie0ddfb7e60f2da5f6eefbb10c83a92e88c137ae3
/system/core/init/builtins.cpp
eefaa1f250c9680ccecf7309b4b542e28b80bf73 14-Nov-2016 Elliott Hughes <enh@google.com> Merge "init start time tracking."
am: 601bf9e7c9

Change-Id: Idd707d4694a4339e26884fe72b8f0c08c4100daf
601bf9e7c978ce70711adb185a200b6ecb75073e 14-Nov-2016 Elliott Hughes <enh@google.com> Merge "init start time tracking."
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/builtins.cpp
d1b560c6f97a01c79ebc90d94744f382dba76de4 10-Nov-2016 Vineela Tummalapalli <vineela.tummalapalli@intel.com> Merge "Implement Reboot bootloader via bootloader_message"
am: e759c83bde

Change-Id: Id0a0e9e9c10f3df206138f297d2acafa87dc4ebf
039734c7deba32a5f6d27a31dcfdc0a9fa19b0fb 29-Oct-2016 Vineela Tummalapalli <vineela.tummalapalli@intel.com> Implement Reboot bootloader via bootloader_message

- Write reboot bootloader message to misc
- Clarify naming for reboot to recovery

BUG: https://issuetracker.google.com/issues/32474515

Change-Id: I4e42509bfcf572e37c8fc070d6571afe406a48b6
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Reviewed-on: https://android.intel.com/548494
/system/core/init/builtins.cpp
1051e107f234cd5ce1fe159fd90756693555a5bd 25-Jun-2016 Yabin Cui <yabinc@google.com> init: use libbootloader_message.

Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
(cherry picked from commit 0b1252cca0ecd5603e0fc0d5dadde91410b6b557)
/system/core/init/builtins.cpp
7948a33f2c5a05d2f116f8b533db9f265b68f92f 14-Oct-2016 Elliott Hughes <enh@google.com> resolve merge conflicts of a4398c1 to stage-aosp-master am: 195669febc
am: b2ab1c43cb

Change-Id: I412943235ad6cd908aca04c56aa19a3d2bbb5413
da46b392f10d2809b5696632f67485f272ec5698 12-Oct-2016 Elliott Hughes <enh@google.com> Move off std::sto* function which abort on failure.

Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
/system/core/init/builtins.cpp
6efc7a787b1f81904e0466c9c8e58174b41d4745 11-Oct-2016 Tao Bao <tbao@google.com> Merge "Update the header path for ext4_utils." am: 5bc3ce85cf am: 148b85b050
am: 2815ac5584

Change-Id: I966296de6eb4ff7518b9cfcd5853fe919765b826
6d881d6db438208a1bce9806753defbb09811962 06-Oct-2016 Tao Bao <tbao@google.com> Update the header path for ext4_utils.

Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
/system/core/init/builtins.cpp
d61a7e2da4e6184797f866abf8020bfe3b928ab0 23-Aug-2016 Wei Wang <wvw@google.com> Split fstab mount into 2 phases

This will make it possible to start some key services before mounting
data partition

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
(cherry picked from commit abfbec342fdd2fc9d139a88a2d950953918e1b4e)
/system/core/init/builtins.cpp
254f44363b85f4665b1942762a708bf87301a462 23-Aug-2016 Wei Wang <wvw@google.com> Split fstab mount into 2 phases

This will make it possible to start some key services before mounting
data partition

(cherry picked from commit abfbec342fdd2fc9d139a88a2d950953918e1b4e)

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
/system/core/init/builtins.cpp
3ad2ffc47447af50b8c5697926dc1807626658ea 05-Aug-2016 Elliott Hughes <enh@google.com> Move init's kernel logging into libbase. am: 7bc87a5a78 am: e2a7eb17b5
am: b7252fc35a

Change-Id: Ibfba937cede98ceb8f4b76d3a636e5b8035689c0
e2a7eb17b5b7784befc5ebd80b535557362cbd29 05-Aug-2016 Elliott Hughes <enh@google.com> Move init's kernel logging into libbase.
am: 7bc87a5a78

Change-Id: Ie5e359e8bd7dee4c0549072c7e955eeefe57d785
7bc87a5a780361928bd1aeed9d2f22233fe05407 05-Aug-2016 Elliott Hughes <enh@google.com> Move init's kernel logging into libbase.

This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
/system/core/init/builtins.cpp
91404d94813cb6fb7a29b185ec58ca5290d9ccdf 18-Jul-2016 Jeff Sharkey <jsharkey@android.com> Merge \"Only restorecon CE storage after unlocked.\" into nyc-mr1-dev
am: 96f387e8c0

Change-Id: I3a1c31334d32e7bdff8e05558356d2833fcfb831
1635afe83d1ebd6b5f1fac1e9c6c6b5cd1c93204 16-Jul-2016 Jeff Sharkey <jsharkey@android.com> Only restorecon CE storage after unlocked.

On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed. This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories. vold will request a restorecon when the keys
are actually installed.

Bug: 30126557
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
/system/core/init/builtins.cpp
1b8159e7ab47d68ab7ff895260fd7e99622f73d5 01-Jul-2016 Yabin Cui <yabinc@google.com> Merge \"init: use libbootloader_message.\" into nyc-mr1-dev
am: ca4cf4e4af

Change-Id: I8234e796a8b35115ef1ecf33c987882f8fe286cd
ca4cf4e4af758754c5f32126084b558c907b110b 30-Jun-2016 Yabin Cui <yabinc@google.com> Merge "init: use libbootloader_message." into nyc-mr1-dev
0b1252cca0ecd5603e0fc0d5dadde91410b6b557 25-Jun-2016 Yabin Cui <yabinc@google.com> init: use libbootloader_message.

Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
/system/core/init/builtins.cpp
40095a6eae1aa53a454a0e93095cadbf7dbbcd7a 30-Jun-2016 Alex Light <allight@google.com> Add umount call to init to unmount a filesystem
am: 68ab20febd

Change-Id: I1166f88814193092f10dad8a2fa841028613e03e
68ab20febd1dd1a033ee9d25fa2ab30c0b13e469 23-Jun-2016 Alex Light <allight@google.com> Add umount call to init to unmount a filesystem

Bug: 29278988
Change-Id: Ia14ab1bcad9513688df97f7b4d9162a9ab282480
/system/core/init/builtins.cpp
7f5b29ff1e5debb36fda8679df3e75343b4ba39f 27-Jun-2016 Elliott Hughes <enh@google.com> resolve merge conflicts of 54c1219 to stage-aosp-master

Change-Id: I4b3b2a8690cfe147929fd096de380a9d4b79f1ec
f86b5a6b90619e02d1d034ef7b0adc3b439f4abb 25-Jun-2016 Elliott Hughes <enh@google.com> Move init to libbase logging.

Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
/system/core/init/builtins.cpp
80744d867f4e6d3f9cf7a0ba99adeb36be8184a3 25-Jun-2016 Elliott Hughes <enh@google.com> Merge \"Remove MTD cruft from init.\"
am: 90db709a2f

Change-Id: I027708dd324000cbfad1a2a6e970f742db97bae5
3195116e9718a4159f4149bcdc0d2a85339fcbf5 25-Jun-2016 Elliott Hughes <enh@google.com> Remove MTD cruft from init.

Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
/system/core/init/builtins.cpp
23a574a195ebe4f755a1f305952332ed18a1242f 24-Jun-2016 Hung-ying Tyan <tyanh@google.com> resolve merge conflicts of 66277db to stage-aosp-master

Change-Id: I58b1f7fec779c707ac4048ae5401087ec4b7c8b0
bfa6d75c60704e73b204b9ddcccd443e862ffa34 17-May-2016 Hung-ying Tyan <tyanh@google.com> Add -f to insmod

When the flag is on, insmod will bypass vermagic and symbol version
checking in the kernel. This is to make it possible to update kernel
without recompiling kernel modules.

BUG=28803994

Change-Id: Ib4be6999ef52baefd4210ee0d242360e43318907
/system/core/init/builtins.cpp
71bac3fa4b519ff9aa537a3ef6b7242b5c8f848c 11-May-2016 Paul Crowley <paulcrowley@google.com> Merge "Wipe device on policy error" into nyc-dev
am: 8a59fa8524

* commit '8a59fa85243a5f748108279f6d30b01292518b0a':
Wipe device on policy error

Change-Id: I35205b2ddf8b3e8d049525e3717d27836d6c59a2
af8be58ca2aeae031cbd49c9deeffeff87699cf1 10-May-2016 Paul Crowley <paulcrowley@google.com> Wipe device on policy error

If we fail to set a crypto policy on a system-DE directory, this is a
serious and unrecoverable condition; the only way forward is to erase
the entire device. In a future commit we will also allow users the
option of booting again.

Bug: 28318405
Change-Id: Iff1e52c5bbee1beed29dc4b609d24bfeb7d138da
/system/core/init/builtins.cpp
f2049163a4ce602dffaa41a747ee5675a0d82752 28-Mar-2016 Nick Kralevich <nnk@google.com> init/builtins.cpp: Switch to finit_module

Switch insmod from using init_module to finit_module. From
"man finit_module":

The finit_module() system call is like init_module(), but reads the
module to be loaded from the file descriptor fd. It is useful when the
authenticity of a kernel module can be determined from its location in
the file system; in cases where that is possible, the overhead of
using cryptographically signed modules to determine the authenticity
of a module can be avoided.

finit_module is preferred over init_module because it allows LSMs, such
as SELinux, to perform a permission check on kernel module loads based on
the file from which the module is loaded. This functionality is not yet
implemented in the Linux kernel, but is on the SEAndroid TODO list.
See https://bitbucket.org/seandroid/wiki/wiki/ToDo

Bug: 27824855

(cherry picked from commit 124a9c97e9815142a33480b81a5a3041a7cd66bd)

Change-Id: I5e87de1a7b8c3d8849bf757c71b08e81c378b021
/system/core/init/builtins.cpp
1a920d72dcc6f8c91fd6ec04954facd4d351fb9d 19-Apr-2016 Paul Lawrence <paullawrence@google.com> Merge "Don\'t start defaultcrypto twice" into nyc-dev
am: fe5d55a

* commit 'fe5d55a68b9dc3a593d3f6ee5be919b8a9de710c':
Don't start defaultcrypto twice

Change-Id: I0e9a27208ea046a2cf738992ba97141da9026c08
1f99218612fa12f2c3354c29bf8d761a27e50148 19-Apr-2016 Paul Lawrence <paullawrence@google.com> Don't start defaultcrypto twice

The old way (using triggers) starts defaultcrypto twice because
queue_property_triggers_action retriggers the action.

Bug: 27452459
Change-Id: I48c844836f551673d0dbfed6c33bd8ee1e035f40
/system/core/init/builtins.cpp
52a302d1e62c35112d8599e1b9ff20dc26b60970 09-Apr-2016 Yabin Cui <yabinc@google.com> Merge "init: write bootloader message directly." into nyc-dev
am: a3a7a88

* commit 'a3a7a886f5277b6223140761e58cea0753854225':
init: write bootloader message directly.

Change-Id: I764e0288b40264b8e48fc09011c3c0475b71a04e
46e037980bdcbd4d7cb73cbf67763d8fc7b75493 07-Apr-2016 Yabin Cui <yabinc@google.com> init: write bootloader message directly.

Bug: 27176738
Change-Id: I8c95a193f3436c0893d5103760b700f3052888db
/system/core/init/builtins.cpp
6ba371065181d556ce8988b361f6a2816df1f696 08-Apr-2016 Elliott Hughes <enh@google.com> Merge "init: drop unused header android_filesystem_config.h" am: 54c27c7
am: 8cb6a9c

* commit '8cb6a9cdb7cb1feaff29914aa88c68399e32f14f':
init: drop unused header android_filesystem_config.h

Change-Id: I1cc001c883199e8355e97d93a2f6ce0d46bdd767
6df15704bd366c174efa95039298dc234f54401f 07-Apr-2016 William Roberts <william.c.roberts@intel.com> init: drop unused header android_filesystem_config.h

Change-Id: I66e637bc2d7fd5f385f40f150becfe515c53c19a
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
/system/core/init/builtins.cpp
402fb79d4354aa3a627bf38a0fc10718c2b90a20 05-Apr-2016 Mark Salyzyn <salyzyn@google.com> init: turn off backlight when performing shutdown cleanup

(cherry pick from commit a98cc9c202b9ff97df89e2258bf04bc3b8b57301)

Try writing a "0" into:

- /sys/class/leds/lcd-backlight/brightness
- /sys/class/backlight/*/brightness

to turn off the backlight during shutdown cleanup.

Bug: 27506425
Change-Id: Ic8a44dc8909b303f24e14f71cfb43292df60efde
/system/core/init/builtins.cpp
24f79bed760db1d074e77f82201fced057d41d80 06-Apr-2016 Mark Salyzyn <salyzyn@google.com> Merge "init: turn off backlight when performing shutdown cleanup" am: adf1cde
am: 23702b5

* commit '23702b538b3a02ca35f24c55d406a7cc7b14641f':
init: turn off backlight when performing shutdown cleanup

Change-Id: I249106a3b6c22e77d06bca5aee1d92184b00ba33
a98cc9c202b9ff97df89e2258bf04bc3b8b57301 05-Apr-2016 Mark Salyzyn <salyzyn@google.com> init: turn off backlight when performing shutdown cleanup

Try writing a "0" into:

- /sys/class/leds/lcd-backlight/brightness
- /sys/class/backlight/*/brightness

to turn off the backlight during shutdown cleanup.

Bug: 27506425
Change-Id: Ic8a44dc8909b303f24e14f71cfb43292df60efde
/system/core/init/builtins.cpp
0fcc2ee4e4e6142c0d789a456f18caf33596ea3c 05-Apr-2016 Mark Salyzyn <salyzyn@google.com> init: watchdog restarted during shutdown fsck

(cherry pick from commit ad575e04a1d89f5a2a4e3006a58e801cad9c9805)

Bug: 27506425
Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
/system/core/init/builtins.cpp
e4c8b31fed15d1e246450d6e7821ca07915b888c 05-Apr-2016 Mark Salyzyn <salyzyn@google.com> Merge "init: watchdog restarted during shutdown fsck" am: 3443caa
am: 34dcdd8

* commit '34dcdd8075a0c12de552219d4f326bccd1c8fe62':
init: watchdog restarted during shutdown fsck

Change-Id: I28e3a730f2d854c51f1d760a5400faecd3f1fafc
ad575e04a1d89f5a2a4e3006a58e801cad9c9805 05-Apr-2016 Mark Salyzyn <salyzyn@google.com> init: watchdog restarted during shutdown fsck

Bug: 27506425
Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
/system/core/init/builtins.cpp
d87a1747aac3016fadb670bf2aecda55d031f417 30-Mar-2016 Nick Kralevich <nnk@google.com> Merge "init/builtins.cpp: Switch to finit_module" am: b3cf2e0
am: 699b115

* commit '699b115be3c79547e9cc6d8bca771d77eb384915':
init/builtins.cpp: Switch to finit_module

Change-Id: Iab21b9e058fe9435847ba9bca4cb2d1c0f50c88f
124a9c97e9815142a33480b81a5a3041a7cd66bd 28-Mar-2016 Nick Kralevich <nnk@google.com> init/builtins.cpp: Switch to finit_module

Switch insmod from using init_module to finit_module. From
"man finit_module":

The finit_module() system call is like init_module(), but reads the
module to be loaded from the file descriptor fd. It is useful when the
authenticity of a kernel module can be determined from its location in
the file system; in cases where that is possible, the overhead of
using cryptographically signed modules to determine the authenticity
of a module can be avoided.

finit_module is preferred over init_module because it allows LSMs, such
as SELinux, to perform a permission check on kernel module loads based on
the file from which the module is loaded. This functionality is not yet
implemented in the Linux kernel, but is on the SEAndroid TODO list.
See https://bitbucket.org/seandroid/wiki/wiki/ToDo

Bug: 27824855
Change-Id: Id0ea88cd1930393c8c73ce38e63d5b2eeadf946a
/system/core/init/builtins.cpp
1098aacde46dffeb97d03e4079a9ef8ffac8199e 05-Mar-2016 Paul Lawrence <paullawrence@google.com> Distinguish between unencrypted and unencryptable

Set ro.crypto.state flag to unencrypted and unsupported accordingly

Bug: 18002358
Change-Id: I1f88ce9704c5505d7b63256e2ebe5f8441c79ad0
/system/core/init/builtins.cpp
3b9c83a0f69778253f82730404363b5f5f795eb2 03-Feb-2016 Jeff Sharkey <jsharkey@android.com> User 0 directories are created by vold now.

This ensures that all users on device follow a consistent path for
setup and validation of encryption policy.

Also add remaining user-specific directories and fix linking order.

Bug: 25796509
Change-Id: I8c2e42a78569817f7f5ea03f54b743a6661fdb9c
/system/core/init/builtins.cpp
69080180cee82bec39148ccab8b0a7928c42ae0e 02-Feb-2016 Paul Lawrence <paullawrence@google.com> Remove code to handle non-default file encryption

Change-Id: I6d986853929c0237c0d958329b8e9aab47907a00
/system/core/init/builtins.cpp
5949745534e11a877ec839931af76c569f78e058 01-Feb-2016 Paul Crowley <paulcrowley@google.com> On FDE devices, initialize user 0

Fix ugly special cases for user 0: initialize them explicitly.

Bug: 26704408
Change-Id: I1b8536b9e5e87ea98b4009a309f2e22c56006651
/system/core/init/builtins.cpp
65f54a8e1917dd673d739621d78786000ecc949a 21-Jan-2016 Paul Crowley <paulcrowley@google.com> Merge "Remove no-longer-needed crypto init builtins"
25778dcf5ec427975927dcf9b925ba57bebe40fc 21-Jan-2016 Hung-ying Tyan <tyanh@google.com> Merge "Allow paths of .rc files to be specified at mount_all" am: e7f9779886
am: 436a8aa9de

* commit '436a8aa9de9c90a8ee95e02e97bf65e50c80d4f4':
Allow paths of .rc files to be specified at mount_all
dc738eaf1547c250979bb9f1ffb64b0836a5e7f3 14-Jan-2016 Hung-ying Tyan <tyanh@google.com> Allow paths of .rc files to be specified at mount_all

In current implementation, the mount_all command imports all .rc files
under /{system,vendor,odm}/etc/init/ after mouting filesystems is complete.
There's a need from ODMs to import different .rc files under different boot
modes (e.g., factory mode). Without this support, they will have to fiddle
around the init implementation.

This commit makes mount_all import the .rc files/directories specified
as additional arguments. If no path is given, the original ones are applied
the same way as the current implementation.

BUG: 26549689
Change-Id: Ie67ce13dde4c440ff8bf534826bc392c882a433f
/system/core/init/builtins.cpp
558d8f4364c87e7ba34ef4c127654cdd9e049072 20-Jan-2016 Paul Crowley <paulcrowley@google.com> Remove no-longer-needed crypto init builtins

Changes to the way FBE works to support lifecycles mean that these
commands aren't needed any more.

Bug: 22358539
Change-Id: Id73339e0aa8070dd688f35b5d59de75236961395
/system/core/init/builtins.cpp
530c8c75e2c02771831e24fbcd8925221267769b 08-Jan-2016 Bertrand Simonnet <bsimonnet@google.com> Merge "init: Allows shutting down cleanly." am: f9f4ee8b72
am: a8c931b7f5

* commit 'a8c931b7f57c8ce74f520d591e99bb367f91dc81':
init: Allows shutting down cleanly.
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/builtins.cpp
6401e61a6aadf68efc80394c6368637d94281983 11-Dec-2015 Sami Tolvanen <samitolvanen@google.com> Merge "Set up dm-verity in EIO mode instead of logging mode" am: 0d1214c68e
am: 42a86f8d1e

* commit '42a86f8d1e918356e86d4eb3fb2444a8c42d25ff':
Set up dm-verity in EIO mode instead of logging mode
0d1214c68ea95543468b09f7ae27bd65c8c8d7c0 10-Dec-2015 Sami Tolvanen <samitolvanen@google.com> Merge "Set up dm-verity in EIO mode instead of logging mode"
c5733cfadbf98c8b6a1b280306cb9abac162f26c 09-Dec-2015 Paul Lawrence <paullawrence@google.com> Add createuserkey

Needed so we can make the user0 key on first boot

Change-Id: I4699dbf2efdec44bb09bc4cfa7eeb59e56cb93ab
/system/core/init/builtins.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/init/builtins.cpp
90f52df257ab020934558a811bad2ba0bae33c5a 02-Dec-2015 Sami Tolvanen <samitolvanen@google.com> Set up dm-verity in EIO mode instead of logging mode

If the device is corrupted, set up dm-verity in EIO mode instead of
logging mode. This prevents corrupted blocks from being returned to
user space. Note that restart mode is used by default and a warning
will be displayed to the user after corruption is first detected.

Bug: 19277516
Change-Id: I38966d73eb814836bc34b4bad1192583e5010b36
/system/core/init/builtins.cpp
af20a7cb12e5426738f8f068f6e5e46871bae1aa 02-Sep-2015 Tom Cherry <tomcherry@google.com> resolved conflicts for merge of cda81d01 to mnc-dr-dev-plus-aosp

Change-Id: I747b279bc49f9f82b8f8859c49b3fc2a4e3b4977
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/builtins.cpp
25c22bb9e71998d0358628052fc32a09ec53bbbf 21-Aug-2015 Tom Cherry <tomcherry@google.com> am 08a6775f: am 2d8be6c2: Merge "init: import init rc scripts from file systems after mount_all"

* commit '08a6775f8cdadf48e7b5f4f4d710180fda43b2b6':
init: import init rc scripts from file systems after mount_all
b8dd0272e5decb066152e9dc99bcb41e60264a99 22-Jul-2015 Tom Cherry <tomcherry@google.com> init: import init rc scripts from file systems after mount_all

Import /{system,vendor,odm}/etc/init/... after file systems are mounted

Bug: 23186545
Change-Id: Idb0cae9773f904c0330054c8b3e31eb87b2fb7cb
/system/core/init/builtins.cpp
9962b04d00d6ee16f347637784049a35548c3f2d 20-Aug-2015 Yusuke Sato <yusukes@google.com> am d1b11a04: am e656be33: Merge "Add |opts| argument to android_fork_execvp_ext"

* commit 'd1b11a04903be74ba6a47307d8c3ef2731e3f4ab':
Add |opts| argument to android_fork_execvp_ext
d81c3c6c45e572365127b73594c0ccf0b7f86f17 14-Aug-2015 Yusuke Sato <yusukes@google.com> Add |opts| argument to android_fork_execvp_ext

to allow the caller to send data to the child's stdin.

Bug: 21725996
Change-Id: I818f5cf61045286c8d64a91b6d50f05740329be1
/system/core/init/builtins.cpp
2647d2e70e089eafbf7e4b1478e8de1aeddf5588 07-Aug-2015 Tom Cherry <tomcherry@google.com> am 4036f5ab: am 4bf3dc93: Merge "Create Service and ServiceManager classes"

* commit '4036f5ab2ffbe5a2e47d46aa376e9791385cc31b':
Create Service and ServiceManager classes
bac3299720623f4226bca103b26260052732ad30 31-Jul-2015 Tom Cherry <tomcherry@google.com> Create Service and ServiceManager classes

Change-Id: I363a5e4751ad83d2f4096882a6fbbeddca03acfe
/system/core/init/builtins.cpp
087cd35b79151978e0f119af32748fbce02564be 03-Aug-2015 Tom Cherry <tomcherry@google.com> resolved conflicts for merge of 0070026c to mnc-dr-dev-plus-aosp

Change-Id: Ibc802572898b6913c1f5d94aaae19974bfc0eb85
adda8f73887c6e4f750db3a414ebaecb2a499dfe 03-Aug-2015 Yusuke Sato <yusukes@google.com> am 2f9e1db3: am b5d6ad81: Merge "Stop calling fsck on shutdown by default"

* commit '2f9e1db37416cdb580d870218b5fbfbed47a3758':
Stop calling fsck on shutdown by default
4247ebfd2faefcfd7abf7a4cc4c85ce6c8b5125c 03-Aug-2015 Tom Cherry <tomcherry@google.com> Merge "init: use std::vector<std::string> for argument passing"
b5d6ad81cb963b6eceeb21c7f93bc433112c4b35 01-Aug-2015 Yusuke Sato <yusukes@google.com> Merge "Stop calling fsck on shutdown by default"
96f67316a22bc9236aed70b198e91a5406389e5b 30-Jul-2015 Tom Cherry <tomcherry@google.com> init: use std::vector<std::string> for argument passing

Change-Id: Ie7a64e65de3a20d0c7f7d8efc0f7c1ba121d07fe
/system/core/init/builtins.cpp
7da270df1d020c8b1ebcd636ae090d1edc1f7e89 30-Jul-2015 Tom Cherry <tomcherry@google.com> am a21d8562: am d548e30f: Merge "init: Create classes for Action and Command"

* commit 'a21d85620560896bbed0cd43db9ed3224ab4e974':
init: Create classes for Action and Command
fa0c21c94ccb98bfa5cf3cc7a6b220be4a5fa378 24-Jul-2015 Tom Cherry <tomcherry@google.com> init: Create classes for Action and Command

This creates the concept of 'event_trigger' vs 'property_trigger'

Previously these were merged into one, such that 'on property:a=b &&
property:b=c' is triggered when properties a=b and b=c as expected,
however combinations such as 'on early-boot && boot' would trigger
during both early-boot and boot. Similarly, 'on early-boot &&
property:a=b' would trigger on both early-boot and again when property
a equals b.

The event trigger distinction ensures that the first example fails to
parse and the second example only triggers on early-boot if
property a equals b.

This coalesces Actions with the same triggers into a single Action object

Change-Id: I8f661d96e8a2d40236f252301bfe10979d663ea6
/system/core/init/builtins.cpp
310851549be9a53d9b3418248e1fd81364aa2e17 25-Jul-2015 Yabin Cui <yabinc@google.com> am bd5f10ad: am 699be5f6: Merge "init: do expand_props before calling the builtins."

* commit 'bd5f10addfba8df40c8293d95c002044acbfa526':
init: do expand_props before calling the builtins.
00ede7d2626f9343d330dc6f5286bba3e99e41d0 24-Jul-2015 Yabin Cui <yabinc@google.com> init: do expand_props before calling the builtins.

Also switch expand_props to std::string.

Bug: 22654233

Change-Id: I62910d4f74e2b1a5bd2b14aea440767a2a8462b7
/system/core/init/builtins.cpp
0ff8590e78d32a38169f1a1f0156d5287f9d6162 24-Jul-2015 Yabin Cui <yabinc@google.com> resolved conflicts for merge of bff40697 to mnc-dr-dev-plus-aosp

Change-Id: I7d7a614a5eb987ef6aecd32ed15a6eaa43e93957
74edcea90e31a3795e58aa1b2bbe96032f0bcd61 24-Jul-2015 Yabin Cui <yabinc@google.com> init: Let property_get return std::string.

Bug: 22654233

Change-Id: Id6091f58432f75e966b9871256049fbe17766c10
/system/core/init/builtins.cpp
2694ad9ad9cdba42d6c912bc836a6ba650303486 22-Jul-2015 Elliott Hughes <enh@google.com> am 7f12fa27: am f5b46079: Merge "init: use init\'s property expansion code for mount_all"

* commit '7f12fa275604504ed874c08d6b7f906e8e522c73':
init: use init's property expansion code for mount_all
12df1e118a78035f0319cd15f77eb29db5fa1dd9 21-Jul-2015 Nan Liu <nan.liu619@gmail.com> init: use init's property expansion code for mount_all

Change-Id: I3bd00c74cd126b66927eca7812943f8427009356
Signed-off-by: Nan Liu <nan.liu619@gmail.com>
/system/core/init/builtins.cpp
f93d42933bfdd351bbb0eda79ccb7194a40461d8 22-Jul-2015 Yusuke Sato <yusukes@google.com> Stop calling fsck on shutdown by default

Instead, run the command only when sys.powerctl is set to
"shutdown,userrequested". This way, we can avoid running
fsck when shutdown is triggered due to a low power state.

This is a follow-up CL for http://r.android.com/158525.

Bug: 21853106
Change-Id: Ie57c23cd25162cc2a8726f876a9ba212080105fb
/system/core/init/builtins.cpp
7954eb0a466ac502d51e3424999f437731d90f49 21-Jul-2015 Yusuke Sato <yusukes@google.com> am ab64465d: am 0e3ce82b: Merge "Use fsck.f2fs -a instead of -f for faster boot"

* commit 'ab64465d1f16f414c0bde5e3c4707c32b8220bbc':
Use fsck.f2fs -a instead of -f for faster boot
0df08271fb41e13550a4f2aa1fbdeb76b9a548c6 08-Jul-2015 Yusuke Sato <yusukes@google.com> Use fsck.f2fs -a instead of -f for faster boot

and run fsck with -f on clean shutdown instead.

With -f, fsck.f2fs always performs a full scan of the /data
partition regardless of whether the partition is clean or not.
The full scan takes more than 2 seconds on volantis-userdebug
and delays the OS boot.

With -a, the command does almost nothing when the partition
is clean and finishes within 20-30ms on volantis-userdebug.
When the partition has an error or its check point has
CP_FSCK_FLAG (aka "need_fsck"), the command does exactly the
same full scan as -f to fix it.

Bug: 21853106
Change-Id: I126263caf34c0f5bb8f5e6794454d4e72526ce38
/system/core/init/builtins.cpp
b7f1f61fbc1c2eae7a689df476da401847a936d9 14-Jul-2015 Paul Crowley <paulcrowley@google.com> am ee923139: Merge "Set up user directory crypto in init." into mnc-dr-dev

* commit 'ee923139c346e6751203fc7d2a341388e01c7b19':
Set up user directory crypto in init.
logd: switch to unordered_map from BasicHashtable
rootdir: make sure the /oem mountpoint is always available
ee923139c346e6751203fc7d2a341388e01c7b19 13-Jul-2015 Paul Crowley <paulcrowley@google.com> Merge "Set up user directory crypto in init." into mnc-dr-dev
c1fa34b9f600c827769b4401d8b12e7c587b68f4 13-Jul-2015 Paul Lawrence <paullawrence@google.com> am d5ef9841: Merge "Change init sequence to support file level encryption" into mnc-dr-dev

* commit 'd5ef984195779aa9e27d7baabdd751d641eea1a0':
Change init sequence to support file level encryption
948410a4936fda5348304af9711db932926bcc1a 01-Jul-2015 Paul Lawrence <paullawrence@google.com> Change init sequence to support file level encryption

File level encryption must get the key between mounting userdata and
calling post_fs_data when the directories are created. This requires
access to keymaster, which in turn is found from a system property.

Split property loaded into system and data, and load in right order.

Bug: 22233063
/system/core/init/builtins.cpp
e8308f852c867bc676e71875ea57de022464ea09 07-Jul-2015 Paul Lawrence <paullawrence@google.com> am 81046166: Merge "Revert "Change init sequence to support file level encryption"" into mnc-dev

* commit '8104616696ac5e806b16a393ea02c4f5d8efc328':
Revert "Change init sequence to support file level encryption"
437bc5dceca1608456c1c40b694645bc2d100ad4 07-Jul-2015 Paul Lawrence <paullawrence@google.com> Revert "Change init sequence to support file level encryption"

This reverts commit d815178b7512cb44d8b5f234e3f823b5a3e44dea.

Change-Id: I7e3f55d3092fcd04ea9f62f1971c9d42570f096c
/system/core/init/builtins.cpp
22d0ee6a25b3bedd6c3cd52473df1404fce8615f 06-Jul-2015 Paul Lawrence <paullawrence@google.com> am a65e402b: Merge "Change init sequence to support file level encryption" into mnc-dev

* commit 'a65e402b613e927697d35e7936c6d80908d77e88':
Change init sequence to support file level encryption
d815178b7512cb44d8b5f234e3f823b5a3e44dea 01-Jul-2015 Paul Lawrence <paullawrence@google.com> Change init sequence to support file level encryption

File level encryption must get the key between mounting userdata and
calling post_fs_data when the directories are created. This requires
access to keymaster, which in turn is found from a system property.

Split property loaded into system and data, and load in right order.

Bug: 22233063
Change-Id: I8a6c40d44e17de386417a443c9dfc3b4e7fe59a5
/system/core/init/builtins.cpp
749af8c08f6db8da4202ad93f9a6d06884b27c0d 28-May-2015 Paul Crowley <paulcrowley@google.com> Set up user directory crypto in init.

(cherry-picked from commit b94032b79c3cded501e2d5f7c328cf8c0c3911c4)

Bug: 19704432
Change-Id: Ife4928ffbee39c8ae69e6ba66d9ce5ef5a0beb76
/system/core/init/builtins.cpp
0a423d994a0dbd05924ae6cff702b5d4d7dd43f0 29-Apr-2015 Paul Lawrence <paullawrence@google.com> DO NOT MERGE Securely encrypt the master key

(chery-picked from commit 806d10be2336f32cdca16c2540cbf3d548f2fec7)

Move all key management into vold
Reuse vold's existing key management through the crypto footer
to manage the device wide keys.

Use ro.crypto.type flag to determine crypto type, which prevents
any issues when running in block encrypted mode, as well as speeding
up boot in block or no encryption.

This is one of four changes to enable this functionality:
https://android-review.googlesource.com/#/c/148586/
https://android-review.googlesource.com/#/c/148604/
https://android-review.googlesource.com/#/c/148606/
https://android-review.googlesource.com/#/c/148607/

Bug: 18151196

Change-Id: I6a8a18f43ae837e330e2785bd26c2c306ae1816b
/system/core/init/builtins.cpp
dd0e3162a598cd6bfe92d5c903e66563fc152e50 27-May-2015 Mark Salyzyn <salyzyn@google.com> init: expand_props on trigger

Bug: 19608716
Change-Id: Ifce8bfde04f8e6f707245e0b53400072d94447b2
/system/core/init/builtins.cpp
cce7e93b287835ffe9cdc3dad3fac52972d84560 12-May-2015 Tom Cherry <tomcherry@google.com> Fix insmod module size

read_file() used to append a new line character to the end of the buffer it
returns, because parse_config() isn't able to cope with input that's not
'\n'-terminated. Fix read_file() to be less insane, and push the workarounds
into the parse_config() callers.

Longer term we should rewrite parse_config().

Bug: http://b/21079470
Change-Id: Ie9d9a7adcd33b66621726aef20c4b8cc51c08be7
(cherry picked from commit eaa3b4ec6f79fe06163b8dd6fe8ba2581d3b9c0b)
/system/core/init/builtins.cpp
30cc3d72498326c77b75cdf02992211d31396b33 27-Apr-2015 Emmanuel Berthier <emmanuel.berthier@intel.com> Enable property expansion for insmod

Useful for dynamic kernel module location.
This permits to use init rule like:

insmod ${persist.modules.location}/<module_name>

Change-Id: If7479bdcb4e69ea7666f52a0075c785be025c2e9
Signed-off-by: Emmanuel Berthier <emmanuel.berthier@intel.com>
(cherry picked from commit ac41230cbc10bae95a049282238adb03605579c2)
/system/core/init/builtins.cpp
eaa3b4ec6f79fe06163b8dd6fe8ba2581d3b9c0b 12-May-2015 Tom Cherry <tomcherry@google.com> Fix insmod module size

read_file() used to append a new line character to the end of the buffer it
returns, because parse_config() isn't able to cope with input that's not
'\n'-terminated. Fix read_file() to be less insane, and push the workarounds
into the parse_config() callers.

Longer term we should rewrite parse_config().

Change-Id: Ie9d9a7adcd33b66621726aef20c4b8cc51c08be7
/system/core/init/builtins.cpp
5138958cb30266e718cd523905037e7e95373271 05-May-2015 Elliott Hughes <enh@google.com> Merge "Enable property expansion for insmod"
806d10be2336f32cdca16c2540cbf3d548f2fec7 29-Apr-2015 Paul Lawrence <paullawrence@google.com> Securely encrypt the master key

Move all key management into vold
Reuse vold's existing key management through the crypto footer
to manage the device wide keys.

Use ro.crypto.type flag to determine crypto type, which prevents
any issues when running in block encrypted mode, as well as speeding
up boot in block or no encryption.

This is one of four changes to enable this functionality:
https://android-review.googlesource.com/#/c/148586/
https://android-review.googlesource.com/#/c/148604/
https://android-review.googlesource.com/#/c/148606/
https://android-review.googlesource.com/#/c/148607/

Bug: 18151196

Change-Id: I6a8a18f43ae837e330e2785bd26c2c306ae1816b
/system/core/init/builtins.cpp
2b3a4939463cb2eb6b65e416f6544a2e2d3bc29b 28-Apr-2015 Paul Lawrence <paullawrence@google.com> Merge "Revert "Securely encrypt the master key""
7ac2807546487de0cd74a8bbd976753c8f5862f3 28-Apr-2015 Paul Lawrence <paullawrence@google.com> Revert "Securely encrypt the master key"

This reverts commit 4bf1887c787a025aad2fbafe382e556e85ac73b0.

Change-Id: Ie6d1f39de530b99b50a27ddc45bcc900a24e04b5
/system/core/init/builtins.cpp
6e8c8f542d673f3402df6b70df64b29c759e526a 28-Apr-2015 Paul Lawrence <paullawrence@google.com> Merge "Revert "Only run vold command when file encryption enabled""
34276a15347cb2dc603ca8e34e57f5c9a0b4ad0d 28-Apr-2015 Paul Lawrence <paullawrence@google.com> Revert "Only run vold command when file encryption enabled"

This reverts commit efe190e02387de382bb6d187ce62aec0fe9cfb44.

Change-Id: Ib15af9a85b0b885a388bda28511a6fc39a777264
/system/core/init/builtins.cpp
a71ef0d5b5c0e304d947f3782603890294d06ee2 28-Apr-2015 Paul Lawrence <paullawrence@google.com> Merge "Only run vold command when file encryption enabled"
9234b169e62b10e38ecd3dc636ccccb425ea4eed 27-Apr-2015 Paul Lawrence <paullawrence@google.com> Merge "Securely encrypt the master key"
ac41230cbc10bae95a049282238adb03605579c2 27-Apr-2015 Emmanuel Berthier <emmanuel.berthier@intel.com> Enable property expansion for insmod

Useful for dynamic kernel module location.
This permits to use init rule like:

insmod ${persist.modules.location}/<module_name>

Change-Id: If7479bdcb4e69ea7666f52a0075c785be025c2e9
Signed-off-by: Emmanuel Berthier <emmanuel.berthier@intel.com>
/system/core/init/builtins.cpp
c7ca9dd6c87d69c73706ddc5d739dd9d71314b62 24-Apr-2015 Elliott Hughes <enh@google.com> Revert "Revert "Remove now-unusable 'setcon' command.""

This reverts commit b862bd00a4192d48c3ae82156d8c35b32283e9e4.

This change was fine but an earlier change it depended on was broken.
That change has been fixed and resubmitted.

Bug: http://b/19702273
Change-Id: I17e565721026e48e2a73526f729f2481d4d6edb5
/system/core/init/builtins.cpp
b862bd00a4192d48c3ae82156d8c35b32283e9e4 24-Apr-2015 Nick Kralevich <nnk@google.com> Revert "Remove now-unusable 'setcon' command."

Temporarily revert because device isn't booting.

This reverts commit 7b15ac99f3bfef33c82ea109487c99a77b41ebfb.

Change-Id: Ice986bac62e20c70f7bedf1744a617b97392ae8c
/system/core/init/builtins.cpp
7b15ac99f3bfef33c82ea109487c99a77b41ebfb 24-Apr-2015 Elliott Hughes <enh@google.com> Remove now-unusable 'setcon' command.

Bug: http://b/19702273
Change-Id: Icd340c80ba074476dcc63f1c1dd5c61a5c768893
/system/core/init/builtins.cpp
4bf1887c787a025aad2fbafe382e556e85ac73b0 30-Mar-2015 Paul Lawrence <paullawrence@google.com> Securely encrypt the master key

Remove unencrypted link since it is easier to manage directly
Move creation of key to vold
Start vold early so this is possible in a timely fashion

This is one of four changes to enable this functionality:
https://android-review.googlesource.com/#/c/144586/
https://android-review.googlesource.com/#/c/144663/
https://android-review.googlesource.com/#/c/144672/
https://android-review.googlesource.com/#/c/144673/

Bug: 18151196
Change-Id: Idb17d1f1a724c6ec509d181ae4427113e9d3b5e6
/system/core/init/builtins.cpp
efe190e02387de382bb6d187ce62aec0fe9cfb44 14-Apr-2015 Paul Lawrence <paullawrence@google.com> Only run vold command when file encryption enabled

Avod slowing other boot times

Change-Id: I4862312ea90d8a1e67d9a755a75f708f5e82cbc5
/system/core/init/builtins.cpp
284c5cb2a16d21e5d5123ae6a0d731dcc6beadca 07-Apr-2015 Sami Tolvanen <samitolvanen@google.com> Merge "Set verity mode as the verified property value"
e2837a9107f8a68a790908d609c0c8dab17d7bdd 03-Apr-2015 Elliott Hughes <enh@google.com> Remove execonce.

Use 'exec' instead.

Change-Id: I1320d1971f7cd8b23753c27aa87089006e112a11
/system/core/init/builtins.cpp
b8c9d273a07f3fc45780e763bb3f7f6266b8cab7 26-Mar-2015 Paul Lawrence <paullawrence@google.com> Revert "Revert "Adding e4crypt support""

Fix build break caused by original change

This reverts commit 84b0bab58fcc7f225e9a17a15c531b0c2fc509c5.

Change-Id: I99fbd7c3d1ed92db1f546033c8493bb71a327924
/system/core/init/builtins.cpp
454742392f72079dbdb0d23ea24e01b5703c1aa5 30-Mar-2015 Sami Tolvanen <samitolvanen@google.com> Set verity mode as the verified property value

Set the verity mode as the value for partition.%s.verified to make it
easier for userspace to determine in which mode dm-verity was started.

Change-Id: Icc635515f8a8ede941277aed196867351d8387cb
/system/core/init/builtins.cpp
cd67f00e18de1c8d48ddb082ecb902fc42c2bacc 21-Mar-2015 Elliott Hughes <enh@google.com> Always use strerror to report errno.

Change-Id: Icd18e4bd7dc093c18967f45b99cd451359457b03
/system/core/init/builtins.cpp
db3f267c99411b10144998c6c1f1a6288d0191bc 20-Mar-2015 Elliott Hughes <enh@google.com> Clean up property setting code.

In particular, ensure that all property_set failures are reported.

Change-Id: Iab94a28bcba2346868c0f39bcfe26e55a2c55562
/system/core/init/builtins.cpp
acbf9bef43bc650ed84ba891183ebdf689dafb64 19-Mar-2015 Sami Tolvanen <samitolvanen@google.com> Add init command to set verified properties

Add a command that updates dm-verity state and sets partition.%.verified
properties used by adb remount.

This is needed in init since fs_mgr cannot set properties:
I6a28cccb1ccce960841af20a4b20c32d424b5524

Change-Id: I0fdf5bc29c56690dcadff9d0eb216d3c68483538
/system/core/init/builtins.cpp
7010301933d428874a2a0dee083a4030e64bcc14 18-Mar-2015 Elliott Hughes <enh@google.com> Remove chroot from init.

This is not obviously useful. Let's wait until we have an actual need.

Change-Id: I2c75c96314b281e89df25b6ed202b3dd5dfdaf15
/system/core/init/builtins.cpp
641d3e8ea066beaed6f8ad8a3e71f1737bffc0cc 15-Mar-2015 Elliott Hughes <enh@google.com> Remove chdir from init.

Change-Id: Ib2880c6cb18db613deac04ee3b06b9719f5248b9
/system/core/init/builtins.cpp
5878aa92cd4cac69aedbebea336e94cce7d3bf28 13-Mar-2015 Elliott Hughes <enh@google.com> Remove obsolete setkey.

It's undocumented and unused.

Change-Id: I685dc900adbc14f2e8b4eeebb1e4d111782f141d
/system/core/init/builtins.cpp
d4b2d8923f9f85f5691aac1e230449052d56c1fd 13-Mar-2015 Stephen Smalley <sds@tycho.nsa.gov> Remove getsebool/setsebool from init and toolbox.

These were leftovers from the SELinux boolean support that
was originally merged. Since Android prohibits SELinux policy
booleans, we can just drop it.

Change-Id: I02f646a7d8db65e153702205b082b87a73f60d73
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
/system/core/init/builtins.cpp
cee683e290244be9a0e89e8a2996f228cafb4389 12-Mar-2015 Nick Kralevich <nnk@google.com> builtins: remove setenforce command

Adding "setenforce 0" to init.rc isn't a supported way to turn off
SELinux, and doesn't work with AOSP SELinux policy. Remove the code
from init.

Change-Id: If8c8149560789c9a7ba518a0a100e6033bb68898
/system/core/init/builtins.cpp
a4d98484a2b64d215d1d35830693a16cf2873308 11-Mar-2015 Elliott Hughes <enh@google.com> Merge "Implement exec."
8ff0190835c89cf6d48221cca68d41a105f67a7b 16-Feb-2015 Sami Tolvanen <samitolvanen@google.com> Add init support for dm-verity logging mode

Add a built-in command for loading verity state. If dm-verity
will be started in logging mode, trigger verity-logging.

Needs changes from
Ibb82953594d234f81ad21c40f524190b88e4ac8f

Change-Id: I5af4918f2f14fdd4d07f51c55837e08111fd3748
/system/core/init/builtins.cpp
8d82ea05cb0945ba6cb8bf321b9ffbd0b6932745 07-Feb-2015 Elliott Hughes <enh@google.com> Implement exec.

Change-Id: I20329bc9b378479d745b498d6a00eca0872cd5ab
/system/core/init/builtins.cpp
e2d63af002a3b494f6bd464f2652b6e1997e7a52 18-Feb-2015 Yabin Cui <yabinc@google.com> Move sprintf to snprintf.

Bug: 19340053
Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
/system/core/init/builtins.cpp
7e952f41f163f76d73768f676d0e8a9fc1d3eb7b 05-Dec-2014 Johan Redestig <johan.redestig@sonymobile.com> Bump do_write buffer size

In the case of do_write (write to generic file) there
is really no relation to the PROP_VALUE_MAX limitation
of system properties. The current value, 92, is not so
much for writing to files so bump it a bit.

Ideally there should not be any low hard limit in this
case. Either expand_props should allocate the output
buffer or take the output fd and to streaming write.
Such a change is rather invasive though and at this
point in time it seems reasonable that one dont want
more than 256 character strings in the init files.

Change-Id: I846a282ae4e747e6171eef38b302b46287951451
/system/core/init/builtins.cpp
f682b4786a4093efb23bf80d69bf80eb274b145b 06-Feb-2015 Elliott Hughes <enh@google.com> Clean up reading and writing in init.

This isn't particularly useful in and of itself, but it does introduce the
first (trivial) unit test, improves the documentation (including details
about how to debug init crashes), and made me aware of how unpleasant the
existing parser is.

I also fixed a bug in passing --- unless you thought the "peboot" and "pm"
commands were features...

Bug: 19217569
Change-Id: I6ab76129a543ce3ed3dab52ef2c638009874c3de
/system/core/init/builtins.cpp
24627906bfee8c4a9eede3deefd12365a78351bf 04-Feb-2015 Elliott Hughes <enh@google.com> Use TEMP_FAILURE_RETRY, always build bootchart.cpp.

Also switch the revision parsing over to sscanf as promised. I haven't
done the hardware parsing because I don't yet know whether we actually need
to keep the space-stripping code.

Change-Id: Ic33378345cd515cb08d00c543acf44eb72673396
/system/core/init/builtins.cpp
f3cf438714aa1284d8a58e2f3b108ba93f6d3abb 04-Feb-2015 Elliott Hughes <enh@google.com> Build init as C++.

This is just the minimal change to keep it building.

Change-Id: I245c5b8413a1db114576c81462eb5737f5ffcef2
/system/core/init/builtins.cpp