aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libselinux/src/label.c4
-rw-r--r--libselinux/src/label_file.c12
-rw-r--r--libselinux/src/label_internal.h3
3 files changed, 16 insertions, 3 deletions
diff --git a/libselinux/src/label.c b/libselinux/src/label.c
index ba316df5..7d71e724 100644
--- a/libselinux/src/label.c
+++ b/libselinux/src/label.c
@@ -56,7 +56,7 @@ static char *selabel_sub(struct selabel_sub *ptr, const char *src)
return NULL;
}
-static struct selabel_sub *selabel_subs_init(const char *path,struct selabel_sub *list)
+struct selabel_sub *selabel_subs_init(const char *path,struct selabel_sub *list)
{
char buf[1024];
FILE *cfg = fopen(path, "r");
@@ -161,8 +161,6 @@ struct selabel_handle *selabel_open(unsigned int backend,
rec->validating = selabel_is_validate_set(opts, nopts);
rec->subs = NULL;
- rec->subs = selabel_subs_init(selinux_file_context_subs_dist_path(), rec->subs);
- rec->subs = selabel_subs_init(selinux_file_context_subs_path(), rec->subs);
if ((*initfuncs[backend])(rec, opts, nopts)) {
free(rec);
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 937e5090..af7fd8f2 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -406,6 +406,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
FILE *homedirfp = NULL;
char local_path[PATH_MAX + 1];
char homedir_path[PATH_MAX + 1];
+ char subs_file[PATH_MAX + 1];
char *line_buf = NULL;
size_t line_len = 0;
unsigned int lineno, pass, i, j, maxnspec;
@@ -427,6 +428,17 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
break;
}
+ /* Process local and distribution substitution files */
+ if (!path) {
+ rec->subs = selabel_subs_init(selinux_file_context_subs_dist_path(), rec->subs);
+ rec->subs = selabel_subs_init(selinux_file_context_subs_path(), rec->subs);
+ } else {
+ snprintf(subs_file, sizeof(subs_file), "%s.subs_dist", path);
+ rec->subs = selabel_subs_init(subs_file, rec->subs);
+ snprintf(subs_file, sizeof(subs_file), "%s.subs", path);
+ rec->subs = selabel_subs_init(subs_file, rec->subs);
+ }
+
/* Open the specification file. */
if (!path)
path = selinux_file_context_path();
diff --git a/libselinux/src/label_internal.h b/libselinux/src/label_internal.h
index 008e09d3..02dbe736 100644
--- a/libselinux/src/label_internal.h
+++ b/libselinux/src/label_internal.h
@@ -36,6 +36,9 @@ struct selabel_sub {
struct selabel_sub *next;
};
+extern struct selabel_sub *selabel_subs_init(const char *path,
+ struct selabel_sub *list);
+
struct selabel_lookup_rec {
security_context_t ctx_raw;
security_context_t ctx_trans;