Commit graph

385 commits

Author SHA1 Message Date
Dima Zavin
487c4ea012 am 7ec62dbd: am 82ea44f8: Merge "Change setsebool syntax to be consistent with other init built-ins."
* commit '7ec62dbd9d2bd7369fa074bf002f642b03e6dd39':
  Change setsebool syntax to be consistent with other init built-ins.
2012-12-19 09:51:38 -08:00
Stephen Smalley
0e23fee505 Change setsebool syntax to be consistent with other init built-ins.
Change setsebool syntax from name=value to name value.
This is to make it consistent with setprop and similar commands.
Update both the init built-in command and the toolbox command
for consistency.

Change-Id: I2c8e016ba26731c4a2ad4a49ae3b89362bf8f8a8
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-12-13 15:41:53 -05:00
Kenny Root
7af628233e am 27888a5d: am 9b82ce20: Merge "Document the SELinux extensions to the Android init language."
* commit '27888a5ded21182e1f15b19010fd2527fb7e1ef0':
  Document the SELinux extensions to the Android init language.
2012-11-27 17:34:27 -08:00
Kenny Root
9b82ce20eb Merge "Document the SELinux extensions to the Android init language." 2012-11-27 11:20:38 -08:00
Stephen Smalley
30f3033042 Label sockets consistently with the seclabel value if specified.
This is necessary to ensure that the adbd socket is created in the
adbd domain rather than the init domain.

Change-Id: Id4997d7f074aeefea62b41c87b46a6609e03f527
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-11-16 14:35:55 -05:00
Stephen Smalley
3fb6110830 Document the SELinux extensions to the Android init language.
Change-Id: I9b066e0789c93e5147c28a60baeed91c44dd9359
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-11-02 15:22:34 -04:00
Nick Kralevich
7c85af005d am 6575a162: am 8f98c4b5: Merge "Fix dirfd crash issue in property service"
* commit '6575a1625ac585b46f90c6f036db9231db50c969':
  Fix dirfd crash issue in property service
2012-10-23 10:49:48 -07:00
Nick Kralevich
6575a1625a am 8f98c4b5: Merge "Fix dirfd crash issue in property service"
* commit '8f98c4b5f011db8637ce1b9361e82d59b13434f4':
  Fix dirfd crash issue in property service
2012-10-23 10:46:55 -07:00
Yi-wei Zhao
e41bc31555 Fix dirfd crash issue in property service
In "init: harden property service" patch, dirfd() is invoked
without checking whether opendir() return successfully. It may
fail if load_persistent_properties() is invoked before userdata
partition is mounted; then dirfd(NULL) will make init crash.
This may happen if "is_charger" is true.

Change-Id: I216fb743a3c9fa050f92fcb31b62e766346d84bb
Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
2012-10-23 21:31:06 +08:00
Kenny Root
429bbfcafb am 2a36ae56: am 7b88a90d: Merge "Remove HAVE_SELINUX guards"
* commit '2a36ae5608e9d655b2bb14ce538f6fbdb910cada':
  Remove HAVE_SELINUX guards
2012-10-17 09:59:41 -07:00
Kenny Root
2a36ae5608 am 7b88a90d: Merge "Remove HAVE_SELINUX guards"
* commit '7b88a90da2a27e347fc16c14fa577f4ae1ef07fd':
  Remove HAVE_SELINUX guards
2012-10-17 09:57:10 -07:00
Kenny Root
b5982bf7c6 Remove HAVE_SELINUX guards
Change-Id: I8272c573b3c5dc663203bafab68fad5e94d89364
2012-10-16 23:18:18 -07:00
Nick Kralevich
87980b5c9f Revert "init: Set ADDR_COMPAT_LAYOUT before spawning processes."
This reverts commit 01b1dee0ab.

Bug: 7188322
Change-Id: Ia159eab36e9e7373f470d20a3796b63868ea5689
2012-10-05 12:45:05 -07:00
Nick Kralevich
569182a2ab am 7f3de6a4: am d282dfc4: Merge "init: Set ADDR_COMPAT_LAYOUT before spawning processes." into jb-mr1-dev
* commit '7f3de6a450f025245bb27fdc13f5bbc1dc22624d':
  init: Set ADDR_COMPAT_LAYOUT before spawning processes.
2012-10-05 12:14:11 -07:00
Nick Kralevich
01b1dee0ab init: Set ADDR_COMPAT_LAYOUT before spawning processes.
Some Android programs have problems with memory which grows
from the top down.  Temporarily set ADDR_COMPAT_LAYOUT to
avoid breaking those programs.

Bug: 7188322
Change-Id: I61760500e670b4563838c63b82d4a0b6e354a86e
2012-10-05 12:02:46 -07:00
Nick Kralevich
474cb0e33a am 33045b3d: am f9c05970: Merge "init: harden property service."
* commit '33045b3d7bd965f67e2e0b175976cf9934fb924f':
  init: harden property service.
2012-10-04 11:47:06 -07:00
Nick Kralevich
7ecfe6a94b init: harden property service.
Don't create temporary files in a well-known location. Rather,
use mkstemp().

Don't read persistent property files from insecure files.

Change-Id: I81e2aca674a2a7ca54869f088737fb228d3af6d2
2012-10-04 10:47:05 -07:00
Nick Kralevich
32b9023d08 init: Don't read local properties if ro.debuggable=0
Bug: 7195965
Change-Id: I29fdad61aa61f2c46d49db227cf7b84d9cc6f25d
2012-09-19 13:03:18 -07:00
Jean-Baptiste Queru
c3a4a054a9 am 3af04b71: am 7c386a61: Merge "Extend and document the "wait" command"
* commit '3af04b71e51e89af02a1fe526e4fc32dce0100d3':
  Extend and document the "wait" command
2012-08-20 10:29:38 -07:00
Jean-Baptiste Queru
7c386a610d Merge "Extend and document the "wait" command" 2012-08-20 09:18:38 -07:00
Jean-Baptiste Queru
d7f78e88b5 am e3bdaeb6: am 2765e4fb: Merge "Use sigemptyset to initialise signal mask as it is more portable. Referencing sa_restorer fails on MIPS"
* commit 'e3bdaeb603ab7ac941b35b41856c6b8ebf47c6bb':
  Use sigemptyset to initialise signal mask as it is more portable. Referencing sa_restorer fails on MIPS
