관리-도구
편집 파일: internal_endpoints.cpython-39.pyc
a ������g�����������������������@���s����d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlmZ�d�dl m Z mZ�d�dlm Z mZmZmZ�ddlmZ�e�e�ZG�dd��dej�ZG�d d ��d ej�ZG�dd��dej�Zd efdefdefgZdS�)�����N)�Path)�Dict�Optional)�Variant�bus�inotify� pathwatch����)�configc�������������������@���sT���e�Zd�ZU�dZee�ed<�dd��Zej j dgd�dd���Zej j g�d�d d ���ZdS�)�cockpit_LoginMessagesN�messagesc�������������� ���C���s����t�j�dd��}|d�u�r$t�d��d�S�t�d|��zFtt|�d��$}|�d��|���|�_ W�d�����n1�sj0����Y��W�n6�t ttfy��}�zt�d|��W�Y�d�}~nd�}~0�0�t�d|�j ��d�S�)NZCOCKPIT_LOGIN_MESSAGES_MEMFDzBCOCKPIT_LOGIN_MESSAGES_MEMFD wasn't set. No login messages today.z(Trying to read login messages from fd %s�rr���z!Reading login messages failed: %sz$Successfully read login messages: %s) �os�environ�pop�logger�debug�open�int�seek�readr���� ValueError�OSError�UnicodeDecodeError)�selfZfdstrZlogin_messages�exc��r����>/usr/lib/python3.9/site-packages/cockpit/internal_endpoints.py�__init__&���s���� ,"zcockpit_LoginMessages.__init__�s)Z out_typesc�����������������C���s ���|�j�pdS�)Nz{}�r����r���r���r���r����get:���s����zcockpit_LoginMessages.getc�����������������C���s ���d�|�_�d�S��Nr ���r!���r���r���r����dismiss>���s����zcockpit_LoginMessages.dismiss) �__name__� __module__�__qualname__r���r����str�__annotations__r���r���� Interface�Methodr"���r$���r���r���r���r���r���#���s��� r���c�������������������@���s����e�Zd�ZU�eed<�ejed<�eej �ed<�e j�d�Z e jeeeeef�f�d�dd��Ze jjg�d�d �eeeeef�d d�dd ��Zdd��Zejeee�d d�dd�Zee�ee�d d�dd�Zdd��Zd S�)�cockpit_Machines�path�watch�pending_notifyz a{sa{sv}})�returnc�������������� ���C���s����i�}t���|�j��d��D�]�}t|��x}zt�|�}W�n0�tjyb���t�d|��Y�W�d�����qY�n0�|���D�]\}}dd��|���D��||<�qlW�d�����q1�s�0����Y��q|S�)Nz/*.jsonz#Invalid JSON in file %s. Ignoring.c�����������������S���s���i�|�]\}}|t�|��qS�r���)r�����.0�key�valuer���r���r���� <dictcomp>X��������z1cockpit_Machines.get_machines.<locals>.<dictcomp>) �globr-���r����json�load�JSONDecodeErrorr���Zwarning�items)r����results�filename�fp�contents�hostname�attrsr���r���r����get_machinesK���s���� 8zcockpit_Machines.get_machines)r���r���za{sv})Zin_typesN)r=���r@���rA���r0���c�����������������C���s��z>|�j��|�����}t�|�}W�d�����n1�s20����Y��W�nV�tjy��}�z(t�dd|��d|��d��|�W�Y�d�}~nd�}~0��ty����i�}Y�n0�|� |i��� dd��|���D����|�j�jddd��t|�j��|�d �� }tj ||d d��W�d�����n1�s�0����Y��d�S�)Nzcockpit.Machines.ErrorzFile z is in invalid format: �.c�����������������S���s���i�|�]\}}||j��qS�r����r4���r1���r���r���r���r5���h���r6���z+cockpit_Machines.update.<locals>.<dictcomp>T)�parents�exist_ok�w����)�indent)r-����joinpathr���r8���r9���r:���r���ZBusError�FileNotFoundError� setdefault�updater;����mkdir�dump)r���r=���r@���rA���r>���r?���r���r���r���r���rM���\���s����,0 zcockpit_Machines.updatec��������������������s,�����fdd�}��j�d�u�r(t����d|���_�d�S�)Nc����������������������s�������di�dg��d���_d�S�)Nzcockpit.MachinesZMachines)Zproperties_changedr/���r���r!���r���r����_notify_nowo���s����z,cockpit_Machines.notify.<locals>._notify_nowg�������?)r/����asyncioZget_running_loopZ call_later)r���rP���r���r!���r����notifyn���s���� zcockpit_Machines.notify)�mask�cookie�namer0���c�����������������C���s���|������d�S�r#����rR���)r���rS���rT���rU���r���r���r����do_inotify_eventx���s����z!cockpit_Machines.do_inotify_event)�fd�errnor0���c�����������������C���s���|������d�S�r#���rV���)r���rX���rY���r���r���r����do_identity_changed{���s����z$cockpit_Machines.do_identity_changedc�����������������C���s0���t��d�|�_d|�_t�t|�j�|��|�_d�|�_d�S�)Nz machines.d.)r ���Z lookup_configr-���r/���r���� PathWatchr(���r.���r!���r���r���r���r���~���s����zcockpit_Machines.__init__)r%���r&���r'���r���r)���r���r[���r���rQ���ZHandler���r*����PropertyZmachines�getterr���r(���r���rB���r+���rM���rR���r����Eventr���rW���rZ���r���r���r���r���r���r,���C���s��� r,���c�������������������@���s����e�Zd�Zejjddd�Zejjddd�Zejjddd�Zejjddd�Z ejjddd�Z ejjddd�Zejjdg�d�Zdd��Z d S�) �cockpit_Userr�����rD����ir����asc�����������������C���s����t��t����}|j|�_|j|�_|j|�_ |j |�_|j|�_ |j|�_t�|j �jg}t���D�]&}|j|jv�rV|j|vrV|�|j��qV||�_d�S�r#���)�pwd�getpwuidr����getuid�pw_namerU����pw_gecos�full�pw_uid�id�pw_gid�gid�pw_dir�home�pw_shell�shell�grp�getgrgid�gr_name�getgrall�gr_mem�append�groups)r����userrw���Zgrr���r���r���r�������s����zcockpit_User.__init__N)r%���r&���r'���r���r*���r\���rU���rh���rj���rl���rn���rp���rw���r���r���r���r���r���r_�������s���r_���z/LoginMessagesz /machinesz/user)rQ���r7���rq���r8���Zloggingr���rc����pathlibr����typingr���r���Zcockpit._vendor.systemd_ctypesr���r���r���r���r`���r ���Z getLoggerr%���r���ZObjectr���r,���r_���ZEXPORTSr���r���r���r����<module>���s$��� D