summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-02-01 15:28:52 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-02-01 15:28:52 -0800
commit544d196e2269503136f73347e6d652b23bb87a0d (patch)
tree5d435482d475e09ab7994043135a3a6b620ccdfe /init
parentcc62beebffc4f7df7073411fbba776e3a4bc27eb (diff)
parent7480c0079d8c7fcfd5b3d9decfdabfebde162781 (diff)
downloadsystem_core-544d196e2269503136f73347e6d652b23bb87a0d.zip
system_core-544d196e2269503136f73347e6d652b23bb87a0d.tar.gz
system_core-544d196e2269503136f73347e6d652b23bb87a0d.tar.bz2
am 7480c007: am b2639f40: Merge "Label sockets consistently with the seclabel value if specified."
# By Stephen Smalley # Via Android Git Automerger (1) and others * commit '7480c0079d8c7fcfd5b3d9decfdabfebde162781': Label sockets consistently with the seclabel value if specified.
Diffstat (limited to 'init')
-rwxr-xr-xinit/init.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/init/init.c b/init/init.c
index 2fbe002..bfaf983 100755
--- a/init/init.c
+++ b/init/init.c
@@ -197,28 +197,36 @@ void service_start(struct service *svc, const char *dynamic_args)
}
if (is_selinux_enabled() > 0) {
- char *mycon = NULL, *fcon = NULL;
+ if (svc->seclabel) {
+ scon = strdup(svc->seclabel);
+ if (!scon) {
+ ERROR("Out of memory while starting '%s'\n", svc->name);
+ return;
+ }
+ } else {
+ char *mycon = NULL, *fcon = NULL;
- INFO("computing context for service '%s'\n", svc->args[0]);
- rc = getcon(&mycon);
- if (rc < 0) {
- ERROR("could not get context while starting '%s'\n", svc->name);
- return;
- }
+ INFO("computing context for service '%s'\n", svc->args[0]);
+ rc = getcon(&mycon);
+ if (rc < 0) {
+ ERROR("could not get context while starting '%s'\n", svc->name);
+ return;
+ }
- rc = getfilecon(svc->args[0], &fcon);
- if (rc < 0) {
- ERROR("could not get context while starting '%s'\n", svc->name);
- freecon(mycon);
- return;
- }
+ rc = getfilecon(svc->args[0], &fcon);
+ if (rc < 0) {
+ ERROR("could not get context while starting '%s'\n", svc->name);
+ freecon(mycon);
+ return;
+ }
- rc = security_compute_create(mycon, fcon, string_to_security_class("process"), &scon);
- freecon(mycon);
- freecon(fcon);
- if (rc < 0) {
- ERROR("could not get context while starting '%s'\n", svc->name);
- return;
+ rc = security_compute_create(mycon, fcon, string_to_security_class("process"), &scon);
+ freecon(mycon);
+ freecon(fcon);
+ if (rc < 0) {
+ ERROR("could not get context while starting '%s'\n", svc->name);
+ return;
+ }
}
}