2012-08-15 09:37:56 -07:00
Iliyan Malchev
a8f1e11bcc Merge "bluetooth: bring up with bluedroid stack" into jb-mr1-dev 2012-08-15 09:20:33 -07:00
Jeonghoon lim
e953e9657c bluetooth: bring up with bluedroid stack
- change permission of "bluetooth." property to AID_BLUETOOTH

Change-Id: Ifcd97f136cfc3372412fe500e4f800d1bbbd065c
2012-08-15 01:34:31 -07:00
Benoit Goby
5c8574b512 init: Fix mkdir command when using ISUID or ISGID bit
On first boot, the directory is created with root:root ownership and
then chowned. chown clears the ISUID and ISGID bits, so we need to chmod
the directory again after chown.

Change-Id: I02dfe7a19a637678256b4e7cc09e6b5431e6f11e
2012-08-14 15:51:44 -07:00
Chris Dearman
6736eb1829 Use sigemptyset to initialise signal mask as it is more portable.
Referencing sa_restorer fails on MIPS

Change-Id: I81c9ed5ef027a9d5258942ffcecb96e3f787e93c
Signed-off-by: Chris Dearman <chris@mips.com>
2012-08-14 15:30:39 -07:00
Jeff Sharkey
90b80de5a7 Merge "Support shared-subtree and bind mount flags." into jb-mr1-dev 2012-08-14 14:17:45 -07:00
Jeff Sharkey
e50ac5f777 Support shared-subtree and bind mount flags.
Bug: 6925012
Change-Id: Id8d887d17c6b1b2f90cfd1a1de991ccaba730b7d
2012-08-14 12:38:14 -07:00
Jean-Baptiste Queru
96539e8153 am ee0d281a: am c95c15b1: Merge "Char device /dev/dri/card0 was not created during startup."
* commit 'ee0d281a3e5fe611bdda23db18fa0e5684ee43ed':
  Char device /dev/dri/card0 was not created during startup.
2012-08-14 08:41:16 -07:00
Jean-Baptiste Queru
c95c15b192 Merge "Char device /dev/dri/card0 was not created during startup." 2012-08-14 08:06:44 -07:00
Kenny Root
2fec4de5c7 am 11c783f1: am 9494f297: Merge "Implement SELinux/MAC checks for property service."
* commit '11c783f1ead9f276e8854cb1adaebeed8517e8a1':
  Implement SELinux/MAC checks for property service.
2012-08-13 10:22:57 -07:00
Kenny Root
605103fb55 resolved conflicts for merge of 4dcd52ab to jb-mr1-dev
Change-Id: Ibd0c03a7883a2e31adab18543c016776b7b36866
2012-08-13 10:21:35 -07:00
rpcraig
63207cd20f Implement SELinux/MAC checks for property service.
This is a set of changes to the init property service
implementation to apply a SELinux check over who can
change what properties. Also included control hooks
for the 'ctl' keys.

Change-Id: I5a18809bf5536f6459a36b6bf0d622b9f5061aa0
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
2012-08-09 10:05:49 -04:00
Stephen Smalley
ae6f3d7c05 Add support for reloading policy from /data/system.
To support runtime policy management, add support for reloading
policy from /data/system.  This can be triggered by setting the
selinux.loadpolicy property to 1, whether from init.rc after
mounting /data or from the system_server (e.g. upon invocation of
a new device admin API for provisioning policy). ueventd and
installd are restarted upon policy reloads to pick up the new
policy configurations relevant to their operation.

Change-Id: I97479aecef8cec23b32f60e09cc778cc5520b691
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-08-09 09:59:10 -04:00
Stephen Hines
4900f43670 am f442cf27: am b3a5343e: Merge "Fixed a discarded const qualifier warning"
* commit 'f442cf27c5d1229eb32973cb499578ccd63ba727':
  Fixed a discarded const qualifier warning
2012-08-08 17:44:04 -07:00
Stephen Hines
b3a5343e3e Merge "Fixed a discarded const qualifier warning" 2012-08-08 15:27:25 -07:00
Jean-Baptiste Queru
ff5c802e6c am faad67fa: am ef3f7fa3: Merge "Set the SELinux security label on new directories."
* commit 'faad67fac68642ca039fe5c29099acebf546f5ee':
  Set the SELinux security label on new directories.
2012-08-08 14:06:27 -07:00
Jean-Baptiste Queru
ef3f7fa32b Merge "Set the SELinux security label on new directories." 2012-08-08 13:42:20 -07:00
Ravi Nagarajan
a8afd723a4 Allow AID_BLUETOOTH to update persist.service.bdroid
When devices are provisioned, bd address path is set in ro.bt.bdaddr_path.
On devices where this property is not present, a random bd address is
generated and saved to the property: persist.service.bdroid.bdaddr
This change allows bluetooth process to update this property
bug 6885309

Change-Id: I2e8a2471a0e890da82e6bbec6a2ef67ec8e1f8f4
2012-08-06 23:56:45 -07:00
Veeren Mandalia
4f97fd91e3 init: fix return value for android uid/gid check
Now get_android_id function returns -EINVAL if the uid/gid is not in the list
of android ids. This will allow ueventd to catch invalid ids and report the
error.

Change-Id: I943b04dd64d518891623e1ee2d561b8061af4863
Signed-off-by: Veeren Mandalia <v.mandalia@sta.samsung.com>
2012-08-03 13:16:05 -07:00
Edwin Vane
de7f1ad86f Fixed a discarded const qualifier warning
Change-Id: I9007924d0bf49705363aa130e6e588a9e0ccdc31
Author: Edwin Vane <edwin.vane@intel.com>
Reviewed-by: Tareq A Siraj <tareq.a.siraj@intel.com>
2012-08-02 09:20:51 -04:00
Ed Heyl
3cac204d35 Merge remote-tracking branch 'goog/jb-dev-mako' into jb-mr1-dev 2012-07-28 11:48:12 -07:00
Stephen Smalley
e096e36e50 Set the SELinux security label on new directories.
Automatically set the SELinux security label on directories created
by init.rc.  This avoids the need to separately call restorecon on
each such directory from the init.rc file.  Also restorecon /dev
and /dev/socket after initial policy load so that they are labeled
correctly before any other dev nodes or sockets are created.

