Commit graph

669 commits

Author SHA1 Message Date
Elliott Hughes
0dccc888bd Remove useless memset from init.
Change-Id: Ia880810bb2c9a976dceeb0ffdba0cb98e69e3c6d
2015-03-18 20:17:31 -07:00
Elliott Hughes
7010301933 Remove chroot from init.
This is not obviously useful. Let's wait until we have an actual need.

Change-Id: I2c75c96314b281e89df25b6ed202b3dd5dfdaf15
2015-03-18 12:41:54 -07:00
Elliott Hughes
cc86fb2b29 Switch init over to _PATH_DEFPATH.
Bug: 19564110
Change-Id: I343b4a360b10319dca13ab01f2d411ff940e9052
2015-03-17 20:01:13 -07:00
Dan Albert
c007bc3856 Revert "Revert "Create libbase.""
This reverts commit a7870d8816.
2015-03-16 10:08:46 -07:00
Nicolas Geoffray
a7870d8816 Revert "Create libbase."
Breaks internal master.

This reverts commit 98ff77204c.

Change-Id: I18dc6021cb43efff8aa88486c2d980dc2b8eedba
2015-03-16 11:07:29 +00:00
Elliott Hughes
641d3e8ea0 Remove chdir from init.
Change-Id: Ib2880c6cb18db613deac04ee3b06b9719f5248b9
2015-03-15 10:52:20 -07:00
Johan Redestig
0b42ba24ac Document mkdir behavioural change
Since 27164dc mkdir will update mode, owner and group even
if the directory exists already

Change-Id: Ic37975d118a87afded5bfade775cb3d0d3b19892
2015-03-15 17:47:36 +01:00
Elliott Hughes
285c2ae04a Merge "Document the mount option string in the readme.txt" 2015-03-15 16:39:56 +00:00
Niklas Tibbling
bc3f69f190 Document the mount option string in the readme.txt
also make a distinction between flag and option.

Change-Id: Ia872bc8dc98b3459f9c1e992d096c115699357af
2015-03-15 16:20:44 +00:00
Dan Albert
98ff77204c Create libbase.
Move StringPrintf and the string based file I/O from libutils to
libbase.

Change-Id: I0297a6063874b9d92100e0dd5123fddfbda932fe
2015-03-14 16:36:18 -07:00
Rom Lemarchand
74b34f3cb7 Remove /proc/cpuinfo parsing
- Clean up the paths for ro.revision and ro.hardware parsing
- Use ro.hardwre in ueventd instead of parsing the kernel command line

(cherry-pick of 38b340a52f8e864650db8bae1eb88d5c00485db0.)

Bug: 19366018
Change-Id: I018a293f3d46e736a8b65132b5b00b0f7c20edae
2015-03-14 11:05:48 -07:00
Elliott Hughes
5878aa92cd Remove obsolete setkey.
It's undocumented and unused.

Change-Id: I685dc900adbc14f2e8b4eeebb1e4d111782f141d
2015-03-13 15:37:54 -07:00
Stephen Smalley
d4b2d8923f 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>
2015-03-13 14:01:58 -04:00
Nick Kralevich
cee683e290 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
2015-03-11 17:48:45 -07:00
Elliott Hughes
58c3bacc38 Fix a printf format string (caught by clang but not GCC).
Change-Id: I665756615eef74b05ef92f5865d910f29ead0695
2015-03-11 12:31:53 -07:00
Elliott Hughes
a4d98484a2 Merge "Implement exec." 2015-03-11 18:20:29 +00:00
Elliott Hughes
7c0c15f0ed Fix outdated comments in grab-bootchart.sh.
I've been deliberately vague about the name of the readme because I want to
come back and switch to markdown, but that probably won't happen today.

Change-Id: I60651703709bbfd499227f882eb949396e8f4f6c
2015-03-06 13:25:32 -08:00
Sami Tolvanen
8ee42f9c50 Merge "Add init support for dm-verity logging mode" 2015-03-04 20:42:09 +00:00
Sami Tolvanen
8ff0190835 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
2015-03-04 03:07:47 +00:00
Elliott Hughes
8d82ea05cb Implement exec.
Change-Id: I20329bc9b378479d745b498d6a00eca0872cd5ab
2015-02-25 17:55:34 -08:00
Mark Salyzyn
d4e5c32af7 init: grab-bootchart.sh: run bootchart and display results
- KISS as all options are now passed to adb for better or worse
- runs bootchart and immediately displays the results

