Commit graph

76 commits

Author SHA1 Message Date
Bertrand SIMONNET
b7e03e82b8 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
2016-01-08 11:12:15 -08:00
Sami Tolvanen
0d1214c68e Merge "Set up dm-verity in EIO mode instead of logging mode" 2015-12-10 20:12:49 +00:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Sami Tolvanen
90f52df257 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
2015-12-02 14:38:01 +00:00
Tom Cherry
af20a7cb12 resolved conflicts for merge of cda81d01 to mnc-dr-dev-plus-aosp
Change-Id: I747b279bc49f9f82b8f8859c49b3fc2a4e3b4977
2015-09-01 15:30:56 -07:00
Tom Cherry
b7349902a9 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
2015-09-01 12:26:02 -07:00
Tom Cherry
25c22bb9e7 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
2015-08-21 21:47:03 +00:00
Tom Cherry
b8dd0272e5 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
2015-08-21 10:14:43 -07:00
Yusuke Sato
9962b04d00 am d1b11a04: am e656be33: Merge "Add |opts| argument to android_fork_execvp_ext"
* commit 'd1b11a04903be74ba6a47307d8c3ef2731e3f4ab':
  Add |opts| argument to android_fork_execvp_ext
2015-08-19 22:20:29 +00:00
Yusuke Sato
d81c3c6c45 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
2015-08-19 11:00:37 -07:00
Tom Cherry
2647d2e70e am 4036f5ab: am 4bf3dc93: Merge "Create Service and ServiceManager classes"
* commit '4036f5ab2ffbe5a2e47d46aa376e9791385cc31b':
  Create Service and ServiceManager classes
2015-08-07 21:13:04 +00:00
Tom Cherry
bac3299720 Create Service and ServiceManager classes
Change-Id: I363a5e4751ad83d2f4096882a6fbbeddca03acfe
2015-08-07 10:16:39 -07:00
Tom Cherry
087cd35b79 resolved conflicts for merge of 0070026c to mnc-dr-dev-plus-aosp
Change-Id: Ibc802572898b6913c1f5d94aaae19974bfc0eb85
2015-08-03 14:19:35 -07:00
Yusuke Sato
adda8f7388 am 2f9e1db3: am b5d6ad81: Merge "Stop calling fsck on shutdown by default"
* commit '2f9e1db37416cdb580d870218b5fbfbed47a3758':
  Stop calling fsck on shutdown by default
2015-08-03 17:56:32 +00:00
Tom Cherry
4247ebfd2f Merge "init: use std::vector<std::string> for argument passing" 2015-08-03 17:51:39 +00:00
Yusuke Sato
b5d6ad81cb Merge "Stop calling fsck on shutdown by default" 2015-07-31 23:13:15 +00:00
Tom Cherry
96f67316a2 init: use std::vector<std::string> for argument passing
Change-Id: Ie7a64e65de3a20d0c7f7d8efc0f7c1ba121d07fe
2015-07-31 16:02:12 -07:00
Tom Cherry
7da270df1d am a21d8562: am d548e30f: Merge "init: Create classes for Action and Command"
* commit 'a21d85620560896bbed0cd43db9ed3224ab4e974':
  init: Create classes for Action and Command
2015-07-30 21:31:38 +00:00
Tom Cherry
fa0c21c94c 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
2015-07-30 13:37:23 -07:00
Yabin Cui
310851549b am bd5f10ad: am 699be5f6: Merge "init: do expand_props before calling the builtins."
* commit 'bd5f10addfba8df40c8293d95c002044acbfa526':
  init: do expand_props before calling the builtins.
2015-07-25 01:19:29 +00:00
Yabin Cui
00ede7d262 init: do expand_props before calling the builtins.
Also switch expand_props to std::string.

Bug: 22654233

Change-Id: I62910d4f74e2b1a5bd2b14aea440767a2a8462b7
2015-07-24 15:02:19 -07:00
Yabin Cui
0ff8590e78 resolved conflicts for merge of bff40697 to mnc-dr-dev-plus-aosp
Change-Id: I7d7a614a5eb987ef6aecd32ed15a6eaa43e93957
2015-07-24 13:58:03 -07:00
Yabin Cui
74edcea90e init: Let property_get return std::string.
Bug: 22654233