Change-Id: If6af6c4887cdead949737cebdd673957e9273ead
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2012-07-26 09:01:22 -04:00
Colin Cross
308bc52d33 ueventd: fixup /sys permissions on change uevents
Change uevents may be triggered after new files are created on a device
in /sys, run the sys permissions fixup when they occur.

Change-Id: Iec2725c9f8a032e5124190444edaf189a766b0b2
2012-07-24 12:36:40 -07:00
Patrick McCormick
96d0a4dda8 Extend and document the "wait" command
The wait command was currently implemented but
undocumented and only used internally. This change
adds a second option toi (optionally) override the default
timeout of 5 seconds.

The wait command can be used to wait for a file to appear
during the boot process, for example a disk or other device,
and is a better alternative than an unconditional sleep.

Change-Id: Ia11d8419c0ea84deec0e1bf5adfca5bc76ff38b7
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2012-07-24 10:31:49 -07:00
Lukasz Anaczkowski
e6f8d45da8 Char device /dev/dri/card0 was not created during startup.
This device is required by libdrm for GPUs like IvyBridge.

Change-Id: I0ac47056a9cec2100f3e6eaa5591571fe6bbc145
Signed-off-by: Lukasz Anaczkowski <lukasz.anaczkowski@intel.com>
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2012-07-23 16:08:17 -07:00
jeonghoon.lim
8c0350f4ee bluetooth: add property permission for bluetooth
add property permission for bluetooth.

Change-Id: I099f325f533d06c63ad43843dd6477ea81fc9781
2012-07-16 17:35:22 -07:00
Arve Hjønnevåg
d97d9074ba Add watchdogd
"/sbin/watchdogd <interval> <margin>" will open /dev/watchdog, try
to set the timeout to <interval>+<margin> then write to it every
<interval> seconds to reset the watchdog.

Change-Id: I15571980cdb868ec19f20e80bf8274b32107d36d
2012-06-14 15:43:23 -07:00
Iliyan Malchev
029d44e6ae HACK: use /firmware/image as a 3rd choice
Change-Id: I74af2e2dc872f88b904ead13e300ae32547e70c8
Signed-off-by: Iliyan Malchev <malchev@google.com>
2012-06-11 14:18:45 -07:00
Benoit Goby
93574c619c init: Fix chown and chmod for write-only files
Change-Id: I570b631ced11ab104aafe7ebfe71bae4e380d8af
2012-05-04 16:29:41 -07:00
Geremy Condra
42a9349dc4 init: make chmod/mkdir/chown not follow symlinks
This change brings init's do_chmod, mkdir, and do_chown into line
with open's O_NOFOLLOW semantics, causing them to fail when the
last element of their target path is a symlink.

Change-Id: If00e1a25cfe17ef6f738af4bf0541abd0c1b084b
2012-05-02 11:13:49 -07:00
Ken Sumrall
048cc27c8a am 0e9dd90a: Change init to use libfs_mgr to mount filesystems.
* commit '0e9dd90ac336278659477cad0b9e9f1004e2b338':
  Change init to use libfs_mgr to mount filesystems.
2012-05-01 14:01:13 -07:00
Ken Sumrall
0e9dd90ac3 Change init to use libfs_mgr to mount filesystems.
The new fs_mgr library moves much of the knowledge of what filesystems
to mount into a new fstab.<device> file, and just calls one function to
mount all the filesystems.

Change-Id: If3db37530a0676000cba3e679db27aca734227e5
2012-05-01 13:14:27 -07:00
Ken Sumrall
08ec39ecc6 Change init to use libfs_mgr to mount filesystems.
The new fs_mgr library moves much of the knowledge of what filesystems
to mount into a new fstab.<device> file, and just calls one function to
mount all the filesystems.

Change-Id: If3db37530a0676000cba3e679db27aca734227e5
2012-04-30 19:31:06 -07:00
Romain Guy
d0ffe3840b am ce182cb8: Merge "Let users with SYSTEM permission set debug. properties" into jb-dev
* commit 'ce182cb8c00d0f5dedadbd4964dbc8cb705b8550':
  Let users with SYSTEM permission set debug. properties
2012-04-27 15:27:48 -07:00
Romain Guy
45fa13f370 Let users with SYSTEM permission set debug. properties
Change-Id: Ieda3f7dd5dca5f6a8fc50b07822e6a875db030ad
2012-04-27 15:19:30 -07:00
Colin Cross
cf41769375 am 64753635: am a02ff986: Merge "init: Add noexec mount option"
* commit '647536359f8ea63330805cb77abbf2f101952daa':
  init: Add noexec mount option
2012-04-27 00:21:22 -07:00
Lars Svensson
b6ee25e3ad init: Add noexec mount option
Change-Id: Ic13d66797a86d38432e79af0c3387ce986d0a19f
2012-04-23 13:27:48 -07:00
Andrew Flynn
34f6d9e910 Don't set ro.carrier in init.c
It will instead be set using PRODUCT_PROPERTY_OVERRIDES
in makefiles

Change-Id: Idc8b480af4c15e15c2d97cdd82a20f259e027c52
2012-04-13 09:00:48 -07:00
Nick Kralevich
6ebf12fe1b init: Change umask of forked processes to 077
Modify init to set the umask to 077 when forking processes.
This helps protect against inadvertant information disclosure
in init's child processes.

ueventd: Keep umask at 000. uevent needs to be able to
create device nodes with exactly the permissions it
indicates.

Testing:
1) Do an "ls -lR /data /dev" on the device before and after
the umask change and diff the output. Verified by hand
that the permission change wouldn't cause any problems.

