403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.217.39
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/sepolicy/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/sepolicy/__pycache__/gui.cpython-39.pyc
a

͌�i#�@s ddlZe�dd�ddlmZddlmZddlmZddlmZddlZddl	Z	ddl
Z
ddl
mZmZm
Z
ddlZ	ddlZ	ddlZddlZddlZddlZd	ZzFddlZiZejd
kr�ded<ejefd
die�ddi��ZejZWnJzddlZeejd<Wn&e�y.ddlZe ejd<Yn0Yn0iZ!e	j"D]Z#e#e!e	j"e#<�q@ed�ed�gZ$ed�ed�gZ%dd�Z&ddl'Z(ed�ed�fZ)ed�ed�fZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8d Z9d!Z:d"Z;d#Z<gd$�Z=ed%�Z>Gd&d'�d'�Z?e@d(k�re?�ZAdS))�N�Gtkz3.0)r)�Gdk)�GLib)�SELinuxDBus)�DISABLED�
PERMISSIVE�	ENFORCINGzselinux-python)�T�unicodeZ	localedirz/usr/share/localeZfallback�_ZNoZYesZDisableZEnablecCs<|dur|durdS|dur dS|dur,dS||k||kS)Nr�����)�a�brr�0/usr/lib/python3.9/site-packages/sepolicy/gui.py�cmpGsrzAdvanced >>zAdvanced <<zAdvanced Search >>zAdvanced Search <<r
�r	������	)	�boolean�fcontext�fcontext-equiv�port�login�user�module�node�	interfacez�<small>
To change from Disabled to Enforcing mode
- Change the system mode from Disabled to Permissive
- Reboot, so that the system can relabel
- Once the system is working as planned
  * Change the system mode to Enforcing</small>
