File: //lib/python3/dist-packages/apparmor/__pycache__/tools.cpython-310.pyc
o
%`b�) � @ s\ d dl Z d dlZd dlmZ d dlmZ d dlm Z m
Z
d dlmZ e� Z
G dd� d�ZdS )� N)� user_perm�cmd)�init_translationc @ s| e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� ZdS )�aa_toolsc C s| t j|jd� || _|j| _| �� d | _|j| _|dv r#|j | _ d S |dkr2|j
| _
t �� | _d S |dkr<|j| _d S d S )N)�
profiledir)�audit�autodep� cleanprof)
�apparmor�init_aa�dir�name�program� profiling�check_profile_dir�silent� do_reload�remove�force�check_for_apparmor�
aa_mountpoint)�self� tool_name�args� r �0/usr/lib/python3/dist-packages/apparmor/tools.py�__init__ s �zaa_tools.__init__c C s t tj�s
t�dtj ��d S )Nz%Cannot write to profile directory: %s)r r
�profile_dir�AppArmorException)r r r r r , s
�zaa_tools.check_profile_dirc c s � | j D ]�}|s qd}d}tj�|�s|�d�r9t�|��� }tj�tj |g�tj kr0d}|}nT|}t�
|d�}nKt�|�}|durNt�|�}t�
|d�}n6tj�tj�tj |��rjd}t�tj�tj |���� }nd|vrzt
�td�d|i � n t
�td�| � q||fV qdS )z6Iterator function to walk the list of arguments passedN�/T��Can't find %(program)s in the system path list. If the name of the application
is correct, please run 'which %(program)s' as a user with correct PATH
environment set up in order to find the fully-qualified path and
use the full path as parameter.r �0%s does not exist, please double-check the path.)r �os�path�exists�
startswithr
�
get_full_path�strip�commonprefixr �$get_profile_filename_from_attachment�which�join�aaui�UI_Info�_)r �pr �profile�fq_pathr* r r r �get_next_to_profile0 s4 �
�zaa_tools.get_next_to_profilec C s� t �� | �� D ]`\}}|d u r|}|rtj�|�s=t �|�s=|r/|�d�s/t� t
d�d�}nt�t
d�| � t�
d� |rJt �|�rJ| �|� qd|vrZt�t
d�d|i � qt�t
d�| � t�
d� qd S )Nr zaThe given program cannot be found, please try with the fully qualified path name of the program: � r! � r r )r
�
read_profilesr2 r"