2) Verify that package installation works, and the permissions
are as expected, when installing a program from market and
"adb install".

Bug: 3272072
Change-Id: Ie4f7f06c0ee9da8d9b6fce25d71d8991a9bce406
2012-04-02 14:11:07 -07:00
Benoit Goby
5890301308 init: Fix chown and chmod for write-only files
Change-Id: I570b631ced11ab104aafe7ebfe71bae4e380d8af
2012-03-28 18:24:08 -07:00
Wei Zhong
f97b887848 Add handling for DEVNAME for usb devices
When creating device node, user-space handler should honor device
node provided by kernel if present.

Bug: 6105248

Change-Id: I9ab3810563f29f065c239e15149882db28f08893
Signed-off-by: Wei Zhong <wzhong@google.com>
2012-03-23 14:16:37 -07:00
Mike Kasick
b54f39fdd9 init: Retain traditional restart behavior for critical and oneshot services.
Adds an SVC_RESTART state that's used for an explicit "restart" of a
running service.  This retains the traditional restart behavior for
critical and oneshot services (previously altered by 7e36edd8), whereby
these services are "simply restarted" instead of counting as a crash (for a
critical serivce) or going into the disabled state (for a oneshot service).
2012-03-22 22:25:17 -04:00
Mike Kasick
7e36edd80f init: Safely restart services to avoid race conditions.
Previously, service restarts (either an explicit "restart", or a "stop,
start" pair) exhibited a race condition whereby the new (restarting)
service process was often spawned before the old (stopping) process had
terminated.  This may have resulted in the new service process failing to
acquire a limited resource (file lock, socket bind, etc.) that the old
process had not yet released.

Now, a stopping service remains in the SVC_RUNNING state until its exiting
process has been reaped by waitpid.  This prevents a "stop, start" sequence
from spawning a second service process before resources held by the first
are released.  This enables safe service restarts by stopping the service,
waiting for the old service process to terminate, and (only then) starting
the new service process.  In the event of "restarting" an already stopped
service, the previous behavior is maintained whereby the service is simply
started.

This scenario could be special-cased by the restart command, however, we
have observed instances where services are, unintentionally, stopped and
started "too quickly," and so simultaneous processes for the same service
should never be allowed.

Note that this commit alters the behaviors for explicit restarts of
critical and oneshot services.  Previously these serivces would simply be
restarted, whereas now, an explicit restart of a critical service counts as
a crash (which may result in a recovery reboot) and oneshot services go
into the disabled state.
2012-03-22 22:11:41 -04:00
Geremy Condra
9ed1fe7732 init: make chmod/mkdir/chown not follow symlinks
This change brings init's do_chmod, mkdir, and do_chown into line
with open's O_NOFOLLOW semantics, causing them to fail when the
last element of their target path is a symlink.

Change-Id: If00e1a25cfe17ef6f738af4bf0541abd0c1b084b
2012-03-21 15:13:08 -07:00
Colin Cross
50fb5a6933 init: manually set controlling tty for console services
Normally, calling open on a tty will set that tty as the process
group controlling tty if none already exists.  However, if the tty
is /dev/console, the kernel will never automatically set it as the
controlling tty.  Call the TIOCSCTTY manually on the fd, which will
always attempt to set it as the controlling tty.

Fixes ctrl-c on the console shell when androidboot.console is not
passed on the kernel command line and the default /dev/console is
used.

Change-Id: I449cc41b47e93ac38ad6987413bb54131e1ec0cd
2012-03-18 15:39:59 -07:00
Colin Cross
9c38e14299 am 1a2f32c4: am d39f9d93: am 9cec99ba: Merge "Fix typo in queue_property_triggers ident"
* commit '1a2f32c4828380ca8590cf664725650ef35f1e37':
  Fix typo in queue_property_triggers ident
2012-03-01 23:57:11 -08:00
Chris Dearman
469b7b2da8 Fix typo in queue_property_triggers ident
Signed-off-by: Chris Dearman <chris@mips.com>
Change-Id: I5f18ccb0912b9bb89c9f5104f9505c610c109af8
2012-03-01 15:29:20 -08:00
Jean-Baptiste Queru
6439693eff am 3b04bde9: am ee79b455: am 93553073: Merge "Extend init and ueventd for SE Android."
* commit '3b04bde991d57765a830e06c6f5bb094722583bd':
  Extend init and ueventd for SE Android.
2012-02-24 11:17:43 -08:00
Stephen Smalley
e46f9d510d Extend init and ueventd for SE Android.
Add SE Android support for init and ueventd.

init:
- Load policy at boot.
- Set the security context for service daemons and their sockets.
- New built-in commands: setcon, setenforce, restorecon, setsebool.
- New option for services: seclabel.

ueventd:
- Set the security context for device directories and nodes.

Change-Id: I98ed752cde503c94d99dfa5b5a47e3c33db16aac
2012-02-01 07:49:08 -05:00
Nick Kralevich
abc12070d0 Merge "Don't read /data/local.prop on user builds" 2012-01-18 15:41:47 -08:00
Nick Kralevich
0dbda7e1c5 Don't read /data/local.prop on user builds
Creating a root owned /data/local.prop is one of the most common
ways to root an Android device. /data/local.prop is only intended
to assist developers on debuggable devices, and is never
intended to be used on production devices.

Change-Id: Ifcfa21c2ee9914b0b54445218b4cf0fea0a98e9c
2012-01-18 13:38:34 -08:00
Nick Kralevich
38f368c1b3 Don't parse properties from unsafe files.
Don't set properties from files that are unsafe (world-writable
or group-writable)

Change-Id: I8da539c6446b10596be1d7c2014e4b9aea13e3fd
2012-01-18 13:22:38 -08:00
Dima Zavin
84bf9af758 init: use init's property expansion code for setprop/write
Change-Id: I3c284860cc8d5106ac2b086e62baeb6263873935
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:36:09 -08:00
Dima Zavin
78a1b1fe1a init: delay importing files until after parsing the current file
If we process the import directive inline, then the ordering of the
commands for the "on xxx" sections would be a little unexpected. The
init.rc files do not really have an implied  order as to which section
appears and gets processed first. The init code itself provides that
ordering explicitly. For the user, the expectation is that if both the
current file and the imported file define a section (e.g. "on init"),
then the commands in the current file will be executed first, and then
the ones from the imported file(s).