c@s�eZdZ�d%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUdV�Z,dWdX�Z-dYdZ�Z.d[d\�Z/d]d^�Z0d_d`�Z1dadb�Z2dcdd�Z3dedf�Z4dgdh�Z5didj�Z6dkdl�Z7dmdn�Z8dodp�Z9dqdr�Z:dsdt�Z;dudv�Z<dwdx�Z=dydz�Z>d{d|�Z?d}d~�Z@dd��ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Za�d&d�dÄZbd�dńZcd�dDŽZdd�dɄZed�d˄Zfd�d̈́Zgd�dτZhd�dфZid�dӄZjd�dՄZkd�dׄZld�dلZmd�dۄZnd�d݄Zod�d߄Zpd�d�Zqd�d�Zrd�d�Zsd�d�Ztd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d	�Z��d
�d�Z��d�d
�Z��d�d�Z��d�d�Z��d�d�Z��d'�d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d �Z��d!�d"�Z��d#�d$�Z�dS((�
SELinuxGuiNFcCCsd|_d|_t|_t�|_z|j��}Wn8tjjy`}zt	|�|�
�WYd}~n
d}~00|��||_d|_
t��}tjjdd�d|_|jd}|�|�|�d�|_|�d�|_|�d	�|_|�d
�|_d|_|�d�|_|�d
�|_t�tjj �|_!t�tjj"�|_#t$�%�d|_&d|_'d|_(d|_)d|_*d|_+d|_,g|_-g|_.i|_/|�d�|_0|�d�|_1|�d�|_2d|_3|�d�|_4|�d�|_5|j5�6|j7�|�d�|_8|�d�|_9|�d�|_:d|_;|�d�|_<|�d�|_=|�d�|_>|�d�|_?|�d�|_@|�d�|_A|�d�|_B|�d�|_C|�d�|_D|jD�EdtjFjG�|�d �|_H|jH�6|j7�|�d!�|_I|�d"�|_J|�d#�|_K|�d$�|_L|�d%�|_M|�d&�|_N|jN�EdtjFjG�|�d'�|_O|jO�6|j7�|�d(�|_P|�d)�|_Q|�d*�|_R|�d+�|_S|�d,�|_T|�d-�|_U|�d.�|_V|�d/�|_W|�d0�|_X|�d1�|_Y|�d2�|_Z|�d3�|_[|�d4�|_\|�d5�|_]|�d6�|_^|�d7�|__|�d8�|_`|j`�EdtjFjG�|�d9�|_a|�d:�|_b|jb�6|j7�|�d;�|_c|�d<�|_d|�d=�|_e|�d>�|_f|�d?�|_g|�d@�|_h|�dA�|_i|�dB�|_j|�dC�|_k|�dD�|_l|�dE�|_m|�dF�|_n|�dG�|_o|�dH�|_p|�dI�|_q|�dJ�|_r|�dK�|_s|�dL�|_tg|_u|�v�dMk�r�|jk�wd�|jm�wd�|jt�wd�|�dN�|_x|�dO�|_y|�dP�|_z|�{�|�dQ�|_||�dR�|_}|�dS�|_~|�dT�|_|�dU�|_�|�dV�|_�|�dW�|_�|�dX�|_�|�dY�|_�|�dZ�|_�|�d[�|_�|�d\�|_�|�d]�|_�|�d^�|_�|�d_�|_�|�d`�|_�|�da�|_�|�db�|_�|�dc�|_�|�dd�|_�|�de�|_�|�df�|_�|�dg�|_�|�dh�|_�|�di�|_�|�dj�|_�|�dk�|_�|�dl�|_�|�dm�|_�|�dn�|_�|�do�|_�|�dp�|_�|�dq�|_�|�dr�|_�|�ds�|_�|�dt�|_�|�du�|_�|�dv�|_�|�dw�|_�|�dx�|_�|�dy�|_�|�dz�|_�|�d{�|_�|�d|�|_�|�d}�|_�|�d~�|_�|j���d�|�d�|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|j��6|j7�|�d��|_�|j����|_�|�d��|_�|j��EdtjFjG�|�d��|_�|j����|_�|�d��|_�|�d��|_�|j��EdtjFjG�|�d��|_�|j��6|j7�|�d��|_�|j����|_�|�d��|_�|�d��|_�|jà6|j7�|�d��|_�|j����|_�|�d��|_�|jƠEdtjFjG�|�d��|_�|jĠ��|_�|�d��|_�|jǠ��|_�|�d��|_�|�d��|_�|jʠEdtjFjG�|�d��|_�|jˠ6|j7�|�d��|_�|j̠��|_�|�d��|_�|�d��|_�|jϠEdtjFjG�|�d��|_�|jР6|j7�|�d��|_�|jѠ��|_�|�d��|_�|�d��|_�|jԠEdMtjFjG�|�d��|_�|jՠ6|j7�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|j�|_�|j٠��|_�|�d��|_�|�d��|_�|jݠEdtjFjG�|�d��|_�|jޠ6|j7�|�d��|_�|jߠ��|_�|�d��|_�|jᠸ�|_�|�d��|_�|�d��|_�|j�EdMtjFjG�|�d��|_�|j�6|j7�|�d��|_�|j核�|_�|�d��|_�|�d��|_�|j�EdtjFjG�|�d��|_�|j�6|j7�|�d��|_�|j核�|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|j��d�|j��d�|j��|j�d�|j�|j�|j�dtj��|�d��|_�|�d��|_�|�d��|_�|�d��|_�|�d��|_�|j���d��|_�|�d��|_�|�d��|�_|�d��|�_|�d��|�_|�d��|�_|�j��d�|�j|j��|�dá|�_|�j��d�|�j|jc�|�dġ|�_|�j��d�|�j|jY�|�dš|�_|�j��d�|�j|jJ�|�dơ|�_	|�j	��d�|�j|j��|�dǡ|�_
|�d�|_|�dȡ|�_|�dɡ|�_|�dʡ|�_
|�dˡ}|�j
��d�|�j|j��g|�_|�j��d�|�j|jԡd|�_d}|�rd�d�g|_-|�r&||j-v�r&|j-��|�n�t���|_-|j-�j�t�jd΍|�rl||j-v�rl|���tdσ|�|�
�|����t|j-�}	�t���}
|j-D]�}|��||��t�t|�j��t|	��|�_|j���|�j�|j��� |�j�|��!�|
��"|g�D]6}�t��#|�}|�r|��||�|j.��|��q|�jd7�_�q�|��$�|j��%|j�|j:��%|j8�|�j&|�j'|�j(|�j)|�j*|�j+|�j,|�j-|�j.|�j/|�j0|�j1|�j2|�j3|�j4|�j5|�j6|�j7|�j8|�j9|�j:|�j;|�j<|�j=|�j>|�j?|�j@|�jA|�jB|�jC|�jD|�jE|�j1|�jF|�jG|�jH|�jI|�jJ|�jJ|�jK|�jL|�jM|�jN|�jO|�jP|�jQ|�jR|�jS|�jT|�jU|�jV|�jH|�jW|�jX|�jY|�jZ|�j[|�j\|�j\|�j\|�j]|�j^|�j_|j7|�j`|�jadМB}
|��b|�|��c|
�|j����td��ed�|�jf�|��f�d|�_g|�j��$�|�j��$�|�jh�tik�r�|��j�nV|j�r�|j��k|j�|j��l|j�|��m�|��`�n|��n�|j��ot�|��p�d|_t��q�dS)�NFT�)Z
plat_specificz
/sepolicy/zsepolicy.glade�outer_notebookZSELinux_windowZMain_selection_menu�main_advanced_labelr�applications_selection_buttonZ
Revert_buttonr
Zadd_path_dialog�error_check_window�error_check_label�advanced_search_windowZadvanced_filterZ
advanced_sort�advanced_filter_entry�advanced_search_treeviewZLogin_label�login_seuser_comboboxZlogin_seuser_liststore�login_name_entry�login_mls_label�login_mls_entryZLogin_button�login_treeview�login_liststore�login_filter�login_popup_window�login_delete_liststore�login_delete_window�user_popup_windowZUser_button�user_liststore�user_filter�
user_treeview�user_roles_comboboxZuser_roles_liststoreZ
User_label�user_name_entry�user_mls_label�user_mls_level_entry�user_mls_entryZselinux_user_combobox�user_delete_liststore�user_delete_window�file_equiv_label�file_equiv_source_entry�file_equiv_dest_entryZfile_equiv_button�file_equiv_treeview�file_equiv_liststore�file_equiv_popup_windowZfile_equiv_filter�file_equiv_delete_liststore�file_equiv_delete_window�app_system_buttonZ
System_buttonZLockdown_buttonZSystems_boxZRelabel_buttonZRelabel_button_no�advanced_system�outer_notebook_frameZsystem_policy_type_label�select_button_browse�cancel_button_browse�moreTypes_window_filesZmore_types_file_liststoreZmoreTypes_treeview_files�system_policy_type_liststore�system_policy_type_comboboxrZEnforcing_button_defaultZPermissive_button_defaultZDisabled_button_defaultZenable_unconfinedZdisable_unconfinedZenable_permissiveZdisable_permissiveZ
enable_ptraceZdisable_ptrace�help_windowZ
help_textv�	info_text�
help_image�forward_button�back_button�
update_window�update_treeviewZUpdate_treestore�apply_buttonZ
Update_buttonZ
Add_buttonZ
Delete_button�files_path_entry�network_ports_entry�files_popup_window�network_popup_windowZ
Network_labelZfiles_labelZmake_path_recursiveZfiles_type_combo_storeZfiles_class_combo_store�files_type_combobox�files_class_combobox�files_mls_label�files_mls_entryZAdvanced_text_filesZcancel_delete_filesZ
tcp_buttonZ
udp_buttonZnetwork_type_combo_storeZnetwork_type_combobox�network_mls_label�network_mls_entryZAdvanced_text_networkZcancel_network_deleteZShow_mislabeled_files�mislabeled_files_label�
warning_filesZ
Modify_button�fix_label_window�fixlabel_label�fix_label_cancel�files_delete_window�files_delete_treeview�files_delete_liststore�network_delete_window�network_delete_treeview�network_delete_liststore�progress_barZExecutable_files_treeview�executable_files_filterZExecutable_files_tabZexecutable_files_treestoreZfiles_buttonZWritable_files_treeviewZwritable_files_treestore�writable_files_filterZWritable_files_tabZApplication_files_treeview�application_files_filterZApplication_files_tabZapplication_files_treestoreZnetwork_buttonZoutbound_treeview�network_out_liststore�network_out_filter�network_out_tabZinbound_treeview�network_in_liststore�network_in_filter�network_in_tabZBoolean_treeview�boolean_liststore�boolean_filterZbooleans_more_detail_windowZbooleans_more_detail_treeviewZbooleans_more_detail_liststoreZBooleans_button�transitions_into_treeview�transitions_into_liststore�transitions_into_filterZTransitions_into_tabZTransitions_button�transitions_from_treeview�transitions_from_treestore�transitions_from_filterZTransitions_from_tabZfile_transitions_treeviewZfile_transitions_liststoreZfile_transitions_filterZfile_transitionsZcombobox_org�application_liststore�completion_entry�entrycompletion_objZShow_modified_only_toggleZEnforcing_labelZEnforcing_buttonZPermissive_button�
status_barzSELinux status�filter_entry�
filter_box�add_modify_delete_boxZactivateZfiles_toggle_deleteZtoggledZfile_equiv_toggle_delete1Zuser_toggle_deleteZlogin_toggle_deleteZnetwork_toggle_deleteZ
toggle_updateZfiles_inner_notebookZnetwork_inner_notebookZtransitions_inner_notebook�loading_guiZhttpd_tZabrt_t)�keyz%s is not a valid domain)BZon_combo_button_clickedZon_disable_ptrace_toggledZ!on_SELinux_window_configure_eventZ%on_entrycompletion_obj_match_selectedZon_filter_changedZ"on_save_changes_file_equiv_clickedZon_save_changes_login_clickedZon_save_changes_user_clickedZon_save_changes_files_clickedZon_save_changes_network_clickedZ)on_Advanced_text_files_button_press_eventZitem_in_tree_selectedZ2on_Application_file_types_treeview_configure_event�on_save_delete_clickedZ)on_moreTypes_treeview_files_row_activatedZon_retry_button_files_clickedZon_make_path_recursive_toggledZ&on_files_path_entry_button_press_eventZon_files_path_entry_changedZon_select_type_files_clickedZon_choose_fileZon_Enforcing_button_toggledZon_confirmation_closeZon_column_clickedZ
on_tab_switchZon_file_equiv_button_clickedzon_app/system_button_clickedzon_app/users_button_clicked�on_show_advanced_search_windowZ on_Show_mislabeled_files_toggledZon_Browse_button_files_clickedZon_cancel_popup_clickedZon_treeview_cursor_changedZ on_login_seuser_combobox_changedZon_user_roles_combobox_changedZon_cancel_button_browse_clickedZon_apply_button_clickedZon_Revert_button_clickedZon_Update_button_clickedZ on_advanced_filter_entry_changedZ)on_advanced_search_treeview_row_activatedZ!on_Select_advanced_search_clickedZ!on_info_button_button_press_eventZon_back_button_clickedZon_forward_button_clickedZ#on_Boolean_treeview_columns_changedZon_completion_entry_changedZon_Add_button_clickedZon_Delete_button_clickedZon_Modify_button_clickedZon_Show_modified_only_toggledZon_cancel_button_config_clickedZon_Import_button_clickedZon_Export_button_clickedZon_enable_unconfined_toggledZon_enable_permissive_toggledZ&on_system_policy_type_combobox_changedZ#on_Enforcing_button_default_toggledZ$on_Permissive_button_default_toggledZ"on_Disabled_button_default_toggledZon_Relabel_button_toggled_cbZ%on_advanced_system_button_press_eventZon_files_type_combobox_changedZon_filter_row_changedZon_button_toggledZ
gtk_main_quitr(r�finish_initZ
advanced_init�
START_PAGE�opager�dbus�
customized�
exceptions�
DBusException�print�quit�init_cur�application�
filter_txtrZBuilder�	distutilsZ	sysconfigZget_python_lib�	code_pathZ
add_from_fileZ
get_objectr%�window�main_selection_windowr&�popupr'�
revert_buttonrZCursorZ
CursorTypeZWATCH�busy_cursorZLEFT_PTR�ready_cursor�selinux�selinux_getpolicytype�initialtype�
current_popup�
import_export�clear_entry�	files_add�network_add�mislabeled_filesZall_domainsZinstalled_listZpreviously_modified�file_dialogr(r)Z
invalid_entryr*�advanced_search_filterZset_visible_func�filter_the_dataZadvanced_search_sortr+r,Zadvanced_search�login_labelr-�login_seuser_combolistr.r/r0�login_radio_buttonr1r2Zset_sort_column_idZSortTypeZ	ASCENDINGr3r4r5r6r7�user_radio_buttonr8r9r:r;�user_roles_combolist�
user_labelr<r=r>r?Z
user_comboboxr@rArBrCrD�file_equiv_radio_buttonrErFrGZfile_equiv_treefilterrHrIrJ�system_radio_button�lockdown_radio_buttonZsystems_box�relabel_button�relabel_button_norKrL�system_policy_labelrMrNrO�more_types_files_liststore�moreTypes_treeviewrPrQZpolicy_list�populate_system_policy�set_visible�enforcing_button_default�permissive_button_default�disabled_button_default�initialize_system_default_mode�enable_unconfined_button�disable_unconfined_button�enable_permissive_button�disable_permissive_buttonZenable_ptrace_button�disable_ptrace_buttonrR�	help_textrSrTrUrVrWrX�update_treestorerY�
update_button�
add_button�
delete_buttonrZr[r\r]�popup_network_label�popup_files_label�recursive_path_toggle�files_type_combolist�files_class_combolistr^r_r`ra�advanced_text_filesZfiles_cancel_button�network_tcp_button�network_udp_button�network_port_type_combolist�network_port_type_comboboxrbrc�advanced_text_networkZnetwork_cancel_button�show_mislabeled_files_onlyrdre�
modify_button�
set_sensitiverfrgrhrirjrkrlrmrnro�executable_files_treeviewrp�executable_files_tabZget_tooltip_textZ executable_files_tab_tooltip_txt�executable_files_liststore�files_radio_buttonZfiles_button_tooltip_txt�writable_files_treeview�writable_files_liststorerq�writable_files_tabZwritable_files_tab_tooltip_txt�application_files_treeviewrr�application_files_tabZ!application_files_tab_tooltip_txt�application_files_liststore�network_radio_buttonZnetwork_button_tooltip_txt�network_out_treeviewrsrtruZnetwork_out_tab_tooltip_txt�network_in_treeviewrvrwrxZnetwork_in_tab_tooltip_txt�boolean_treeviewryrz�boolean_more_detail_windowZboolean_more_detail_treeview�!boolean_more_detail_tree_data_set�boolean_radio_button�
active_buttonZboolean_button_tooltip_txtr{r|r}�transitions_into_tabZ transitions_into_tab_tooltip_txt�transitions_radio_buttonZtransitions_button_tooltip_txtr~rr��transitions_from_tabZ transitions_from_tab_tooltip_txt�transitions_file_treeview�transitions_file_liststoreZtransitions_file_filter�transitions_file_tabZ transitions_file_tab_tooltip_txtZ
combobox_menur�r�r�Zset_minimum_key_lengthZset_text_columnZset_match_func�
match_funcZset_completionZset_icon_from_stockZ
STOCK_FIND�show_modified_only�current_status_label�current_status_enforcing�current_status_permissiver�Zget_context_id�
context_idr�r�r��cellZdel_cell_files�connect�on_toggle_updateZdel_cell_files_equivZ
del_cell_userZdel_cell_loginZdel_cell_networkZupdate_cell�inner_notebook_files�inner_notebook_network�inner_notebook_transitionsZall_entries�	on_toggleZloading�append�sepolicyZget_all_domains�sort�str�lower�errorr�show�lenZget_init_entrypoints_str�
combo_box_add�floatZ
percentageZset_fractionZset_pulse_step�	idle_func�getZfind_entrypoint_path�hideZ	set_model�open_combo_menu�on_disable_ptrace�hide_combo_menu�set_application_label�get_filter_data�update_to_file_equiv�update_to_login�update_to_user�update_to_files�update_to_network�reveal_advanced�cursor_changed�resize_wrapr��populate_type_combo�invalid_entry_retry�recursive_path�highlight_entry_text�autofill_add_files_entry�select_type_more�on_browse_select�set_enforce�confirmation_close�column_clicked�
clear_filters�show_file_equiv_page�system_interface�users_interfacer��show_mislabeled_files�browse_for_files�close_popup�login_seuser_combobox_change�user_roles_combobox_change�close_config_window�apply_changes_button_press�update_or_revert_changes�get_advanced_filter_data�advanced_item_selected�advanced_item_button_push�on_help_button�on_help_back_clicked�on_help_forward_clicked�resize_columns�application_selected�add_button_clicked�delete_button_clicked�modify_button_clicked�on_show_modified_only�import_config_show�export_config_show�unconfined_toggle�permissive_toggle�change_default_policy�change_default_mode�relabel_on_reboot�reveal_advanced_system�show_more_types�
tab_change�closewindow�previously_modified_initializeZconnect_signalsrZtimeout_add_seconds�selinux_status�lockdown_inited�statusr�show_system_page�	set_label�set_text�show_applications_page�clearbuttons�set_current_page�reinit�main)�self�app�testr��eZbuilderZ
glade_filer��path�lengthZentrypoint_dict�domainZ
entrypoint�dicrrr�__init__vs"