Bug: 19485335
Bug: 18390773
Change-Id: Id32930031371d0368e605810f0c998232a1d4f16
2015-02-24 13:56:43 -08:00
Yabin Cui
e2d63af002 Move sprintf to snprintf.
Bug: 19340053
Change-Id: Id0d866e6195ed4752b4be6081eeb2aab8b1dbe9a
2015-02-17 19:27:51 -08:00
Elliott Hughes
0f58cb0035 Remove unused variable BOOTCHART_DEFAULT_TIME_SEC.
Change-Id: Id43c73dd32d2f9f1eee9592b55aa3fd3c02094b2
2015-02-13 16:17:42 -08:00
Elliott Hughes
841b263fae Further refactoring of the bootchart code.
Change-Id: Ifed6ae8d481b605139fd27799574de4c2d0f5908
2015-02-13 15:15:11 -08:00
Yongqin Liu
a197ff12dd bootchart: fix bootchart can not be triggered problem
bootchart uses a file on the data partition to decide if it should collect
data for bootchart, but the data partition will be mounted by the mount_all
command in the "on fs" section, and it will be only added into the action
queue when command "trigger fs" is executed, but that's after the
bootchart_init action (late_init).

This change makes bootchart_init a builtin command of init,
and make it executed as the first command of "on post-fs" section
which will be triggered after the "on fs" section.

This change also refactors the bootchart code to all be in bootchart.cpp.

Change-Id: Ia74aa34ca5b785f51fcffdd383075a549b2a99d9
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2015-02-12 12:13:24 -08:00
Johan Redestig
7e952f41f1 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
2015-02-07 10:57:10 +01:00
Elliott Hughes
f682b4786a 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
2015-02-06 14:20:30 -08:00
Elliott Hughes
c0e919c920 Stop using #if for conditional compilation.
Use regular 'if' to prevent bitrot.

Also remove remaining typedefs.

Change-Id: I2e6ca928e2db29b88b643cf990ff05cfb0be94a6
2015-02-04 17:16:11 -08:00
Elliott Hughes
24627906bf 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
2015-02-04 10:25:09 -08:00
Elliott Hughes
2145779c87 Fix clang "ueventd.cpp:111:1: error: no return statement in function returning non-void".
Change-Id: I69c9e5534975bffa0fbf98ca4af50400f6b94aa0
2015-02-04 10:19:50 -08:00
Elliott Hughes
f3cf438714 Build init as C++.
This is just the minimal change to keep it building.

Change-Id: I245c5b8413a1db114576c81462eb5737f5ffcef2
2015-02-04 08:59:10 -08:00
Dmitriy Ivanov
3107a2f5f2 Fix x86_64 build
Change-Id: Iaa3a641907de55b398a3bdd0bbc63cbb9d367982
2015-02-03 16:43:15 -08:00
Elliott Hughes
d4a6fc5bc2 Merge "Init: Fix Clang unsupported attributes" 2015-02-03 22:51:47 +00:00
Andreas Gampe
0ab46c9e2b Init: Fix literal
This is a literal 0 implicitly converted to a NULL.

Change-Id: I0573e85eb0578f938877c4bec79054081c27e661
2015-02-03 11:31:11 -08:00
Andreas Gampe
fe2fb359d6 Init: Fix Clang unsupported attributes
Make attributes conditional on not compiling with Clang.

Change-Id: Ic4e9b382308651c7b1901bfa192b6591672dc5ab
2015-02-03 11:25:26 -08:00
Elliott Hughes
d3e37d14e7 Trivial cleanup of recent changes.
A typo in the documentation for one, and a couple of signed/unsigned warnings
in the implementation of the other.