The current implementation did not do that. It processed the import
directive inline, and thus the imported (i.e. dependent) files would
appear first in the command lists for the sections. This created
unintended side effects and the solution would have been to try and
put the import lines somewhere in the middle of the init file. This
would be difficult to notice and hard to extract the dependencies.

To solve this, we add the imports to a list for each file being parsed
and process the list after finishing parsing the file. This provides
predictable order for imports and provides a logical flow from the
user perspective: the currently parsed file gets to run its commands
before the files being imported.

Change-Id: I06dc35ff286314060e16b18923683cd2787269de
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:36:06 -08:00
Dima Zavin
5511c84a50 init: export all androidboot cmd line values as ro.boot.xx props
Also, clean up how we initialize the ro.xx properties and process
the kernel command line.

Change-Id: Iedda6c90e31340a189171a44b2767480403354f7
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:36:02 -08:00
Dima Zavin
3e7b7739e3 init: import the hardware specific init file in init.rc
This removes the hardcoding of the file import in init and instead
allows the init.rc file to fully control what is loaded.

Change-Id: I933e5bbab57f1e8705a370d660f92c6508da94d2
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:35:58 -08:00
Dima Zavin
a6235eacf4 init: allow init file imports to use properties in names
Adds new property syntax in init files during init file filename
expansion during the import command:
${prop.name}

So, one can do:  import /init.${ro.hardware}.usb.rc

Should convert other usages of property names to use the new function.

Change-Id: I9205d7d7a2da620bc8e6b89ac0eb554fad53ded3
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:35:53 -08:00
Dima Zavin
d7634c9cda init: initialize property area early at boot
The property service is still started later, but the property area
and the initial boot properties are initialized before the init.rc
file is processed. This allows init.rc files to have access to boot
properties during parsing.

Change-Id: Iae9ed1093c821831a864b39ae6bc697e62b94757
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-11 04:35:49 -08:00
Dima Zavin
ebe2cb312d init: use init's property expansion code for setprop/write
Change-Id: I3c284860cc8d5106ac2b086e62baeb6263873935
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:02:28 -08:00
Dima Zavin
304f12270d init: delay importing files until after parsing the current file
If we process the import directive inline, then the ordering of the
commands for the "on xxx" sections would be a little unexpected. The
init.rc files do not really have an implied  order as to which section
appears and gets processed first. The init code itself provides that
ordering explicitly. For the user, the expectation is that if both the
current file and the imported file define a section (e.g. "on init"),
then the commands in the current file will be executed first, and then
the ones from the imported file(s).

The current implementation did not do that. It processed the import
directive inline, and thus the imported (i.e. dependent) files would
appear first in the command lists for the sections. This created
unintended side effects and the solution would have been to try and
put the import lines somewhere in the middle of the init file. This
would be difficult to notice and hard to extract the dependencies.

To solve this, we add the imports to a list for each file being parsed
and process the list after finishing parsing the file. This provides
predictable order for imports and provides a logical flow from the
user perspective: the currently parsed file gets to run its commands
before the files being imported.

Change-Id: I06dc35ff286314060e16b18923683cd2787269de
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:02:00 -08:00
Dima Zavin
8886112d87 init: export all androidboot cmd line values as ro.boot.xx props
Also, clean up how we initialize the ro.xx properties and process
the kernel command line.

Change-Id: Iedda6c90e31340a189171a44b2767480403354f7
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:02:00 -08:00
Dima Zavin
7634bf87cf init: import the hardware specific init file in init.rc
This removes the hardcoding of the file import in init and instead
allows the init.rc file to fully control what is loaded.

Change-Id: I933e5bbab57f1e8705a370d660f92c6508da94d2
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:02:00 -08:00
Dima Zavin
976b878a0a init: allow init file imports to use properties in names
Adds new property syntax in init files during init file filename
expansion during the import command:
${prop.name}

So, one can do:  import /init.${ro.hardware}.usb.rc

Should convert other usages of property names to use the new function.

Change-Id: I9205d7d7a2da620bc8e6b89ac0eb554fad53ded3
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:01:57 -08:00
Dima Zavin
65a8360795 init: initialize property area early at boot
The property service is still started later, but the property area
and the initial boot properties are initialized before the init.rc
file is processed. This allows init.rc files to have access to boot
properties during parsing.

Change-Id: Iae9ed1093c821831a864b39ae6bc697e62b94757
Signed-off-by: Dima Zavin <dima@android.com>
2011-12-20 13:46:17 -08:00
Jeff Brown
33901e6024 Delete dead code.
Change-Id: Icfb9bcee2c524026ecbeb7e30e943d8ca299a33a
2011-11-18 15:21:56 -08:00
Ken Sumrall
a286480f56 Fix the class_reset command
The class_reset command used to reset services that had been set to
"disabled" in the init.rc file to a non-disabled state.  Now, if the
service was originally set to "disabled", have the reset command set
it back to disabled.  Otherwise, set it to the "reset" state as it
currently does.

Change-Id: I0c10582e46a8e443d4748d9d893ae762b19b653a
2011-10-26 16:58:27 -07:00
Vladimir Chtchetkine
2b99543cef Pick up on androidboot.hardware kernel cmd option
x86 emulator passes hardware name through the androidboot.hardware kernel cmd option, and
ueventd must pick up on it to locate proper ueventd.rc file for that hardware.

Change-Id: Id61c5b67fe6275a15c7aa62556e0b89eda7968f8
2011-09-28 11:44:30 -07:00
Dima Zavin
ebf46586f5 init: do not load default.prop from ramdisk in charger mode
Change-Id: Ic471b891829d7f857674b925c9948954972d9ecb
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-06 10:12:41 -07:00
Dima Zavin
ca47cef749 init: add charge mode handling
Introduces a 'charger' section that is processed when androidboot.mode
supplied on the kernel commandline is "charger".

