semodule_deps
PATCH 1/1 semodule_deps
Steve,
Below is a patch for a tool that generates dependency information about policy modules (in the form of policy packages). It also adds a field to export the source module name for each avrule_block in a linked policy. Please apply.
Thanks,
Karl
libsepol/include/sepol/policydb/policydb.h +4 -0
@@ -326,6 +326,10 @@ typedef struct avrule_decl {/* for additive statements (type attribute, roles, and users) */ symtab_t symtab[SYM_NUM ]; + +/* In a linked module this will contain the name of the module +* from which this avrule_decl originated. */ +char *module_name;struct avrule_decl *next; } avrule_decl_t;
libsepol/src/avrule_block.c +1 -0
@@ -102,6 +102,7 @@ void avrule_decl_destroy(avrule_decl_t *scope_index_destroy (&x->required);scope_index_destroy (&x->declared);symtabs_destroy (x->symtab); +free (x->module_name);free (x); }
libsepol/src/link.c +18 -10
@@ -1319,6 +1319,16 @@ static int copy_avrule_block(link_state_ ret =-1 ; goto cleanup; } + +if (module->policy->name !=NULL ) { + new_decl->module_name =strdup (module->policy->name); +if (new_decl->module_name ==NULL ) { +ERR (state->handle,"Out of memory\n" ); + ret =-1 ; + goto cleanup; + } + } +if (last_decl ==NULL ) { new_block->branch_list = new_decl; }else {
@@ -1328,6 +1338,7 @@ static int copy_avrule_block(link_state_ state->base->decl_val_to_struct[state->next_decl_id -1 ] = new_decl; state->decl_to_mod[state->next_decl_id] = module->policy; + module->avdecl_map[decl->decl_id] = new_decl->decl_id; ret =copy_avrule_decl (state, module, decl, new_decl);
@@ -1609,10 +1620,8 @@ static int debug_requirements(link_stateif (ret <0 ) {return ret; }else if (ret ==0 ) { -char *mod_name = - state->decl_to_mod[cur->branch_list->decl_id]-> - name ? state->decl_to_mod[cur->branch_list-> - decl_id]->name :"BASE" ; +char *mod_name = cur->branch_list->module_name ? + cur->branch_list->module_name :"BASE" ;if (req.symbol_type ==SYM_CLASSES ) {struct find_perm_arg fparg;
@@ -1677,8 +1686,9 @@ static void print_missing_requirements(l missing_requirement_t * req) {policydb_t *p = state->base; -char *mod_name = state->decl_to_mod[cur->branch_list->decl_id]->name ? - state->decl_to_mod[cur->branch_list->decl_id]->name :"BASE" ; +char *mod_name = cur->branch_list->module_name ? + cur->branch_list->module_name :"BASE" ; +if (req->symbol_type ==SYM_CLASSES ) {struct find_perm_arg fparg;
@@ -1749,10 +1759,8 @@ static int enable_avrules(link_state_t * } decl = block->branch_list;if (state->verbose) { -char *mod_name = - state->decl_to_mod[decl->decl_id]-> - name ? state->decl_to_mod[decl->decl_id]-> - name :"BASE" ; +char *mod_name = decl->module_name ? + decl->module_name :"BASE" ;INFO (state->handle,"check module %s decl %d\n" , mod_name, decl->decl_id); }
policycoreutils/Makefile +1 -1
@@ -1,4 +1,4 @@ -SUBDIRS=setfiles semanage load_policy newrole run_init restorecon restorecond secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand setsebool po +SUBDIRS=setfiles semanage load_policy newrole run_init restorecon restorecond secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po all install relabel clean: @for subdir in $(SUBDIRS); do \
policycoreutils/semodule_deps/Makefile new file +24 -0
@@ -0,0 +1,24 @@ +# Installation directories. +PREFIX ?= ${DESTDIR}/usr +INCLUDEDIR ?= $(PREFIX)/include +BINDIR ?= $(PREFIX)/bin +LIBDIR ?= ${PREFIX}/lib +MANDIR ?= $(PREFIX)/share/man + +CFLAGS ?= -Werror -Wall -W +override CFLAGS += -I$(INCLUDEDIR) +LDLIBS = $(LIBDIR)/libsepol.a + +all: semodule_deps + +semodule_deps: semodule_deps.o + +install: all + -mkdir -p $(BINDIR) + install -m 755 semodule_deps $(BINDIR) + test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8 + +relabel: + +clean: + -rm -f semodule_deps *.o
policycoreutils/semodule_deps/semodule_deps.8 new file +46 -0
46 lines not on this page · raw message
policycoreutils/semodule_deps/semodule_deps.c new file +360 -0
360 lines not on this page · raw message
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.