Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /proc/self/root/lib/python3.9/site-packages/sepolicy/__pycache__/
Dosya Yükle :
Şuanki Dosya : //proc/self/root/lib/python3.9/site-packages/sepolicy/__pycache__/manpage.cpython-39.pyc

a

�y
f���@sgd�ZddlZddlZddlZddlZddlZddddd�Zdgd	gd
dgdgd
gdgd�ZdgZe�	de�
eej�
de������Zdad,dd�Zdadadd�Zdadd�Zdadd�Zdadd�Zdadd�Zdad d!�Zd"d#�Zd$d%�Zd&d'�Z Gd(d)�d)�Z!Gd*d+�d+�Z"dS)-)�ManPage�HTMLManPages�gen_domains�N)Zamavis_tZclamd_tZ
clamscan_tZfreshclam_t)Zrgmanager_tZ
corosync_tZ	aisexec_tZpacemaker_tZqemu_tZphpfpm_t)Zantivirus_tZ	cluster_tZsvirt_tZhttpd_tZsambaZapacheZvirtZlibvirtZbindZsmartmonZraid)ZsmbdZhttpdZvirtdZnamedZfsdaemonZmdadmz/varz%y-%m-%d�SOURCE_DATE_EPOCH�#/usr/share/selinux/devel/policy.xmlcCs�trtSddl}iaz�|jj�t�|��}|�d�D]b}|�d�D]R}|�d�}|dksB|dkrbqB|dkrnd}|dkrzd}|�d	�D]}|j	t|<q�qBq4Wnt
y�Yn0tS)
NrZlayer�module�name�userZ
unconfinedZ
unprivuserZunconfineduserZsummary)�modules_dictZxml.etree.ElementTreeZetreeZElementTreeZ
fromstring�sepolicyZ
policy_xml�findall�get�text�IOError)�pathZxmlZtree�l�mr�b�r�4/usr/lib/python3.9/site-packages/sepolicy/manpage.py�gen_modules_dict/s(
rcCs�trtrttfSgaiag}t�tj�}|D]4}|�|d�d|vr,|dt|d�d�d<q,|D]}|dvrft�|�dd��qft��ttfS)Nr�range�_r)Zsystem_u�rootZunconfined_uZ_u�)	�users�users_ranger�infoZUSER�append�split�replace�sort)ZallusersZ
allusers_info�d�urrr�get_all_users_infoKsr$cCststt�tjd��datS�NZ
entry_type�types)�all_entrypoints�nextrr�	ATTRIBUTErrrr�get_entrypointscsr*cCs�trtSgat��D](}d}|dd�}|tvr2qt�|�qt��D]0}|dd�tvsF|dkrdqFt�|dd��qFt��tS)NF���Zsystem_r)�domainsr�get_all_domainsr�
get_all_rolesr!)r"�found�domain�rolerrrrlsrcCs"tdurtt�tjd��datS)NZ	exec_typer&)�
exec_typesr(rrr)rrrr�_gen_exec_types�sr3cCs"tdurtt�tjd��datSr%)�entry_typesr(rrr)rrrr�_gen_entry_types�sr5cCsTtrtSt�tj�}ia|D]2}z|dt|d<Wqgt|d<Yq0qtS)N�
attributesr)r&rr�TYPE)Z	all_typesZrecrrr�
_gen_types�sr8cCsd�|dt|���d��S)N� r)�join�lenr)�fZtrimrrr�prettyprint�sr=cCsbt�tjg�}tjD]H}g}|D].}|�d�dd|kr |�|�d�d�q t|�||<q|S)N�/���r)�dict�fromkeys�string�
ascii_lettersrr�sorted)Zmanpage_listZalphabet_manpages�iZtemp�jrrr�get_alphabet_manpages�s
rGcCsrzddlm}Wnty.ddlm}Yn0|d|�\}}|dkrnt|d�t|d�}|�|�|��dS)Nr)�getstatusoutputz)/usr/bin/groff -man -Thtml %s 2>/dev/nullzhas been created�w)ZcommandsrH�ImportError�
subprocess�print�open�write�close)Zhtml_manpageZmanpagerH�rc�output�fdrrr�convert_manpage_to_html�s


rSc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rzF
            Generate a HTML Manpages on an given SELinux domains
    cCs8t|�|_t|�|_||_|d|_|j|_|��dS)Nr>)rG�
