summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge "init: use unique_fd in builtins.cpp" am: c34afb1cd5 am: 76756aa1ddTom Cherry2017-08-021-60/+38
|\| | | | | | | | | | | am: 54032d387a Change-Id: I20865544dd1692979c8fbd21c05272a98c00eca4
| * init: use unique_fd in builtins.cppTom Cherry2017-08-011-60/+38
| | | | | | | | | | | | Test: boot Change-Id: I09295856dbd0de9436a95a2fe99ab6be156b995f
* | Merge changes Ibd57c103,I81f1e8ac,Ia6e546fe am: 2a2a8d9ec0 am: b1c18af247Tom Cherry2017-08-011-20/+40
|\| | | | | | | | | | | am: 3d6b46a789 Change-Id: I704cb309efb106cff34c28b9c7fde3e86bb34cc0
| * init: rename ServiceManager to ServiceList and clean it upTom Cherry2017-08-011-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * init: move exec operations out of ServiceManagerTom Cherry2017-08-011-2/+21
| | | | | | | | | | | | | | | | | | 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
* | Merge "init: remove Parser singleton and related cleanup" am: 379123f9ab am: ↵Tom Cherry2017-07-281-13/+7
|\| | | | | | | | | | | | | | | bf4afbb288 am: 1b74d14b7e Change-Id: Ifaaeae8fb3f43235846207fa02a83edbc1e427d9
| * init: remove Parser singleton and related cleanupTom Cherry2017-07-271-13/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Merge "Move Timer from init to libbase" am: 896297b2ef am: 7ff0b008f7Tom Cherry2017-07-101-2/+3
|\| | | | | | | | | | | am: 4e5c4f18d8 Change-Id: Iffad0dcde94fce7dac627ebf0530420f9cfd38d1
| * Move Timer from init to libbaseTom Cherry2017-07-101-2/+3
| | | | | | | | | | | | | | Test: boot bullhead Test: new libbase unit tests Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
* | Merge "init: Support custom shutdown actions" am: c1bc4241f8 am: 5b89535442Wei Wang2017-07-051-1/+1
|\| | | | | | | | | | | am: b39890048c Change-Id: I57a0422f47094cc061163510138e9562648fdd98
| * init: Support custom shutdown actionsWei Wang2017-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "init: create android::init:: namespace" am: 040212706b am: d3d79b2196Tom Cherry2017-06-231-0/+6
|\| | | | | | | | | | | am: b57e1180e3 Change-Id: Ic6d35273820d70136a6085bf49dcf3afcbb24f24
| * init: create android::init:: namespaceTom Cherry2017-06-231-0/+6
| | | | | | | | | | | | | | | | With some small fixups along the way Test: Boot bullhead Test: init unit tests Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
* | Merge "init: cleanup some string usage" am: 84c2eebbdd am: 77382acf42Tom Cherry2017-06-231-9/+4
|\| | | | | | | | | | | am: 288fb7c2cc Change-Id: I61e6ee578e55ebe343112c8114816ac4e18b9c7e
| * init: cleanup some string usageTom Cherry2017-06-221-9/+4
| | | | | | | | | | | | | | | | | | | | | | 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
| * init: remove restorecon() from util.cppTom Cherry2017-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "init: remove restorecon() from util.cpp" into oc-dev-plus-aospTom Cherry2017-05-091-1/+1
|\ \ | | | | | | | | | | | | | | | am: 2813d87484 Change-Id: Ib6619f696fb08b99410b3a33221fe8eacebf89d6
| * | init: remove restorecon() from util.cppTom Cherry2017-05-081-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | 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
* | Merge changes I46690d1c,I84c11aa5 am: 0dda322d4a am: 18b23afa4b am: 3f9ba91d8fTom Cherry2017-05-081-17/+55
|\| | | | | | | | | | | am: 756ee8ded9 Change-Id: Ib005ef875bfc8116c320007acc10e7cf9accdc10
| * init: do not log directly from read_file() and write_file()Tom Cherry2017-05-051-6/+27
| | | | | | | | | | | | | | | | | | | | 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
| * init: Check DecodeUid() result and use error stringTom Cherry2017-05-051-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "init: use do_exec() for init_user0" am: 5ad06cbb1c am: 577c75e78c am: ↵Tom Cherry2017-05-031-1/+3
|\| | | | | | | | | | | | | | | bc8a4ad7aa am: 10cdd5bbf1 Change-Id: I3fa46dc57426738550beffb71932e06a0407c68c
| * init: use do_exec() for init_user0Tom Cherry2017-05-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "ueventd: do not reference init's sehandle" am: 672dd970f4 am: ↵Tom Cherry2017-05-031-2/+2
|\| | | | | | | | | | | | | | | e4988c9a34 am: 4c664d8c5c am: 214e45a5a7 Change-Id: I9e73d1849df48dffd886f47c2b358f36309918c0
| * ueventd: do not reference init's sehandleTom Cherry2017-05-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge changes Ic446c026,I86568a5b am: 51b7cb006f am: 41dbec9791 am: fea35fc7e4Tom Cherry2017-04-241-2/+2
|\| | | | | | | | | | | am: d0ea8a98cd Change-Id: I4f8fe713f768748e521ad4d6c18edf0e4b382591
| * init: create init_tests.cppTom Cherry2017-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
| * init: clean up the SectionParser interface and Parser classTom Cherry2017-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Support metadata encryptionPaul Lawrence2017-04-211-0/+17
|/ | | | | | Bug: 29189559 Test: Angler, Marlin build and boot Change-Id: Ia7b070781f5f16ff8bfd934569a2209c80c28385
* init: handle sys.powerctl immediatelyTom Cherry2017-04-171-53/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* fs_mgr: support AVB in fs_mgr_update_verity_state()Bowgo Tsai2017-04-141-4/+4
| | | | | | | | | | | | | | | | | | | | | 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
* Passing additional parameter to powerctlDmitri Plotnikov2017-04-121-2/+6
| | | | | Test: adb reboot recovery,foo and verify that the parameter reaches bootloader Change-Id: I9690cf96cf9730e5324b9f5310c3d0341fe25fe2
* init: clean up more headersTom Cherry2017-04-071-0/+1
| | | | | | | We don't need everyone including <sys/system_properties.h> Test: boot bullhead Change-Id: I73d507e4f273678eaf15947725741e1e3b966cc6
* init: more header cleanupTom Cherry2017-04-061-15/+9
| | | | | | | | | | 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
* init: use read_file and write_file to implement do_copy builtinYongqin Liu2017-04-041-55/+5
| | | | | | | | | | | | | | | | | | | 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>
* init: Use std::string for write_file()Tom Cherry2017-04-031-5/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Merge "Make init builtin command installkey respect property updates"Tom Cherry2017-03-311-2/+8
|\
| * Make init builtin command installkey respect property updatesJanis Danisevskis2017-03-301-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Revert "init: use read_file and write_file to implement do_copy builtin""Wonsik Kim2017-03-311-5/+55
|\ \ | |/ |/|
| * Revert "init: use read_file and write_file to implement do_copy builtin"Wonsik Kim2017-03-311-4/+54
| | | | | | | | | | | | This reverts commit 82bac0de6d95bcdf45729516f6a4f29eb2681118. Change-Id: Ibfdf453bd85ba4fcd1948b78bd22e639a883653e
* | Merge changes from topic 'exec-start-update-verifier'Treehugger Robot2017-03-291-13/+8
|\ \ | | | | | | | | | | | | | | | * changes: init.rc: launch update_verifier with exec_start init: add exec_start command
| * | init: add exec_start commandTom Cherry2017-03-271-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | init: replace property_get with its android::base equivalentTom Cherry2017-03-291-4/+4
| | | | | | | | | | | | | | | | | | | | | Slowly try to decouple property_service.cpp from the rest of init. Test: Boot bullhead Change-Id: I267ae0b057bca0bf657b97cb8bfbb18199282729
* | | Merge "init: remove unused cutils includes"Treehugger Robot2017-03-291-1/+0
|\ \ \
| * | | init: remove unused cutils includesTom Cherry2017-03-281-1/+0
| |/ / | | | | | | | | | | | | Test: Boot bullhead Change-Id: I629f9c3863f00fa38f87a68442c2380d28764718
* / / init: add class_restartSteven Moreland2017-03-271-0/+7
|/ / | | | | | | | | | | Bug: 34093663 Test: hwservicemanager `onrestart class_restart hal` works Change-Id: Ie1e4daab2b7b4c6c714d4e3d05afa2d86d6233df
* | Merge "init: use read_file and write_file to implement do_copy builtin"Treehugger Robot2017-03-241-55/+5
|\|
| * init: use read_file and write_file to implement do_copy builtinYongqin Liu2017-03-241-54/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | remove emergency shutdown and improve init's reboot logicKeun-young Park2017-03-221-168/+33
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* powerctl: add thermal-shutdown commandTodd Poynor2017-03-171-0/+3
| | | | | | | | Add sys.powerctl property interface for initiating thermal shutdown. Bug: 30994946 Test: Manual: setprop sys.powerctl thermal-shutdown Change-Id: Iffce60bd3cb4b40a5859623d10b91bee5101f168