Change-Id: I8fb4b7448ac901c543dea7420aabcedf13ec1bd8
2015-02-02 16:43:32 -08:00
San Mehat
429721c5c4 init: Implement 'exec' command.
(cherry-pick of d05ab3952ec0e38f33a0e80ce6b9eb45b0064ba4.)

Change-Id: Id6d9bb32e51a0ad090ed8240cc505dc45b57b35d
2015-02-02 16:22:56 -08:00
Badhri Jagan Sridharan
0b41512a2e init: Add support "&&" operator in property triggers
"&&" operator can now be used to test the validity
of two of more properties.

For example:

on property:test.a=1 && property:test.b=1
    setprop test.c 1

The above stub sets the test.c to 1 only when
both test.a=1 and test.b=1

(cherry-pick of 162f7d797c67019a7a3f08c3b0f0ffc91d548ddc.)

Change-Id: I72c19f7aa92231372a416193618ee6c7fd368141
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
2015-02-02 16:21:05 -08:00
Nick Kralevich
45a884f85f Add O_CLOEXEC to lots of open() calls.
and other related fixups.

Change-Id: Ia88fb37a07ff6777d00c49800081f5a519c0c78d
2015-02-02 14:37:22 -08:00
Nick Kralevich
bc60954fae builtins.c: Don't require file open() for chmod/chown
42a9349dc4 modified init's
builtin chmod, chown, and mkdir calls to avoid following
symlinks. This addressed a number of attacks we were seeing
at the time where poorly written init scripts were following
attacker supplied symlinks resulting in rooting vulnerabilities.

To avoid race conditions, the previous implementation only ran
fchown / fchmod on file descriptors opened with open(O_NOFOLLOW).
Unfortunately, unlike the normal "chown" or "chmod" calls, this
requires read or write access to the underlying file. This
isn't ideal, as opening some files may have side effects, or
init may not have permission to open certain files (such as when
SELinux is enabled).

Instead of using open(O_NOFOLLOW) + fchown(), use lchown() instead.
As before, the target of the symlink won't be modified by chown.
This also supports setting the ownership of symlinks.

Instead of using open(O_NOFOLLOW) + fchmod(), use
fchmodat(AT_SYMLINK_NOFOLLOW) instead. As before, the target of the
symlink won't be modified by chmod.

This change will continue to ensure that chown/chmod/mkdir doesn't
follow symlinks, without requiring init to open every file in
read-only or read-write mode.

This change depends on bionic commit I1eba0cdb2c509d9193ceecf28f13118188a3cfa7

Addresses the following mako/occam SELinux denial:

  audit(1422770408.951:6): avc:  denied  { write } for  pid=1 comm="init" name="smd7" dev="tmpfs" ino=7207 scontext=u:r:init:s0 tcontext=u:object_r:radio_device:s0 tclass=chr_file

Change-Id: I14fde956784d65c44e7aa91dd7eea9a004df3081
2015-02-02 13:45:21 -08:00
Elliott Hughes
3d74d7a739 Add missing includes.
Change-Id: Iaa130c0a7eb2cbc0c8486546e5b622661b6d9e23
2015-01-29 21:31:23 -08:00
Chih-Hung Hsieh
d3d4741584 Enable clang for init, after fix of global .mk files.
LOCAL_FORCE_STATIC_EXECUTABLE was not working properly for clang
because -Bstatic was ignored by clang. We can now enable clang
for init after the -static flag is added to link static executable
files in build/core/definitions.mk.

BUG: 18008984
Change-Id: I3f361b83c1e0b313914603dff33fd090cd3b116a
2015-01-22 15:28:56 -08:00
Andres Morales
1f1b058e35 property_service: Added vendor build properties to load_all_props
Change-Id: Id50a6dd7fd40752efff8a327ea6b4a45b07fc1b2
2015-01-13 18:18:41 -08:00
dcashman
05345bfdb0 Move property_context label handling to libselinux.
Resubmission of commit: dab91bd37af6be355163ee33ca6f1b00e7dd1b51

Change-Id: Iad9517d3f81f7c091307b3e7497675e2cdc32be5
2014-12-10 13:21:17 -08:00
Nick Kralevich
59f64ec31f Revert "Move property_context label handling to libselinux."
Emulator fails to boot.