manpage_roles�manpage_domains�
os_version�old_path�new_path� _HTMLManPages__gen_html_manpages)�selfrTrUrrVrrr�__init__�s


zHTMLManPages.__init__cCs|��|��|��dS�N)�_write_html_manpage�
_gen_index�_gen_css�rZrrrZ__gen_html_manpages�sz HTMLManPages.__gen_html_manpagescCs�tj�|j�st�|j�|j��D]<}t|�r$|D]*}t|j|�	dd�dd|j
|�q4q$|j��D]<}t|�rl|D]*}t|j|�	dd�dd|j
|�q|qldS)N�_selinux�rz.html)�osr�isdirrX�mkdirrU�valuesr;rS�rsplitrWrT)rZr0r"r1�rrrrr]�s*z HTMLManPages._write_html_manpagec	Cs~|jd}t|d�}|�d|j�|jD]$}t|j|�r*|�d||f�q*|�d�d}|jD]N}t|j|�rd|d7}|j|D](}|�dd	�d
}|d||||f7}q�qd|�d|�|jD]$}t|j|�r�|�d
||f�q�|�d�d}|jD]T}t|j|��r|d7}|j|D]*}|�dd	�d
}|d||||f7}�q(�q|�d|�|��t	d|�dS)Nz
index.htmlrIz�
<html>
<head>
	<link rel=stylesheet type="text/css" href="style.css" title="style">
	<title>SELinux man pages</title>
</head>
<body>
<h1>SELinux man pages for %s</h1>
<hr>
<table><tr>
<td valign="middle">
<h3>SELinux roles</h3>
z
<a href=#%s_role>%s</a>z
</td>
</tr></table>
<pre>
rz<p>rarbrzo<a name=%s_role></a><a href=%s.html>%s_selinux(8)</a> - Security Enhanced Linux Policy for the %s SELinux user
zH%s
</pre>
<hr>
<table><tr>
<td valign="middle">
<h3>SELinux domains</h3>z
<a href=#%s_domain>%s</a>
			zv<a name=%s_domain></a><a href=%s.html>%s_selinux(8)</a> - Security Enhanced Linux Policy for the %s SELinux processes
z%s
</pre>
</body>
</html>
�%s has been created)
rXrMrNrVrTr;rgrUrOrL)	rZ�htmlrRZletterZ
rolename_bodyrhZrolenameZdomainname_body�
domainnamerrrr^�sN

�
�

�
�

�zHTMLManPages._gen_indexcCs6|jd}t|d�}|�d�|��td|�dS)Nz	style.cssrIaQ
html, body {
    background-color: #fcfcfc;
    font-family: arial, sans-serif;
    font-size: 110%;
    color: #333;
}

h1, h2, h3, h4, h5, h5 {
	color: #2d7c0b;
	font-family: arial, sans-serif;
	margin-top: 25px;
}

a {
    color: #336699;
    text-decoration: none;
}

a:visited {
    color: #4488bb;
}

a:hover, a:focus, a:active {
    color: #07488A;
    text-decoration: none;
}

a.func {
    color: red;
    text-decoration: none;
}
a.file {
    color: red;
    text-decoration: none;
}

pre.code {
    background-color: #f4f0f4;
//    font-family: monospace, courier;
    font-size: 110%;
    margin-left: 0px;
    margin-right: 60px;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 8px;
    padding-right: 8px;
    border: 1px solid #AADDAA;
}

.url {
    font-family: serif;
    font-style: italic;
    color: #440064;
}
ri)rWrMrNrOrL)rZZ	style_cssrRrrrr_)s



9zHTMLManPages._gen_cssN)	�__name__�
__module__�__qualname__�__doc__r[rYr]r^r_rrrrr�sGrc@s6eZdZdZdZddgZgZgZdLdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'dHdI�Z(dJdK�Z)dS)MrzK
        Generate a Manpage on an SELinux domain in the specified path
    NZDisabledZEnabled�/tmpr>FcCs�||_||_||_t��d|_t�|_t��|_	t�
