HEX
Server: LiteSpeed
System: Linux ratab.tasjeel.ae 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: arhamste (1605)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/ipapython/__pycache__/kernel_keyring.cpython-36.pyc
3

�d[e'�@s�ddlmZddlZddlmZddlmZddlmZdZ	dZ
dd	�Zd
d�Zdd
�Z
ddd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�)�absolute_importN)�run)�paths)�tasksz@s�usercCsttjdtgddd�}|jS)z
    Dump all keys
    �listFT)�
raiseonerr�capture_output)rr�KEYCTL�KEYRING�output)�result�r�$/usr/lib/python3.6/kernel_keyring.py�	dump_keys(srcCsDt|t�st�ttjdtt|gddd�}|jr:t	d|��|j
j�S)zv
    One cannot request a key based on the description it was created with
    so find the one we're looking for.
    �searchFT)rr	zkey %s not found)�
isinstance�str�AssertionErrorrrr
r�KEYTYPE�
returncode�
ValueError�
raw_output�rstrip)�keyr
rrr�get_real_key1s
rcCsBt|t�st�ttjdt|gddd�}|jr8td|��|j	j
�S)z�
    Fetches the value of a persistent key from storage, trimming trailing
    any tailing whitespace.

    Assert when key is not a string-type.
    Zget_persistentFT)rr	zpersistent key %s not found)rrrrrr
rrrrr)rr
rrr�get_persistent_key>s
rTcCsF|rtj�dk	rdStj�}ytt|��Wntk
r@dSXdS)z�Returns True if the kernel persistent keyring is supported.

    If check_container is True and a containerized environment is detected,
    return False. There is no support for keyring namespace isolation yet.
    NFT)rZdetect_container�os�geteuidrrr)Zcheck_containerZuidrrr�is_persistent_keyring_supportedMsrcCs4t|t�st�yt|�dStk
r.dSXdS)zC
    Returns True/False whether the key exists in the keyring.
    TFN)rrrrr)rrrr�has_key^sr cCsFt|t�st�t|�}ttjd|gddd�}|jr@td|j	��|j
S)z�
    Read the keyring and return the value for key.

    Use pipe instead of print here to ensure we always get the raw data.
    �pipeFT)rr	zkeyctl pipe failed: %s)rrrrrrr
rr�	error_logr)r�real_keyr
rrr�read_keyjsr$cCsft|t�st�t|t�st�t|�rXt|�}ttjd|g|dd�}|j	rbt
d|j��n
t||�dS)zK
    Update the keyring data. If they key doesn't exist it is created.
    ZpupdateF)�stdinrzkeyctl pupdate failed: %sN)
rrr�bytesr rrrr
rrr"�add_key)r�valuer#r
rrr�
update_keyzsr)cCsbt|t�st�t|t�st�t|�r0td|��ttjdt	|t
g|dd�}|jr^td|j��dS)z*
    Add a key to the kernel keyring.
    zkey %s already existsZpaddF)r%rzkeyctl padd failed: %sN)
rrrr&r rrrr
rrrr")rr(r
rrrr'�s
r'cCsDt|t�st�t|�}ttjd|tgdd�}|jr@t	d|j
��dS)z'
    Remove a key from the keyring
    �unlinkF)rzkeyctl unlink failed: %sN)rrrrrrr
rrrr")rr#r
rrr�del_key�sr+)T)Z
__future__rrZipapython.ipautilrZipaplatform.pathsrZipaplatform.tasksrrrrrrrr r$r)r'r+rrrr�<module>s