"

�I



zSELinuxGui.__init__cCsi|_tD]}i|j|<q
dS�N)�cur_dict�keys)rP�krrrr�tszSELinuxGui.init_curcCsHd}|jD]8}|j|D](}||kr8|j||=dS|d7}qq
dS�Nrr
)rZ)rP�ctr�ir\�jrrr�
remove_curys
zSELinuxGui.remove_curcCszt��|_Wnty&t|_Yn0|jtkr�|j�d�|j�d�|j�d�|j	�d�|j
�|jt
d��|j�t�n|�|j�tj�d�r�|j�d�n|j�d�t��d}t��d}|tkr�|j	�d�|tkr�|j�d�|tk�r|j�d�dS)NFzSystem Status: Disabled�
/.autorelabelTr
)r�Zsecurity_getenforcerG�OSErrorrr�r�r�r�r�r��pushr�rrSrI�
DISABLED_TEXT�set_enforce_text�osrT�existsr��
set_activer�r��selinux_getenforcemoderrr�r�)rPZ
policytype�moderrrrE�s0

zSELinuxGui.selinux_statuscCs�|jr
dS|��d|_|j�t�d��i|_|j���	d�D]:}|�	�}t
|�dkrZq@|dt
|�dkd�|j|d<q@|j�|jdd	�|j�|jd
d	�|�
�dS)NTZdeny_ptrace�
r	r)Zpriority�Disabledr
�
unconfinedrm�permissivedomains)rF�
wait_mouser�rir�Zsecurity_get_boolean_activeZmodule_dictr�Z
semodule_list�splitrr�r��ready_mouse)rP�m�modrrr�
lockdown_init�s"zSELinuxGui.lockdown_initcGs�|��}|sdS|jtkr4|��dkr4|�|j|�|jtkrp|j�|d�}|��dkrp|rp|�	|j�|d��|jt
kr�|j�|d�}|r�|j��|j
�|�dS)NZmore_detail_colr	Zrestorecon_colrr
)�get_selected_iterr��
BOOLEANS_PAGEZget_name�display_more_detailr��
FILES_PAGE�	liststore�	get_value�fix_mislabeled�TRANSITIONS_PAGEr�Zclickedr�rJ)rP�treeviewZtreepathZtreecol�args�iterZvisibleZ	bool_namerrrr �s



zSELinuxGui.column_clickedcCst��rt��qdSrY)rZevents_pendingZmain_iteration�rPrrrr�szSELinuxGui.idle_funccCs<z$|j�|d��|�dkr WdSWdSty6Yn0dS)NrrTF)r�r{�find�AttributeError)rPZ
completionZ
key_stringr�Z	func_datarrrr��szSELinuxGui.match_funccCs�|j�|jdk�|j�|jt|j�dk�z0td|j|j|jfd�}|��}|�	�Wnt
ytd}Yn0|j��}|�
|d|ji�|j�|�|j�d|j|j|jf�|�|j�dS)Nrr
z
%shelp/%s.txt�rr$�APPz
%shelp/%s.png)rVr��	help_pagerUr�	help_list�openr��read�close�IOErrorr�Z
get_bufferrJr�Z
set_bufferrTZ
set_from_file�
show_popuprR)rP�fd�bufr�rrr�help_show_page�s

zSELinuxGui.help_show_pagecGs|jd8_|��dS�Nr
�r�r��rPrrrrr1�szSELinuxGui.on_help_back_clickedcGs|jd7_|��dSr�r�r�rrrr2�sz"SELinuxGui.on_help_forward_clickedcGs^d|_g|_|jtkr.|j�td��dg|_|jtkrR|j�td��gd�|_|jtkr�|j	�
�}|tkr�|j�td��dg|_|tkr�|j�td��d	g|_|t
kr�|j�td
��dg|_|jtk�r|j�
�}|tkr�|j�td��d
g|_|tk�r|j�td��dg|_|jtk�r�|j�
�}|tk�rX|j�td��gd�|_|tk�rz|j�td��dg|_|tk�r�|j�td��dg|_|jtk�r�|j�td��gd�|_|jtk�r�|j�td��gd�|_|jtk�r|j�td��ddg|_|jtk�r2|j�td��dg|_|jtk�rV|j�td��d g|_|��S)!NrzHelp: Start Page�startzHelp: Booleans Page)ZbooleansZbooleans_toggledZ
booleans_moreZbooleans_more_showzHelp: Executable Files PageZ
files_execzHelp: Writable Files PageZfiles_writezHelp: Application Types PageZ	files_appz'Help: Outbound Network Connections PageZports_outboundz&Help: Inbound Network Connections PageZ
ports_inboundz&Help: Transition from application Page)Ztransition_fromZtransition_from_booleanZtransition_from_boolean_1Ztransition_from_boolean_2z&Help: Transition into application PageZ
transition_toz&Help: Transition application file PageZtransition_filezHelp: Systems Page)�systemZsystem_boot_modeZsystem_current_modeZ
system_exportZsystem_policy_typeZsystem_relabelzHelp: Lockdown Page)ZlockdownZlockdown_unconfinedZlockdown_permissiveZlockdown_ptracezHelp: Login PagerZ
login_defaultzHelp: SELinux User Page�userszHelp: File Equivalence PageZ
file_equiv)r�r�r�r�rR�	set_titlerrwryr��get_current_page�EXE_PAGE�
WRITABLE_PAGE�APP_PAGE�NETWORK_PAGEr��
OUTBOUND_PAGE�INBOUND_PAGEr}r��TRANSITIONS_FROM_PAGE�TRANSITIONS_TO_PAGE�TRANSITIONS_FILE_PAGE�SYSTEM_PAGE�
LOCKDOWN_PAGE�
LOGIN_PAGE�	USER_PAGE�FILE_EQUIV_PAGEr��rPr�ipagerrrr0�sl














zSELinuxGui.on_help_buttoncGsX|jdkrDd|_|j��}|j�|dd|dd�|j��n|j��d|_dS)Nrr
r�A)r�r�Zget_positionr�Zmoverr	)rPr�locationrrrr
*s


zSELinuxGui.open_combo_menucGs|j��d|_dS�Nr)r�r	r�r�rrrr4s
zSELinuxGui.hide_combo_menucGs
d|_dS�NT)r
r�rrrr
8sz SELinuxGui.set_application_labelcGst|�dSrY�r�r�rrrr;szSELinuxGui.resize_wrapcCsHt��d|_|jtkr |j|_|jtkr2|j|_|jtkrD|j	|_dSr�)
r�rj�enforce_moderr��enforce_buttonrr�rr�r�rrrr�>s


z)SELinuxGui.initialize_system_default_modecCsrttjt��dd��d}|��d}|D]B}|j��}|j�|d|�||j	krd|j
�|�||_|d7}q*|S)NT)�topdownr
r)
�nextrg�walkr�Zselinux_pathr�rPr��	set_valuer�rQri�typeHistory)rP�typesr^�itemr�rrrr�Gs


z!SELinuxGui.populate_system_policyc
Gs�|jdkrdSz�td|���D]v}zZ|�||�}|dusH|dusH|durLWq|�|j�dksp|���|j�dkrzWWdSWqttfy�Yq0qWnYn0dS)Nr$TrFr)r��range�
get_n_columnsr{r�rr��	TypeError)rP�listr�r�x�valrrrr�Ts
$zSELinuxGui.filter_the_datac
Cs�|��D]x}||D]j\}}d�|�|f}	|	|jdvrh|jd|	ddkrPq||jd|	dkrhq|�|d�|�||�qqdS)N�,r�action�-d�type�, )r[�joinrZ�network_initial_data_insert)
rPrQ�netd�protocol�	direction�modelr\�t�portsZpkeyrrr�
net_updategszSELinuxGui.net_updatecCs�|��t��}|j��|D]�}|j��}||drV|�|�}|�||d�}n|}||d}|j�|d|�|j�|d|�|j�|d||d�q|��dS)N�modify�equivrr
r)	rpr�Zget_file_equivrF�clearr��markupr�rr)rPZedict�fr��namer�rrr�file_equiv_initializers


z SELinuxGui.file_equiv_initializec	Cs�|��|j��t��D]�}|j��}|j�|dt|d��|d}d|vrZ|�d�|j�|dd�	|��|j�|d|�
dd	��|j�|d
|�
dd	��|j�|dd
�q|��dS)Nrr��rolesZobject_rr
r�r�levelr$r	r�rT)rpr8r�r��get_selinux_usersr�r�r�remover�rrr)rP�ur�r�rrr�user_initialize�s


zSELinuxGui.user_initializecCs�|��|j��t��D]Z}|j��}|j�|d|d�|j�|d|d�|j�|d|d�|j�|dd�q|��dS)	Nrr�r
�seuserr�mlsr	T)rpr2r�r�Zget_login_mappingsr�r�rr)rPr�r�rrr�login_initialize�s