�|_t��|_
t��|_t��|_t�d|_t�d|_t��|_t��|_t�|_t�|_t�|_|jr�|jd|_n|jt �!�|_t�"|j�|_#t$j%|dd�||_&|jr�|jd|_'n|jd|_'t�(|j'�|_)t�*|�\|_+|_,|j+d|_-|�.�d	||j+f|_/t0|j/d
�|_1|j+d|jv�r�|�2�|j�r�|j3�4|j/�n|j�r�|j5�4|j/�|�6�|j1�7�t8�9�D],}||j+k�r�t8|D]}|�:|��qАq�dS)NrrbZ
file_contextsT)�exist_okz
policy.xmlr�_t�%s/%s_selinux.8rI�_r);rj�source_filesrrZ
gen_port_dict�portrecsrr,r-�all_domainsZget_all_attributes�all_attributesZ
get_all_boolsZ	all_boolsZget_all_port_types�all_port_typesr.Z	all_rolesr$�	all_users�all_users_rangeZget_all_file_types�all_file_typesZget_all_role_allows�role_allowsr8r&r3r2r5r4Zfcpath�selinuxZselinux_file_context_pathZ
get_fcdict�fcdictrc�makedirsr�xmlpathZ
gen_bool_dict�
booleans_dictZgen_short_namerk�
short_name�type�
_gen_bools�
man_page_pathrMrR�_ManPage__gen_user_man_pagerTrrU�_ManPage__gen_man_pagerO�
equiv_dict�keys�_ManPage__gen_man_page_link)rZrkrrrurj�k�aliasrrrr[ssX







zManPage.__init__cCs�g|_g|_|jg}|jtvrJt|jD] }|d|jvr(|�|d�q(|D].}t�|�\}}|j|7_|j|7_qN|j�	�|j�	�dS)Nrr)
�bools�domainboolsr�rkr�rwrrZ	get_boolsr!)rZr&�tr�r�rrrr��s

zManPage._gen_boolscCs|jSr\)r�r`rrr�get_man_page_path�szManPage.get_man_page_pathcCs�|jd|_|jst|j�|_z|j|j|_Wnd|j|_Yn0|j|jvr�tt�	tj
|j��d|_|�
�|��|��|��|��|��|��|��n|��|��|��|��|��|��dS)Nrtz%s user roler6)rkr1r
rr��descrzr(rrr7r�r6�_user_header�_user_attribute�	_can_sudo�_xwindows_login�_network�	_booleans�
_home_exec�_transitions�_role_header�_port_types�
_mcs_types�_writes�_footerr`rrrZ__gen_user_man_page�s.
zManPage.__gen_user_man_pagecCsLd|j|f}td|j|fd�|_|j�d|j�|j��t|�dS)NrsrIz.so man8/%s_selinux.8)rrMrRrNrkrOrL)rZr�rrrrZ__gen_man_page_link�s

zManPage.__gen_man_page_linkc	Cs�g|_i|_g|_|��|jD]x}z<t|r^|j}|j}t|D]}|�|�qB||_||_WntyvYq Yn0t	t
�t
jd|��d|j|<q |�
�|��|��|��|��|��|��|��|��|��|��dS)Nz%sr6)�	anon_listr6�ptypes�_get_ptypes�typealias_typesrRr��_typealias_gen_man�KeyErrorr(rrr7�_header�_entrypoints�_process_typesr�r��_nsswitch_domainr�r��
_file_context�_public_contentr�)rZZdomain_typerRr�r�rrrZ__gen_man_page�s6


"zManPage.__gen_man_pagecCs4|jD](}|�|j�s"|�|j�r|j�|�qdSr\)rw�
startswithr�rkr�r)rZr<rrrr�s
zManPage._get_ptypescCsZd|j|dd�f|_g|_d|_t|jd�|_|�|dd��|��|j��dS)Nrsr+rrI)	rr��ports�booltextrMrR�
_typealiasr�rO)rZr�rrrr�szManPage._typealias_gen_mancCsH|j�d|td��|j�d||jd��|j�dd|ji�dS)Nz\.TH  "%(typealias)s_selinux"  "8"  "%(date)s" "%(typealias)s" "SELinux Policy %(typealias)s")�	typealias�datez�
.SH "NAME"
%(typealias)s_selinux \- Security Enhanced Linux Policy for the %(typealias)s processes
.SH "DESCRIPTION"

%(typealias)s_t SELinux domain type is now associated with %(domainname)s domain type (%(domainname)s_t).
)r�rkzC
Please see

.B %(domainname)s_selinux

