-static int selinux_getconfromexe(
- const char *exe,
- security_context_t *newcon) {
-
- security_context_t mycon = NULL, fcon = NULL;
- security_class_t sclass;
- int r = 0;
-
- r = getcon(&mycon);
- if (r < 0)
- goto fail;
-
- r = getfilecon(exe, &fcon);
- if (r < 0)
- goto fail;
-
- sclass = string_to_security_class("process");
- r = security_compute_create(mycon, fcon, sclass, newcon);
-
-fail:
- if (r < 0)
- r = -errno;
-
- freecon(mycon);
- freecon(fcon);
- return r;
-}
-
-static int selinux_getfileconfrompath(
- const security_context_t scon,
- const char *path,
- const char *class,
- security_context_t *fcon) {
-
- security_context_t dir_con = NULL;
- security_class_t sclass;
- int r = 0;
-
- r = getfilecon(path, &dir_con);
- if (r >= 0) {
- r = -1;
- if ((sclass = string_to_security_class(class)) != 0)
- r = security_compute_create(scon, dir_con, sclass, fcon);
- }
- if (r < 0)
- r = -errno;
-
- freecon(dir_con);
- return r;
-}