Change-Id: Id6091f58432f75e966b9871256049fbe17766c10
2015-07-24 11:14:08 -07:00
Elliott Hughes
2694ad9ad9 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
2015-07-22 18:05:02 +00:00
Nan Liu
12df1e118a init: use init's property expansion code for mount_all
Change-Id: I3bd00c74cd126b66927eca7812943f8427009356
Signed-off-by: Nan Liu <nan.liu619@gmail.com>
2015-07-22 10:36:49 -07:00
Yusuke Sato
f93d42933b 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
2015-07-21 17:45:01 -07:00
Yusuke Sato
7954eb0a46 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
2015-07-21 18:28:40 +00:00
Yusuke Sato
0df08271fb 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
2015-07-15 10:13:51 -07:00
Paul Crowley
b7f1f61fbc 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
2015-07-14 00:27:56 +00:00
Paul Crowley
ee923139c3 Merge "Set up user directory crypto in init." into mnc-dr-dev 2015-07-13 20:52:45 +00:00
Paul Lawrence
c1fa34b9f6 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
2015-07-13 17:53:08 +00:00
Paul Lawrence
948410a493 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
2015-07-07 13:23:19 -07:00
Paul Lawrence
e8308f852c 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"
2015-07-07 18:20:27 +00:00
Paul Lawrence
437bc5dcec Revert "Change init sequence to support file level encryption"
This reverts commit d815178b75.

Change-Id: I7e3f55d3092fcd04ea9f62f1971c9d42570f096c
2015-07-07 17:05:58 +00:00
Paul Lawrence
22d0ee6a25 am a65e402b: Merge "Change init sequence to support file level encryption" into mnc-dev
* commit 'a65e402b613e927697d35e7936c6d80908d77e88':
  Change init sequence to support file level encryption
2015-07-06 20:34:05 +00:00
Paul Lawrence
d815178b75 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
2015-07-06 07:52:06 -07:00
Paul Crowley
749af8c08f Set up user directory crypto in init.
(cherry-picked from commit b94032b79c)

Bug: 19704432
Change-Id: Ife4928ffbee39c8ae69e6ba66d9ce5ef5a0beb76
2015-06-23 15:21:51 +00:00
Paul Lawrence
0a423d994a DO NOT MERGE Securely encrypt the master key
(chery-picked from commit 806d10be23)

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
2015-05-29 17:39:16 +00:00
Mark Salyzyn
dd0e3162a5 init: expand_props on trigger
Bug: 19608716
Change-Id: Ifce8bfde04f8e6f707245e0b53400072d94447b2
2015-05-27 14:06:28 -07:00
Tom Cherry
cce7e93b28 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 eaa3b4ec6f)
2015-05-12 19:42:38 -07:00
Emmanuel Berthier
30cc3d7249 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 ac41230cbc)
2015-05-12 15:01:02 -07:00
Tom Cherry
eaa3b4ec6f 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
2015-05-12 14:18:49 -07:00
Elliott Hughes
5138958cb3 Merge "Enable property expansion for insmod" 2015-05-04 22:54:10 +00:00
Paul Lawrence
806d10be23 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
2015-04-28 15:34:10 -07:00
Paul Lawrence
2b3a493946 Merge "Revert "Securely encrypt the master key"" 2015-04-28 19:15:40 +00:00
Paul Lawrence
7ac2807546 Revert "Securely encrypt the master key"
This reverts commit 4bf1887c78.

Change-Id: Ie6d1f39de530b99b50a27ddc45bcc900a24e04b5
2015-04-28 19:15:01 +00:00
Paul Lawrence
6e8c8f542d Merge "Revert "Only run vold command when file encryption enabled"" 2015-04-28 19:14:45 +00:00
Paul Lawrence
34276a1534 Revert "Only run vold command when file encryption enabled"
This reverts commit efe190e023.

Change-Id: Ib15af9a85b0b885a388bda28511a6fc39a777264
2015-04-28 19:12:35 +00:00
Paul Lawrence
a71ef0d5b5 Merge "Only run vold command when file encryption enabled" 2015-04-28 15:24:10 +00:00
Paul Lawrence
9234b169e6 Merge "Securely encrypt the master key" 2015-04-27 20:08:53 +00:00