/usr/lib/python3.9/site-packages/sepolgen/__pycache__
NameSizeModeActions
access.cpython-39.opt-1.pyc113610644editdlrm
access.cpython-39.pyc113610644editdlrm
audit.cpython-39.opt-1.pyc172600644editdlrm
audit.cpython-39.pyc172600644editdlrm
classperms.cpython-39.opt-1.pyc24710644editdlrm
classperms.cpython-39.pyc24710644editdlrm
defaults.cpython-39.opt-1.pyc22980644editdlrm
defaults.cpython-39.pyc22980644editdlrm
interfaces.cpython-39.opt-1.pyc125920644editdlrm
interfaces.cpython-39.pyc125920644editdlrm
lex.cpython-39.opt-1.pyc213770644editdlrm
lex.cpython-39.pyc213770644editdlrm
matching.cpython-39.opt-1.pyc61690644editdlrm
matching.cpython-39.pyc61690644editdlrm
module.cpython-39.opt-1.pyc71700644editdlrm
module.cpython-39.pyc71700644editdlrm
objectmodel.cpython-39.opt-1.pyc39710644editdlrm
objectmodel.cpython-39.pyc39710644editdlrm
output.cpython-39.opt-1.pyc35450644editdlrm
output.cpython-39.pyc35450644editdlrm
policygen.cpython-39.opt-1.pyc128870644editdlrm
policygen.cpython-39.pyc129200644editdlrm
refparser.cpython-39.opt-1.pyc292590644editdlrm
refparser.cpython-39.pyc292590644editdlrm
refpolicy.cpython-39.opt-1.pyc401730644editdlrm
refpolicy.cpython-39.pyc401730644editdlrm
sepolgeni18n.cpython-39.opt-1.pyc3940644editdlrm
sepolgeni18n.cpython-39.pyc3940644editdlrm
util.cpython-39.opt-1.pyc63640644editdlrm
util.cpython-39.pyc63640644editdlrm
yacc.cpython-39.opt-1.pyc531330644editdlrm
yacc.cpython-39.pyc532120644editdlrm
__init__.cpython-39.opt-1.pyc1440644editdlrm
__init__.cpython-39.pyc1440644editdlrm
Edit: /usr/lib/python3.9/site-packages/sepolgen/__pycache__/module.cpython-39.pyc (7170B)
a BÒivã@s dZddlZddlZzddlmZWneyBddlmZYn0ddlZddlZddl Z ddl Z ddl m Z dd„Z Gdd „d ƒZd d „ZGd d „d ƒZdS)zU Utilities for dealing with the compilation of modules and creation of module tress. éN)Úgetstatusoutputé)ÚdefaultscCs0t d|¡}t|ƒdkr(|d ¡r(dSdSdS)z'Check that a module name is valid. z[^a-zA-Z0-9_\-\.]rTFN)ÚreÚfindallÚlenÚisalpha)ÚmodnameÚm©r ú3/usr/lib/python3.9/site-packages/sepolgen/module.pyÚ is_valid_name(s r c@sNeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ddd„Z dS)Ú ModuleTreecCs||_d|_dS©N)r Údirname)Úselfr r r r Ú__init__2szModuleTree.__init__cCs|jSr©r©rr r r Údir_name6szModuleTree.dir_namecCs|jd|jdS)Nú/z.te©rr rr r r Úte_name9szModuleTree.te_namecCs|jd|jdS)Nrz.fcrrr r r Úfc_name<szModuleTree.fc_namecCs|jd|jdS)Nrz.ifrrr r r Úif_name?szModuleTree.if_namecCs|jd|jdS)Nrú.pprrr r r Ú package_nameBszModuleTree.package_namecCs |jdS)Nz /Makefilerrr r r Ú makefile_nameEszModuleTree.makefile_nameNcCs’|d|j|_t |j¡t| ¡dƒ}|r>| d|¡n| dt ¡¡|  ¡t|  ¡dƒ  ¡t|  ¡dƒ  ¡t|  ¡dƒ  ¡dS)NrÚwzinclude ) r rÚosÚmkdirÚopenrÚwriterÚrefpolicy_makefileÚcloserrr)rZparent_dirnameZmakefile_includeÚfdr r r ÚcreateHs zModuleTree.create)N) Ú__name__Ú __module__Ú __qualname__rrrrrrrr&r r r r r1srcCstj tj |¡d¡dS)Nrr)rÚpathÚsplitextÚsplit)Ú sourcenamer r r Úmodname_from_sourcenameXsr.c@sTeZdZdZddd„Zdd„Zdd„Zd d „Zdd d „Zdd„Z dd„Z dd„Z dS)ÚModuleCompilerasModuleCompiler eases running of the module compiler. The ModuleCompiler class encapsulates running the commandline module compiler (checkmodule) and module packager (semodule_package). You are likely interested in the create_module_package method. Several options are controlled via parameters (only effects the non-refpol builds): .mls [boolean] Generate an MLS module (by passed -M to checkmodule). True to generate an MLS module, false otherwise. .module [boolean] Generate a module instead of a base module. True to generate a module, false to generate a base. .checkmodule [string] Fully qualified path to the module compiler. Default is /usr/bin/checkmodule. .semodule_package [string] Fully qualified path to the module packager. Defaults to /usr/bin/semodule_package. .output [file object] File object used to write verbose output of the compililation and packaging process. NcCs<t ¡|_d|_d|_d|_||_d|_t  ¡|_ d|_ dS)z‡Create a ModuleCompiler instance, optionally with an output file object for verbose output of the compilation process. Tz/usr/bin/checkmodulez/usr/bin/semodule_packageÚz /usr/bin/makeN) ÚselinuxZis_selinux_mls_enabledÚmlsÚmoduleÚ checkmoduleÚsemodule_packageÚoutputÚ last_outputrr#Úrefpol_makefileÚmake)rr6r r r rts  zModuleCompiler.__init__cCs |jr|j |d¡||_dS)NÚ )r6r"r7)rÚstrr r r ÚoszModuleCompiler.ocCs$| |¡t|ƒ\}}| |¡|Sr)r<r)rÚcommandÚrcr6r r r Úrun†s   zModuleCompiler.runcCsJ| d¡}t|ƒdkr td|ƒ‚d |dd…¡}|d}|d}||fS)zþGenerate the module and policy package filenames from a source file name. The source file must be in the form of "foo.te". This will generate "foo.mod" and "foo.pp". Returns a tuple with (modname, policypackage). Ú.éz,invalid sourcefile name %s (must end in .te)réÿÿÿÿz.modr)r,rÚ RuntimeErrorÚjoin)rr-Z splitnameÚbasenamer Ú packagenamer r r Ú gen_filenamess   zModuleCompiler.gen_filenamesTcCsD|r| |¡n0| |¡\}}| ||¡| ||¡t |¡dS)aŒCreate a module package saved in a packagename from a sourcename. The create_module_package creates a module package saved in a file named sourcename (.pp is the standard extension) from a source file (.te is the standard extension). The source file should contain SELinux policy statements appropriate for a base or non-base module (depending on the setting of .module). Only file names are accepted, not open file objects or descriptors because the command line SELinux tools are used. On error a RuntimeError will be raised with a descriptive error message. N)Ú refpol_buildrGÚcompileÚpackagerÚunlink)rr-Z refpolicyr rFr r r Úcreate_module_packagežs    z$ModuleCompiler.create_module_packagecCs4|jd|j}| |¡}|dkr0td|jƒ‚dS)Nz -f rúcompilation failed: %s)r9r8r?rCr7)rr-r=r>r r r rH¶s zModuleCompiler.refpol_buildcCsp|jg}|jr| d¡|jr(| d¡| d¡| |¡| |¡| d |¡¡}|dkrltd|jƒ‚dS)Nz-Mú-mú-oú rrM)r4r2Úappendr3r?rDrCr7)rr-r Úsr>r r r rI¿s     zModuleCompiler.compilecCsZ|jg}| d¡| |¡| d¡| |¡| d |¡¡}|dkrVtd|jƒ‚dS)NrOrNrPrzpackaging failed [%s])r5rQr?rDrCr7)rr rFrRr>r r r rJÍs    zModuleCompiler.package)N)T) r'r(r)Ú__doc__rr<r?rGrLrHrIrJr r r r r/[s   r/)rSrZtempfileÚ subprocessrÚ ImportErrorZcommandsrZos.pathÚshutilr1r0rr rr.r/r r r r Ús   '