zSELinuxGui.login_initializecCs|tjj|dddd�}|�||dt|j�tjj|dddd�}|�||dt|j�tjj|dddd�}|�||dt|j�dS)N�tcp�name_connectT�Zcheck_bools�	name_bind�udp)r��network�get_network_connectr�r�rsr�rv)rPrQr�rrr�network_initialize�szSELinuxGui.network_initializecCsD|��}|�|d|�|�|d|�|�|d|�|�|dd�dS)Nrr
rrT�r�r�)rPr�r�ZportTyper�r�rrrr��s
z&SELinuxGui.network_initial_data_insertcCs�d}|��}|D](}|d|kr0|�|�dS|d7}q|�|d�}|�|d�td�krp|�|�}|d}n|��}|�|d|�|�|�dS)Nrr
�More...)�	get_modelri�get_iterr{rZ
insert_beforer�r�)rP�comboboxr�r^rzr_�niterr�rrr�combo_set_active_text�s



z SELinuxGui.combo_set_active_textcCs2|��}|��}|dkrdS|�|�}|�|d�Sr�)r��
get_activer�r{)rPr�rz�indexr�rrr�combo_get_active_text�s
z SELinuxGui.combo_get_active_textcCs:|durdS|j��}|j�|d|�|j�|d|�dSr])r�r�r�)rPr��val1r�rrrr�s

zSELinuxGui.combo_box_addcGsN|j��}|��d}|dur"dS|j�|d�}|�|j|�|�|j�dS�Nr
r)	r��
get_selection�get_selectedr�r{r�r^rCrO)rPrrQr�rrrr�s
zSELinuxGui.select_type_morecGsx|j��}|��\}}|�|�}|j�|�}|j�|d�}|durFdS|j�d�|j	�
�|�|j�|j
�|�dS�Nr
r$)r,r�r��convert_iter_to_child_iterr�r�r{r+rJr*r	rr&r�)rPr�rowr�r�rQrrrr/�s


z$SELinuxGui.advanced_item_button_pushcGs`|j�|�}|j�|�}|j�|d�}|j�d�|j��|�	|j
�|j�|�|��dSr�)
r�r�r�r�r{r+rJr*r	rr&r�r4)rPr~rTrr�rQrrrr.�s
z!SELinuxGui.advanced_item_selectedcCs2|r.t|�dkr.|jD]}||dkrdSqdS�NrTF)rr�)rPrQ�itemsrrr�find_application�s

zSELinuxGui.find_applicationcGs�|j�d�|j�d�|j�d�|j�d�|j��}|�|�sHdS|�	�|j
�d�|j�d�|j
��|j��|j��|j��|j��|j��|j��|j��|j��z*|ddkr�t�|�}|s�WdS||_Wnty�Yn0|��|�|j���|��|� |�d|_!|�"|�|�#|�|�$|�|�%|�|�&|�|�'|�|�(|�|j)�*t+d�|�|j,�*t+d�|�|j-�*t+d�|�|j.�*t+d	�|�|j/�*t+d
�|�|j0�*t+d�|�|j1�*t+d�|�|j2�*t+d
�|�|j3�4t+d�|�|j5�4t+d�|�|j6�4t+d�|�|j3�*t+d�|�|j5�*t+d�|�|j6�*t+d�|�|j7�*t+d�|�||_|j8�4|j�|�9�dS)NFr$Tr�/z(File path used to enter the '%s' domain.z)Files to which the '%s' domain can write.z6Network Ports to which the '%s' is allowed to connect.z5Network Ports to which the '%s' is allowed to listen.z File Types defined for the '%s'.zODisplay boolean information that can be used to modify the policy for the '%s'.z;Display file type information that can be used by the '%s'.zADisplay network ports to which the '%s' can connect or listen to.z!Application Transitions Into '%s'z!Application Transitions From '%s'zFile Transitions From '%s'zVExecutables which will transition to '%s', when executing selected domains entrypoint.zQExecutables which will transition to a different domain, when '%s' executes them.z4Files by '%s' with transitions to a different label.zADisplay applications that can transition into or out of the '%s'.):r�r�rdrer�rJr��get_textr�rKr�r�r�r�r�rvrsryr|rr�r�r�r�Zget_init_transtyper��
IndexErrorrprDr�r�rN�boolean_initializer��executable_files_initializer��writable_files_initialize�transitions_into_initialize�transitions_from_initialize�application_files_initialize�transitions_files_initializer��set_tooltip_textrr�rurxr�r�r�r�r�rIr�r�r�r'rr)rPrrQrrrr4�sr




















zSELinuxGui.application_selectedcCs t��t��|_t��|_dSrY)r�rNZ
get_fcdict�fcdictZget_local_file_paths�local_file_pathsr�rrrrN7s
zSELinuxGui.reinitcCs�i|_|�d�D�]�}|��}t|�dkr,q|ddkr:q|d|jvrVi|j|d<|ddkr�d|ddki|jd|d	<|dd
kr�|d|dd
�|jd
|d	<|ddkr�d|di|jd|d	<|ddk�rd|d|dd�|jd|d	<|ddk�r2d|di|jd|d	|df<|ddk�rf|d|d|dd�|jd|d	<|ddk�r�|ddk�r�d|jv�r�i|jd<d|di|jd|d	<n"d|di|jd|d	|df<|ddkrd|ddki|jd|d	<qd|jv�rdSd|jfd |jffD]2\}}||jdv�r&|�|jd|d��q&tD]"}||jv�r^|j�|ii��q^dS)!Nrlrr
z-Dr�activerz-1rrr	r)r�r�r"r�r�s0)r�r��roler���r!r)�maskr�r�rz-err�r �enabledr�rnro)�	cust_dictrqrr�r�rir[�update)rPr�r_ZrecZsemodule�buttonrrrrD<sJ ""&
" z)SELinuxGui.previously_modified_initializecCs�t�|�|_|j��D]�}t|j|�dkr.q|j|d}|j|dD]`}||f|jdvr�|jd||fddkr|qJ||jd||fdkr�qJ|�|j|||�qJqdS)Nrr
rr�r�r�)r�Zget_entrypoints�entrypointsr[rrZ�files_initial_data_insertr�)rPr��exe�
file_classrTrrrr�fsz&SELinuxGui.executable_files_initializecCsBz(t�|d�d}t�|�d}||kWSty<YdS0dS)Nrr
F)r��matchpathcon�
getfileconrc)rPrT�con�currrr�
mislabeledts
zSELinuxGui.mislabeledcCs�|�|�sdSt�|d�d}t�|�d}d|_|�|dd�|�|dd�|�|dd�|�|d|�d�d�|�|d	|�d�d�dS)
Nrr
Tr	rr�:rr)rr�rrr�r�rq)rP�treerTr�r�rrrrr�set_mislabeled|s
zSELinuxGui.set_mislabeledcCs�t�|�|_|j��D]�}t|j|�dkrD|�|jd|td��q|j|d}|j|dD]`}||f|jdvr�|jd||fddkr�q`||jd||fdkr�q`|�|j|||�q`qdS)	Nrz	all filesr
rrr�r�r�)	r�Zget_writable_files�writable_filesr[rr
r�rrZ)rPr��writerrTrrrr��sz$SELinuxGui.writable_files_initializec	Cs�|�d�}|dur td�}d}nh||f|jv}t�|�D],}|�|�}|�|d|�|�||||�q8|r�|�|�}|�|�}|�|�}|�|d|�|�|d|�|�|d|�|�|d|�dS)NzMISSING FILE PATHFrr
rr)r�rrr�Z	find_filer�rr�)	rPrzrTZ
selinux_labelrr�r��pr�rrrr
�s"




z$SELinuxGui.files_initial_data_insertcCsd|S)Nz	<b>%s</b>r�rPr�rrrr��szSELinuxGui.markupc	Cs |rt�ddt�dd|��SdS)Nz</b>$r$z^<b>)�re�subrrrr�unmarkup�szSELinuxGui.unmarkupcCs�t�|�|_|j��D]�}t|j|�dkr.q|j|d}|j|dD]p}tj||jd�}||f|jdvr�|jd||fddkr�qJ||jd||fdkr�qJ|�|j	|||�qJqdS)Nrr
)r�rr�r�r�)
r�Zget_file_types�
file_typesr[rZget_descriptionr�rZr
r�)rPr�rQrrT�descrrrr��sz'SELinuxGui.application_files_initializecCs,d}|jD]}t|j|�dkr
dSq
dSr�)rZr)rPr_r\rrr�modified�s

zSELinuxGui.modifiedcCsZt�|�D]J}|D]@\}}||jdvr:|jd|d}t�|�}|�|||�qq
dS)Nrr)r�Z	get_boolsrZ�boolean_desc�boolean_initial_data_insert)rPr��blistrrr rrrr��s
zSELinuxGui.boolean_initializecCsR|j��}|j�|d|�|j�|d|�|j�|d|�|j�|dtd��dS)Nrr
rr	r�)ryr�r�r)rPr�r rr�rrrr#�s

z&SELinuxGui.boolean_initial_data_insertcCs^t�|�D]N}d}d}d}d|vr*|d}d|vr:|d}d|vrJ|d}|�|||�q
dS)Nr�target�source)r�Zget_transitions_into�$transitions_into_initial_data_insert)rPr�r�r�
executabler&rrrr��sz&SELinuxGui.transitions_into_initializecCsd|j��}|dkr0|j�|dt|dd�n|j�|dd�|j�|d|�|j�|d|�dS)Nrr
�Defaultr)r|r�r�r)rPrr(r&r�rrrr'�s
z/SELinuxGui.transitions_into_initial_data_insertc	Cs�t�|�D]�}d}d}d}d|vr*|d}d|vr:|d}d|vrJ|d}|�|||�z&|j|dD]}|�|||�qhWq
ty�Yq
0q
dS)Nrr%�	transtypeZregex)r�Zget_transitions�$transitions_from_initial_data_insertr�KeyError)rPr�r�rr(r*Zexecutable_typerrrr��s z&SELinuxGui.transitions_from_initializecCs�|j�d�}|dkr6|j�|dd�|j�|dd�n�|j�|�}|j�|dt|dd�d}|ddr�|j�|dtd�|�n|j�|dtd	�|�|j�|d|dd�|j�|dd
�|j�|d|�|j�|d|�dS)Nrr)rFr
)z<span foreground="blue"><u>z</u></span>rz:To disable this transition, go to the %sBoolean section%s.z9To enable this transition, go to the %sBoolean section%s.Tr	)rr�r�rr)rPrr(r*r�r�r�rrrr+sz/SELinuxGui.transitions_from_initial_data_insertcCsFt�|�D]6}d|vr |d}nd}|�|d|d|d|�q
dS)N�filenamer%�classr*)r�Zget_file_transitions�%transitions_files_initial_data_insert)rPr�r_r-rrrr�s

