def test_writeaboolean(self, sh): print "Testing active boolean write..." (status, key) = semanage.semanage_bool_key_create(sh, "allow_execmem") if status < 0: raise Error("Could not create SEBool key") if self.verbose: print "SEBool key created: ", key (status, old_bool) = semanage.semanage_bool_query_active(sh, key) if status < 0: raise Error("Could not query old SEBool") if self.verbose: print "Query status (commit number): ", status (status, abool) = semanage.semanage_bool_create(sh) if status < 0: raise Error("Could not create SEBool object") if self.verbose: print "SEBool object created." status = semanage.semanage_bool_set_name(sh, abool, "allow_execmem") if status < 0: raise Error("Could not set name") if self.verbose: print "SEBool name set: ", semanage.semanage_bool_get_name(abool) semanage.semanage_bool_set_value(abool, 0) if self.verbose: print "SEbool value set: ", semanage.semanage_bool_get_value(abool) print "Starting transaction..." status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_set_active(sh, key, abool) if status < 0: raise Error("Could not modify SEBool") status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit test transaction") print "Commit status (transaction number): ", status print "Resetting old active boolean..." status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_set_active(sh, key, old_bool) if status < 0: raise Error("Could not reset test SEBool") if self.verbose: print "SEBool active reset: ", status status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit reset transaction") print "Commit status (transaction number): ", status semanage.semanage_bool_key_free(key) semanage.semanage_bool_free(abool) semanage.semanage_bool_free(old_bool)
def test_writeaboolean(self,sh): print "Testing active boolean write..." (status, key) = semanage.semanage_bool_key_create(sh, "allow_execmem") if status < 0: raise Error("Could not create SEBool key") if self.verbose: print "SEBool key created: ", key (status, old_bool) = semanage.semanage_bool_query_active(sh, key) if status < 0: raise Error("Could not query old SEBool") if self.verbose: print "Query status (commit number): ", status (status, abool) = semanage.semanage_bool_create(sh) if status < 0: raise Error("Could not create SEBool object") if self.verbose: print "SEBool object created." status = semanage.semanage_bool_set_name(sh, abool, "allow_execmem") if status < 0: raise Error("Could not set name") if self.verbose: print "SEBool name set: ", semanage.semanage_bool_get_name(abool) semanage.semanage_bool_set_value(abool, 0) if self.verbose: print "SEbool value set: ", semanage.semanage_bool_get_value(abool) print "Starting transaction..." status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_set_active(sh,key,abool) if status < 0: raise Error("Could not modify SEBool") status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit test transaction") print "Commit status (transaction number): ", status print "Resetting old active boolean..." status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_set_active(sh, key,old_bool) if status < 0: raise Error("Could not reset test SEBool") if self.verbose: print "SEBool active reset: ", status status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit reset transaction") print "Commit status (transaction number): ", status semanage.semanage_bool_key_free(key) semanage.semanage_bool_free(abool) semanage.semanage_bool_free(old_bool)
def test_abooleans(self,sh): print "Testing active booleans..." (status, ablist) = semanage.semanage_bool_list_active(sh) if status < 0: raise Error("Could not list active booleans") print "Query status (commit number): ", status if (len(ablist) == 0): print "No active booleans found!" print "This is not necessarily a test failure." return for abool in ablist: if self.verbose: print "Active boolean reference: ", abool name = semanage.semanage_bool_get_name(abool) value = semanage.semanage_bool_get_value(abool) print "Active Boolean: ", name, " Value: ", value semanage.semanage_bool_free(abool)
def test_abooleans(self, sh): print "Testing active booleans..." (status, ablist) = semanage.semanage_bool_list_active(sh) if status < 0: raise Error("Could not list active booleans") print "Query status (commit number): ", status if (len(ablist) == 0): print "No active booleans found!" print "This is not necessarily a test failure." return for abool in ablist: if self.verbose: print "Active boolean reference: ", abool name = semanage.semanage_bool_get_name(abool) value = semanage.semanage_bool_get_value(abool) print "Active Boolean: ", name, " Value: ", value semanage.semanage_bool_free(abool)
def test_abooleans(self, sh): print("Testing active booleans...") (status, ablist) = semanage.semanage_bool_list_active(sh) if status < 0: raise Error("Could not list active booleans") print("Query status (commit number): %s" % status) if len(ablist) == 0: print("No active booleans found!") print("This is not necessarily a test failure.") return for abool in ablist: if self.verbose: print("Active boolean reference: %s" % abool) name = semanage.semanage_bool_get_name(abool) value = semanage.semanage_bool_get_value(abool) print("Active Boolean: %s Value: %s" % (name, value)) semanage.semanage_bool_free(abool)
def test_writeboolean(self,sh): print "Testing boolean write..." (status, pbool) = semanage.semanage_bool_create(sh) if status < 0: raise Error("Could not create SEBool object") if self.verbose: print "SEBool object created." status = semanage.semanage_bool_set_name(sh, pbool, "allow_execmem") if status < 0: raise Error("Could not set name") if self.verbose: print "SEBool name set: ", semanage.semanage_bool_get_name(pbool) semanage.semanage_bool_set_value(pbool, 0) if self.verbose: print "SEbool value set: ", semanage.semanage_bool_get_value(pbool) (status,key) = semanage.semanage_bool_key_extract(sh, pbool) if status < 0: raise Error("Could not extract SEBool key") if self.verbose: print "SEBool key extracted: ", key (status,exists) = semanage.semanage_bool_exists_local(sh,key) if status < 0: raise Error("Could not check if SEBool exists") if self.verbose: print "Exists status (commit number): ", status if exists: (status, old_bool) = semanage.semanage_bool_query_local(sh, key) if status < 0: raise Error("Could not query old SEBool") if self.verbose: print "Query status (commit number): ", status print "Starting transaction..." status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_modify_local(sh, key, pbool) if status < 0: raise Error("Could not modify SEBool") status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit test transaction") print "Commit status (transaction number): ", status status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") if not exists: print "Removing boolean..." status = semanage.semanage_bool_del_local(sh, key) if status < 0: raise Error("Could not delete test SEBool") if self.verbose: print "Boolean delete: ", status else: print "Resetting boolean..." status = semanage.semanage_bool_modify_local(sh, key, old_bool) if status < 0: raise Error("Could not reset test SEBool") if self.verbose: print "Boolean modify: ", status status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit reset transaction") print "Commit status (transaction number): ", status semanage.semanage_bool_key_free(key) semanage.semanage_bool_free(pbool) if exists: semanage.semanage_bool_free(old_bool)
def test_writeboolean(self, sh): print("Testing boolean write...") (status, pbool) = semanage.semanage_bool_create(sh) if status < 0: raise Error("Could not create SEBool object") if self.verbose: print("SEBool object created.") status = semanage.semanage_bool_set_name(sh, pbool, "allow_execmem") if status < 0: raise Error("Could not set name") if self.verbose: print("SEBool name set: %s" % semanage.semanage_bool_get_name(pbool)) semanage.semanage_bool_set_value(pbool, 0) if self.verbose: print("SEbool value set: %s" % semanage.semanage_bool_get_value(pbool)) (status, key) = semanage.semanage_bool_key_extract(sh, pbool) if status < 0: raise Error("Could not extract SEBool key") if self.verbose: print("SEBool key extracted: %s" % key) (status, exists) = semanage.semanage_bool_exists_local(sh, key) if status < 0: raise Error("Could not check if SEBool exists") if self.verbose: print("Exists status (commit number): %s" % status) if exists: (status, old_bool) = semanage.semanage_bool_query_local(sh, key) if status < 0: raise Error("Could not query old SEBool") if self.verbose: print("Query status (commit number): %s" % status) print("Starting transaction...") status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") status = semanage.semanage_bool_modify_local(sh, key, pbool) if status < 0: raise Error("Could not modify SEBool") status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit test transaction") print("Commit status (transaction number): %s" % status) status = semanage.semanage_begin_transaction(sh) if status < 0: raise Error("Could not start semanage transaction") if not exists: print("Removing boolean...") status = semanage.semanage_bool_del_local(sh, key) if status < 0: raise Error("Could not delete test SEBool") if self.verbose: print("Boolean delete: %s" % status) else: print("Resetting boolean...") status = semanage.semanage_bool_modify_local(sh, key, old_bool) if status < 0: raise Error("Could not reset test SEBool") if self.verbose: print("Boolean modify: %s" % status) status = semanage.semanage_commit(sh) if status < 0: raise Error("Could not commit reset transaction") print("Commit status (transaction number): %s" % status) semanage.semanage_bool_key_free(key) semanage.semanage_bool_free(pbool) if exists: semanage.semanage_bool_free(old_bool)