관리-도구
편집 파일: misc.cpython-39.pyc
a �����!c�+����������������������@���sJ��d�Z�ddlmZmZ�ddlmZ�ddlmZmZmZ�ddl T�ddl ZddlZ ddlZ ddlZ ddlZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZdgZdadd ��Zdad d��Zdd ��ZG�dd��de �Z!dd��Z"dd��Z#d(dd�Z$dd��Z%dd��Z&dd��Z'd)dd�Z(d d!��Z)da*d"d#��Z+d*d$d%�Z,d+d&d'�Z-dS�),z% Assorted utility functions for yum. �����)�print_function�absolute_import)�unicode_literals)�base64_decodebytes� basestring�unicode)�*NZsha256c�����������������C���s���t�du�rt�d�ja�t�|��S�)z( Tests if a string is a shell wildcard. Nz[*?]|\[.+\])�_re_compiled_glob_match�re�compile�search)�s��r����0/usr/lib/python3.9/site-packages/dnf/yum/misc.py�re_glob.���s����r���c�����������������C���sD���t�du�r(t�d�j}t�d�j}||fa�t�D�]}||��r,�dS�q,dS�)zC Tests if a string needs a full nevra match, instead of just name. Nz.*([-.*?]|\[.+\]).z[0-9]+:TF)�_re_compiled_full_matchr ���r����match)r ���ZoneZtwoZrecr���r���r����re_full_search_needed6���s����r���c�������������������C���s���t�d�S�)Nr���)�_default_checksumsr���r���r���r����get_default_chksum_typeD���s����r���c�������������������@���s:���e�Zd�ZdZd dd�Zdd��Zdd��Zd d ��Zdd��ZdS�)� GenericHolderz�Generic Holder class used to hold other objects of known types It exists purely to be able to do object.somestuff, object.someotherstuff or object[key] and pass object to another function that will understand itNc�����������������C���s ���||�_�d�S��N)�_GenericHolder__iter)�self�iterr���r���r����__init__M���s����zGenericHolder.__init__c�����������������C���s���|�j�d�urt|�|�j���S�d�S�r���)r���r����r���r���r���r����__iter__P���s���� zGenericHolder.__iter__c�����������������C���s ���t�|�|�rt|�|�S�t|��d�S�r���)�hasattr�getattr�KeyError)r����itemr���r���r����__getitem__T���s���� zGenericHolder.__getitem__c�����������������C���s���dd��t�|�����D��S�)z!Return a dictionary of all lists.c�����������������S���s"���i�|�]\}}t�|�tu�r||�qS�r���)�type�list)�.0�keyZlist_r���r���r���� <dictcomp>\���s����z+GenericHolder.all_lists.<locals>.<dictcomp>)�vars�itemsr���r���r���r���� all_listsZ���s����zGenericHolder.all_listsc�����������������C���s0���|�������D�]\}}t|���|g���|��q|�S�)z7 Concatenate the list attributes from 'other' to ours. )r*���r)���r(���� setdefault�extend)r����otherr&����valr���r���r����merge_lists_���s����zGenericHolder.merge_lists)N) �__name__� __module__�__qualname__�__doc__r���r���r"���r*���r/���r���r���r���r���r���G���s��� r���c�����������������C���s����t��dd|��}�t���}d}d}|��d�D�]d}|�d�r<d}q(|rR|���dkrRd}q(|rf|�d�rf�q�q(|rz|�d�rz�q�q(|r(|�|d���q(t|� ���S�) z,Convert ASCII-armored GPG key to binary s��� ?���� r���s$���-----BEGIN PGP PUBLIC KEY BLOCK-----���������s"���-----END PGP PUBLIC KEY BLOCK-----����=) r ����sub�io�BytesIO�split� startswith�strip�writer����getvalue)�rawkey�blockZinblockZpastheaders�liner���r���r���� procgpgkeye���s ���� rC���c�����������������C���sR���|���dd�D�]@}|d�|krt|d�d�}||kr8�dS�||k�rF�dS��dS�qd S�) ab�� Return if the GPG key described by the given keyid and timestamp are installed in the rpmdb. The keyid and timestamp should both be passed as integers. The ts is an rpm transaction set object Return values: - -1 key is not installed - 0 key with matching ID and timestamp is installed - 1 key with matching ID is installed but has an older timestamp - 2 key with matching ID is installed but has a newer timestamp No effort is made to handle duplicates. The first matching keyid is used to calculate the return result. �namez gpg-pubkey�version�release����r���r5����������)ZdbMatch�int)�ts�keyidZ timestampZhdrZinstalledtsr���r���r����keyInstalled����s����rM���Tc�������������� ���C���s���t�j�|�st��|��tj�|���H�tj�����}tt�j� |d�d��}|� d��W�d�����n1�sh0����Y��|�|���|�r0|d�}t�j�|��s0t�j|dd��t�|d��D�]4}t�j� |�}|d�|�} t�|| ��t��| d��q�d } tt�j� |d�d d��}|� | ��W�d�����n1��s&0����Y��W�d�����W�d�����dS�1��sT0����Y��W�d�����n1��st0����Y��d�S�)Nzgpg.conf�wbr6���z-roi���)�modez/*�/z�lock-never no-auto-check-trustdb trust-model direct no-expensive-trust-checks no-permission-warning preserve-permissions �wT)�os�path�exists�makedirs�dnfZcryptoZpubring_dirZContext�open�joinr>���Z op_import�glob�basename�shutil�copy�chmod)r@���rL���ZgpgdirZmake_ro_copy�ctx�fpZrodir�frZ���Zro_fZoptsr���r���r����import_key_to_pubring����s&���� ( *ra���c������������ ������C���s����t����}�z.t�|��}tj�|d��}dtjj|f�}W�n"�t yX���dtjj|�f�}Y�n0�dtjj |f�}tt�|��}|D�]>}t�� |�}t|d��r|t|d��dkr||d�|�kr||��S�q|tj|tjj d�}|S�)zqreturn a path to a valid and safe cachedir - only used when not running as root or when --tempcache is setr���z%s-%s-z%s/%s*i�������)�prefix�dir)rR����geteuid�pwd�getpwuidrV���Zi18nZucd�constZPREFIXr ���ZTMPDIR�sortedrY����lstat�S_ISDIR�S_IMODE�tempfileZmkdtemp) �uidZusertup�usernamerc����dirpathZ cachedirsZthisdirZstatsZcachedirr���r���r����getCacheDir����s���� ( rq���c�����������������C���sb���g�}t�|��}t|��}�d}||krL||�}|�|�||����||7�}||8�}q|�|�|d����|S�)zE Given a seq, split into a list of lists of length max_entries each. r���N)�lenr$����append)�seqZmax_entries�retZnumZbeg�endr���r���r���� seq_max_split����s���� rw���c�������������� ���C���sF���zt��|���W�n2�ty@�}�z|jtjkr,��W�Y�d}~n d}~0�0�dS�)z| Call os.unlink, but don't die if the file isn't there. This is the main difference between "rm -f" and plain "rm". N)rR����unlink�OSError�errno�ENOENT)�filename�er���r���r����unlink_f����s ����r~���Fc�������������� ���C���sv���zt��|��W�S��typ�}�zL|jtjtjfv�r<W�Y�d}~dS�|rZ|jtjkrZW�Y�d}~dS���W�Y�d}~n d}~0�0�dS�)zF Call os.stat(), but don't die if the file isn't there. Returns None. N)rR����statry���rz���r{����ENOTDIRZEACCES)r|���Z ignore_EACCESr}���r���r���r����stat_f����s����r����c��������������� ���C���sb���z>t�d��"}�|����}t|�W��d����W�S�1�s20����Y��W�n�ttfy\���t����Y�S�0�dS�)z� Get the audit-uid/login-uid, if available. os.getuid() is returned instead if there was a problem. Note that no caching is done here. z/proc/self/loginuidN)rW����readrJ����IOError� ValueErrorrR����getuid)�fo�datar���r���r����_getloginuid����s���� ,r����c�������������������C���s���t�du�rt��a�t�S�)z� Get the audit-uid/login-uid, if available. os.getuid() is returned instead if there was a problem. The value is cached, so you don't have to save it. N)�_cached_getloginuidr����r���r���r���r����getloginuid��s����r����c����������� ��� ���C���s����|r |}nJd}|���d�}|dkr@|�|d��}|dv�r@|�d|��}|du�rTtj�d��|r�t|��}t|�}|r�|r�|j|jkr�|S�ztj�|�|d��W�n4�t y��}�ztj�t |���W�Y�d}~n d}~0�0�|r�|r�t�||j|jf��|S�)z�take a filename and decompress it into the same relative location. When the compression type is not recognized (or file is not compressed), the content of the file is copied to the destinationN�.r���)z.zckz.xzz.bz2z.gzz.lzmaz.zstz(Could not determine destination filenamei���) �rfindrV���� exceptionsZ MiscErrorr�����st_mtime�libdnfZutils� decompress�RuntimeError�strrR����utime) r|����destZcheck_timestamps�outZdot_pos�ext�fir����r}���r���r���r���r������s,���� &r����c�������������� ���C���s����g�}t���|��D�]�}t|��t}|D�]^}t�d|�r2q |���}|���}|sHq |rt|�dd�}|�dd�}|�|�����q |� |��q W�d����q1�s�0����Y��q|S�)a(�� Takes a glob of a dir (like /etc/foo.d/\*.foo) returns a list of all the lines in all the files matching that glob, ignores comments and blank lines, optional paramater 'line_as_list tells whether to treat each line as a space or comma-separated list, defaults to True. z\s*(#|$)� � �,N) rY���rW���r ���r����rstrip�lstrip�replacer,���r;���rs���)ZthisglobZline_as_list�results�fnamer`���rB���r���r���r����read_in_items_from_dot_dir9��s"���� ,r����)NT)F)NF)T).r3���Z __future__r���r���r���Z dnf.pycompr���r���r���r���Zlibdnf.utilsr����Z dnf.constrV���Z dnf.cryptoZdnf.exceptionsZdnf.i18nrz���rY���r9���rR���Zos.pathrf���r ���r[���rm���r���r ���r���r���r���r����objectr���rC���rM���ra���rq���rw���r~���r����r����r����r����r����r����r���r���r���r����<module>���sJ��� # $