Commit graph

35 commits

Author SHA1 Message Date
Greg Hackmann
d68db71e75 init: limit visibility of init_parser.c helpers
To prevent clashing with forthcoming changes to uevent_parser.c

Change-Id: I2ee183261c7f43e0e4104a16a280c7ee73d7df96
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-11-25 11:24:16 -08:00
Nick Kralevich
aa4051dc4f am 2f924ebe: am a94d2b39: Merge "Add a restorecon_recursive built-in command to init."
* commit '2f924ebe0b0891dba1996c246839427b23705018':
  Add a restorecon_recursive built-in command to init.
2013-10-10 12:38:44 -07:00
Stephen Smalley
726e8f7a8f Add a restorecon_recursive built-in command to init.
Functionally equivalent to the restorecon -R toolbox command.
A use case is given by:
I48eaa2b9901ac8c978192c14493ba1058a089423

Also, fix error handling and documentation for restorecon command.

Change-Id: Ia7fbcc82645baf52c6bff0490d3492f458881cbb
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-10-10 14:09:19 -04:00
Benoit Goby
4820022b5e am 0b7d588d: am f2c4c4ad: Merge "init: Fix queue_all_property_triggers with nonexistent properties"
* commit '0b7d588d531691904530ba57d772b31fb24ed343':
  init: Fix queue_all_property_triggers with nonexistent properties
2013-09-24 16:15:43 -07:00
Benoit Goby
d679e1b572 init: Fix queue_all_property_triggers with nonexistent properties
Don't queue actions for "on property=*" if the property does not exist.
This fixes these errors on boot:

    init: property 'sys.powerctl' doesn't exist while
    expanding '${sys.powerctl}'
    init: powerctl: cannot expand '${sys.powerctl}

Change-Id: I3bd354d73a860f856be5df2c654f940445f9efd9
2013-09-24 15:20:34 -07:00
Colin Cross
b69f863455 am 0cbaed42: am a8ba1f2f: Merge "Add support for socket security context specification."
* commit '0cbaed4211b514dd2aaa4d28f8936ba58e83c6a5':
  Add support for socket security context specification.
2013-08-23 18:40:12 -07:00
Stephen Smalley
8348d279c7 Add support for socket security context specification.
Add an optional argument to the socket option for specifying
a SELinux security context for the socket.  Normally the socket
security context is automatically computed from the service security
context or set using the seclabel option, but this facility allows
dealing with two scenarios that cannot be addressed using the existing
mechanisms:
1) Use of logwrapper to wrap a service.
In this case, init cannot determine the service security context
as it does not directly execute it and we do not want logwrapper
to run in the same domain as the service.

2) Situations where a service has multiple sockets and we want to
label them distinctly.

Change-Id: I7ae9088c326a2140e56a8044bfb21a91505aea11
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-08-23 08:35:43 -04:00
Ken Sumrall
a76baaabe5 Add swapon_all to init's builtin commands
For enabling swap devices found in the fstab file

Change-Id: Iec4fd4d208df3d7a161a90d95f8606e8b516334a
2013-07-09 18:42:09 -07:00
Colin Cross
1a6f4c3bf2 init: switch property_get to use __system_property_get
(cherry picked from commit 2deedfe0b1)

Change-Id: If3fba2cc1dd5c167b0924ddfe42dbe2e6387208a
2013-06-17 16:57:32 -07:00
Colin Cross
2deedfe0b1 init: switch property_get to use __system_property_get
Change-Id: I4fc0502a1a5b331087618a4d2e3d90948743d7bd
2013-06-17 12:44:35 -07:00
Colin Cross
e9ab162f30 init: prevent action being added to the action_queue twice
Property triggers may cause an action to be queued twice, resulting
in a loop in the action queue.  Keep actions that are not on the queue
in the list_empty state (act->qlist->next == act->qlist), and only
add them to the list if they are in that state.

Bug: 8335133
Change-Id: I3a3ec18176cf19cbaa3a45220a03c7560eacfe79
2013-06-10 14:16:00 -07:00
gcondra@google.com
acef650dbc am 43329bc1: am 8a387870: Revert "Reload policy after setting up the data partition."
* commit '43329bc1c99c0f5f3670a8aaab39e54df34819a1':
  Revert "Reload policy after setting up the data partition."
2013-05-20 16:35:34 -07:00
repo sync
8a3878700e Revert "Reload policy after setting up the data partition."
This reverts commit fee250d27a.
2013-05-17 12:47:04 -07:00
gcondra@google.com
efbe7fc6cc am 63577d92: am fee250d2: Reload policy after setting up the data partition.
* commit '63577d9280e7919bfb7221030d211b833e66bb1e':
  Reload policy after setting up the data partition.
2013-04-30 17:18:05 -07:00
repo sync
fee250d27a Reload policy after setting up the data partition.
This forces a policy reload + fixcon to deal with dynamically
delivered policy changing labels on device nodes.

It's implemented as a new keyword in init.

Bug: 8702843
Change-Id: I803cf1ecf6ff8318ce25dcc5cda4f292adc9738c
2013-04-30 11:40:22 -07:00
Nick Kralevich
ca8e66a8b0 Make init handle reboots
Move the responsibility for rebooting the system from the
reboot command to init. Init is in a better position to take
actions to bring the system down cleanly, including making sure
filesystems are mounted read-only.

The only UIDs which can perform an init triggered reboot are
root, system, and shell.

Modify the reboot command so that it calls into init to perform
the reboot. The reboot command no longer requires CAP_SYS_BOOT.

Remove the -n reboot option and code which supports it.  Anyone needing
to do an unclean shutdown can just do a 'echo c > /proc/sysrq-trigger'.

Modify adb so that it calls into init to perform a shutdown.

Bug: 8646621
Change-Id: I84c0513acb549720cb0e8c9fcbda0050f5c396f5
2013-04-23 13:21:40 -07:00
Colin Cross
a5064626de init: prevent action being added to the action_queue twice
Property triggers may cause an action to be queued twice, resulting
in a loop in the action queue.  Keep actions that are not on the queue
in the list_empty state (act->qlist->next == act->qlist), and only
add them to the list if they are in that state.

Bug: 8335133
Change-Id: I3a3ec18176cf19cbaa3a45220a03c7560eacfe79
2013-03-07 13:44:59 -08:00
Kenny Root
b5982bf7c6 Remove HAVE_SELINUX guards
Change-Id: I8272c573b3c5dc663203bafab68fad5e94d89364
2012-10-16 23:18:18 -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
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
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
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
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
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
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
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
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
Bruce Beare
1be6968d9d init: Fix parser line numbering
Change-Id: I1ac481a2cef749b26c73bc9e6a212e6ace7a0ae2
2011-01-07 11:19:04 -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
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
Mike Lockwood
912ff85b03 init: Add support for SOCK_SEQPACKET socket type
Change-Id: Ib264ecf9beb2685b070436d2bdec9655c7a31b47
Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-10-01 08:20:36 -04:00
Colin Cross
6310a8261c init: Split parser into generic parser and init parser
Change-Id: I451ebc4ff12f2ac660eb533fa10ad561fa25c9dd
2010-04-21 19:43:40 -07:00