z'SELinuxGui.transitions_files_initializecCsZ|j��}|j�|d|�|j�|d|�|j�|d|�|dkrFd}|j�|d|�dS)Nrr
r�*r	)r�r�r�)rPrT�tclass�destr�r�rrrr/#s
z0SELinuxGui.transitions_files_initial_data_insertcGs4|��d|_d|_d|_d|_|j�d�|j��|j	�
d�|j�
d�|j�
d�|j
�
d�|j��r�|j�t�|j|_|j	�
d�|j���r�|�|j�|j	�
d�|j�
|j�|j�
|j�|j
�
|j�|j�t�|d|jk�r|d}n
|j��}|tk�r*|j|_td�}n6|tk�rF|j|_td�}n|tk�r`|j |_td�}|j!�"td�||j#d	��|j$�"td
�||j#d	��|j�"td�||j#d	��|j%���r�|j�&�|j	�
d�|j�t'�|d|j(k�r�|d}n
|j(��}|t)k�r |j*|_td�}|t+k�r:|j,|_td
�}|j!�"td�|j#|d��|j$�"td�|j#|d��|j�"td�|j#|d��|j-���r|j�t.�|d|j/k�r�|d}n
|j/��}|t0k�r�|j1|_|t2k�r�|j3|_|t4k�r|j5|_|j6���r"|j�t7�|j8��|j9���rL|�:�|j�t;�|j8��|j<���r�|j�t=�|j�&�|j	�
d�|j>|_|j!�"td��|j$�"td��|j�"td��|j?���r|j�t@�|j�&�|j	�
d�|jA|_|j!�"td��|j$�"td��|j�"td��|jB���r~|j�tC�|j�&�|j	�
d�|jD|_|j!�"td��|j$�"td��|j�"td��|j��|_E|j�r$|j8�&�|j�F�|_|j�F�|_|j�F�|_tGd|j�H��D]D}|j�I|�}|�r�|�J�d}tK|tLjM��r�|j�N||jOd��q�|j�P��Q�|j�d�dS)NFTrrr(�writabler�z4Add new %(TYPE)s file path for '%(DOMAIN)s' domains.)ZTYPEZDOMAINz3Delete %(TYPE)s file paths for '%(DOMAIN)s' domain.z�Modify %(TYPE)s file path for '%(DOMAIN)s' domain. Only bolded items in the list can be selected, this indicates they were modified previously.r�zlisten for inbound connectionszMAdd new port definition to which the '%(APP)s' domain is allowed to %(PERM)s.)r�ZPERMzVDelete modified port definitions to which the '%(APP)s' domain is allowed to %(PERM)s.zMModify port definitions to which the '%(APP)s' domain is allowed to %(PERM)s.z%Add new SELinux User/Role definition.z.Delete modified SELinux User/Role definitions.z7Modify selected modified SELinux User/Role definitions.z!Add new Login Mapping definition.z*Delete modified Login Mapping definitions.z3Modify selected modified Login Mapping definitions.z$Add new File Equivalence definition.z-Delete modified File Equivalence definitions.z�Modify selected modified File Equivalence definitions. Only bolded items in the list can be selected, this indicates they were modified previously.)Rr!r~�treesort�
treefilterrzr�r�r�r	r�r�r�rdrer�r�r%rMrwr�r�r�r�ryr�r�r�r�rr�r�r�r�r�rr�r�r�rr�r�r�r�r�r�r�r}r�r�r~r�r{r�r�r�r�r�r�rur�r�r�r:r�r�r1r�r�rEr�r�r�r�Z
get_columnZ	get_cells�
isinstancerZCellRendererTextZ
set_sort_func�	stripsortr�Zunselect_all)rPrr��categoryr��colr�rrrrB,s�
























zSELinuxGui.tab_changec	Cs:|��\}}|�|�||��}|�|�||��}t||�SrY)Zget_sort_column_idrr{r)	rPr�Zrow1Zrow2Z	user_dataZsort_columnrr�Zval2rrrr7�szSELinuxGui.stripsortcCs�|j�|�}|j�|�}|j��|j�td�|j�	|d��t
�|j|j�	|d��}|D]$}|�
|d|d|d|d�q\|�|j�dS)NzBoolean %s Allow Rulesrr&r%r.Zpermlist)rzr�r�r�r�r�r�rryr{r�Zget_boolean_rulesr��display_more_detail_initr�)rP�windowsrT�itr$rrrrrx�s
"zSELinuxGui.display_more_detailcCs0|j��}|j�|dd|||d�|�f�dS)Nrzallow %s %s:%s { %s };� )r�r�r�r�)rPr&r%Z
class_typeZ
permissionr�rrrr:�s
z#SELinuxGui.display_more_detail_initcGs�d|_|jtkrJ|j�td�|j�|j�td�|j�|�	|�dS|jt
kr�|j�td�|j�|j�td�|j�|�
|�|j��}|tkr�|j�d�n|j�d�d|_|jtkr�|j�td	��|j�td
��|�|�d|_|jtk�r2|j�td��|j�td��|�|�d|_|jtk�r�|j�d
�|j�d
�|j�td��|j�td��d|_|� |j�|�!�dS)NFzGAdd Network Port for %s.  Ports will be created when update is applied.zAdd Network Port for %szMAdd File Labeling for %s. File labels will be created when update is applied.�Add File Labeling for %szex: /usr/sbin/Foobarzex: /var/lib/FoobarTzGAdd Login Mapping. User Mapping will be created when Update is applied.zAdd Login MappingzQAdd SELinux User Role. SELinux user roles will be created when update is applied.zAdd SELinux Usersr$zMAdd File Equivalency Mapping. Mapping will be created when update is applied.zAdd SELinux File Equivalency)"r�r�r�r�rJrr�r]r��init_network_dialogryr�r\�init_files_dialogr�r�r�rZr�r�r�r4�login_init_dialogr�r�r7�user_init_dialogr�rCrDrBrGr��new_updatesr�rrrr5�sB







zSELinuxGui.add_button_clickedcCs||_|��dSrY)r�r)rPr�rrrr��szSELinuxGui.show_popupcGs|j��|j�d�dSr�)r�r	r�r�r�rrrr'�s
zSELinuxGui.close_popupcGs�d}|jr&|��}|s&|j�d�dSd|_|jtkr@|�|�|jtk�rZ|j	�
td�|j�|j
�td�|j�d|_|�|�d|_d}d}|j��}|tk�r |j�|�}||_|j�|d�}|j�
|�|j�|d�}|dkr�|�|j|�|j�|d�}|dk�r |�|j|�|tk�r�|j�|�}||_|j�|d�}|j�
|�|j�|d�}	|	dk�r||�|j|	�|j�|d�}|dk�r�|�|j|�|tk�rZ|j �|�}||_|j!�|d�}|j�
|�z&|j!�|d�}
|
�"d	�d�"d
�}
Wnt#�yYn0|j!�|d�}	|	dk�r:|�|j|	�|
d}|dk�rZ|�|j|�|jt$k�r�|�%|�|j&�
|j'�|d��|j(�
|j'�|d��|j)�
|j'�|d��|�|j*|j'�|d��|j+�
td��|j,�td
��|�-|j,�|jt.k�r||�/|�|j0�
|j1�|d��|j2�
|j1�|d��|�|j3|j1�|d��|j4�
td��|j5�td��|�-|j5�|jt6k�r�|j7�
|�8|j9�|d���|j:�
|�8|j9�|d���|j;�
td��|j<�td��d|_=|�-|j<�dS)NFTzPModify File Labeling for %s. File labels will be created when update is applied.r>�Modifyr
rrz<b>z</b>r	zUModify SELinux User Role. SELinux user roles will be modified when update is applied.zModify SELinux UserszLModify Login Mapping. Login Mapping will be modified when Update is applied.zModify Login MappingzPModify File Equivalency Mapping. Mapping will be created when update is applied.zModify SELinux File Equivalency)>r~rvr�r�r�r�r��modify_button_network_clickedryr�rJrr�r\r��delete_old_itemr@r�r�r�rpr�r�r{rZr�r^r_r�rqr�r�rrr�rqr�r�rBr<r8r>r?r;r�r7r�r�rAr.r2r0r-r�r4r�rCrrFrDrBrGr�)rPrr��	operationr�r�rT�ftyper1r�Zget_typerrrr7�s�













z SELinuxGui.modify_button_clickedcGsB|j�|�}|j�|d�}|�|j|�|�|j�|j��dSr�)	r�r�r{r�r^r�r\rOr	)rPrZlocrr�rHrrrrIs
zSELinuxGui.populate_type_combocCs.|dkrdS|�d�rd}nd}|�|�dS)NZ	_script_tZ_tr)�endswithrq)rPrVZ
split_charrrr�strip_domainPs
zSELinuxGui.strip_domaincCs|D]}|�|�rdSqdS)NTF)�
startswith)rPr��exclude_listrSrrr�exclude_typeYs
zSELinuxGui.exclude_typecGs�g}|j�d�|�|j�|j��}|j��|j��|�	|j
�}|jD]B}|d�|�rL|d|j
krL|d�d�sL|�
|�	|d��qL|j���z�tjD]$}|j�
�}|j�|dtj|�q�|tk�rL|jdk�rL|j��D]D}|�|��r|j�
�}|j�|d|�|j�
�}|j�|d|�q�|j�d�|j�d��n|tk�r�|jdk�r�|j��D]`}	|	�|��r�|�|	|��s�|	|jv�r�|j�
�}|j�|d|	�|j�
�}|j�|d|	��ql|j�d�n�|tk�rh|jdk�rht��D]`}
|
�|��r�|
�|��r>|�|
|��s>|j�
�}|j�|d|
�|j�
�}|j�|d|
��q�|j�d�Wnt�y�td�Yn0|j�d�|j� d�|j�
�}|j�|dt!d��dS)	NTrZ	httpd_sysrFrrr�)"r_r�r�r\r�r�r�r�r�rJr�r�rKr�r�r��
file_type_strr�r�rr[rir�rrMrr�Zget_all_file_typesr�r�r^rarJr)rPrrLr�Zcompare�d�filesr�rrrQrrrr@_s`



*




&




