+
                             *   R t ^ RIt^ RIHt  ]P                  ! RR4        ^ RIHt RtRs
Rs^ RIHt ^ R	IHt ^ R
IHt ^ RItR tR tR tR tR tR tR tR tR tR tR tR tR#   ]]]P                  3 d    Rt LXi ; i  ] d    Rt Lgi ; i)z(Functions for NetworkManager interactionN)GLibNMz1.0)r   TF)errors)FirewallError)logc                 R    \         '       g   \        \        P                  R4      hR# )zICheck function to raise a MISSING_IMPORT error if the import of NM failedzgi.repository.NM = 1.0N)_nm_importedr   r   MISSING_IMPORT     8/usr/lib/python3.14/site-packages/firewall/core/fw_nm.pycheck_nm_importedr   !   s     <F113KLL r   c                     \         # )zfReturns true if NM has been properly imported
@return True if import was successful, False otherwirse
)r   r
   r   r   nm_is_importedr   '   s
     r   c                     R p \         '       g!   \        P                  P                  R4      s M\        P
                  ! \        4       \        P                  ! ^V 4      s\         # )zReturns the NM client object or None if the import of NM failed
@return NM.Client instance if import was successful, None otherwise
c                     Rs RsR# )zf
Release the client to avoid excess memory usage when libnm pushes
irrelevant (to firewalld) updates.
N)
_nm_client_nm_client_timeoutr
   r   r   _releasenm_get_client.<locals>._release3   s     
!r   N)r   r   Clientnewr   source_remover   timeout_add_seconds)r   s    r   nm_get_clientr   .   sJ    
" :YY]]4(
 	-.11!X>r   c                   \        4        \        4       P                  V 4      pVf   R# VP                  4       pVf   R#  VP	                  4       \
        P                  P                  \
        P                  P                  ,          ,          '       d   R#  VP                  4       pVf   RpV#   \         d    TP                  4       '       d    R#  L>i ; i)zGet zone of connection from NM
@param connection name
@return zone string setting of connection, empty string if not set, None if connection is unknown
N )r   r   get_connection_by_uuidget_setting_connection	get_flagsr   SettingsConnectionFlagsNM_GENERATEDNM_VOLATILEAttributeErrorget_unsavedget_zone)
connectionconsetting_conzones   &   r   nm_get_zone_of_connectionr*   K   s    
 
/
0
0
<C
{,,.K
==?&&33((445
 
 	
 !D|K   ?? s   AB0 0 CCc                    \        4        \        4       P                  V4      pVf   R# VP                  4       pVf   R# V R8X  d   Rp VP	                  RV 4       VP                  RR4      # )zoSet the zone for a connection
@param zone name
@param connection name
@return True if zone was set, else False
NFr   r)   T)r   r   r   r   set_propertycommit_changes)r)   r&   r'   r(   s   &&  r   nm_set_zone_of_connectionr.   l   sj     
/
0
0
<C
{,,.KrzVT*dD))r   c                   V P                  4        VP                  4        \        4        \        4       P                  4       pV Fv  pVP	                  4       '       d   K  VP                  4       pVP                  4       pVP                  4       pWAV&   V F!  pVP                  4       pV'       g   K  WPV&   K#  	  Kx  	  R# )zbGet active connections from NM
@param connections return dict
@param connections_name return dict
N)	clearr   r   get_active_connectionsget_vpnget_idget_uuidget_devicesget_ip_iface)	connectionsconnections_nameactive_connections
active_connameuuiddevicesdevip_ifaces	   &&       r   nm_get_connectionsr@      s     &??A(
  """$((*!%C'')Hx(,H%  )r   c                 4   \        4        . p \        4       P                  4        F  pVP                  4       '       d   K   VP	                  4       pVP                  4       \        P                  P                  \        P                  P                  ,          ,          '       d   K   VP                  4        F.  pVP                  4       pV'       g   K  V P                  V4       K0  	  K  	  V #   \         d    XP                  4       '       d    K   Lni ; i)z?Get active interfaces from NM
@returns list of interface names
)r   r   r1   r2   get_connectionr   r   r    r!   r"   r#   r$   r5   r6   append)active_interfacesr:   r'   r>   r?   s        r   nm_get_interfacesrE      s    
 #o<<>
	++-C}}**77,,889  	 ))+C'')Hx!((2 ,% ?.   	    !	s   A#C00 DDc                     . p\        4        F1  p\        V4      pV \        V4      8X  g   K   VP                  V4       K3  	  V# )N)rE   nm_get_connection_of_interfacer*   rC   )r)   
interfaces	interfaceconns   &   r   nm_get_interfaces_in_zonerK      sB    J&(	-i8,T22i( )
 r   c                    \        4        \        4       P                  4        F#  pVP                  4       pVf   K  W 8X  g   K!  Vu # 	  R# )znGet device from NM which has the given IP interface
@param interface name
@returns NM.Device instance or None
N)r   r   r5   r6   )rI   devicer?   s   &  r   nm_get_device_by_ip_ifacerN      sF    
 /--/&&( M 0 r   c                   \        4        \        V 4      pVf   R# VP                  4       pVf   R#  VP                  4       pVP	                  4       \
        P                  P                  ,          '       d   R#  VP                  4       #   \         d,    XP                  4       '       d    R#  TP                  4       # i ; i)z}Get connection from NM that is using the interface
@param interface name
@returns connection that is using interface or None
N)r   rN   get_active_connectionrB   r   r   r    r!   r#   r$   r4   )rI   rM   r:   r'   s   &   r   rG   rG      s    
 &y1F~--/J'')==?R77DDDD E      ??    s   AB  C Cc                     \         '       g   R #  \        P                  ! 4       p V P                  \        P
                  \        P                  4      pVP                  p?? V#   \         d    \        P                  ! R4        R # i ; i)Nz(Failed to get bus name of NetworkManager)r   dbus	SystemBus
get_objectr   DBUS_INTERFACE	DBUS_PATHbus_name	Exceptionr   debug2)busobjr;   s      r   nm_get_bus_namer\      sg    <?nnnnR..=|| ?

=>?s   AA# #!BBc                  >    \         '       g   R # \        P                  # )r   )r   r   rU   r
   r   r   nm_get_dbus_interfacer^     s    <r   )__doc__gigi.repositoryr   require_versionr   r   ImportError
ValueErrorErrorr   r   firewallr   firewall.errorsr   firewall.core.loggerr   rR   r   r   r   r*   r.   r@   rE   rK   rN   rG   r\   r^   r
   r   r   <module>ri      s    / 	 
tU#$ 
   ) $ M:B*,-: F"!8c TZZ0   Ls"   B A* *BB	BB