In this mode, sections such as fs, post-fs, etc are skipped. Only the
'early-init' and 'init' sections of the init rc files are processed before
processing the 'charger' section.

Change-Id: If9eb6334de18f04cbcf2aab784578e2993615242
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-02 12:11:18 -07:00
Dima Zavin
da04c52ab1 init/cutils: move list utility code to cutils from init
Change-Id: I357ceee813700297d8343159f22a07659e768d41
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-02 12:11:18 -07:00
Dima Zavin
8f91282ebe init/cutils: move kernel logging interface to libcutils from init
Change-Id: Ia0f91b1fcd6cae69d76bf3dd841340958db938a8
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-02 12:11:17 -07:00
Dima Zavin
2d55e02d0f libcutils/init: move uevent socket opening code to libcutils
Change-Id: I90adf78c0eb6185505f2bf7b62e96e25ab918345
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-02 12:11:17 -07:00
Dima Zavin
3bea0790e2 init: check for list empty when getting commands for action
Change-Id: Id42d6a6b6297919b2e6520e074e31b5e01ae17bc
Signed-off-by: Dima Zavin <dima@android.com>
2011-08-26 14:03:32 -07:00
Benoit Goby
5da93589f1 Allow radio to set sys.usb.config
This allows the ril to put the phone into diagnostic mode

Change-Id: Iafc8164991550e7ab0ffda8b8da1d58e34a4225b
2011-08-22 12:12:37 -07:00
Benoit Goby
22bfc4cca0 Allow radio to set net.cdma* properties
Change-Id: I656abde9d06175eb158e84de4d08ede42620b46a
2011-07-28 18:10:23 -07:00
Benoit Goby
7100f640de Allow radio to set net.lte* properties
Change-Id: I4b7a280ba4c773673b28db8cfbbffcb360ee717f
2011-07-25 18:02:06 -07:00
Conley Owens
c21dcef9fe am 45e8fc6b: am 8621b5ea: am 212282c3: am 80dbd2a7: Merge "Fix build error in init when building with bootchart"
* commit '45e8fc6bfd9221274f48861287ff7af06ee7a199':
  Fix build error in init when building with bootchart
2011-07-25 17:25:13 -07:00
Conley Owens
45e8fc6bfd am 8621b5ea: am 212282c3: am 80dbd2a7: Merge "Fix build error in init when building with bootchart"
* commit '8621b5ea475822499128e6f138a9dfc224bbb569':
  Fix build error in init when building with bootchart
2011-07-25 12:21:21 -07:00
Conley Owens
80dbd2a7f2 Merge "Fix build error in init when building with bootchart" 2011-07-21 17:41:32 -07:00
Chia-chi Yeh
9bb4d411e0 init: update permissions for VPN.
VPN no longer uses system properties to keep network parameters.
Besides, profiles are now stored and encrypted by keystore.

Change-Id: I7575f04f350b7d8d5ba7008eb874a72180d057e8
2011-07-08 20:03:03 -07:00
Chia-chi Yeh
27164dce5f init: make "mkdir" work even when the directory already exists.
This allows us to change permissions and ownerships of directories
in init scripts without adding additional commands.

Change-Id: I1815d6015953035251b98f28c0f3efd3c7f25f80
2011-07-08 16:06:56 -07:00
Mike Lockwood
d18678f882 init: Handle EINTR in handle_property_set_fd()
Change-Id: I5a6f1791eaf11e98b1d81697112d78c99822fba5
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-01 15:04:38 -04:00
Mike Lockwood
1f0bd32f90 init: Add support for assigning system properties to system properties in init.rc
For example:
    setprop sys.usb.config $persist.sys.usb.config

Change-Id: I7b4e1ed1335906b32621bd96a341b0f94bbee7f5
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-09 15:42:54 -07:00
Mike Lockwood
f5cb5b2435 init: Fix the init.rc import command
Change-Id: I8a91c3f7d1ca31e137d9043bb7f56e4a44fb63df
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-09 15:42:47 -07:00
Mike Lockwood
7ba61b15ed init: Allow wildcards in property triggers by using * for property value
For example, the following trigger will fire when the sys.foo property
is set to any value:

on property:sys.foo=*
    write /data/foo hello

It is also possible to refer to the property within the trigger actions:

on property:sys.foo=*
    write /data/foo $sys.foo

Change-Id: If78d20a532f77e17aa5703d53be581ad6736cbcf
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-09 15:42:42 -07:00
Mike Lockwood
2c4d5dc415 init: Add support for writing system property value to a file in init.rc
The write command will write a property value if the value starts with a "$'

For example:
    write /sys/class/android_usb/iSerial $ro.serialno

Use double leading '$' if you need to write a string that starts with '$':

    write /data/foo $$hello

to write "$hello" to /data/foo

Change-Id: I55431ac7715a5347bb95c3a15aee97c575444dde
2011-06-09 15:42:31 -07:00
Ken Sumrall
211ce13432 Merge "Teach the mount command in init to not consider a wiped partition to be encrypted." 2011-05-27 16:13:43 -07:00
Ken Sumrall
7bc6e9ebe4 Teach the mount command in init to not consider a wiped partition to be encrypted.
Change-Id: I3e989f0b81ec35084baddc04e014406f4d90ce04
2011-05-26 20:01:39 -07:00
Nick Kralevich
57de8b8f27 rename uevent_checked_recv to uevent_kernel_multicast_recv
Change-Id: I1839627490080efcbb7269699709064856312f8b
2011-05-11 14:58:24 -07:00
Nick Kralevich
4682abaaa6 am b0d0e260: resolved conflicts for merge of 2baeb898 to honeycomb-plus-aosp
* commit 'b0d0e260bd6118959fa0e2d3c84037b3e0178551':
  Fold uevent message origin checking from init into libcutils.