zSELinuxGui.init_files_dialogcGs�|��}|s|j�d�dS|j�td�|j�|j�td�|j�d|_	|�
|�d}d}d|_|��}|j�
|d�}|j�|�|j�
|d�}|dkr�|j�d�n|d	kr�|j�d�|j�
|d
�}|dkr�|�|j|�||_	dS)NFzJModify Network Port for %s.  Ports will be created when update is applied.zModify Network Port for %srDr
Trr�r�r)rvr�r�r�rJrr�r]r�rFr?r�rzr{r[r�rir�r�r�)rPrr�rGr�rr�r�rrrrE�s.
z(SELinuxGui.modify_button_network_clickedcGs�|�|j�|j��}|j��|j�d��z,|tkrPt	j
j|jdddd�}n8|t
kr�t	j
j|jdddd�}|t	j
j|jdddd�7}g}|��D]<}||D].\}}||dd	gvr�|�d
�r�q�|�|�q�q�|��|�|j�}|ddkr�|dd�}|d
}d}	d}
|D]8}|�|��r&|	}
|j��}|j�|d|�|	d7}	�q|j�|
�Wnt�ynYn0|j�d�|j�d�dS)Nr$r�r�Tr�r�r�Zport_tZunreserved_port_tZ_typerrOrrr
r)r�r]r�r�r�r�r[rJr�r�r�r�r�r�r[rIr�r�rJrKr�r�rir�r�rc)rPrr�r�Z
port_typesr\r�r�Zshort_domainr^�foundr�rrrr?�sF



zSELinuxGui.init_network_dialogcGsJ|�|�}|j��dkrFt��D]$}||dkr |j�|�dd��q dS�Nr$r�r�)r�r0r�r�r�rJr)rP�comborr�r�rrrr(�s

z'SELinuxGui.login_seuser_combobox_changecGsJ|�|�}|j��dkrFt��D]$}||dkr |j�|�dd��q dSrR)r�r?r�r��
get_all_rolesrJr)rPrSrZseroler�rrrr)�s

z%SELinuxGui.user_roles_combobox_changecCsNd}|jsdS|j��}|s dS|��\}}|rJ|�|�}|rJ|j�|�}|SrY)r~r�r�r�r5)rPr�r�r4rrrrv�s

zSELinuxGui.get_selected_itercGsb|j�d�|��}|dkr,|j�d�dS|j|rD|j|dsHdS|j�|j|d�dS)NFr)r�r�rvrz)rPrr�rrrr�szSELinuxGui.cursor_changedcGsj|�|j�|j��t��}|��|D]"}|j��}|j�|dt	|��q*|j
�d�|j�d�dS�Nrr$)
r�r4r�r�r�Z
get_all_usersr�r�r�rr.rJr0)rPrr�r�r�rrrrA�s

zSELinuxGui.login_init_dialogcGsj|�|j�|j��t��}|��|D]"}|j��}|j�|dt	|��q*|j
�d�|j�d�dSrU)
r�r7r�r�r�rTr�r�r�rr<rJr?)rPrr�r�r�rrrrB
s

zSELinuxGui.user_init_dialogc
Csj|jrfd|��}|��z|j�|�Wn2tjjy\}z|�|�WYd}~n
d}~00|��dS)Nzboolean -m -%d deny_ptrace)	r�r�rpr��semanager�r�rrr)rP�checkbutton�
update_bufferrSrrrrs zSELinuxGui.on_disable_ptracecs�|j����fdd�}g}|jtkrd|��s8|�|j�S|jD]$}|d|jdvr>|�||��q>|jt	kr�|j
��}|��s�|tkr�|�
|j�S|tkr�|�|j�S|tkr�|�|j�S|jD](}|d|df|jdvr�|�|�q�|jtk�rF|���s|�|j�S|jD]0}|d|df|jdv�r|�||���q|jtk�r�|��d	k�sh|��S|jD](}|d|jd
v�rn|�||���qn|jtk�r�|���s�|��S|jD](}|d|jdv�r�|�||���q�|jtk�r8|��d	k�s|��S|jD](}|d|jdv�r|�||���q|j��|D]6}|j��}td��D]}|j�||||��q^�qFdS)
Ncs&g}td��D]}|�||�q|Sr�)r�r�)r��lr_�rUrr�dup_row"sz1SELinuxGui.on_show_modified_only.<locals>.dup_rowrrrrr
rTrrr)rzr�r�rwr�r�r�r	r�ryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)rPrWr[Zappend_listr�r�r�r_rrZrr8sd













z SELinuxGui.on_show_modified_onlyc	Cs8|�d�}|�|d|�|�|d|�|�|d|�dS�Nrr
rr�)	rPrrQr�rGrTZfclassrHr�rrr�init_modified_files_liststorecs
z(SELinuxGui.init_modified_files_liststorecGstd�dS)Nzrestore to default clicked...r�r�rrr�restore_to_defaultiszSELinuxGui.restore_to_defaultcGs(|�|j�|j�d�|j�d�dSr�)rCr(r\r�r]r�rrrrlszSELinuxGui.invalid_entry_retrycCsVt|�dks|ddkrR|j��|j�d�|j�d�|j�td�|�dSdS)Nrr�FzAThe entry '%s' is not a valid path.  Paths must begin with a '/'.T)	rr(rr\r�r]r)rJr)rPZ
insert_txtrrr�error_check_filesqs
zSELinuxGui.error_check_filescCslz t|�}|dks|dkrt�WnFtyf|j��|j�d�|j�d�|j�t	d��YdS0dS)Nr
iFz'Port number must be between 1 and 65536T)
�int�
ValueErrorr(rr\r�r]r)rJr)rPrZpnumrrr�error_check_networkzs
zSELinuxGui.error_check_networkcGs2|jr.|�|j�td�kr.|j��|j��dS)Nr�)r�r�r^rr\r	rOrr�rrrrA�s
zSELinuxGui.show_more_typesc	Gs|��|�|j�}|j��}|j��}|jr�|��}|j�	|d�}|j�	|d�}|j�	|d�}|j
�|d|�|j
�|d|�|j
�|d|�d|||||d�|jd|<n"|j
�
d�}d||d�|jd|<|j
�|d|�|j
�|d|�|j
�|d|�|��dS)	Nrr
r�-m)r�r�r��oldrange�	oldseuser�oldnamer�-a)r�r�r�)r'r�r-r0r�r.r�rvr2r{rzr�rZr�rC)	rPrr��	mls_ranger�r�rfrerdrrrr�s&

zSELinuxGui.update_to_loginc	Gsj|��|�|j�}|j��}|j��}|j��}|jr�|��}|j	�
|d�}|j	�
|d�}|j	�
|d�}	|j	�
|d�}
|j�|d|�|j�|d|�|j�|d|	�|j�|d|
�d||||
|	||d�|j
d|<nD|j�d�}|s�|�r
d|||d	�|j
d|<nd|d
�|j
d|<|j�|d|�|j�|d|�|j�|d|�|j�|d|�|��dS)Nrr
r	rrc)r�r�r�rrd�oldlevel�oldrolesrfrrg)r�r�r�r)r�r)r'r�r;r>r�r?r<r�rvr8r{rzr�rZr�rC)rPrr�r�rhr�r�rfrjrirdrrrr�s2


"
zSELinuxGui.update_to_usercGs�|��|j��}|j��}|jrl|��}|�|j�|d��}|�|j�|d��}d|||d�|j	d|<n |j�
d�}d|d�|j	d|<|j�|d|�|��|j�|d|�|��dS)Nrr
rc)r��src�oldsrc�olddestrrg�r�rk)r'rDr�rCr�rvrrzr�rZr�r�)rPrr2rkr�rmrlrrrr�s

zSELinuxGui.update_to_file_equivc
Gs0|��d|_|j��}|�|�r&dS|�|j�}|j��}|�|j�}|j	r�|�
�}|�|j�
|d��}|�|j�|d��}|j�
|d�}	d||||	d�|jd||f<n$|j�d�}d|d	�|jd||f<|j�|d|�|��|j�|d|�|��|j�|d|�|��d
|_|j�d
�|��dS)NTrr
rrc)r�r��oldtype�oldpathZoldclassrrg�r�r�F)r'r�rZr�r_r�r^rar_r�rv�unmarkrzr{r�rZr�r�r�rirC)
rPrrT�setyper�r1r�rp�	oldsetypeZ	oldtclassrrrr�s,


 zSELinuxGui.update_to_filesc
Gs2d|_|j��}|�|�rdS|j��r.d}nd}|�|j�}|j��}|j	r�|�
�}|�|j�
|d��}|�|j�
|d��}|�|j�|d��}	d|||	||d�|jd	||f<n&|j�d�}d
||d�|jd	||f<|j�|d|�|j�|d|�|j�|d|�d|_|j��|j�d�|��dS)
NTr�r�rr
rrc)r�r�r�ro�oldprotocol�oldportsrrg)r�r�r�F)r�r[r�rbr�r�r�r�rcr�rvrrrzr{r�rZr�r]r	r�r�rC)
rPrr�r�rsr�r�rvrurtrrrr�s0



"
zSELinuxGui.update_to_networkc	Gs�d}|j�d�|jtkr�|j��|jd}|D]R\}}|||fd}|j��}|j�|d|�|j�|d|�|j�|d|�q2|�	|j
�dS|jtk�r$|j��|jd}|D]X\}	}
||	|
fd}|j��}|j�|d|	�|j�|d|�|j�|dt
j|
�q�|�	|j�dS|jtk�r�|j��|jd	}|D]|}||d
}
||�dd�}||�d
d�}|j��}|j�|d|�|j�|d|
�|j�|d|�|j�|d|��qH|�	|j�dS|jtk�rh|j��|jd}|D]\}||d}||�dd�}|j��}|j�|d|�|j�|d|�|j�|d|��q�|�	|j�dS|jtk�r�|j��|jD]N}|d�r�|j��}|j�|d|�|d��|j�|d|�|d���q�|�	|j�dSdS)NZAddFrr�r
rr	rrrr�r$r�rrr�r)r�r�r�r�rnr�r	r�r�r�rlryrkr�rNrir�r@rrAr�r5r6r�rHrFrrI)rPrrGZ	port_dictr�r�rsr�Z
fcontext_dictrTr1Z	user_dictrr�r�r�Z
login_dictrr�r�rrrr6sv
