man page for more details.
rk)rRrN�man_daterk)rZr�rrrr�s�
��zManPage._typealiascCs2|j�d|jtd��|j�dd|ji�dS)Nz_.TH  "%(domainname)s_selinux"  "8"  "%(date)s" "%(domainname)s" "SELinux Policy %(domainname)s")rkr�a�
.SH "NAME"
%(domainname)s_selinux \- Security Enhanced Linux Policy for the %(domainname)s processes
.SH "DESCRIPTION"

Security-Enhanced Linux secures the %(domainname)s processes via flexible mandatory access control.

The %(domainname)s processes execute with the %(domainname)s_t SELinux type. You can check if you have these processes running by executing the \fBps\fP command with the \fB\-Z\fP qualifier.

For example:

.B ps -eZ | grep %(domainname)s_t

rk)rRrNrkr�r`rrrr�'s
�
�zManPage._headercCsH|j|dd��|j|ddd�}|ddkrD|dd�}|S)N�rrbr?�.)r��lower�rZrr�rrr�_format_boolean_desc9s,zManPage._format_boolean_desccCsld}|j|jD]V\}}|�d�r:||jvr:|j�|�q||jvrFq|d|�|�||j||f7}q|S)NrZ
anon_writezg
.PP
If you want to %s, you must turn on the %s boolean. %s by default.

.EX
.B setsebool -P %s 1

.EE
)r�r��endswithr�rr�r��enabled_str)rZr�rZenabledrrr�_gen_bool_text?s
�	zManPage._gen_bool_textcCs>|��|_|jdkr:|j�d|j|jf�|j�|j�dS)Nrz�
.SH BOOLEANS
SELinux policy is customizable based on least access required.  %s policy is extremely flexible and has several booleans that allow you to manipulate the policy and run %s with the tightest access possible.

)r�r�rRrNrkr`rrrr�Rs


�zManPage._booleanscCs�g}ddg}d}|j��D]}d|j|vr|�|�qt|�rv|j�d�|D]$}|d|�|�d�|�||f7}qP|j�|�dS)NZauthlogin_nsswitch_use_ldapZkerberos_enabledrZnsswitch_domainz
.SH NSSWITCH DOMAIN
zb
.PP
If you want to %s for the %s, you must turn on the %s boolean.

