summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-02-01 19:04:56 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-02-01 19:04:56 +0000
commitb2639f4015c9fb2ff10c7bfae6074a8d968f5b7e (patch)
treee3d21c5d6de8b8af10cea9d90d17100674b8269e
parentf8afaebec3d10879f22406ac1bf06a246d448f93 (diff)
parent30f30330420ca4d7913a49e6fd652b4768045ecb (diff)
downloadsystem_core-b2639f4015c9fb2ff10c7bfae6074a8d968f5b7e.zip
system_core-b2639f4015c9fb2ff10c7bfae6074a8d968f5b7e.tar.gz
system_core-b2639f4015c9fb2ff10c7bfae6074a8d968f5b7e.tar.bz2
Merge "Label sockets consistently with the seclabel value if specified."
-rwxr-xr-xinit/init.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/init/init.c b/init/init.c
index b20b434..48d8559 100755
--- a/init/init.c
+++ b/init/init.c
@@ -198,28 +198,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;
+ }
}
}