z SELinuxGui.delete_button_clickedcGsd|��|jtkrJ|jD]0}|drd|dd�|jd|d|df<q|jtkr�|jD]4}|drZd|dd�|jd|dt|df<qZ|jtkr�|j	D].}|dr�d|d|d	d
�|jd|d<q�|jt
k�r|jD]4}|dr�d|d|d|dd�|jd
|d<q�|jtk�rX|j
D],}|d�r*d|dd�|jd|d<�q*|��dS)Nrr�r	rqrr
rrr)r�rr�r)r�rr�r�rrnr)r'r�r�rnrZryrk�reverse_file_type_strr�r@r�r5r�rHrC�rPr�deleterrrr�Ps,

&

*

$
*

 z!SELinuxGui.on_save_delete_clickedcGs(|jD]}t|d|d|d�qdSr\)rkr�rxrrr�!on_save_delete_file_equiv_clickedhs
z,SELinuxGui.on_save_delete_file_equiv_clickedcCs||d||d<dSr�r)rPr�rTr�rrrr�lszSELinuxGui.on_toggle_updatecCsTd}|D]F}|d|dkrF|d|dkrF|�|�}|�|�dS|d7}qdS)Nrrr
)r�r�)rPrzr�r^r�r�rrr�ipage_deleteos 

zSELinuxGui.ipage_deletecCs�|sdS|j�|�}|j�|�}|�|d�}|�|d|�|d��|�|d�}||jdvrl|jd|=nd|i|jd|<|��dS)Nrrrr)rzr�r�r{r�rZrC)rPr�rTr�r�r�rrrrr�xszSELinuxGui.on_togglecGs|��|_|j��dSrY)r�r�r��refilter)rP�entryrrrrr-�s
z#SELinuxGui.get_advanced_filter_datacGs|��|_|j��dSrY)r�r�r5r|)rPr;rrrrr�s
zSELinuxGui.get_filter_datacGs$d|_|j��|jdD]�}|jd|d}|j�d�}|j�|dd�|j�|dt�|��|j�|dt|jd|d�|j�|dd�|j�|�}|j�|dt	d	�|�|j�|dd
�q|jdD�]~\}}|jd||fd}|jd||fd}|j�d�}|j�|dd�|j�|d|�|j�|dd�|d
k�rj|j�|dt	d�|j
�|dk�r�|j�|dt	d�|j
�|dk�r�|j�|dt	d�|j
�|j�|�}|j�|dd
�|j�|dt	d�|�|j�|�}|j�|dd
�|j�|dt	d�tj|�|j�|�}|j�|dd
�|j�|dt	d�|�q�|jdD�]z\}	}
|jd|	|
fd}|j�d�}|j�|dd�|j�|d|�|j�|dd�|d
k�r�|j�|dt	d�|j
�|dk�r|j�|dt	d�|j
�|dk�r(|j�|dt	d�|j
�|j�|�}|j�|dt	d�|	�|j�|dd
�|j�|�}|j�|dt	d�|
�|j�|dd
�|jd|	|
fd}|j�|�}|j�|dd
�|j�|dt	d�|��q`|jdD�]r}|jd|d}|j�d�}|j�|dd�|j�|d|�|j�|dd�|d
k�rZ|j�|dt	d��|dk�rx|j�|dt	d��|dk�r�|j�|dt	d��|j�|�}|j�|dt	d �|�|j�|dd
�|j�|�}|j�|dd
�|jd|d!}|j�|dt	d"�|�|jd|�d#d$�}
|j�|�}|j�|dd
�|j�|dt	d%�|
��q�|jd&D�]r}|jd&|d}|j�d�}|j�|dd�|j�|d|�|j�|dd�|d
k�r�|j�|dt	d'��|dk�r�|j�|dt	d(��|dk�r|j�|dt	d)��|j�|�}|j�|dd
�|j�|dt	d*�|�|j�|�}|j�|dd
�|jd&|d+}|j�|dt	d,�|�|jd&|�d#d$�}
|j�|�}|j�|dd
�|j�|dt	d%�|
��qh|jd-D�](}|jd-|d}|j�d�}|j�|dd�|j�|d|�|j�|dd�|d
k�rZ|j�|dt	d.��|dk�rx|j�|dt	d/��|dk�r�|j�|dt	d0��|j�|�}|j�|dd
�|j�|dt	d1�|�|j�|�}|j�|dd
�|jd-|d2}|j�|dt	d3�|��q�|�
|j�dS)4NTrr�rr
rrr	zSELinux name: %sFrr�rgzAdd file labeling for %sr�zDelete file labeling for %srczModify file labeling for %sz
File path: %szFile class: %szSELinux file type: %srzAdd ports for %szDelete ports for %szModify ports for %szNetwork ports: %szNetwork protocol: %srzAdd userzDelete userzModify userzSELinux User : %srz	Roles: %sr�r$zMLS/MCS Range: %srzAdd login mappingzDelete login mappingzModify login mappingzLogin Name : %sr�zSELinux User: %srzAdd file equiv labeling.zDelete file equiv labeling.zModify file equiv labeling.zFile path : %srkzEquivalence: %s)r
r�r�rZr�r�r�r"r�rr�rNrr�rW)rPrZboolsrGr�r�rTr1rsrr�rr�r�rr�rkrrr�
update_gui�s�
"














zSELinuxGui.update_guicCsL|j��r|j|_|j��r$|j|_|j��r6|j|_|j��rH|j|_dSrY)r�r�r�r�r�r�r�rrr�set_active_application_button	s



z(SELinuxGui.set_active_application_buttonTcCs~|j��|j�d�|j�d�|j�d�|j�d�|j�d�|j�d�|j	�d�|j
�d�|rz|j�d�dS)NFr$)
r�r	r�r�r�r�r�r�r�r�r�r�rJ)rPr�rrrrL!	s
zSELinuxGui.clearbuttonscCsP|��|j�d�|j�d�|j�td��|j�d�|��|�	�dS)NTZSystem)
rLr�r�r�r'rIrrirBrr�rrrrH.	szSELinuxGui.show_system_pagecGsX|��|��|j�d�|j�td��|��|��|j	�
d�|j�
d�dS)NTzFile Equivalence)rLr�r�rir'rIrrBrr�r�r�r�rrrr"7	szSELinuxGui.show_file_equiv_pagecCsx|��|j�d�|j�d�|j�td��|j�d�|��|�	�|�
�|��|j�
d�|j�
d�dS)NTZUsers)rLr�r�r�r'rIrrirBr�r�rr�r�r�r�rrr�show_users_pageA	szSELinuxGui.show_users_pagecCsZ|�d�|j�d�|j�d�|j�d�|j�d�|j�d�|��|��dS�NFT)	rLr�r�r�r�r�rirBrr�rrrrKN	s
z!SELinuxGui.show_applications_pagecGs|��dSrY)rHr�rrrr#X	szSELinuxGui.system_interfacecGs|��dSrY)r�r�rrrr$[	szSELinuxGui.users_interfacec	Gs�g}d}|j��}|��dkr�|jD]T}|j�|�}|j�|�}|j�|�}|dkr$|j�|d�dkrp|�	|�|d7}q$|D]}|j�
|�q~nT|jdkr�|j��|t
kr�|�|j�n*|tkr�|�|j�n|tkr�|�|j�dS)NrTrFr
)r�r�r�rzr4r�r�r5r{r�r�r�r�r�r�r�r�r�r�)	rPrWrZiterlistr^r�r�r�Zitersrrrr%^	s,





z SELinuxGui.show_mislabeled_filescCspt�|�d�d�d}t�|d�d�d�d}|jtd�|||d�dd�tjjkrl|j	�
|�|��dS)	Nr
rrrzbRun restorecon on %(PATH)s to change its type from %(CUR_CONTEXT)s to the default %(DEF_CONTEXT)s?)�PATHZCUR_CONTEXTZDEF_CONTEXTzrestorecon dialog)�title)r�rrqr�verifyrr�ResponseTypeZYESr�Z
restoreconr4)rPrTrrrrrr|w	s
&zSELinuxGui.fix_mislabeledcGs$|j�|���|j�|���dSrY)r�r�r!r�r�rrrrC~	szSELinuxGui.new_updatescGsF|��|��td�k|_|jr2|j�td��n|j�td��dS)NZUpdatezUpdate ChangeszRevert Changes)r~�	get_labelrr
rWr��rPrrrrrr,�	s
z#SELinuxGui.update_or_revert_changescGsb|��|jr|��n|��d|_|�|j���d|_|��|�	�|�
�|j��dSr�)
r'r
�update_the_system�revert_datar�rDr�r�r!r4rCr�r�r�rrrr+�	s
z%SELinuxGui.apply_changes_button_pressc
Gsn|��|��}|��z|j�|�Wn0tjjyX}zt|�WYd}~n
d}~00|��|�	�dSrY)
r'�
format_updaterpr�rVr�r�r�rrr�)rPrrXrSrrrr��	szSELinuxGui.update_the_systemcCs2dddddd�}|D]}||kr||SqdS)Nrr
r)zExecutable FileszWritable FileszApplication File TypeZInboundZOutboundZBooleansr)rP�lookupZipage_values�valuerrr�ipage_value_lookup�	s
zSELinuxGui.ipage_value_lookupcCs4|�d�d}|�d�d}|dkr,||_n|SdS)Nz: r
rzSELinux name)rqZbool_revert)rPZ	attributeZbool_idrrr�get_attributes_update�	s
z SELinuxGui.get_attributes_updatec		Csf|��d}|jD�]L}|dvrN|j|D]"}|d|j||d|f7}q*|dv�r|j|D]�}|j||ddkr�|d|7}qbd	|j||vr�|d
|j||d|j||d|j||d	|f7}qb|d|j||d|j||d|f7}qb|d
v�r�|j|D]�}|j||ddk�rJ|d|7}n�d|j||v�r�d	|j||v�r�|d|j||d|j||d|j||d	|j||d|f7}n.|d|j||d|j||d|f7}�q |dv�rd|j|D]Z}|j||ddk�r2|d|7}n.|d|j||d|j||d|f7}�q|dv�r�|j|D]j}|j||ddk�r�|d|7}n>|d|j||d|j||d|j||d|f7}�qx|dvr|j|D]h\}}|j|||fddk�r,|d||f7}n0|d|j||d|j||d||f7}�q�q|S)Nr$rzboolean -m -%d %s
rrr�r�zlogin -d %s
r�zlogin %s -s %s -r %s %s
r�zlogin %s -s %s %s
rzuser -d %s
r�zuser %s -L %s -r %s -R %s %s
rzuser %s -R %s %s
rzfcontext -d %s
zfcontext %s -e %s %s
rkrzfcontext %s -t %s -f %s %s
r�r.rzport -d -p %s %s
zport %s -t %s -p %s %s
)r�rZ)	rPrXr\rrYr�r�rr�rrrr��	sH 
@0
(P2
2
B6zSELinuxGui.format_updatecCsXd}g}d}|jD]$}|j|ds.|�|�|d7}q|��|D]}|�|�qDdS)Nrr$r
)r�r��reversera)rPr^Zremove_listrXr�rrrr��	s


zSELinuxGui.revert_datacGsN|��tdk}|r$|�td�n|�td�|j�|�|j�|�dSr])r��ADVANCED_LABELrJr�r�rQ�rP�labelrZadvancedrrrr@�	sz!SELinuxGui.reveal_advanced_systemcGsf|��tdk}|r$|�td�n|�td�|j�|�|j�|�|j�|�|j�|�dSr])r�r�rJr`r�rarbrcr�rrrr�	szSELinuxGui.reveal_advancedcGsF|��tdkr(|�td�|��n|�td�|�|j�dSr�)r��ADVANCED_SEARCH_LABELrJr'r�r*)rPr�rrrrr�
s