.EX
.B setsebool -P %s 1
.EE
�, )r6r�rr;rRrNr�r:)rZZnsswitch_typesZnsswitch_booleansZnsswitchbooltextr�rrrrr�^s�	zManPage._nsswitch_domaincCsZt|j�dkrdS|j�dd|ji�|j�dd�|j��|j�dd|ji�dS)Nra�
.SH PROCESS TYPES
SELinux defines process types (domains) for each process running on the system
.PP
You can see the context of a process using the \fB\-Z\fP option to \fBps\bP
.PP
Policy governs the access confined processes have to files.
SELinux %(domainname)s policy is very flexible allowing users to setup their %(domainname)s processes in as secure a method as possible.
.PP
The following process types are defined for %(domainname)s:
rkz
.EX
.B %s
.EEr�z�
.PP
Note:
.B semanage permissive -a %(domainname)s_t
can be used to make the process type %(domainname)s_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated.
)r;r�rRrNrkr:r`rrrr�vs
�
��zManPage._process_typescCs�g|_|jD](}|�|j�s(|�|j�r|j�|�qt|j�dkrHdS|j�dd|ji�|jD]h}|j�d|�d}dD]J}||f|j	vr�|r�|j�d�d}|j�d	|d
�
|j	||f�f�q�qddS)Nra�
.SH PORT TYPES
SELinux defines port types to represent TCP and UDP ports.
.PP
You can see the types associated with a port by using the following command:

.B semanage port -l

.PP
Policy governs the access confined processes have to these ports.
SELinux %(domainname)s policy is very flexible allowing users to setup their %(domainname)s processes in as secure a method as possible.
.PP
The following port types are defined for %(domainname)s:rkz

.EX
.TP 5
.B %s
.TP 10
.EE
T��tcpZudpz

Default Defined Ports:Fz

%s %s
.EE�,)r�ryr�r�rkrr;rRrNrvr:)rZr<�p�onceZprotrrrr��s,
�
��zManPage._port_typesc	Cslg}g}g}|jD]T}|�|j�r|�|�||jvs@||jvrJ|�|�||jvr||j|d}qt|�dkrxdS|��i}|D]h}d}|D]$}|�|�r�||�|�d}q�q�|s�t	D],}	|�|	�r�|�
d�r�g||dd�<q�q�q�g}
|D]}t||�dkr�|
�|�q�|j�dd|ji�t|
�dk�rz|j�d	�|
D]*}	|j�d
|j|	|	�
d�dd
���qN|�r�|j�d|j|dd��|j�dd|ji�|��|D]�}|j�d|t�|�f�||jv�r�d}t|j|d�dk�r�d}|j�d||j|ddf�|j|ddd�D]}
|j�d|
��q@�q�|j�d�dS)N�regexrFTz(/.*)?i����a�
.SH FILE CONTEXTS
SELinux requires files to have an extended attribute to define the file type.
.PP
You can see the context of a file using the \fB\-Z\fP option to \fBls\bP
.PP
Policy governs the access confined processes have to these files.
SELinux %(domainname)s policy is very flexible allowing users to setup their %(domainname)s processes in as secure a method as possible.
.PP
rkz 
.PP
.B EQUIVALENCE DIRECTORIES
a�
.PP
%(domainname)s policy stores data with multiple different file context types under the %(equiv)s directory.  If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping.  If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e %(equiv)s /srv/%(alt)s
.br
.B restorecon -R -v /srv/%(alt)s
.PP
r>r?)rk�equivZalta�
.PP
.B STANDARD FILE CONTEXT

SELinux defines the file context types for the %(domainname)s, if you wanted to
store files with these types in a different paths, you need to execute the semanage command to specify alternate labeling and then use restorecon to put the labels on disk.

.B semanage fcontext -a -t %(type)s '/srv/my%(domainname)s_content(/.*)?'
.br
.B restorecon -R -v /srv/my%(domainname)s_content

Note: SELinux often uses regular expressions to specify labels that match multiple files.
)rkr�z=
.I The following file types are defined for %(domainname)s:
z

.EX
.PP
.B %s
.EE

- %s
rrb�sz
.br
.TP 5
Path%s:
%sz, %sa

.PP
Note: File context can be temporarily modified with the chcon command.  If you want to permanently change the file context you need to use the
.B semanage fcontext
command.  This will modify the SELinux labeling database.  You will need to use
.B restorecon
to apply the labels.
)r|r�rkrr2r4rr;r!�
equiv_dirsr�rRrNrrZget_description)rZ�flistZflist_non_execZmpathsr<ZmdirsZmpr/Zmd�er�r�plural�xrrrr��sz




	��

���
�zManPage._file_contextcCs`d}|jD]D}||jkrq
|�|j�r2|d|7}|�|jd�r
|d|7}q
|j�|�dS)Nrz, %s_selinux(8)r)r,rkr�r�rRrN)rZ�retr"rrr�	_see_also*s

zManPage._see_alsocCsvt|j�dkrr|j�dd|ji�|jD]F}|j|dd��|j|ddd�}|j�d|||f�q*dS)Nra,
.SH SHARING FILES
If you want to share files with multiple domains (Apache, FTP, rsync, Samba), you can set a file context of public_content_t and public_content_rw_t.  These context allow any of the above domains to read the content.  If you want a particular domain to write to the public_content_rw_t domain, you must set the appropriate boolean.
.TP
Allow %(domainname)s servers to read the /var/%(domainname)s directory by adding the public_content_t file type to the directory and by restoring the file type.
.PP
.B
semanage fcontext -a -t public_content_t "/var/%(domainname)s(/.*)?"
.br
.B restorecon -F -R -v /var/%(domainname)s
.pp
.TP
Allow %(domainname)s servers to read and write /var/%(domainname)s/incoming by adding the public_content_rw_t type to the directory and by restoring the file type.  You also need to turn on the %(domainname)s_anon_write boolean.
.PP
.B
semanage fcontext -a -t public_content_rw_t "/var/%(domainname)s/incoming(/.*)?"
.br
.B restorecon -F -R -v /var/%(domainname)s/incoming
.br
.B setsebool -P %(domainname)s_anon_write 1
rkr�rbzW
.PP
If you want to %s, you must turn on the %s boolean.

.EX
.B setsebool -P %s 1
.EE
)r;r�rRrNrkr�r�r�rrrr�5s�
,�zManPage._public_contentcCsp|j�d�t|j�dkr&|j�d�|jdkr<|j�d�|j�d|j�|jdkrd|j�d�|��dS)Na#
.SH "COMMANDS"
.B semanage fcontext
can also be used to manipulate default file context mappings.
.PP
.B semanage permissive
can also be used to manipulate whether or not a process type is permissive.
.PP
.B semanage module
can also be used to enable/disable/install/remove policy modules.
rzF
.B semanage port
can also be used to manipulate the port definitions
rzA
.B semanage boolean
can also be used to manipulate the booleans
z�
.PP
.B system-config-selinux
is a GUI tool available to customize SELinux policy settings.