This reverts commit 98069027bd.

Bug: 18692152
Change-Id: If362e1311bc3f07e033ba81190c05608ada7c361
2014-12-10 02:02:32 +00:00
dcashman
98069027bd Move property_context label handling to libselinux.
Change-Id: I76e2ed95d4e4f8618458e63d30ae82e37d1acf7b
2014-12-03 15:18:40 -08:00
Andreas Gampe
a016c42b4f Init: Remove unused variables
For build-system CFLAGS clean-up, fix unused variables.

Use a #define instead of static variable in a header file.

Change-Id: Id47bf38e51644b61a9f3ac1893a16553695f1aac
2014-11-24 19:52:41 -08:00
Ying Wang
dbb78d65c0 Use LOCAL_POST_INSTALL_CMD to simplify symlink creation.
Change-Id: I67ad7248c26561d394e66901e90ef5814ec69fb3
2014-11-24 15:43:34 -08:00
Tomasz Kondel
fca58f4b18 Fix segfault in get_character_device_symlinks()
A segmentation fault will occur when strchr function returns NULL.

Change-Id: I76076acfff16056179bf24dff5df9f81d9a45125
2014-11-13 18:23:34 +00:00
Tomasz Kondel
bfdcc40bff Close fd on error path in do_mount()
This fix closes a file descriptor before returning
error from do_mount()

Change-Id: Ib370229f16bf9ac385162d6b163cc5b079a1e73e
2014-11-13 18:20:55 +00:00
Daniel Rosenberg
b95122205d property_service: Added vendor build properties to load_all_props
Change-Id: I267bd848e1f6e2978024c07e603b25f1f41f5fbf
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-11-11 12:17:00 -08:00
Elliott Hughes
57583a789f init isn't built for platforms without dirent::d_type.
Change-Id: Icd4b431576f2ba619ff4ae6fb871bb0210d3b2f2
2014-11-10 15:00:00 -08:00
Chih-hung Hsieh
5d727710ba am 2d241ec8: am 3a387176: Merge "Don\'t build init with clang for now"
* commit '2d241ec8a86c56bbf8522eb007674d7b4e3d164d':
  Don't build init with clang for now
2014-10-16 16:32:17 +00:00
Bernhard Rosenkraenzer
84e07fb7a4 Don't build init with clang for now
init doesn't start when built with clang.
Set LOCAL_CLANG:=false until this is analyzed and fixed.

Change-Id: I5a7944aef676ce88defe5c0449e712d9812fb5f3
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2014-10-04 01:36:49 +02:00
Jeff Sharkey
380e3e67ba am 2b16bf88: Merge "Include reason when wiping data." into lmp-dev
* commit '2b16bf88c768003291f027fdfac94d84abe9dbe6':
  Include reason when wiping data.
2014-09-24 23:35:43 +00:00
Jeff Sharkey
d26135b34d Include reason when wiping data.
This will help us track down who requested a data wipe.

Bug: 17412160
Change-Id: I40f73d2d0f08123d2afc044a3dde485151b400d9
2014-09-24 11:46:36 -07:00
Elliott Hughes
2e826dc2b1 am ae3a8961: am fed0f06b: Merge "init: Fix memory corruption when sanitizing platform paths"
* commit 'ae3a8961f01e436a70cab569483b8ebcc1f56c0c':
  init: Fix memory corruption when sanitizing platform paths
2014-09-23 02:16:48 +00:00
Christopher R. Palmer
07f3fee164 init: Fix memory corruption when sanitizing platform paths
This commit fixes code that incorrectly increments s when it
hits the terminator character of the string being sanitized.
This means it will randomly start trashing memory beyond the
end of the string being sanitized until it happens to hit two
NULs (\0\0) which will break it out of the loop.

Change-Id: I76553d7f183236a78a0bc7b408e92559b98f732f
2014-09-22 20:42:25 -04:00
Paul Lawrence
48fb175d22 am 40af0929: Fix charger mode on first boot of force encrypt devices
* commit '40af09297f9d60a3cfd4a186ff294cef6255a9df':
  Fix charger mode on first boot of force encrypt devices
