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__/change_profile.cpython-310.pyc
o

%`b;�@svddlmZmZddlmZmZmZddlmZm	Z	m
Z
mZmZddl
mZe�ZGdd�de�ZGdd�de	�Zd	S)
�)�RE_PROFILE_CHANGE_PROFILE�strip_quotes)�AppArmorBug�AppArmorException�type_is_str)�BaseRule�BaseRuleset�parse_modifiers�logprof_value_or_all�quote_if_needed)�init_translationcs�eZdZdZGdd�de�ZeZdZgd�Z		d�fd	d
�	Z	e
dd��Ze
d
d��Zddd�Z
dd�Zdd�Zdd�Z�ZS)�ChangeProfileRulez6Class to handle and store a single change_profile rulec@seZdZdS)z$ChangeProfileRule.__ChangeProfileAllN)�__name__�
__module__�__qualname__�rr�>/usr/lib/python3/dist-packages/apparmor/rule/change_profile.py�__ChangeProfileAllsr�change_profile)�safe�NFrNc		stt|�j|||||d�|r(|dkr|dkrtd|��|r$|tjkr(td��||_d|_d|_|tjkr:d|_n*t	|�r\|�
�sFtd	��|�d
�sP|�d�rT||_ntdt|���td
t|���d|_
d|_|tjkrtd|_dSt	|�r�|�
�r�||_
dStd��td
t|���)zl
            CHANGE_PROFILE RULE = 'change_profile' [ [ EXEC MODE ] EXEC COND ] [ -> PROGRAMCHILD ]
        )�audit�deny�
allow_keyword�comment�	log_eventr�unsafez-Unknown exec mode (%s) in change_profile rulezCExec condition is required when unsafe or safe keywords are presentNFTz+Empty exec condition in change_profile rule�/�@z?Exec condition in change_profile rule does not start with /: %sz.Passed unknown object to ChangeProfileRule: %s�+Empty target profile in change_profile rule)�superr
�__init__r�ALLr�execmode�execcond�
all_execcondsr�strip�
startswith�str�
targetprofile�all_targetprofiles)	�selfr#r$r)rrrrr��	__class__rrr!'s>�



zChangeProfileRule.__init__cCs
t�|�S)N)r�search)�cls�raw_rulerrr�_matchTs
zChangeProfileRule._matchc
	Cs�|�|�}|sttd�|��t|�\}}}}|�d�}|�d�r)t|�d��}ntj}|�d�r9t|�d��}	ntj}	t|||	||||d�S)z+parse raw_rule and return ChangeProfileRulez Invalid change_profile rule '%s'r#r$r))rrrr)r1r�_r	�grouprr
r")
r/r0�matchesrrrrr#r$r)rrr�_parseXs



�zChangeProfileRule._parsercCs�d|}|jr
d|j}nd}|jrd}n|jr dt|j�}ntd��|jr*d}n|jr5dt|j�}ntd��d||��||||jfS)z)return rule (in clean/default formatting)z  z %srz%Empty execcond in change_profile rulez -> %srz%s%schange_profile%s%s%s,%s)	r#r%r$rrr*r)�
modifiers_strr)r+�depth�spacer#r$r)rrr�	get_cleanqszChangeProfileRule.get_cleancCsh|j|jkr|jtjvs|jtjvrdS|�|j|j|j|jd�s#dS|�|j|j|j|jd�s2dSdS)z2check if other_rule is covered by this rule objectFzexec conditionztarget profileT)r#r
�equiv_execmodes�_is_covered_plainr$r%r)r*)r+�
other_rulerrr�is_covered_localvars�sz&ChangeProfileRule.is_covered_localvarscCs�t|�tkstdt|���|j|jkr"|jtjvs |jtjvr"dS|j|jks.|j|jkr0dS|j|jks<|j	|j	kr>dSdS)z,compare if rule-specific variables are equalz"Passed non-change_profile rule: %sFT)
�typer
rr(r#r:r$r%r)r*)r+�rule_obj�strictrrr�is_equal_localvars�sz$ChangeProfileRule.is_equal_localvarscCsPg}|jr|td�|jg7}t|j|j�}t|j|j�}|td�|td�|gS)Nz	Exec ModezExec ConditionzTarget Profile)r#r2r
r$r%r)r*)r+�headers�execcond_txt�targetprofiles_txtrrr�logprof_header_localvars�s�z*ChangeProfileRule.logprof_header_localvars)FFFrN)r)rrr�__doc__�object�$_ChangeProfileRule__ChangeProfileAllr"�	rule_namer:r!�classmethodr1r5r9r=rArE�
__classcell__rrr,rr
s"�-


r
c@seZdZdZdd�ZdS)�ChangeProfileRulesetz>Class to handle and store a collection of change_profile rulescCsdS)z�Return the next possible glob. For change_profile rules, that can be "change_profile EXECCOND,",
           "change_profile -> TARGET_PROFILE," or "change_profile," (all change_profile).
           Also, EXECCOND filename can be globbedzchange_profile,r)r+�path_or_rulerrr�get_glob�szChangeProfileRuleset.get_globN)rrrrFrNrrrrrL�srLN)�apparmor.regexrr�apparmor.commonrrr�
apparmor.rulerrr	r
r�apparmor.translationsrr2r
rLrrrr�<module>s(