.SH AUTHOR
This manual page was auto-generated using
.B "sepolicy manpage".

.SH "SEE ALSO"
selinux(8), %s(8), semanage(8), restorecon(8), chcon(1), sepolicy(8)z, setsebool(8))rRrNr;r�r�rkr�r`rrrr�Ws

�
zManPage._footercCs>||jdfvrdS|�d�r:|D]}||j|vr dSq dS)Nr0FrrT)r�r�r&)rZ�checkr6�arrr�_valid_write�s
zManPage._valid_writecs�dd�t�fdd�t���D�}t|�dkr0dS�j�d�t|�dkrXdd	�|�}nd
|d}�j�d�j|�jf�d|vr�|�d��j�d
�g}|D] }|�j	vr�|�j	|d7}q��j�dd	�|��dS)NcSsg|]}|d�qS)�targetr)�.0r�rrr�
<listcomp>��z(ManPage._entrypoints.<locals>.<listcomp>cs&|d�jko$|ddko$d|dvS)N�source�class�file�
entrypoint�permlist�r�)�yr`rr�<lambda>�sz&ManPage._entrypoints.<locals>.<lambda>rz
.SH "ENTRYPOINTS"
rbz\fB%s\fP file typesr�z\fB%s\fP file typezw
The %s_t SELinux type can be entered via the %s.

The default entrypoint paths for the %s_t domain are the following:
Zbin_tz]
All executables with the default executable label, usually stored in /usr/bin and /usr/sbin.r�z
%s)
�filterr�get_all_allow_rulesr;rRrNr:rk�remover)rZZentrypointsZentrypoints_str�pathsr�rr`rr��s,��

�zManPage._entrypointscCsXztt�tjd��}Wnty*YdS0|j|dvr>dS|j�dd|ji�dS)N�mcs_constrained_typer&a�
.SH "MCS Constrained"
The SELinux process type %(type)s_t is an MCS (Multi Category Security) constrained type.  Sometimes this separation is referred to as sVirt. These types are usually used for securing multi-tenant environments, such as virtualization, containers or separation of users.  The tools used to launch MCS types, pick out a different MCS label for each process group.

For example one process might be launched with %(type)s_t:s0:c1,c2, and another process launched with %(type)s_t:s0:c3,c4. The SELinux kernel only allows these processes can only write to content with a matching MCS label, or a MCS Label of s0. A process running with the MCS level of s0:c1,c2 is not allowed to write to content with the MCS label of s0:c3,c4
r�)	r(rrr)�
StopIterationr�rRrNrk)rZr�rrrr��s�zManPage._mcs_typescsD�jg�z*�tt�fdd�t����dd7�WnYn0tt�fdd�t����}|dusnt|�dkrrdSg}ddg}|D].}��|d|�r�|d|vr�|�|d�q�t|�dkr�dS�j	�
d	��j	�
d
�j�|��d|vr�dg}|D]D}�j	�
d|�|�j
vr��j
|d
D]}�j	�
d|��q&q�dS)Ncs|d�jkS)Nrr��r�r`rrr��r�z!ManPage._writes.<locals>.<lambda>rr6cs.|d�vo,tddg��|d�o,|ddkS)Nr�rMrNr�r�r�)�set�issubsetr�)�src_listrrr��s�Z	proc_typeZsysctl_typer�z
.SH "MANAGED FILES"
z�
The SELinux process type %s_t can manage files labeled with the following file types.  The paths listed are the default paths for these file types.  Note the processes UID still need to have DAC permissions.
Z	file_typez
.br
.B %s