2014-09-16 22:43:18 +00:00
Paul Lawrence
40af09297f Fix charger mode on first boot of force encrypt devices
waitpid breaks whenever child status signals. Need to loop, continuing
on errno EINTR

Bug: 17515976
Change-Id: Ibb29056a38b3c90dc7904de8c6aedb5a362e511d
2014-09-16 22:14:46 +00:00
Nick Kralevich
042ece12be am 465fc3b9: am 1cbf4329: Merge "Remove obsolete warning from restorecon_recursive documentation."
* commit '465fc3b974384feea3ea991a5e2f801ce1253e2f':
  Remove obsolete warning from restorecon_recursive documentation.
2014-09-02 15:59:17 +00:00
Stephen Smalley
d9c19b0c15 Remove obsolete warning from restorecon_recursive documentation.
We originally included a warning to not invoke restorecon_recursive
with a path leading to a shell-writable or app-writable directory
due to concerns about the potential for mischief with symlinks during
the restorecon_recursive.  However, this warning was never necessary for
calling restorecon_recursive during system initialization before an adb
shell or app can run, and we have further prohibited init from
reading/following symlinks that can be created by shell or apps in
policy, so this warning is superfluous.  It also contradicts current
usage of restorecon_recursive in rootdir/init.rc, since it is called
there on /data.

Change-Id: I28a635e0b5991ced8adcef93e7a04f9d9e5634fd
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-09-02 09:34:53 -04:00
Elliott Hughes
d546cb59ea am bf921c51: am 7a1973ec: Merge "remove examples of unimplemented triggers ( device-added device-removed ) from init/readme.txt"
* commit 'bf921c5112043b5e39b76e76f38f2818bc904b05':
  remove examples of unimplemented triggers ( device-added device-removed ) from init/readme.txt
2014-08-29 22:38:37 +00:00
Trevor Drake
d028394a27 remove examples of unimplemented triggers ( device-added device-removed )
from init/readme.txt

Change-Id: I16e226d8f563a223ae20044fff30498883bc4ae2
2014-08-29 20:07:28 +01:00
Elliott Hughes
a1e9ced56e am 8e207634: am d5f230af: Merge "Remove descriptions of unimplemented triggers."
* commit '8e207634c89e18a319c6514c39acd5aaff6d8f83':
  Remove descriptions of unimplemented triggers.
2014-08-28 17:15:26 +00:00
Trevor Drake
d4a497714a Remove descriptions of unimplemented triggers.
device-added, device-removed and service-exited were described but
never implemented.

Change-Id: I6fbd05a85576d18d6741fc6dd549acc9132b0531
2014-08-28 15:38:52 +01:00
Paul Lawrence
a95e10fe31 am a005e779: Merge "Enable not rebooting during default encryption" into lmp-dev
* commit 'a005e7795e3dfb7cc0bd2bc65208d2490bfc89d8':
  Enable not rebooting during default encryption
2014-08-26 04:53:43 +00:00
Paul Lawrence
c23074f386 Enable not rebooting during default encryption
Need to not set this property) during mount, since it can't
be changed later (ro property)

Also no reason to start class main on encryption cycle - we'll
show surfaceflinger, which is enough UI for this short cycle.

Bug: 17041092
Change-Id: Ica5339c54e45716d0fe20e23c0ab857f388d23ed
2014-08-25 19:24:10 +00:00
Kenny Root
c6c8b563e6 am cf2b944d: am 5a1d5a8c: Merge "ueventd: call _exit for safety"
* commit 'cf2b944df6d744d279a434ec280f9bd8cef03a5b':
  ueventd: call _exit for safety
2014-08-25 18:03:27 +00:00
Kenny Root
17baff480a ueventd: call _exit for safety
Make sure to call _exit instead of exit to avoid triggering exit
handlers that may have existed in the parent process.

Print out a log message when forking to process firmware events fails.

Change-Id: I2436bdf85d9a8ea26b718e62023f1dac89864667
2014-08-25 10:05:08 -07:00
Elliott Hughes
0fd33562d6 am 5d228392: am d24240fb: Merge "Fixed the pacing logic in bootchart data collection."
* commit '5d2283927a9527130cad15d33c1e2b360f4bd46f':
  Fixed the pacing logic in bootchart data collection.
