Type / attribute require ambiguity
I'm almost done with patches to allow sepolgen to update require blocks in module policy (see attached patch). In the process of testing this as part of the refpolicy build process I ran into a problem.
It is often unclear whether an identifier is referencing a type or attribute. Take the following example:
typeattribute foo bar;
allow domain bar : file write;
allow foo baz : file read;
Here it can be determined that foo must be a type and bar must be an attribute, but there is not enough information to determine which domain or baz is. Unfortunately, simply requiring domain as a type yields the following at link time:
libsepol.type_copy_callback: foo: Expected domain to be a type, but it was already declared as an attribute. libsemanage.semanage_link_sandbox: Link packages failed /usr/sbin/semodule: Failed!
Any thoughts on making the linker 'upgrade' types to attributes so that ambiguous identifiers can always be required as types? Otherwise automatically generating requires will never work.
Karl
sepolgen/src/Makefile +2 -0
@@ -2,12 +2,14 @@ all: ; install: $(MAKE) -C sepolgen $@ + $(MAKE) -C tools $@ $(MAKE) -C share $@ relabel: ; clean: $(MAKE) -C sepolgen $@ + $(MAKE) -C tools $@ $(MAKE) -C share $@ rm -f *~ *.pyc rm -f parser.out parsetab.py
sepolgen/src/sepolgen/defaults.py +3 -0
@@ -24,6 +24,9 @@ def data_dir(): def data_dir(): return "/var/lib/sepolgen" +def tools(): + return data_dir() + "/tools" + def perm_map(): return data_dir() + "/perm_map"
sepolgen/src/sepolgen/output.py +5 -6
@@ -43,9 +43,7 @@ class ModuleWriter: if self.sort: sort_filter(self.module) - # FIXME - make this handle nesting - for node, depth in refpolicy.walktree(self.module, showdepth=True): - fd.write("%s\n" % str(node)) + refpolicy.write_tree(module, fd) # Helper functions for sort_filter - this is all done old school # C style rather than with polymorphic methods because this sorting
@@ -110,8 +108,9 @@ def sort_filter(module): # Module statement mod = node.module_declaration() - c.append(mod) - c.append(refpolicy.Comment()) + if mod: + c.append(mod) + c.append(refpolicy.Comment()) # Requires for require in refpolicy.requires(node):
@@ -153,7 +152,7 @@ def sort_filter(module): node.children = c - for node in refpolicy.nodes(module): + for node in refpolicy.walktree(module, type=refpolicy.Node): sort_node(node)
sepolgen/src/sepolgen/policygen.py +68 -48
138 lines not on this page · raw message
sepolgen/src/sepolgen/refparser.py +65 -31
170 lines not on this page · raw message
sepolgen/src/sepolgen/refpolicy.py +571 -143
934 lines not on this page · raw message
sepolgen/src/sepolgen/tools.py +67 -0
67 lines not on this page · raw message
sepolgen/src/tools/Makefile +13 -0
@@ -0,0 +1,13 @@ +LIBDIR=$(DESTDIR)/var/lib/sepolgen +TOOLDIR=$(LIBDIR)/tools +BINDIR=$(DESTDIR)/usr/bin + +all: + +install: + install -m 755 sepolgen $(BINDIR) + -mkdir -p $(TOOLDIR) + install -m 755 sepolgen-*.py $(TOOLDIR) + +clean: + rm -f *~ *.pyc
sepolgen/src/tools/sepolgen +68 -0
68 lines not on this page · raw message
sepolgen/src/tools/sepolgen-update.py +89 -0
89 lines not on this page · raw message