2011-04-27 13:49:59 -07:00
Nick Kralevich
b0d0e260bd resolved conflicts for merge of 2baeb898 to honeycomb-plus-aosp
Change-Id: Ib3169b3a36aa13ef413da624355b1737e9b76fd9
2011-04-27 13:09:24 -07:00
Vernon Tang
3f582e92f0 Fold uevent message origin checking from init into libcutils.
Change-Id: I7cbc0cb840d1b4962e6c360fdad9a9c0ce20e87b
2011-04-28 05:16:21 +10:00
Nick Kralevich
bb738d6727 am de35f274: am 03752be0: am 0c297f5e: Merge "Revert "Fold uevent message origin checking from init into libcutils.""
* commit 'de35f2741c4e32e331a92be99f7c04b92b94beb2':
  Revert "Fold uevent message origin checking from init into libcutils."
2011-04-27 10:37:48 -07:00
Nick Kralevich
de35f2741c am 03752be0: am 0c297f5e: Merge "Revert "Fold uevent message origin checking from init into libcutils.""
* commit '03752be0a437d12e19ac73ebe23385fe6f756e2c':
  Revert "Fold uevent message origin checking from init into libcutils."
2011-04-27 10:35:06 -07:00
Nick Kralevich
de9e65dd65 Revert "Fold uevent message origin checking from init into libcutils."
This reverts commit 8405ec0e75.

The original change does not compile.
2011-04-27 10:21:24 -07:00
Nick Kralevich
3268eda4dc am e3ab4245: am a7cf7ed9: am 282c2ab4: Merge "Fold uevent message origin checking from init into libcutils."
* commit 'e3ab42457077ec2a66bac553e59a7fee08d4fa9e':
  Fold uevent message origin checking from init into libcutils.
2011-04-27 10:00:34 -07:00
Nick Kralevich
e3ab424570 am a7cf7ed9: am 282c2ab4: Merge "Fold uevent message origin checking from init into libcutils."
* commit 'a7cf7ed93486240ca48a407e67c7c3683a3b93aa':
  Fold uevent message origin checking from init into libcutils.
2011-04-27 09:59:14 -07:00
Vernon Tang
8405ec0e75 Fold uevent message origin checking from init into libcutils.
Change-Id: I1a38e611a7ad990f74306ce453740a1eeed2416d
2011-04-27 14:17:15 +10:00
Carl-Emil Lagerstedt
9ab8190e41 Fix build error in init when building with bootchart
There was a build error in init.c if you enabled bootchart, this
should probably be shipped upstream if not fixed already.

Change-Id: Iea3451c3e15d5cac00c5420d99bfce9a950aaaac
2011-04-11 14:17:54 +02:00
Brad Fitzpatrick
d6efa45489 am 80337ffc: am 47e4ee59: am 71ead183: Close the client socket early for ctl.* properties.
* commit '80337ffcf45205750b8b90cbbe28c4c8e7e2baff':
  Close the client socket early for ctl.* properties.
2011-04-01 12:27:04 -07:00
Brad Fitzpatrick
71ead18353 Close the client socket early for ctl.* properties.
Bug: 4199411
Change-Id: I3bf335e16e0df8405c538989a8f4f6db7795fa36
2011-04-01 12:00:35 -07:00
Colin Cross
ab0c4e0356 Merge "ueventd: track platform device uevents to parse block device names" 2011-03-31 17:01:26 -07:00
Colin Cross
320cbfa719 Merge "ueventd: refactor uevent handling" 2011-03-31 17:01:13 -07:00
Colin Cross
fadb85e3bd ueventd: track platform device uevents to parse block device names
The mmc block devices on panda boards use a platform device called
omap/omap_hsmmc.0.  The number of path entries in the uevent after
the platform device is unknown, and the number of path entries in
the platform device is unknown, so the only way to determine how
many entries make up the platform device is to compare against
a list of platform devices.

Add a list of platform devices that have been registered, and
iterate through it to determine the platform device portion of
a block device uevent.

Change-Id: I1480bc6429172ca6997d548787be3863ce062472
2011-03-31 16:44:04 -07:00
Colin Cross
eb5ba83065 ueventd: refactor uevent handling
Change-Id: I2002be3580ff87b0a55dc030a9099bf6d795011f
2011-03-31 16:37:20 -07:00
Brad Fitzpatrick
9f1e0e3ae3 Close the property socket *after* updating properties.
Also remove some dead code.

Bionic update is in change I3e80cecf

Bug: 4185486
Change-Id: I28e06197ff7a452c70b89b9fc5e2bcf0d9d54bbe
2011-03-30 15:27:03 -07:00
Brad Fitzpatrick
8ec49049da Close the property socket *after* updating properties.
Also remove some dead code.

Bionic update is in change I3e80cecf

Bug: 4185486
Change-Id: I8dd685eaea1a927c1659df5a1228cc259227ad1c
2011-03-30 14:18:25 -07:00
Brian Swetland
8d48c8e457 defer firmware load until after filesystems are mounted
In some situations a driver could try to request firmware before
/system is mounted.  Previously we'd fail the request.  Now we
will retry the read-from-filesystem every 100ms until we find the
firmware or we've finished the "fs" and "post-fs" stages of init.

Change-Id: Ie32402f7d41c818bf20f3297286ed5f99705b72c
2011-03-25 13:01:35 -07:00
Ken Sumrall
c5c51033c8 Load the persistent properties after decrypting the /data partition
Fix for bug 3415286.  The persistent properties are normally read early
in the boot process after /data is mounted.  However, for an encrypted
system, at that point /data is a tmpfs ramdisk.  This change adds a new
command to init (load_persist_props) to read the persistent properties,
and adds an action to init.rc to load the persistent properties.  This
action is triggered by setting a property in vold, but that's in a
different CL.

Change-Id: I74b3057974ee6029c29d956b76fef5566700d471
2011-03-10 18:12:19 -08:00
Ken Sumrall
e3aeeb4de3 Try to unmount writable filesystems when rebooting
Ext4 filesystems like to be unmounted before rebooting.  The Android system
doesn't have a traditional Linux init setup, and shutting down the system
was not much more than calling sync(2) and reboot(2).  This adds a new
function to libcutils called android_reboot().  By default, it calls sync()
and then remounts all writable filesystems as read-only and marks them clean.
There is a flag parameter in which the caller can ask for sync() not to be
called, or to not remount the filesystems as read-only.  Then it will call
reboot(2) as directed by the other parameters.  This change also updates
adb, init and toolbox to call the new android_reboot() function.
Fixes bugs 3350709 and 3495575.

