a {ÄÏh«Ÿã @sgd¢ZddlZddlZddlZddlZddlZdddddœZdgd gd d gd gd gdgdœZdgZe  de  e ej   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_tZ freshclam_t)Z rgmanager_tZ corosync_tZ aisexec_tZ pacemaker_tZqemu_tZphpfpm_t)Z antivirus_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.ElementTreeZetreeZ ElementTreeZ 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Únextr rÚ 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(r rr)rrrrÚ_gen_exec_types…sr3cCs"tdurtt tjd¡ƒdatSr%)Ú entry_typesr(r rr)rrrrÚ_gen_entry_typessr5cCsTtrtSt tj¡}ia|D]2}z|dt|d<Wqgt|d<Yq0qtS)NÚ attributesr)r&r rÚ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å SELinux man pages

SELinux man pages for %s


SELinux roles

z %sz
rz

rarbrzo%s_selinux(8) - Security Enhanced Linux Policy for the %s SELinux user zH%s


SELinux domains

z %s zv%s_selinux(8) - Security Enhanced Linux Policy for the %s SELinux processes z%s ú%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„Z dd„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!dd?„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 |jvrˆ| 2¡|jr¦|j3 4|j/¡n|jrž|j5 4|j/¡| 6¡|j1 7¡t8 9¡D],}||j+kr¸t8|D]}| :|¡qÐq¸dS) NrrbZ file_contextsT)Úexist_okz policy.xmlrÚ_tú%s/%s_selinux.8rIÚ_r);rjÚ source_filesrr Z 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‰rwrr Z get_boolsr!)rZr&ÚtrrŽ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(r rr7r„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)rZrrrrrZ__gen_man_page_linkßs  zManPage.__gen_man_page_linkc Csög|_i|_g|_| ¡|jD]x}z| ¡|_|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_typesc CsÒ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| ƒdkrz|j   d ¡| D]*} |j   d |j| |   d ¡d d œ¡qN|rœ|j   d|j|d dœ¡|j   dd|ji¡| ¡|D]œ}|j   d|t |¡f¡||jvr¾d} t|j|dƒdkr¾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¸rRrNrr Zget_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_writes 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Ú ‹óz(ManPage._entrypoints..cs&|dˆjko$|ddko$d|dvS)NÚsourceÚclassÚfileÚ entrypointÚpermlist©r„)Úyr`rrÚ‹sz&ManPage._entrypoints..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)rZZ entrypointsZentrypoints_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(r rr)Ú 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öd g}|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..rr6cs.|dˆvo,tddgƒ |d¡o,|ddkS)NrÒrMrNrÖrÓrÔ)ÚsetÚissubsetrà)Úsrc_listrrrÙÃs ÿZ proc_typeZ sysctl_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Úr Zget_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. Z admindomainz· 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. ) r rérRrNZget_network_connectr„r;rkr:)rZréÚnetZportdictr¿rr­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..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Úr rÛ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§rržrår“r•r”r–rèr—r™ršr›rrrrrisN 9   +p "* #0-)r)r)#Ú__all__rBr~r rcÚtimer£r‰rÄÚstrftimeÚgmtimeÚintÚenvironr r²r rrrr$r'r*r,rr2r3r4r5r&r8r=rGrSrrrrrrÚsHü  ÿ   )