Home | History | Annotate | Download | only in src

Lines Matching refs:semanage

4 import semanage
126 (trans_cnt, mlist, mlist_size) = semanage.semanage_module_list(sh)
137 module = semanage.semanage_module_list_nth(mlist, idx)
139 print "Module name: ", semanage.semanage_module_get_name(module)
144 (status, slist) = semanage.semanage_seuser_list(sh)
155 print "seuser name: ", semanage.semanage_seuser_get_name(seuser)
156 print " seuser mls range: ", semanage.semanage_seuser_get_mlsrange(seuser)
157 print " seuser sename: ", semanage.semanage_seuser_get_sename(seuser)
158 semanage.semanage_seuser_free(seuser)
163 (status, ulist) = semanage.semanage_user_list(sh)
174 print "User name: ", semanage.semanage_user_get_name(user)
175 print " User labeling prefix: ", semanage.semanage_user_get_prefix(user)
176 print " User mls level: ", semanage.semanage_user_get_mlslevel(user)
177 print " User mls range: ", semanage.semanage_user_get_mlsrange(user)
178 print " User number of roles: ", semanage.semanage_user_get_num_roles(user)
180 (status, rlist) = semanage.semanage_user_get_roles(sh, user)
187 semanage.semanage_user_free(user)
192 (status, plist) = semanage.semanage_port_list(sh)
203 low = semanage.semanage_port_get_low(port)
204 high = semanage.semanage_port_get_high(port)
205 con = semanage.semanage_port_get_con(port)
206 proto = semanage.semanage_port_get_proto(port)
207 proto_str = semanage.semanage_port_get_proto_str(proto)
212 (rc, con_str) = semanage.semanage_context_to_string(sh,con)
215 semanage.semanage_port_free(port)
220 (status, flist) = semanage.semanage_fcontext_list(sh)
231 expr = semanage.semanage_fcontext_get_expr(fcon)
232 type = semanage.semanage_fcontext_get_type(fcon)
233 type_str = semanage.semanage_fcontext_get_type_str(type)
234 con = semanage.semanage_fcontext_get_con(fcon)
238 (rc, con_str) = semanage.semanage_context_to_string(sh,con)
241 semanage.semanage_fcontext_free(fcon)
246 (status, ilist) = semanage.semanage_iface_list(sh)
257 name = semanage.semanage_iface_get_name(iface)
258 msg_con = semanage.semanage_iface_get_msgcon(iface)
259 if_con = semanage.semanage_iface_get_ifcon(iface)
260 (rc, msg_con_str) = semanage.semanage_context_to_string(sh,msg_con)
262 (rc, if_con_str) = semanage.semanage_context_to_string(sh, if_con)
265 semanage.semanage_iface_free(iface)
270 (status, blist) = semanage.semanage_bool_list(sh)
281 name = semanage.semanage_bool_get_name(pbool)
282 value = semanage.semanage_bool_get_value(pbool)
284 semanage.semanage_bool_free(pbool)
289 (status, ablist) = semanage.semanage_bool_list_active(sh)
300 name = semanage.semanage_bool_get_name(abool)
301 value = semanage.semanage_bool_get_value(abool)
303 semanage.semanage_bool_free(abool)
308 (status, nlist) = semanage.semanage_node_list(sh)
320 (status, addr) = semanage.semanage_node_get_addr(sh, node)
323 (status, mask) = semanage.semanage_node_get_mask(sh, node)
326 proto = semanage.semanage_node_get_proto(node)
327 proto_str = semanage.semanage_node_get_proto_str(proto)
328 con = semanage.semanage_node_get_con(node)
330 (status, con_str) = semanage.semanage_context_to_string(sh, con)
334 semanage.semanage_node_free(node)
339 (status, user) = semanage.semanage_user_create(sh)
344 status = semanage.semanage_user_set_name(sh,user, "testPyUser")
347 if self.verbose: print "User name set: ", semanage.semanage_user_get_name(user)
349 status = semanage.semanage_user_add_role(sh, user, "user_r")
353 status = semanage.semanage_user_set_prefix(sh,user, "user")
356 if self.verbose: print "User prefix set: ", semanage.semanage_user_get_prefix(user)
358 status = semanage.semanage_user_set_mlsrange(sh, user, "s0")
361 if self.verbose: print "User mlsrange: ", semanage.semanage_user_get_mlsrange(user)
363 status = semanage.semanage_user_set_mlslevel(sh, user, "s0")
366 if self.verbose: print "User mlslevel: ", semanage.semanage_user_get_mlslevel(user)
368 (status,key) = semanage.semanage_user_key_extract(sh,user)
373 (status,exists) = semanage.semanage_user_exists_local(sh,key)
379 (status, old_user) = semanage.semanage_user_query_local(sh, key)
385 status = semanage.semanage_begin_transaction(sh)
387 raise Error("Could not start semanage transaction")
389 status = semanage.semanage_user_modify_local(sh,key,user)
393 status = semanage.semanage_commit(sh)
398 status = semanage.semanage_begin_transaction(sh)
400 raise Error("Could not start semanage transaction")
404 status = semanage.semanage_user_del_local(sh, key)
410 status = semanage.semanage_user_modify_local(sh, key, old_user)
415 status = semanage.semanage_commit(sh)
420 semanage.semanage_user_key_free(key)
421 semanage.semanage_user_free(user)
422 if exists: semanage.semanage_user_free(old_user)
427 (status, seuser) = semanage.semanage_seuser_create(sh)
432 status = semanage.semanage_seuser_set_name(sh,seuser, "testPySEUser")
435 if self.verbose: print "SEUser name set: ", semanage.semanage_seuser_get_name(seuser)
437 status = semanage.semanage_seuser_set_sename(sh, seuser, "root")
440 if self.verbose: print "SEUser seuser: ", semanage.semanage_seuser_get_sename(seuser)
442 status = semanage.semanage_seuser_set_mlsrange(sh, seuser, "s0:c0.c255")
445 if self.verbose: print "SEUser mlsrange: ", semanage.semanage_seuser_get_mlsrange(seuser)
447 (status,key) = semanage.semanage_seuser_key_extract(sh,seuser)
452 (status,exists) = semanage.semanage_seuser_exists_local(sh,key)
458 (status, old_seuser) = semanage.semanage_seuser_query_local(sh, key)
464 status = semanage.semanage_begin_transaction(sh)
466 raise Error("Could not start semanage transaction")
468 status = semanage.semanage_seuser_modify_local(sh,key,seuser)
472 status = semanage.semanage_commit(sh)
477 status = semanage.semanage_begin_transaction(sh)
479 raise Error("Could not start semanage transaction")
483 status = semanage.semanage_seuser_del_local(sh, key)
489 status = semanage.semanage_seuser_modify_local(sh, key, old_seuser)
494 semanage.semanage_commit(sh)
499 semanage.semanage_seuser_key_free(key)
500 semanage.semanage_seuser_free(seuser)
501 if exists: semanage.semanage_seuser_free(old_seuser)
506 (status, port) = semanage.semanage_port_create(sh)
511 semanage.semanage_port_set_range(port,150,200)
512 low = semanage.semanage_port_get_low(port)
513 high = semanage.semanage_port_get_high(port)
516 semanage.semanage_port_set_proto(port, semanage.SEMANAGE_PROTO_TCP);
518 semanage.semanage_port_get_proto_str(semanage.SEMANAGE_PROTO_TCP)
520 (status, con) = semanage.semanage_context_create(sh)
525 status = semanage.semanage_context_set_user(sh, con, "system_u")
528 if self.verbose: print "SEContext user: ", semanage.semanage_context_get_user(con)
530 status = semanage.semanage_context_set_role(sh, con, "object_r")
533 if self.verbose: print "SEContext role: ", semanage.semanage_context_get_role(con)
535 status = semanage.semanage_context_set_type(sh, con, "http_port_t")
538 if self.verbose: print "SEContext type: ", semanage.semanage_context_get_type(con)
540 status = semanage.semanage_context_set_mls(sh, con, "s0:c0.c255")
543 if self.verbose: print "SEContext mls: ", semanage.semanage_context_get_mls(con)
545 status = semanage.semanage_port_set_con(sh, port, con)
550 (status,key) = semanage.semanage_port_key_extract(sh,port)
555 (status,exists) = semanage.semanage_port_exists_local(sh,key)
561 (status, old_port) = semanage.semanage_port_query_local(sh, key)
567 status = semanage.semanage_begin_transaction(sh)
569 raise Error("Could not start semanage transaction")
571 status = semanage.semanage_port_modify_local(sh,key,port)
575 status = semanage.semanage_commit(sh)
580 status = semanage.semanage_begin_transaction(sh)
582 raise Error("Could not start semanage transaction")
586 status = semanage.semanage_port_del_local(sh, key)
592 status = semanage.semanage_port_modify_local(sh, key, old_port)
597 status = semanage.semanage_commit(sh)
602 semanage.semanage_context_free(con)
603 semanage.semanage_port_key_free(key)
604 semanage.semanage_port_free(port)
605 if exists: semanage.semanage_port_free(old_port)
610 (status, fcon) = semanage.semanage_fcontext_create(sh)
615 status = semanage.semanage_fcontext_set_expr(sh, fcon, "/test/fcontext(/.*)?")
618 if self.verbose: print "SEFContext expr set: ", semanage.semanage_fcontext_get_expr(fcon)
620 semanage.semanage_fcontext_set_type(fcon, semanage.SEMANAGE_FCONTEXT_REG)
622 ftype = semanage.semanage_fcontext_get_type(fcon)
623 print "SEFContext type set: ", semanage.semanage_fcontext_get_type_str(ftype)
625 (status, con) = semanage.semanage_context_create(sh)
630 status = semanage.semanage_context_set_user(sh, con, "system_u")
633 if self.verbose: print "SEContext user: ", semanage.semanage_context_get_user(con)
635 status = semanage.semanage_context_set_role(sh, con, "object_r")
638 if self.verbose: print "SEContext role: ", semanage.semanage_context_get_role(con)
640 status = semanage.semanage_context_set_type(sh, con, "default_t")
643 if self.verbose: print "SEContext type: ", semanage.semanage_context_get_type(con)
645 status = semanage.semanage_context_set_mls(sh, con, "s0:c0.c255")
648 if self.verbose: print "SEContext mls: ", semanage.semanage_context_get_mls(con)
650 status = semanage.semanage_fcontext_set_con(sh, fcon, con)
655 (status,key) = semanage.semanage_fcontext_key_extract(sh,fcon)
660 (status,exists) = semanage.semanage_fcontext_exists_local(sh,key)
666 (status, old_fcontext) = semanage.semanage_fcontext_query_local(sh, key)
672 status = semanage.semanage_begin_transaction(sh)
674 raise Error("Could not start semanage transaction")
676 status = semanage.semanage_fcontext_modify_local(sh,key,fcon)
680 status = semanage.semanage_commit(sh)
685 status = semanage.semanage_begin_transaction(sh)
687 raise Error("Could not start semanage transaction")
691 status = semanage.semanage_fcontext_del_local(sh, key)
697 status = semanage.semanage_fcontext_modify_local(sh, key, old_fcontext)
702 status = semanage.semanage_commit(sh)
707 semanage.semanage_context_free(con)
708 semanage.semanage_fcontext_key_free(key)
709 semanage.semanage_fcontext_free(fcon)
710 if exists: semanage.semanage_fcontext_free(old_fcontext)
715 (status, iface) = semanage.semanage_iface_create(sh)
720 status = semanage.semanage_iface_set_name(sh, iface, "test_iface")
723 if self.verbose: print "SEIface name set: ", semanage.semanage_iface_get_name(iface)
725 (status, con) = semanage.semanage_context_create(sh)
730 status = semanage.semanage_context_set_user(sh, con, "system_u")
733 if self.verbose: print "SEContext user: ", semanage.semanage_context_get_user(con)
735 status = semanage.semanage_context_set_role(sh, con, "object_r")
738 if self.verbose: print "SEContext role: ", semanage.semanage_context_get_role(con)
740 status = semanage.semanage_context_set_type(sh, con, "default_t")
743 if self.verbose: print "SEContext type: ", semanage.semanage_context_get_type(con)
745 status = semanage.semanage_context_set_mls(sh, con, "s0:c0.c255")
748 if self.verbose: print "SEContext mls: ", semanage.semanage_context_get_mls(con)
750 status = semanage.semanage_iface_set_ifcon(sh, iface, con)
755 status = semanage.semanage_iface_set_msgcon(sh, iface, con)
760 (status,key) = semanage.semanage_iface_key_extract(sh,iface)
765 (status,exists) = semanage.semanage_iface_exists_local(sh,key)
771 (status, old_iface) = semanage.semanage_iface_query_local(sh, key)
777 status = semanage.semanage_begin_transaction(sh)
779 raise Error("Could not begin semanage transaction")
781 status = semanage.semanage_iface_modify_local(sh,key,iface)
785 status = semanage.semanage_commit(sh)
790 status = semanage.semanage_begin_transaction(sh)
792 raise Error("Could not begin semanage transaction")
796 status = semanage.semanage_iface_del_local(sh, key)
802 status = semanage.semanage_iface_modify_local(sh, key, old_iface)
807 status = semanage.semanage_commit(sh)
812 semanage.semanage_context_free(con)
813 semanage.semanage_iface_key_free(key)
814 semanage.semanage_iface_free(iface)
815 if exists: semanage.semanage_iface_free(old_iface)
820 (status, pbool) = semanage.semanage_bool_create(sh)
825 status = semanage.semanage_bool_set_name(sh, pbool, "allow_execmem")
828 if self.verbose: print "SEBool name set: ", semanage.semanage_bool_get_name(pbool)
830 semanage.semanage_bool_set_value(pbool, 0)
831 if self.verbose: print "SEbool value set: ", semanage.semanage_bool_get_value(pbool)
833 (status,key) = semanage.semanage_bool_key_extract(sh, pbool)
838 (status,exists) = semanage.semanage_bool_exists_local(sh,key)
844 (status, old_bool) = semanage.semanage_bool_query_local(sh, key)
850 status = semanage.semanage_begin_transaction(sh)
852 raise Error("Could not start semanage transaction")
854 status = semanage.semanage_bool_modify_local(sh, key, pbool)
859 status = semanage.semanage_commit(sh)
864 status = semanage.semanage_begin_transaction(sh)
866 raise Error("Could not start semanage transaction")
870 status = semanage.semanage_bool_del_local(sh, key)
876 status = semanage.semanage_bool_modify_local(sh, key, old_bool)
881 status = semanage.semanage_commit(sh)
886 semanage.semanage_bool_key_free(key)
887 semanage.semanage_bool_free(pbool)
888 if exists: semanage.semanage_bool_free(old_bool)
893 (status, key) = semanage.semanage_bool_key_create(sh, "allow_execmem")
898 (status, old_bool) = semanage.semanage_bool_query_active(sh, key)
903 (status, abool) = semanage.semanage_bool_create(sh)
908 status = semanage.semanage_bool_set_name(sh, abool, "allow_execmem")
911 if self.verbose: print "SEBool name set: ", semanage.semanage_bool_get_name(abool)
913 semanage.semanage_bool_set_value(abool, 0)
914 if self.verbose: print "SEbool value set: ", semanage.semanage_bool_get_value(abool)
917 status = semanage.semanage_begin_transaction(sh)
919 raise Error("Could not start semanage transaction")
921 status = semanage.semanage_bool_set_active(sh,key,abool)
925 status = semanage.semanage_commit(sh)
931 status = semanage.semanage_begin_transaction(sh)
933 raise Error("Could not start semanage transaction")
935 status = semanage.semanage_bool_set_active(sh, key,old_bool)
940 status = semanage.semanage_commit(sh)
945 semanage.semanage_bool_key_free(key)
946 semanage.semanage_bool_free(abool)
947 semanage.semanage_bool_free(old_bool)
953 (status, node) = semanage.semanage_node_create(sh)
958 status = semanage.semanage_node_set_addr(sh, node, semanage.SEMANAGE_PROTO_IP6, "ffee:dddd::bbbb")
962 status = semanage.semanage_node_set_mask(sh, node, semanage.SEMANAGE_PROTO_IP6, "::ffff:ffff:abcd:0000")
966 semanage.semanage_node_set_proto(node, semanage.SEMANAGE_PROTO_IP6);
968 semanage.semanage_node_get_proto_str(semanage.SEMANAGE_PROTO_IP6)
970 (status, con) = semanage.semanage_context_create(sh)
975 status = semanage.semanage_context_set_user(sh, con, "system_u")
978 if self.verbose: print "SEContext user: ", semanage.semanage_context_get_user(con)
980 status = semanage.semanage_context_set_role(sh, con, "object_r")
983 if self.verbose: print "SEContext role: ", semanage.semanage_context_get_role(con)
985 status = semanage.semanage_context_set_type(sh, con, "lo_node_t")
988 if self.verbose: print "SEContext type: ", semanage.semanage_context_get_type(con)
990 status = semanage.semanage_context_set_mls(sh, con, "s0:c0.c255")
993 if self.verbose: print "SEContext mls: ", semanage.semanage_context_get_mls(con)
995 status = semanage.semanage_node_set_con(sh, node, con)
1000 (status,key) = semanage.semanage_node_key_extract(sh, node)
1005 (status,exists) = semanage.semanage_node_exists_local(sh,key)
1011 (status, old_node) = semanage.semanage_node_query_local(sh, key)
1017 status = semanage.semanage_begin_transaction(sh)
1019 raise Error("Could not start semanage transaction")
1021 status = semanage.semanage_node_modify_local(sh,key, node)
1025 status = semanage.semanage_commit(sh)
1030 status = semanage.semanage_begin_transaction(sh)
1032 raise Error("Could not start semanage transaction")
1036 status = semanage.semanage_node_del_local(sh, key)
1042 status = semanage.semanage_node_modify_local(sh, key, old_node)
1047 status = semanage.semanage_commit(sh)
1052 semanage.semanage_context_free(con)
1053 semanage.semanage_node_key_free(key)
1054 semanage.semanage_node_free(node)
1055 if exists: semanage.semanage_node_free(old_node)
1113 sh=semanage.semanage_handle_create()
1115 if (semanage.semanage_is_managed(sh) != 1):
1118 status = semanage.semanage_connect(sh)
1120 raise Error("Could not establish semanage connection")
1124 status = semanage.semanage_disconnect(sh)
1128 semanage.semanage_handle_destroy(sh)