2014-08-06 22:40:43 +00:00
Elliott Hughes
d24240fb4f Merge "Fixed the pacing logic in bootchart data collection." 2014-08-06 17:15:22 +00:00
Bo (Andover) Zhang
3700373c67 Fixed the pacing logic in bootchart data collection.
Ideally bootchart collects system data every BOOTCHART_POLLING_MS ms.
However, the current bootchart pacing logic would collect data every
time the main loop in init.c is executed. This results in:

1. Multiple data samples being taken consecutively or prematurely. In
many cases, these data samples have the same timestamp (in jiffies).
The off-line data processing tool would complain about dividing by
zero "interval" and bail out.

2. Because of the ineffective pacing, bootchart data collection would
terminate prematurely. The total duration of data collection is usually
much shorter than what the user specifies.

The fix is to check whether BOOTCHART_POLLING_MS ms has elapsed
before taking a new data sample. For this purpose, /proc/uptime
is used to get the time values, consistent with the precision of
bootchart timestamps.

Change-Id: I106bf91dbda01059b719df6c73b8bd1cd54a64f0
Signed-off-by: Bo (Andover) Zhang <zhang@broadcom.com>
2014-07-29 21:09:01 -04:00
Elliott Hughes
0b6f8974c9 am 95ec9ae2: am bce3c0c7: Merge "Clarify init\'s write command."
* commit '95ec9ae2c6bad929853c8e0574a354f2eda9604b':
  Clarify init's write command.
2014-07-25 23:04:03 +00:00
Elliott Hughes
afc08ce392 Clarify init's write command.
Bug: https://code.google.com/p/android/issues/detail?id=73996
Change-Id: I4f8d3927d17a4021a2436c2859aa732479c5a118
2014-07-25 14:57:47 -07:00
Elliott Hughes
d41f1a7ae4 Clarify init's write command.
Bug: https://code.google.com/p/android/issues/detail?id=73996

(cherry picked from commit afc08ce392)

Change-Id: Id2fb11d5259957ef23cc839fba14af8452fc69e4
2014-07-25 15:49:44 -07:00
Riley Andrews
4aa98b0c7c am c6ac2793: am ebf9f8f1: Merge "Move unlink("/dev/.booting") until after filesystems are mounted."
* commit 'c6ac27937c632b00836ad72c83c9e7a640030aff':
  Move unlink("/dev/.booting") until after filesystems are mounted.
2014-07-14 20:11:41 +00:00
Riley Andrews
80c7a5e8a8 Move unlink("/dev/.booting") until after filesystems are mounted.
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: Ifdd5dd1e95d7e064dde5c80b70198882d949a710
2014-07-14 13:17:43 -07:00
Elliott Hughes
ecba4dc037 am 85dfe988: am 796fccb8: Merge "Fix environment variable assignment in init"
* commit '85dfe98830c78f1c3d400ca7be4ac594bfcdd275':
  Fix environment variable assignment in init
2014-07-12 19:36:57 +00:00
Riley Andrews
9464e5a58d Move unlink("/dev/.booting") until after filesystems are mounted.
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
2014-07-11 15:47:15 -07:00
James Morrissey
381341f5f7 Fix environment variable assignment in init
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
2014-07-10 11:22:46 -07:00
Nick Kralevich
3b4c0bda07 ueventd fixup_sys_perms: fixup SELinux labels unconditionally
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
2014-07-07 11:14:59 -07:00
Colin Cross
09117c70f1 Merge "ueventd: allow matching symlink names when setting permissions" 2014-07-02 20:52:43 +00:00
Colin Cross
43d537e0de ueventd: allow matching symlink names when setting permissions
Change-Id: I5f6cc2a25f1236fbe2c7193b65363b7883b9ba2e
2014-07-02 13:56:55 -07:00
Nick Kralevich
4ef159a3c7 am 7367ecbc: am 06023134: am 8022ce1e: Merge "ueventd fixup_sys_perms: fixup SELinux labels unconditionally"
* commit '7367ecbc4839e3a608ab9b7742c659b58065209f':
  ueventd fixup_sys_perms: fixup SELinux labels unconditionally