z)SELinuxGui.on_show_advanced_search_windowcCsJ|r&|j�|jtd��|j�d�n |j�|jtd��|j�d�dS)NzSystem Status: EnforcingTzSystem Status: Permissive)r�rdr�rr�rir�)rPr�rrrrf	
s
zSELinuxGui.set_enforce_textcCs,|js
dS|j�|���|�|���dSrY)r�r�Z
setenforcer�rf�rPrrrrr
szSELinuxGui.set_enforcecGs`|j��}|dkrdSd|_|j��|j�|�|jdkrH|�|�n|jdkr\|�|�dS)NF�Import�Export)	r��get_filenamer�r	rZrJr��
import_config�
export_config)rPrr-rrrr
s



zSELinuxGui.on_browse_selectcGsX|j��}|j��r0|�d�sT|j�|d�n$|�d�rT|�d�d}|j�|�dS)N�(/.*)?r)rZr�r�r�rIrJrq)rPrrTrrrr$
s



zSELinuxGui.recursive_pathcGs"|��}|jr|�d�d|_dS�Nr$F)r�r�rJ)rPZ	entry_objrZtxtrrrr-
s
zSELinuxGui.highlight_entry_textcCsv|��}|dkrdS|�d�r*|j�d�tjD]@}|�|�r0|jD]*}|d�tj|�rD|�|j	|d�qDq0dS)Nr$r�Tr)
r�rIr�rir�ZDEFAULT_DIRSrKr�r�r^)rPr}�textrOr�rrrr3
s



z#SELinuxGui.autofill_add_files_entrycGs&|j�d�|_|j��}|j��}dSr�)r�Zget_colZboolean_column_1Z	get_widthZget_cell_renderers)rPr�widthZrendererrrrr3?
s
zSELinuxGui.resize_columnscGs|j��dSrY)r�rr�rrrr&D
szSELinuxGui.browse_for_filescGs|j��dSrY)r�r	r�rrrr*G
szSELinuxGui.close_config_windowcGsl|j|j��krdS|�td��tjjkr<|j�|j�dS|j	�
|�|j��|j	�d�|j��|_dS)Nz�Changing the policy type will cause a relabel of the entire file system on the next boot. Relabeling takes a long time depending on the size of the file system.  Do you wish to continue?T)
r�rQr�r�rrr��NOrir�r=r��relabel_on_bootr�rrrr=J
sz SELinuxGui.change_default_policycCs4|js
dS|�|�|��r0|j�|�����dSrY)r��enabled_changedr�r�r>r�rr�rrrr>V
s

zSELinuxGui.change_default_modecGs0|j�tjj�|j�d�|j��d|_dS)NzImport Configurationr�)r��
set_actionr�FileChooserActionZOPENr�rr�r�rrrr9]
s
zSELinuxGui.import_config_showcGs0|j�tjj�|j�d�|j��d|_dS)NzExport Configurationr�)r�r�rr�ZSAVEr�rr�r�rrrr:d
s
zSELinuxGui.export_config_showcCs:|��|j��}t|d�}|�|�|��|��dS)N�w)rpr�r�r�rr�rr)rPr-r�r�rrrr�j
s


zSELinuxGui.export_configcCsRt|d�}|��}|��|��z|j�|�WntyDYn0|��dS)Nr�)r�r�r�rpr�rVrcrr)rPr-r�r�rrrr�r
s
zSELinuxGui.import_configcCsV|||f|vri||||f<||f||||fvrR|||	|
d�||||f||f<dS)N)r�r��changed�oldr)rPrWrQr�rGr�qrHr�r�r�rrr�init_dictionary}
szSELinuxGui.init_dictionarycCs*|�d�d}|dkrdS|dkr&dSdS)N�-r
�0F�1T)rq)rPrrrr�translate_bool�
s
zSELinuxGui.translate_boolc
Gsv|j��}tj�d�}|r"|r"dS|s.|s.dSz|j�|�Wn2tjjyp}z|�	|�WYd}~n
d}~00dS)Nrb)
r�r�rgrTrhr�r�r�r�r)rPrrrhrSrrrr?�
s
zSELinuxGui.relabel_on_rebootcGs
|��|j�d�|j�d�|j|krV|�|j�|�|j	�t
d�krV|j	�d�|j|kr�|jrt|�|j�n|j
r�|�|j�|j��s�|j��r�|j�d�|j�d�|j�d�|j�d�|j�d�|j�d�|j��tdk�r|j�td�dS)NFTr�rr
)r	r�rir�r�rOr�r\r�r^rr(r�r�r]r`Zget_visiblerbr�r�rar�rcr&r�r�rJ)rPr�rrrrrC�
s,

zSELinuxGui.closewindowcCs|j���|j�|��dSrY)r��
get_window�
set_cursorr�rr�rrrrp�
szSELinuxGui.wait_mousecCs|j���|j�|��dSrY)r�r�r�r�rr�rrrrr�
szSELinuxGui.ready_mouser$cCsNt�ddtjjtjj|�}|�|�|�tjj	�|�
�|��}|��|Sr�)
r�
MessageDialog�MessageType�INFO�ButtonsTypeZYES_NOr��set_position�WindowPosition�MOUSE�show_all�run�destroy)rP�messager��dlgZrcrrrr��
s�
zSELinuxGui.verifycCsDt�ddtjjtjj|�}|�tjj�|�	�|�
�|��dSr�)rr�r�ZERRORr�ZCLOSEr�r�r�r�r�r�)rPr�r�rrrr�
s�zSELinuxGui.errorcCs�|��sdS|��}|dkrH|jtkrH|�td��tjjkrH|j	�
d�|dkr||jtkr||�td��tjjkr||j	�
d�||_	dS)Nrma�Changing to SELinux disabled requires a reboot.  It is not recommended.  If you later decide to turn SELinux back on, the system will be required to relabel.  If you just want to see if SELinux is causing a problem on your system, you can go to permissive mode which will only log errors and not enforce SELinux policy.  Permissive mode does not require a reboot.  Do you wish to continue?Tz�Changing to SELinux enabled will cause a relabel of the entire file system on the next boot. Relabeling takes a long time depending on the size of the file system.  Do you wish to continue?)r�r�r�rr�rrr�r�r�ri)rPZradior�rrrr��
szSELinuxGui.enabled_changedcGs|j�d�|j�d�dSr�)r�rJr�rir�rrrr!�
szSELinuxGui.clear_filterscGsB|js
dS|��|j��r*|j�d�n|j�d�|��dS)Nzmodule -e unconfinedzmodule -d unconfined)r�rpr�r�r�rVrrr�rrrr;�
s
zSELinuxGui.unconfined_togglecGsB|js
dS|��|j��r*|j�d�n|j�d�|��dS)Nzmodule -e permissivedomainszmodule -d permissivedomains)r�rpr�r�r�rVrrr�rrrr<�
s
zSELinuxGui.permissive_togglecGs:t|j�dkr.|�td�td��tjjkr.dS|��dS)Nra0You are attempting to close the application without applying your changes.
    *    To apply changes you have made during this session, click No and click Update.
    *    To leave the application without applying your changes, click Yes.  All changes that you have made during this session will be lost.zLoss of data DialogT)rr�r�rrr�r�r�r�rrrr�
szSELinuxGui.confirmation_closecGst�d�dSr�)�sys�exitr�rrrr��
szSELinuxGui.quit)NF)T)r$)��__name__�
__module__�__qualname__rXr�rarErur rr�r�r1r2r0r
rr
rr�r�r�r�r�r�r�r�r�r�r�rrr/r.r�r4rNrDr�rrr�r
r�rr�r!r�r#r�r'r�r+r�r/rBr7rxr:r5r�r'r7rrJrMr@rEr?r(r)rvrrArBrr8r]r^rr_rbrArrrrrr6r�rzr�r{r�r-rr~rrLrHr"r�rKr#r$r%r|rCr,r+r�r�r�r�r�r@rr�rfrrrrrr3r&r*r=r>r9r:r�r�r�r�r?rCrprrr�rr�r!r;r<rr�rrrrr#ts*	@
	
	

B*

	})Y	5+

D	
A	

	


/		
	


r#�__main__)BZgiZrequire_versionZ
gi.repositoryrrrZsepolicy.sedbusrr�r�r�rrrZsepolicy.networkZsepolicy.manpager�rgr�unicodedataZPROGNAME�gettext�kwargs�version_infoZtranslationr�r�builtinsr�__dict__�ImportErrorZ__builtin__r
rwrNr�rr�rZdistutils.sysconfigr�r�r�r�r�r�r�r�r�r�r�rwryr�r}r�r�r�r�r�r�r[rer#r�r�rrrr�<module>s�

���

		


Youez - 2016 - github.com/yon3zu
LinuXploit