Change-Id: I16d71ffce3134310d7a260f61ec6f4dd204124a7
2011-03-10 18:11:46 -08:00
Amol Bhatkar
cf01597121 property_service: Give radio permission to set net.qmi*
Change-Id: I771ef22859799b863ab79de9d3248ef610af4dd8
2011-03-02 16:00:58 -08:00
Ken Sumrall
dd4d786cbf Fix for bug 3379244, non-eMMC devices don't start all services.
Fix for non-eMMC based devices to properly start the "on nonencrypted"
action.

Change-Id: I5d2966db352b02f1a1724fb105e1cefc46037e42
2011-02-17 18:09:47 -08:00
Ken Sumrall
203bad597f Add the commands rm and rmdir to init.
rm only removes a single non-directory directory entry (no -r support)
rmdir removes a single empty directory

Change-Id: I49702b02ba98a177027b126268c2c2846f968195
2011-01-18 17:39:24 -08:00
Ken Sumrall
4e84d3bcf9 Set a read-only property to indicate if the device is running encrypted.
The UI needs to know if the device is running with an encrypted
filesystem or now.  So set a read-only property at boot to let it know.

Change-Id: I753de2d606c975bcbe9946d10fd47558cf357dac
2011-01-14 12:44:09 -08:00
Jean-Baptiste Queru
f5cb0a1385 am fc0b4ff1: Merge "init: Fix parser line numbering"
* commit 'fc0b4ff1c8675be3626510a5adfbcae507ecfa43':
  init: Fix parser line numbering
2011-01-07 15:34:03 -08:00
Bruce Beare
1be6968d9d init: Fix parser line numbering
Change-Id: I1ac481a2cef749b26c73bc9e6a212e6ace7a0ae2
2011-01-07 11:19:04 -08:00
Colin Cross
8bc6fb3433 am bf10797e: am f7ca6040: Fix infinite loop in init when debugging is turned off
* commit 'bf10797e538f9fa252d72710bd5ecf0ef1f6f3e0':
  Fix infinite loop in init when debugging is turned off
2011-01-04 18:50:51 -08:00
Colin Cross
bf10797e53 am f7ca6040: Fix infinite loop in init when debugging is turned off
* commit 'f7ca6040616f672a6f0039d55e39c610b7c1cf91':
  Fix infinite loop in init when debugging is turned off
2011-01-04 18:49:07 -08:00
Colin Cross
f7ca604061 Fix infinite loop in init when debugging is turned off
If a keychord is pressed when debugging is turned off, the main
event poll in init will return an event on the keychord fd,
but handle_keychord never reads the data.  Once this happens,
the poll will always return immediately, and init enters an
infinite loop.  Fix it by always reading from the keychord fd,
but only handling the returned keychord if debugging is
enabled.

Change-Id: Ie4efa98247d3cc978d275dc8a4516b32aa710278
2011-01-04 18:21:22 -08:00
Bruce Beare
378083a3f0 init: Fix parser line numbering
Change-Id: I3885dd7d631e7330d92780df822b3ee1a8d0350b
Signed-off-by: Bruce Beare <brucex.j.beare@intel.com>
2011-01-02 17:00:08 -08:00
Ken Sumrall
752923c168 Changes to init to support encrypted filesystems.
These are the changes to init and init.rc necessary to
support booting with and encrypted /data filesystem.
A corresponding change to init.<device>.rc goes along
with this change.

Change-Id: I0c7e2cc39568358014a82e317735c0eae14dd683
2010-12-18 19:03:54 -08:00
Mike Lockwood
58aa5b0ee0 init: Allow non-root adbd to switch between TCP and USB modes
Change-Id: I9e93ceefadfaa2a4f8ec25cfa05fa4821fd98093
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-12-10 09:48:41 -08:00
Iliyan Malchev
d5c8ddfdf3 Revert "Add "slow_start" keyword to init"
This reverts commit 50b3afd9f3.
2010-12-08 16:19:12 -08:00
Paul Eastham
50b3afd9f3 Add "slow_start" keyword to init
This keyword will cause init to wait a few seconds before exec'ing
the target binary.  Maybe only useful for hacks and debugging.

Change-Id: I85caa0bcbc0be7e48bd21eb9e31e039c0740c8d5
2010-12-04 17:39:26 -08:00
Olivier Bailly
7e06476f6d Merge "Add missing headers for compilation on x86 targets" 2010-11-29 15:13:50 -08:00
Nick Kralevich
2268718ee2 check the return value of setuid and friends
Under some circumstances, setuid() and family can fail,
returning a non-zero value.  (see "man setuid" for details).
If this happens, we want to ensure that init doesn't spawn a
process which has root privileges when it's not suppose to.

Change-Id: Idd03f2c8f82a7eaf6e696b5bcfe308e51ea58b52
2010-11-17 16:55:42 -08:00
Olivier Bailly
b93e5812fa Add missing headers for compilation on x86 targets
Change-Id: I5f4dc797b353a0f01fa00d38375ec303bf863254
2010-11-17 11:47:23 -08:00
Benoit Goby
609d8828d3 init: Abort firmware transfer if firmware is missing
If firmware is not found, write -1 /sys/$DEVPATH/loading to cancel the
firmware load. Otherwise the driver has to wait for the 60s timeout.

Change-Id: Id2787cda9b2be45b9adea41f6f161cd54cda212e
Signed-off-by: Benoit Goby <benoit@android.com>
2010-11-09 18:49:40 -08:00
Brian Swetland
7ca8f1243b am 439b4dfb: am bc57d4ce: init: support owner/permission setting for sysfs attributes of devices 2010-10-26 15:42:22 -07:00
Brian Swetland
439b4dfb27 am bc57d4ce: init: support owner/permission setting for sysfs attributes of devices 2010-10-26 15:40:19 -07:00