summaryrefslogtreecommitdiffstats
path: root/init
Commit message (Collapse)AuthorAgeFilesLines
* Clarify init's write command.Elliott Hughes2014-07-251-3/+3
| | | | | Bug: https://code.google.com/p/android/issues/detail?id=73996 Change-Id: I4f8d3927d17a4021a2436c2859aa732479c5a118
* Move unlink("/dev/.booting") until after filesystems are mounted.Riley Andrews2014-07-111-15/+8
| | | | | | | Move the unlink out of init.c and into init.rc, so that the file will be removed after all the filesystems with firmware are up. Change-Id: I7442df2042cc2788d0301f00e3c2fba7d6e0e1c7
* Fix environment variable assignment in initJames Morrissey2014-07-102-8/+22
| | | | | | | | | | | | | | | | | | | | | The init process allows environment variables to be specified in the rc script globally, via 'export', and for a specific process, via the 'setenv' option. However, the mechanism for assembling the environment simply appended the new variable without checking whether it was already defined, so it was not possible to overwrite an existing entry. This patch fixes that behaviour. Limitations and concerns: The limit of a maximum number of 31 variables is unchanged. Currently, most callers of "add_environment" do not check the return value, but the function now logs the failure rather than failing silently. Change-Id: Ie9a68c37a0f55c5b40e904e695cd35514f67f480
* ueventd fixup_sys_perms: fixup SELinux labels unconditionallyNick Kralevich2014-07-071-13/+15
| | | | | | | | | | | | | Currently, the fixup code in fixup_sys_perms() scans through all entries in uevent*.rc. If it finds a match, then it performs a fixup. If there's no match in that file, no fixup is performed. SELinux file labels are independently stored in /file_contexts, with no relationship to the files in /ueventd.rc. Even when no entries exist in ueventd.rc, we still want to fixup the SELinux file label in /sys when a uevent message occurs. Change-Id: I0ccb5395ec0be9282095b844a5022e8c0d8903ac
* Merge "ueventd: allow matching symlink names when setting permissions"Colin Cross2014-07-021-13/+38
|\
| * ueventd: allow matching symlink names when setting permissionsColin Cross2014-07-021-13/+38
| | | | | | | | Change-Id: I5f6cc2a25f1236fbe2c7193b65363b7883b9ba2e
* | Remove an unused #include of <sys/_properties.h>.Elliott Hughes2014-06-301-3/+0
| | | | | | | | | | Bug: 15704351 Change-Id: I7841da7176d0638ae6737fe719cd187892bc38e6
* | Add ability to adjust init log level at runtime.Riley Andrews2014-06-261-4/+17
| | | | | | | | | | | | | | + Add a new property, sys.init_log_level, which can be set after init bootstrap. This will control the level at which init does prints to klog. Change-Id: Ia15b2110157b5e6b713785ece9b0fb94889be6c8
* | Improve init's debug printing.Riley Andrews2014-06-263-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | + Make prints of rc commands significantly more verbose. All commands will log all arguments, file/line number of the command, return value, and parent action which triggered the command. init: command 'mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000' action=init status=0 (/init.rc:89) init: command 'setprop net.tcp.default_init_rwnd 60' action=boot status=0 (/init.rc:403) Change-Id: I5498c7258e4891706be4a12546df4231d14d86c4
* | Merge "property_service: get rid of hard coded property / control list"Nick Kralevich2014-06-251-105/+4
|\ \
| * | property_service: get rid of hard coded property / control listNick Kralevich2014-06-171-105/+4
| | | | | | | | | | | | | | | | | | | | | | | | Don't force people to make modifications to property_service.c when handling properties. Exclusively use the SELinux rules, which are more flexible and easily adjusted. Change-Id: Ic0bbd01b5df2eef0040286ac59c0a01e9bd14315
* | | Redirect libselinux logging to dmesg for ueventd.Stephen Smalley2014-06-243-1/+8
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already do this for init, but had failed to do it for ueventd and could not capture any logging from libselinux calls made by ueventd. Truly enabling non-error logging also requires uncommenting a line in Android.mk: LOCAL_CFLAGS += -DLOG_UEVENTS=1 which enables other logging and sets the default log level to INFO, or otherwise changing the klog level in the ueventd code (is not settable by init.rc loglevel). Change-Id: I00e6f9d6271f2a21d9078c96368816d74d6d2850 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* | Add ability to boot from charger mode.Riley Andrews2014-06-206-16/+21
| | | | | | | | | | | | | | | | | | Add the ability to boot up directly from charger mode, instead of forcing charger mode to initiate a full restart to launch 'full' android. This should shave a few seconds off of boot time on supported devices (just manta for now). Change-Id: Ieec4494d929e92806e039f834d78b9002afd15c4
* | init/ueventd: adds wildcard matching for ueventd rulesDaniel Leung2014-06-203-4/+20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | The sysfs nodes can change from devices to devices for a particular class of peripheral. Some of them even change after suspend/resume, e.g. rfkill for USB bluetooth adapters. This patch adds to the way how ueventd rules with wildcard are handled. In addition to matching the prefix with a trailing wildcard, now rules can have wildcard anywhere in the rule. The wildcard matching is implemented using fnmatch(), where its matching is simliar to shell pathname expansion. It suits this particular usage model well. To avoid abuse, the number of slashes has to match between path name and the rule. For example, instead of creating a rule to match: /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/bluetooth/hci0/rfkill* , this would suffice: /sys/devices/pci0000:00/0000:00:1d.0/*/*/*/*/bluetooth/hci0/rfkill* The prefix matching behavior is retained, such that those rules do not have to pay for processing penalty with fnmatch(). Change-Id: I3ae6a39c838f6d12801cb71958e481b016f731f5 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
* Extend ueventd to use the label-by-symlink support in libselinux.Stephen Smalley2014-06-161-3/+4
| | | | | | | | | | | | | | When ueventd creates a device node, it may also create one or more symlinks to the device node. These symlinks may be the only stable name for the device, e.g. if the partition is dynamically assigned. A corresponding change with the same Change-Id to external/libselinux introduces selabel_lookup_best_match() to support looking up the "best match" for a device node based on its real path (key) and any links to it (aliases). This change updates ueventd to use this new interface to find the best match for the device node when creating it. Change-Id: Id6c2597eee2b6723a5089dcf7c450f8d0a4128f4 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* Only allow disabling SELinux on userdebug / eng buildsNick Kralevich2014-06-022-1/+5
| | | | | | | | Only parse and honor the kernel command line on userdebug or eng builds. On user builds, assume that selinux is always enabled and enforcing. Change-Id: I71c66e4365bdf2f226800634126a38b716d96599
* Merge "SELinux changes to check policy versions during a reload."Nick Kralevich2014-05-311-8/+5
|\
| * SELinux changes to check policy versions during a reload.Robert Craig2014-04-281-8/+5
| | | | | | | | | | | | | | | | | | | | | | When deciding on which property_contexts policy to load during a reload, an initial call is made to libselinux to grab the correct policy index. This policy index represents whether the /data/security or the rootfs version will be used. Change-Id: I4716039bb0f5ba1e961977a18350347a67969dca Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
* | Merge "ueventd: support by-name symlinks for PCI block devices"Colin Cross2014-05-221-6/+44
|\ \
| * | ueventd: support by-name symlinks for PCI block devicesAndrew Boie2014-05-131-6/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To ensure that well-crafted removable media can't spoof the internal partitions, for platform devices the controller id is inside the generated path. We now do the same for PCI devices. The generated path has two levels; the PCI domain/bus, and then the peripheral ID. This lets us get by-name symlinks for PCI media, such as the SATA controllers on PC-like hardware. The symlinks will be created under /dev/block/pci/. For example: /dev/block/pci/pci0000:00/0000:00:1f.2/by-name/ Change-Id: Icee3e86bef5569c2bbd94c26bc00d49028345e3b Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
* | | Remove unnecessary #includes of <sys/atomics.h>.Elliott Hughes2014-05-221-1/+0
| | | | | | | | | | | | | | | Bug: 14903517 Change-Id: I5b0a418dd982f1a2fd90609b12bd8364f7f34996
* | | correct the setenv option judging conditionGavin.Chang2014-05-161-1/+1
| | | | | | | | | | | | Change-Id: I10ed6275374f572da639f26611f607bf7607905c
* | | Merge "init: logd: Allow Developer settings to adjust logd size"Mark Salyzyn2014-05-161-0/+1
|\ \ \
| * | | init: logd: Allow Developer settings to adjust logd sizeMark Salyzyn2014-05-131-0/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - AID_SYSTEM can set persist.logd.size - AID_SYSTEM can issue command to /dev/socket/logd to change the runtime global log sizes. - Add support for ro.logd.size.* as populated by BoardConfig.mk - Limit size to maximum ~3% of physical memory. Bug: 14563261 Bug: 14627052 Change-Id: I606420db2e9d9d032296e71149e4a5b20cbd1137
* | | Clean up some unnecessary system_properties cruft.Elliott Hughes2014-05-142-3/+0
|/ / | | | | | | | | Bug: 14970171 Change-Id: I6f54c35e265b849be914120f795c9f8e0cec34bb
* | init: add 'enable <service>' to negate "service <service>... disabled"JP Abgrall2014-05-036-2/+33
| | | | | | | | | | | | | | | | | | | | | | enable <servicename> Turns a disabled service into an enabled one as if the service did not specify disabled in the rc file. It will also start the service if needed. Bug: 14472973 Change-Id: Id0b49cc687a2bc74f6f92e066c617724cc94908d Signed-off-by: JP Abgrall <jpa@google.com>
* | init: 64-bit build issueMark Salyzyn2014-05-011-1/+2
| | | | | | | | | | | | (cherry pick from Icc5344abc184adf4247175d85b2da08af4636e49) Change-Id: I88b0c9b20720ac62ebae8359ded4ab77b4ebcdde
* | ueventd: Ueventd changes the permission of sysfs files for max/minRuchi Kandoi2014-05-011-1/+1
|/ | | | | | | | | | | | cpufreq The owner and permissions for the sysfs file /sys/devices/system/cpu*/cpufreq/scaling_max/min_freq is changed. This would allow the PowerHAL to change the max/min cpufreq even after the associated CPU's are hotplugged out and back in. Change-Id: Ibe0b4aaf3db555ed48e89a7fcd0c5fd3a18cf233 Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
* Merge "Sync persist property immediately,in case of suddenly remove the ↵Colin Cross2014-04-181-0/+1
|\ | | | | | | battery."
| * Sync persist property immediately,in case of suddenly remove the battery.OPPO2014-03-311-0/+1
| | | | | | Change-Id: I83c5812c69db532f4675f5dbfa508e55999c8dfe
* | init: unused paramter warning messagesMark Salyzyn2014-04-011-0/+2
|/ | | | Change-Id: I1667371106be4b230ac3850e9819e4549eea2973
* ueventd: fix klog debug typoAlex Ray2014-03-191-2/+2
| | | | Change-Id: Ib0acece15145cc0e868452ede8f3acbab419b965
* Add "import" support to system property files.Jeff Sharkey2014-03-191-22/+57
| | | | | | | | | | | | | During boot, allow a property file to import properties from another file. Supports importing the entire file, a specific key, or any keys matching a specific prefix. Here's some example syntax: import /oem/oem.prop import /oem/oem.prop foo.* import /oem/oem.prop foo.bar Bug: 13340779 Change-Id: I867f9a10ca09684326675d9f051f5cf2ae171617
* don't load property_contexts from /dataNick Kralevich2014-03-111-1/+0
| | | | | | Bug: 12613118 Change-Id: I5a84b13d2151075d5136e3682431fbcc9307df13 (cherry picked from commit dc3a42bb11dc2aefee37f799b5a1cce87cf35aaf)
* ueventd: easier debug loggingAlex Ray2014-03-073-2/+11
| | | | | | | Move ueventd debug flag into the Android.mk. Boost klog level if event logging enabled. Change-Id: Iae48edbc43c487092c2424023576af29c76ff401
* liblog: enable logging to logd.Mark Salyzyn2014-02-281-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | * Modify liblog to send all messages to the new syslog user space daemon. Original-Change-Id: I0ce439738cd921efb2db4c1d6a289a96bdbc8bc2 Original-Change-Id: If4eb0d09409f7e9be3eb4bb7017073dc7e931ab4 Signed-off-by: Nick Kralevich <nnk@google.com> * Add a TARGET_USES_LOGD make flag for BoardConfig.mk to manage whether logd is enabled for use or not. * rename syslog to logd to avert confusion with bionic syslog * Add fake log support back in * prefilter for logging messages from logd * Fill in timestamps at logging source * update abstract log reader * switch from using suffix for id to v3 format * log a message when creating devices that a deprecated interface is being utilized. Signed-off-by: Mark Salyzyn <salyzyn@google.com> (cherry pick from commit 099e2c1f6f706a8600c1cef74cce9066fc315480) Change-Id: I47929a5432977a1d7235267a435cec0a7d6bd440
* Remove an unused #include of <asm/page.h>.Elliott Hughes2014-02-241-1/+0
| | | | Change-Id: I000aead8c82ec11151f69e6ce439dd09b0f0b4f4
* Enable building init with -Wall -Werror.Stephen Smalley2014-02-191-2/+23
| | | | | | | | Eliminates various warnings from SELinux-related code. Bug: 12587913 Change-Id: I28921f0ebd934324436609540d95ccef58552b64 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* Convert all selinux_android_restorecon and _setfilecon calls to new API.Stephen Smalley2014-02-071-2/+2
| | | | | | | | | | | libselinux selinux_android_restorecon API is changing to the more general interface with flags and dropping the older variants. Also get rid of the old, no longer used selinux_android_setfilecon API and rename selinux_android_setfilecon2 to it as it is the only API in use. Change-Id: I1e71ec398ccdc24cac4ec76f1b858d0f680f4925 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* Move restorecon and restorecon_recursive code to libselinux.Stephen Smalley2014-01-282-51/+5
| | | | | | | | | | | | This requires telling libselinux to use the sehandle already obtained by init rather than re-acquiring it internally. init retains ownership of the sehandle because it performs the initial load, uses the sehandle for other purposes (e.g. labeling of directories created via mkdir and labeling of socket files), and handles the policy reload property trigger. Change-Id: I4a380caab7f8481c33eb64fcdb16b6cabe918ebd Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* system/core 64-bit cleanup.Elliott Hughes2014-01-162-4/+4
| | | | | | | | | This cleans up most of the size-related problems in system/core. There are still a few changes needed for a clean 64-bit build, but they look like they might require changes to things like the fastboot protocol. Change-Id: I1560425a289fa158e13e2e3173cc3e71976f92c0
* restorecon_recursive("/sys") speed boot timeNick Kralevich2014-01-101-11/+34
| | | | | | | | | | | | | | | | | | Currently, the restorecon_recursive("/sys") call in init.c takes approx 2 seconds on hammerhead. This change reduces the delay to 1.2 seconds. 1) Avoid double stat call when using nftw (time savings of 0.3 seconds) 2) Avoid the repeated calls to is_selinux_enabled() (time savings of 0.5 seconds) Avoid calling lsetfilecon if the file is already properly labeled. This doesn't speed up the restorecon on /sys, but it should help when handling files on /data. Bug: 11640230 Change-Id: Ie212ce4f4acade208c5676d60c1f03f50e2388a4
* Merge "ueventd: fix a busy loop while reading uevents"Colin Cross2013-12-282-2/+2
|\
| * ueventd: fix a busy loop while reading ueventsAmir Goldstein2013-11-172-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under certain conditions, poll() may raise the POLLERR flag along with POLLIN, in which case the check for (ufd.revents == POLLIN) results in an endless busy loop. The following fix was applied to hardware/libhardware_legacy/uevent/uevent.c to fix a similar bug: commit 3aabb260ceef10377c31c9e45fb239247f5cfeba Author: Mathias Agopian <mathias@google.com> Date: Mon Oct 1 14:53:18 2012 -0700 fix a typo in uevent_next_eventi Bug: 7114973 Change-Id: I15a4c714b59aeb1d02db00517d70b5f0e5ab22c2 Applying the same fix for two more poll loops in init and ueventd. Change-Id: I50693f6d3c904992ac4b8a9a14a83c7106e6b9e0
* | Log a warning on services that lack SELinux domains.Stephen Smalley2013-12-091-0/+3
| | | | | | | | | | | | | | | | | | Sample output on flo: <3>[ 7.270568] init: Warning! Service irsc_util needs a SELinux domain defined; please fix! <3>[ 8.290832] init: Warning! Service bootanim needs a SELinux domain defined; please fix! Change-Id: If5514b188517917d58ee81c446af563b0443be45 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* | init: add subsystem rules to ueventd.rcGreg Hackmann2013-11-265-33/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default ueventd creates device nodes under /dev based on the ueventd DEVPATH. Several subsystems have special rules which are hardcoded in devices.c. Moving forward these special rules should go in ueventd.rc. Special rules have the syntax: subsystem <s> devname (uevent_devname|uevent_devpath) [dirname <dir>] Devices matching SUBSYSTEM=<s> will be populated under <dir>. dirname is optional and defaults to /dev. If dirname is provided, <dir> must start with "/". If devname is uevent_devname, ueventd will create the device node as <dir>/DEVNAME. DEVNAME may include intermediate subdirectories, which ueventd will automatically create. If devname is uevent_devpath, ueventd will use the legacy behavior of computing DEVPATH_BASE=basepath(DEVPATH), and creating the device node as <dir>/DEVPATH_BASE. The new parsing code is based on init_parser.c, with small tweaks to handle commands which don't fall under a section header. Change-Id: I3bd1b59d7e62dfc9d289cf6ae889e237fb5bd7c5 Signed-off-by: Greg Hackmann <ghackmann@google.com>
* | init: handle ueventd path truncation betterGreg Hackmann2013-11-261-2/+16
| | | | | | | | | | | | | | | | Log an error before discarding problematic events, and add a missing truncation check to the usb subsystem's unique codepath Change-Id: I0d05aa287ffc63b46d1752d2a7409d35dc8caca7 Signed-off-by: Greg Hackmann <ghackmann@google.com>
* | Merge "init: limit visibility of init_parser.c helpers"Greg Hackmann2013-11-262-6/+5
|\ \
| * | init: limit visibility of init_parser.c helpersGreg Hackmann2013-11-252-6/+5
| | | | | | | | | | | | | | | | | | | | | To prevent clashing with forthcoming changes to uevent_parser.c Change-Id: I2ee183261c7f43e0e4104a16a280c7ee73d7df96 Signed-off-by: Greg Hackmann <ghackmann@google.com>
* | | Make init distinguish between orderly exit and being killed by signals.Elliott Hughes2013-11-251-1/+9
|/ / | | | | | | | | Bug: 11826724 Change-Id: I7c11f602447dbd6862decc51cdfe883003cf7d67