Commit graph

240 commits

Author SHA1 Message Date
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
b3a5343e3e Merge "Fixed a discarded const qualifier warning" 2012-08-08 15:27:25 -07:00
Jean-Baptiste Queru
ef3f7fa32b Merge "Set the SELinux security label on new directories." 2012-08-08 13:42:20 -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
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
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
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
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