2014-07-07 20:05:16 +00:00
Colin Cross
0c44584b47 am b18d44e4: am ab7e5752: am 09117c70: Merge "ueventd: allow matching symlink names when setting permissions"
* commit 'b18d44e458501f6b5b99349acc68d3d4e90e9d62':
  ueventd: allow matching symlink names when setting permissions
2014-07-02 23:13:48 +00:00
JP Abgrall
cee206880e [HACK]fs_mgr+init: Format via recovery if encryptable /data is wiped
If the encryptable partition is wiped (4KB worth of 0 or 0xff),
then reboot into recovery to format /data+/cache

This is while waiting for the Mac OS support to format f2fs.
The flashstation running on Mac OS will currently just erase userdata
and not format it with f2fs.

Bug: 15720406
Bug: 15747366
Change-Id: Ib7cca3e1701483a09573457a835750f34da71ee0
2014-07-02 14:28:50 -07:00
JP Abgrall
f22b745294 fs_mrg: clean up multi-type mount_all
Move the code that attempts to mount alternative fstab entries
into its own function.
Clarify return codes.
Suggest wipe via recovery in error messages.

Bug: 15747366
Change-Id: I3634477cd4d1d73f974f3e906c53285f0d9e0eac
Signed-off-by: JP Abgrall <jpa@google.com>
2014-07-02 13:39:44 -07:00
Elliott Hughes
e61679c2fe am fac28281: am b13e4b5e: am 5a53ee05: Merge "Remove an unused #include of <sys/_properties.h>."
* commit 'fac2828161b6b14b7e862d94f2f4ef467621c832':
  Remove an unused #include of <sys/_properties.h>.
2014-06-30 19:41:05 +00:00
Elliott Hughes
11d783f1e7 Remove an unused #include of <sys/_properties.h>.
Bug: 15704351
Change-Id: I7841da7176d0638ae6737fe719cd187892bc38e6
2014-06-30 10:11:55 -07:00
Riley Andrews
24912dc446 resolved conflicts for merge of fa6f2543 to master
Change-Id: I04ce82e5d245e90e2cc62b76d688ec902c1a471d
2014-06-26 20:49:46 -07:00
Riley Andrews
1bbef88e80 Add ability to adjust init log level at runtime.
+ 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
2014-06-26 15:05:20 -07:00
Riley Andrews
24a3b783d5 Improve init's debug printing.
+ 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
2014-06-26 15:05:15 -07:00
Nick Kralevich
f95244a9fc resolved conflicts for merge of dd8e63a4 to master
Change-Id: I5ee88d4a3846cb617ec115cb55c8192c8ecf2f4f
2014-06-26 05:13:39 -07:00
Nick Kralevich
64f5fe2796 Merge "property_service: get rid of hard coded property / control list" 2014-06-25 17:34:34 +00:00
Nick Kralevich
61be43907f am 471a7034: am aadf9f11: am 4ad20e55: Merge "Redirect libselinux logging to dmesg for ueventd."
* commit '471a7034b2fca93f174c88e275d3968032730aa7':
  Redirect libselinux logging to dmesg for ueventd.
2014-06-25 18:46:59 +00:00
Stephen Smalley
439224e275 Redirect libselinux logging to dmesg for ueventd.
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>
2014-06-24 14:11:59 -04:00
Riley Andrews
6bd4588d65 resolved conflicts for merge of 079c637f to master
Change-Id: Iab9a857026de954d7497d6b0eaf3751d2d3904c7
2014-06-23 15:20:51 -07:00
Ruchi Kandoi
c603720aed ueventd: UEVENT_MSG_LEN changed to 2048 from 1048 in compliance with the
BUFFER_LEN in the kobject_uevent in kernel.

Change-Id: Ib98626f20a7c26e7718bbe4d5ec4513a1ae5d9b7
2014-06-23 11:22:09 -07:00
Riley Andrews
e4b7b294f3 Add ability to boot from charger mode.
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
2014-06-20 16:43:00 -07:00