r�z	%s
.br
)r��listr�rZget_all_types_infor�r;r�rrRrNrkr!r)rZr�Z
all_writesr6rEr<rr)rZr�rr��sD*���
�zManPage._writescCs|j|jvr|j|jSdS)NZs0)rkr{r`rrr�_get_users_range�szManPage._get_users_rangecCsd|j�dd|ji�|j�d|j|j|��d��d|jvr`d|jvr`|j�dd|ji�dS)Nzd.TH  "%(type)s_selinux"  "8"  "%(type)s" "mgrepl@redhat.com" "%(type)s SELinux Policy documentation"r�a
.SH "NAME"
%(user)s_u \- \fB%(desc)s\fP - Security Enhanced Linux Policy

.SH DESCRIPTION

\fB%(user)s_u\fP is an SELinux User defined in the SELinux
policy. SELinux users have default roles, \fB%(user)s_r\fP.  The
default role has a default type, \fB%(user)s_t\fP, associated with it.

The SELinux user will usually login to a system with a context that looks like:

.B %(user)s_u:%(user)s_r:%(user)s_t:%(range)s

Linux users are automatically assigned an SELinux users at login.
Login programs use the SELinux User to assign initial context to the user's shell.

SELinux policy uses the context to control the user's access.

By default all users are assigned to the SELinux user via the \fB__default__\fP flag

On Targeted policy systems the \fB__default__\fP user is assigned to the \fBunconfined_u\fP SELinux user.

You can list all Linux User to SELinux user mapping using:

.B semanage login -l

If you wanted to change the default user mapping to use the %(user)s_u user, you would execute:

.B semanage login -m -s %(user)s_u __default__

)r�r	r�login_userdomainz�
If you want to map the one Linux user (joe) to the SELinux user %(user)s, you would execute:

.B $ semanage login -a -s %(user)s_u joe

r	)rRrNrkr�r�r6rxr`rrrr��s��!�zManPage._user_headerc
Cs�d|j}|j�d�||jvr�|jd}|j�dd|ji�|j|D]N}|j�d|dd�|jd��|j�d	|jd
�|g|j|�d��qJ|j�d|j�dS)
Nz	%s_sudo_tz

.SH SUDO
rtz�
The SELinux user %(user)s can execute sudo.

You can set up sudo to allow %(user)s to transition to an administrative domain:

Add one or more of the following record to sudoers using visudo.

r	z�
USERNAME ALL=(ALL) ROLE=%(admin)s_r TYPE=%(admin)s_t COMMAND
.br
sudo will run COMMAND as %(user)s_u:%(admin)s_r:%(admin)s_t:LEVEL
r+)Zadminr	a_
You might also need to add one or more of these new roles to your SELinux user record.

List the SELinux roles your SELinux user can reach by executing:

.B $ semanage user -l |grep selinux_name

Modify the roles list and add %(user)s_r to this list.

.B $ semanage user -m -R '%(roles)s' %(user)s_u

For more details you can see semanage man page.

r9)r	Zrolesz7
The SELinux type %s_t is not allowed to execute sudo.
)rkrRrNr&r}r:)rZZsudotyper1Z	adminrolerrrr�s"


��
��zManPage._can_sudocCsd|j�d�d|jvr(|j�d|j�d|jvrD|j�d|j�d|jvr`|j�d|j�dS)Nz
.SH USER DESCRIPTION
Zunconfined_usertypez�
The SELinux user %s_u is an unconfined user. It means that a mapped Linux user to this SELinux user is supposed to be allow all actions.
Zunpriv_userdomainz�
The SELinux user %s_u is defined in policy as a unprivileged user. SELinux prevents unprivileged users from doing administration tasks without transitioning to a different role.
Zadmindomainz�
The SELinux user %s_u is an admin user. It means that a mapped Linux user to this SELinux user is intended for administrative actions. Usually this is assigned to a root Linux user.
)rRrNr6rkr`rrrr�Fs
�
�
�zManPage._user_attributecCsJd|jvrF|j�d�d|jvr4|j�d|j�n|j�d|j�dS)NZx_domainz
.SH X WINDOWS LOGIN
z3
The SELinux user %s_u is able to X Windows login.
z7
The SELinux user %s_u is not able to X Windows login.
�rxrRrNr6rkr`rrrr�Ys

��zManPage._xwindows_logincCsJd|jvrF|j�d�d|jvr4|j�d|j�n|j�d|j�dS)Nr�z
.SH TERMINAL LOGIN
z2
The SELinux user %s_u is able to terminal login.
z6
The SELinux user %s_u is not able to terminal login.
r�r`rrr�_terminal_logings

