grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a q©j`ã@sÒddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z ddl m Z mZmZmZddlmZe e¡ZGdd„dejƒZGd d „d ejƒZGd d „d ejƒZd efdefdefgZdS)éN)ÚPath)ÚDictÚOptional)ÚVariantÚbusÚinotifyÚ pathwatché)Úconfigc@s`eZdZUdZeeed<ddœdd„Zej j dgd�dd „ƒZ ej j gd�ddœd d „ƒZ dS) Úcockpit_LoginMessagesNÚmessages©Úreturnc CsÀtj dd¡}|dur$t d¡dSt d|¡zFtt|ƒdƒ�$}| d¡| ¡|_ Wdƒn1sj0YWn6t t t fy¬}zt d|¡WYd}~nd}~00t d|j ¡dS)NZCOCKPIT_LOGIN_MESSAGES_MEMFDzBCOCKPIT_LOGIN_MESSAGES_MEMFD wasn't set. No login messages today.z(Trying to read login messages from fd %sÚrrz!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_typescCs |jpdS)Nz{}©r ©rrrrÚget.szcockpit_LoginMessages.getcCs d|_dS©Nr"r#rrrÚdismiss2szcockpit_LoginMessages.dismiss) Ú__name__Ú __module__Ú __qualname__r rÚstrÚ__annotations__r rÚ InterfaceÚMethodr$r&rrrrr s   r c@sÖeZdZUeed<ejed<eej ed<e j   d¡Z e jeeeeeffdœdd„ƒZe j jgd¢d �eeeeefd d œd d „ƒZd dœdd„Zejeeed dœdd„Zeeeed dœdd„Zdd„Zd S)Úcockpit_MachinesÚpathÚwatchÚpending_notifyz a{sa{sv}}r c Csêi}t |j›d�¡D]Î}z–t|ƒ�z}zt |¡}Wn2tjyft d|¡YWdƒWqYn0| ¡D]\}}dd„| ¡Dƒ||<qpWdƒn1s¤0YWqt yâ}zt  d||¡WYd}~qd}~00q|S)Nz/*.jsonz#Invalid JSON in file %s. Ignoring.cSsi|]\}}|t|ƒ“qSr)r©Ú.0ÚkeyÚvaluerrrÚ Móz1cockpit_Machines.get_machines..z-Unreadable machines.d file %s: %s. Ignoring.) Úglobr/rÚjsonÚloadÚJSONDecodeErrorrZwarningÚitemsrÚerror)rÚresultsÚfilenameÚfpÚcontentsÚhostnameÚattrsrrrrÚ get_machines?s  :&zcockpit_Machines.get_machines)r!r!za{sv})Zin_typesN)r?rBrCrc Cs z>|j |¡ ¡�}t |¡}Wdƒn1s20YWnVtjy€}z(t dd|›d|›d�¡|‚WYd}~nd}~0ty”i}Yn0|  |i¡  dd„|  ¡Dƒ¡|jj ddd�t|j |¡d ƒ� }tj ||d d �Wdƒn1sþ0YdS) Nzcockpit.Machines.ErrorzFile z is in invalid format: Ú.cSsi|]\}}||j“qSr©r5r2rrrr6_r7z+cockpit_Machines.update..T)ÚparentsÚexist_okÚwé)Úindent)r/Újoinpathrr9r:r;rZBusErrorÚFileNotFoundErrorÚ setdefaultÚupdater<ÚmkdirÚdump)rr?rBrCr@rArrrrrOSs,0   zcockpit_Machines.updatecs2ddœ‡fdd„ }ˆjdur.t ¡ d|¡ˆ_dS)Nr csˆ didg¡dˆ_dS)Nzcockpit.MachinesZMachines)Zproperties_changedr1rr#rrÚ _notify_nowfsz,cockpit_Machines.notify.._notify_nowgð?)r1ÚasyncioZget_running_loopZ call_later)rrRrr#rÚnotifyes zcockpit_Machines.notify)ÚmaskÚcookieÚnamercCs | ¡dSr%©rT)rrUrVrWrrrÚdo_inotify_eventosz!cockpit_Machines.do_inotify_event)ÚfdÚerrnorcCs | ¡dSr%rX)rrZr[rrrÚdo_identity_changedrsz$cockpit_Machines.do_identity_changedcCs0t d¡|_d|_t t|jƒ|¡|_d|_dS)Nz machines.d.)r Z lookup_configr/r1rÚ PathWatchr*r0r#rrrr us zcockpit_Machines.__init__)r'r(r)rr+rr]rrSZHandlerr,ÚPropertyZmachinesÚgetterrr*rrDr-rOrTrÚEventrrYr\r rrrrr.7s     r.c@sŠeZdZejjddd�Zejjddd�Zejjddd�Zejjddd�Z ejjddd�Z ejjddd�Z ejjdgd�Z ddœd d „Z dS) Ú cockpit_Userr!ÚrFÚirÚasNr cCsˆt t ¡¡}|j|_|j|_|j|_ |j |_ |j |_ |j|_t |j ¡jg}t ¡D]&}|j|jvrV|j|vrV| |j¡qV||_dSr%)ÚpwdÚgetpwuidrÚgetuidÚpw_namerWÚ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ÚuserryZgrrrrr ‡s zcockpit_User.__init__)r'r(r)rr,r^rWrjrlrnrprrryr rrrrra~sraz/LoginMessagesz /machinesz/user)rSr8rsr9ZloggingrreÚpathlibrÚtypingrrZcockpit._vendor.systemd_ctypesrrrrrbr Z getLoggerr'rZObjectr r.raZEXPORTSrrrrÚs$    Gý