Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge "Label sockets consistently with the seclabel value if specified."

  • Loading branch information...
commit b2639f4015c9fb2ff10c7bfae6074a8d968f5b7e 2 parents f8afaeb + 30f3033
Colin Cross authored Gerrit Code Review committed

Showing 1 changed file with 27 additions and 19 deletions. Show diff stats Hide diff stats

  1. +27 19 init/init.c
46 init/init.c
@@ -198,28 +198,36 @@ void service_start(struct service *svc, const char *dynamic_args)
198 198 }
199 199
200 200 if (is_selinux_enabled() > 0) {
201   - char *mycon = NULL, *fcon = NULL;
  201 + if (svc->seclabel) {
  202 + scon = strdup(svc->seclabel);
  203 + if (!scon) {
  204 + ERROR("Out of memory while starting '%s'\n", svc->name);
  205 + return;
  206 + }
  207 + } else {
  208 + char *mycon = NULL, *fcon = NULL;
202 209
203   - INFO("computing context for service '%s'\n", svc->args[0]);
204   - rc = getcon(&mycon);
205   - if (rc < 0) {
206   - ERROR("could not get context while starting '%s'\n", svc->name);
207   - return;
208   - }
  210 + INFO("computing context for service '%s'\n", svc->args[0]);
  211 + rc = getcon(&mycon);
  212 + if (rc < 0) {
  213 + ERROR("could not get context while starting '%s'\n", svc->name);
  214 + return;
  215 + }
209 216
210   - rc = getfilecon(svc->args[0], &fcon);
211   - if (rc < 0) {
212   - ERROR("could not get context while starting '%s'\n", svc->name);
213   - freecon(mycon);
214   - return;
215   - }
  217 + rc = getfilecon(svc->args[0], &fcon);
  218 + if (rc < 0) {
  219 + ERROR("could not get context while starting '%s'\n", svc->name);
  220 + freecon(mycon);
  221 + return;
  222 + }
216 223
217   - rc = security_compute_create(mycon, fcon, string_to_security_class("process"), &scon);
218   - freecon(mycon);
219   - freecon(fcon);
220   - if (rc < 0) {
221   - ERROR("could not get context while starting '%s'\n", svc->name);
222   - return;
  224 + rc = security_compute_create(mycon, fcon, string_to_security_class("process"), &scon);
  225 + freecon(mycon);
  226 + freecon(fcon);
  227 + if (rc < 0) {
  228 + ERROR("could not get context while starting '%s'\n", svc->name);
  229 + return;
  230 + }
223 231 }
224 232 }
225 233

0 comments on commit b2639f4

Please sign in to comment.
Something went wrong with that request. Please try again.