��zManPage._terminal_loginc	Cs�ddlm}|j�d�dD]�}|�|j|d�}t|�dkr�|j�d|j|f�|D],}||D]\}}|j�dd�|��qbqV|�|jd	d
�}t|�dkr|j�d|j�|D],}||D]\}}|j�dd�|��q�q�qdS)Nr)�networkz
.SH NETWORK
r�Z	name_bindzH
.TP
The SELinux user %s_u is able to listen on the following %s ports.
z
.B %s
r�r�Zname_connectzJ
.TP
The SELinux user %s_u is able to connect to the following tcp ports.
)	rr�rRrNZget_network_connectr�r;rkr:)rZr�ZnetZportdictr�r�r�rrrr�us.��
��zManPage._networkcsXtt�fdd�t����}�j�d�|durB�j�d�j�n�j�d�j�dS)Ncs@|d�jko>|ddko>|ddko>tgd���t|d��S)Nr�r�Zuser_home_typer�r�)Zioctl�read�getattrZexecuteZexecute_no_transrMr�)r�r�r�r�r`rrr��s
�
�z$ManPage._home_exec.<locals>.<lambda>z
.SH HOME_EXEC
z;
The SELinux user %s_u is able execute home content files.
z?
The SELinux user %s_u is not able execute home content files.
)r�r�rr�rRrNrk)rZr�rr`rr��s���zManPage._home_execcCs|j�dd|ji�dS)Na�
.SH TRANSITIONS

Three things can happen when %(type)s attempts to execute a program.

\fB1.\fP SELinux Policy can deny %(type)s from executing the program.

.TP

\fB2.\fP SELinux Policy can allow %(type)s to execute the program in the current user type.

Execute the following to see the types that the SELinux user %(type)s can execute without transitioning:

.B sesearch -A -s %(type)s -c file -p execute_no_trans

.TP

\fB3.\fP SELinux can allow %(type)s to execute the program and transition to a new type.

Execute the following to see the types that the SELinux user %(type)s can execute and transition:

.B $ sesearch -A -s %(type)s -c process -p transition

r�)rRrNr�r`rrrr��s�zManPage._transitionscCs�|j�dd|ji�|j�d|j|jd��g}|jD]"}|jd|j|vr:|�|�q:t|�dkr�d}t|�dkr�d	}|j�d
d�|�||jf�dS)Nzd.TH  "%(user)s_selinux"  "8"  "%(user)s" "mgrepl@redhat.com" "%(user)s SELinux Policy documentation"r	a[
.SH "NAME"
%(user)s_r \- \fB%(desc)s\fP - Security Enhanced Linux Policy

.SH DESCRIPTION

SELinux supports Roles Based Access Control (RBAC), some Linux roles are login roles, while other roles need to be transition into.

.I Note:
Examples in this man page will use the
.B staff_u
SELinux user.

Non login roles are usually used for administrative tasks. For example, tasks that require root privileges.  Roles control which types a user can run processes with. Roles often have default types assigned to them.

The default type for the %(user)s_r role is %(user)s_t.

The
.B newrole
program to transition directly to this role.

.B newrole -r %(user)s_r -t %(user)s_t

.B sudo
is the preferred method to do transition from one role to another.  You setup sudo to transition to %(user)s_r by adding a similar line to the /etc/sudoers file.

USERNAME ALL=(ALL) ROLE=%(user)s_r TYPE=%(user)s_t COMMAND

.br
sudo will run COMMAND as staff_u:%(user)s_r:%(user)s_t:LEVEL

When using a non login role, you need to setup SELinux so that your SELinux user can reach %(user)s_r role.

Execute the following to see all of the assigned SELinux roles:

.B semanage user -l

You need to add %(user)s_r to the staff_u user.  You could setup the staff_u user to be able to use the %(user)s_r role with a command like:

.B $ semanage user -m -R 'staff_r system_r %(user)s_r' staff_u

)r�r	rtrrrbr�z�

SELinux policy also controls which roles can transition to a different role.
You can list these rules using the following command.

.B search --role_allow

SELinux policy allows the %s role%s can transition to the %s_r role.

r�)rRrNrkr�r}rr;r:)rZZtrolesrEr�rrrr��s"�)�*
	�zManPage._role_header)rpr>FF)*rlrmrnror
r�rUrTr[r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrisN
9 	+p"*	#0-)r)r)#�__all__rBr~rrc�timer�r�r��strftime�gmtime�int�environr
r�r
rrrr$r'r*r,rr2r3r4r5r&r8r=rGrSrrrrrr�<module>sH� 
�


)

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4