HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/apparmor/rule/__pycache__/include.cpython-310.pyc
o

%`b��@szddlmZmZddlmZmZmZmZddlm	Z	m
Z
mZddlZddl
mZe�ZGdd�de	�ZGdd	�d	e
�ZdS)
�)�
RE_INCLUDE�re_match_include_parse)�AppArmorBug�AppArmorException�is_skippable_file�type_is_str)�BaseRule�BaseRuleset�
parse_commentN)�init_translationcsleZdZdZdZ		d�fdd�	Zedd	��Zed
d��Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�IncludeRulez/Class to handle and store a single include rule�includeF�Nc		s�tt|�j|||||d�|rtd|jj��|r!td|jj��t|�tur1td|jj|f��t|�turAtd|jj|f��t|�sOtd|jj|f��|s[td|jj|f��||_	||_
||_dS)N)�audit�deny�
allow_keyword�comment�	log_eventz(Attempt to initialize %s with audit flagz'Attempt to initialize %s with deny flagz*Passed unknown type for ifexists to %s: %sz)Passed unknown type for ismagic to %s: %sz&Passed unknown type for path to %s: %szPassed empty path to %s: %s)�superr�__init__r�	__class__�__name__�type�boolr�path�ifexists�ismagic)	�selfrrrrrrrr�r��7/usr/lib/python3/dist-packages/apparmor/rule/include.pyrs(�
zIncludeRule.__init__cCs
t�|�S)N)r�search)�cls�raw_rulerrr �_match9s
zIncludeRule._matchc	CsT|�|�}|sttd�|j|f��t|�}t||j�\}}}||||ddd|d�S)z%parse raw_rule and return IncludeRulezInvalid %s rule '%s'F)rrrr)r$r�_�	rule_namer
r)r"r#�matchesrrrrrrr �_parse=s
�zIncludeRule._parsercCsLd|}d}|jrd}|jrd||j||j|jfSd||j||j|jfS)z)return rule (in clean/default formatting)z  rz
 if existsz
%s%s%s <%s>%sz
%s%s%s "%s"%s)rrr&rr)r�depth�space�ifexists_txtrrr �	get_cleanMszIncludeRule.get_cleancCs>|j|jkrdS|j|jkr|jdkrdS|j|jkrdSdS)z2check if other_rule is covered by this rule objectFT)rrr)r�
other_rulerrr �is_covered_localvars[sz IncludeRule.is_covered_localvarscCsZt|�t|�kstd|jt|�f��|j|jkrdS|j|jkr#dS|j|jkr+dSdS)z,compare if rule-specific variables are equalzPassed non-%s rule: %sFT)rrr&�strrrr)r�rule_obj�strictrrr �is_equal_localvarsjszIncludeRule.is_equal_localvarscCstd�|��gS)N�Include)r%r,)rrrr �logprof_header_localvars{s�z$IncludeRule.logprof_header_localvarscCs�|j�d�r
|j}ntj�||j�}g}tj�|�r=tt�|��D]}t|�r(q!tj�||�}tj�|�r:|�	|�q!|Stj�
|�rJ|�	|�|S|jdkrT|�	|�|S)z_ get list of full paths of an include (can contain multiple paths if self.path is a directory) �/F)r�
startswith�os�join�isdir�sorted�listdirr�isfile�append�existsr)r�profile_dir�	full_path�filesr�	file_namerrr �get_full_paths�s&
��

�
zIncludeRule.get_full_paths)FFFrN)r)r�
__module__�__qualname__�__doc__r&r�classmethodr$r(r,r.r2r4rC�
__classcell__rrrr rs�


rc@seZdZdZdd�ZdS)�IncludeRulesetz7Class to handle and store a collection of include rulescCs"g}|jD]	}||�|�7}q|S)z get full path of all includes )�rulesrC)rr?�pathsr0rrr �get_all_full_paths�s
z!IncludeRuleset.get_all_full_pathsN)rrDrErFrLrrrr rI�srI)�apparmor.regexrr�apparmor.commonrrrr�
apparmor.rulerr	r
r7�apparmor.translationsrr%rrIrrrr �<module>s