VULN_CHECK_I913V6 =j oddlZddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z mZmZmZmZddlmZddlmZGd d e Zy) N)config)dbus_to_python%dbus_introspection_prepare_properties!dbus_introspection_add_properties)log)DbusServiceObject)handle_exceptionsdbus_handle_exceptionsdbus_service_methoddbus_service_signaldbus_polkit_require_auth)errors) FirewallErrorceZdZdZdZ ej jZ e fdZ e dZ e dZ e dZeej dd e dJd Zeej d d e dJd Zeej jeej de dJdZeej ddZeej j.eej0d e dJfd Zeej j4de dJdZeej j4d e dJdZeej j4de dJdZeej j4d e dJdZeej j4e dJdZeej j4d e dZ eej j4e dJdZ!eej j4d e dZ"eej j4d e dJdZ#eej j4d e d Z$eej j4d e dJd!Z%eej j4d e dJd"Z&eej j4d e dJd#Z'eej j4d e dJd$Z(eej j4d e dJd%Z)eej j4d e dJd&Z*eej j4d'e dJd(Z+eej j4d'e dJd)Z,eej j4de dJd*Z-eej j4de dJd+Z.eej j4dd, e dJd-Z/eej j4d.e dJd/Z0eej j4d.e dJd0Z1eej j4d e dJd1Z2eej j4d e dJd2Z3eej j4d d, e dJd3Z4eej j4d'e dJd4Z5eej j4d'e dJd5Z6eej j4de dJd6Z7eej j4de dJd7Z8eej j4dd, e dJd8Z9eej j4d.e dJd9Z:eej j4d.e dJd:Z;eej j4d e dJd;Z<eej j4d e dJd<Z=eej j4d d, e dJd=Z>eej j4d>e dJd?Z?eej j4d>e dJd@Z@eej j4d d e dJdAZAeej j4de dJdBZBeej j4d e dJdCZCeej j4dd, e dJdDZDeej j4d.e dJdEZEeej j4d.e dJdFZFeej j4d e dJdGZGeej j4d e dJdHZHeej j4d d, e dJdIZIxZJS)KFirewallDConfigServicezFirewallD main classTctt| |i|||_||_||_||_|d|_|d|_d|j z|_ t|tjjy)Nrzconfig.service.%d) superr__init__parentrobjitem_idbusnamepath _log_prefixrdbusDBUS_INTERFACE_CONFIG_SERVICE)selfrconfservicerargskwargs __class__s C/usr/lib/python3.12/site-packages/firewall/server/config_service.pyrzFirewallDConfigService.__init__,sr $d4dEfE   Aw G .=- &++;; cyNrs r$__del__zFirewallDConfigService.__del__:s r%c$|jyr')remove_from_connectionr)s r$ unregisterz!FirewallDConfigService.unregister>s ##%r%c|dk(r)tj|jjS|dk(r)tj|jjS|dk(r)tj|jj S|dk(r)tj |jjS|dk(r)tj |jjStjjd|z)NnamefilenamerdefaultbuiltinzDorg.freedesktop.DBus.Error.InvalidArgs: Property '%s' does not exist) rStringrr/r0rBooleanr1r2 exceptions DBusException)r property_names r$ _get_propertyz$FirewallDConfigService._get_propertyFs F ";;txx}}- - j (;;txx001 1 f $;;txx}}- - i '<< 0 01 1 i '<< 0 01 1/////1>? r%ssv) in_signature out_signaturec&t|t}t|t}tjd|j|||t j jk7r"t jjd|z|j|S)Nz%s.Get('%s', '%s')Jorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not exist) rstrrdebug1rrrrr5r6r8)rinterface_namer7senders r$GetzFirewallDConfigService.GetXs(<&}c:  $"2"2NM  V[[FF F////02@A  !!-00r%sza{sv}cJt|t}tjd|j||t j jk7r"t jjd|zi}dD]}|j|||<t j|dS)Nz%s.GetAll('%s')r>)r/r0rr1r2sv signature) rr?rr@rrrrr5r6r8 Dictionary)rrArBretxs r$GetAllzFirewallDConfigService.GetAlljs(< $d&6&6G V[[FF F////02@A  CA''*CFDsd33r%ssv)r;ct|t}t|t}t|}tjd|j||||j j ||tjjk7r"tjjd|ztjjd|z)Nz%s.Set('%s', '%s', '%s')r>zGorg.freedesktop.DBus.Error.PropertyReadOnly: Property '%s' is read-only) rr?rr@rr accessCheckrrrr5r6)rrAr7 new_valuerBs r$SetzFirewallDConfigService.Set{s(<&}c: "9-  &         ' V[[FF F////02@A  oo++ )+8 9  r%zsa{sv}asrGct|t}t|}t|}tjd|j|||y)Nz&%s.PropertiesChanged('%s', '%s', '%s'))rr?rr@r)rrAchanged_propertiesinvalidated_propertiess r$PropertiesChangedz(FirewallDConfigService.PropertiesChangedsI(<+,>?!/0F!G 4      "  r%)r<ctjd|jtt||j |jj}t||tjjS)Nz%s.Introspect()) rdebug2rrr Introspectrrget_busrrrr)rrBdatar#s r$rXz!FirewallDConfigService.Introspectsb $d&6&67+T= IIt||++- 1 $ AA  r%z(sssa(ss)asa{ss}asa(ss))ctjd|j|jj |j S)get settings for servicez%s.getSettings())rr@rrget_service_configrrrBs r$ getSettingsz"FirewallDConfigService.getSettingss2 %t'7'78{{--dhh77r%ctjd|j|jj |j S)r\z%s.getSettings2())rr@rrget_service_config_dictrr^s r$ getSettings2z#FirewallDConfigService.getSettings2s2 &(8(89{{22488< TXX]]#r%cNtj|jd|dy)Nz .Updated('')rr@rrr/s r$rezFirewallDConfigService.Updated )9)94@Ar%ctjd|j|jj ||j j |j|jj|jy)zremove servicez%s.removeService()N) rr@rrrOrremove_servicer removeServicer^s r$removezFirewallDConfigService.removesW ')9)9: ' ""488, !!$((+r%cNtj|jd|dy)Nz .Removed('rprqrrs r$RemovedzFirewallDConfigService.Removedrsr%ct|t}tjd|j||j j ||jj|j||_ |j|y)zrename servicez%s.rename('%s')N) rr?rr@rrrOrrename_servicerRenamed)rr/rBs r$renamezFirewallDConfigService.renamesadC( $d&6&6= ';;--dhh= Tr%cNtj|jd|dy)Nz .Renamed('rprqrrs r$r|zFirewallDConfigService.Renamed rsr%chtjd|j|jdS)Nz%s.getVersion()rrr@rr_r^s r$ getVersionz!FirewallDConfigService.getVersion- $d&6&67!!$$r%ct|t}tjd|j||j j |t|j}||d<|j|y)Nz%s.setVersion('%s')r rr?rr@rrrOlistr_rh)rversionrBrgs r$ setVersionz!FirewallDConfigService.setVersionsa!#. ($*:*:GD '((*+  Hr%chtjd|j|jdS)Nz %s.getShort()rrr^s r$getShortzFirewallDConfigService.getShort#s, ?D$4$45!!$$r%ct|t}tjd|j||j j |t|j}||d<|j|y)Nz%s.setShort('%s')rr)rshortrBrgs r$setShortzFirewallDConfigService.setShort)sauc* &(8(8%@ '((*+  Hr%chtjd|j|jdS)Nz%s.getDescription()rr^s r$getDescriptionz%FirewallDConfigService.getDescription5s- ($*:*:;!!$$r%ct|t}tjd|j||j j |t|j}||d<|j|y)Nz%s.setDescription('%s')rr)r descriptionrBrgs r$setDescriptionz%FirewallDConfigService.setDescription;sa%[#6  ,d.>.> L '((*+!  Hr%za(ss)chtjd|j|jdS)Nz %s.getPorts()rr^s r$getPortszFirewallDConfigService.getPortsGs, ?D$4$45!!$$r%cg}t|tD]>}t|tr|jt |.|j|@|}t j d|jdjd|D|jj|t|j}||d<|j|y)Nz%s.setPorts('[%s]'),c3:K|]}d|dd|ddywz('rz, 'rrpNr(.0ports r$ z2FirewallDConfigService.setPorts.._JEDd1gtAw7Er rr isinstanceappendtuplerr@rjoinrrOr_rhrportsrB_portsrrgs r$setPortszFirewallDConfigService.setPortsOs "5$/D$% eDk* d# 0  !    HHJEJ J '((*+  Hr%ct|t}t|t}tjd|j|||j j |t|j}||f|dvrttj|d||dj||f|j|y)Nz%s.addPort('%s', '%s')r:rr?rr@rrrOrr_rrALREADY_ENABLEDrrhrrprotocolrBrgs r$addPortzFirewallDConfigService.addPortfsdC(!(C0 +T-=-=tXN '((*+ ( x{ * 6 648RS S D(+, Hr%ct|t}t|t}tjd|j|||j j |t|j}||f|dvrttj|d||dj||f|j|y)Nz%s.removePort('%s', '%s')rrrr?rr@rrrOrr_rr NOT_ENABLEDrwrhrs r$ removePortz!FirewallDConfigService.removePortssdC(!(C0 .0@0@$Q '((*+ ( 8A; . 2 2tX4NO O D(+, Hr%bct|t}t|t}tjd|j||||f|j dvS)Nz%s.queryPort('%s', '%s')rrr?rr@rr_rrrrBs r$ queryPortz FirewallDConfigService.queryPortsS dC(!(C0 -t/?/?xPh4#3#3#5a#888r%aschtjd|j|jdS)Nz%s.getProtocols()rr^s r$ getProtocolsz#FirewallDConfigService.getProtocolss- &(8(89!!$$r%ct|t}tjd|jdj ||j j|t|j}||d<|j|y)Nz%s.setProtocols('[%s]')rr) rrrr@rrrrOr_rh)r protocolsrBrgs r$ setProtocolsz#FirewallDConfigService.setProtocolssj#9d3  ,d.>.>@ST '((*+  Hr%cZt|t}tjd|j||j j |t|j}||dvrttj||dj||j|y)Nz%s.addProtocol('%s')rrrrrBrgs r$ addProtocolz"FirewallDConfigService.addProtocols"(C0 )4+;+;XF '((*+ x{ " 6 6A A 8$ Hr%cZt|t}tjd|j||j j |t|j}||dvrttj||dj||j|y)Nz%s.removeProtocol('%s')rrrs r$removeProtocolz%FirewallDConfigService.removeProtocols"(C0 ,d.>.>I '((*+ 8A; & 2 2H= = 8$ Hr%ct|t}tjd|j|||j dvS)Nz%s.queryProtocol(%s')rr)rrrBs r$ queryProtocolz$FirewallDConfigService.queryProtocols@ "(C0 *D,<,}t|tr|jt |.|j|@|}t j d|jdjd|D|jj|t|j}||d<|j|y)Nz%s.setSourcePorts('[%s]')rc3:K|]}d|dd|ddywrr(rs r$rz8FirewallDConfigService.setSourcePorts..rrrrrs r$setSourcePortsz%FirewallDConfigService.setSourcePortss "5$/D$% eDk* d# 0  '    HHJEJ J '((*+  Hr%ct|t}t|t}tjd|j|||j j |t|j}||f|dvrttj|d||dj||f|j|y)Nz%s.addSourcePort('%s', '%s')rrrrs r$ addSourcePortz$FirewallDConfigService.addSourcePortsdC(!(C0 143C3CT8T '((*+ ( x{ * 6 648RS S D(+, Hr%ct|t}t|t}tjd|j|||j j |t|j}||f|dvrttj|d||dj||f|j|y)Nz%s.removeSourcePort('%s', '%s')rrrrs r$removeSourcePortz'FirewallDConfigService.removeSourcePortsdC(!(C0 4d6F6FhW '((*+ ( 8A; . 2 2tX4NO O D(+, Hr%ct|t}t|t}tjd|j||||f|j dvS)Nz%s.querySourcePort('%s', '%s')rrrs r$querySourcePortz&FirewallDConfigService.querySourcePortsS dC(!(C0 3T5E5EtXVh4#3#3#5a#888r%chtjd|j|jdS)Nz%s.getModules()rr^s r$ getModulesz!FirewallDConfigService.getModulesrr%ct|t}g}|D]L}|jdr(|jdd}d|vr|jdd}|j |N|}t j d|jdj||jj|t|j}||d<|j|y)N nf_conntrack__-z%s.setModules('[%s]')rr) rr startswithreplacerrr@rrrrOr_rh)rmodulesrB_modulesmodulergs r$ setModulesz!FirewallDConfigService.setModules s!$/F  1<&=#^^C5F OOF #   *D,<,OP '((*+  Hr%ct|t}|jdr(|jdd}d|vr|jdd}t j d|j ||jj|t|j}||dvrttj||dj||j|y)Nrrrrz%s.addModule('%s')r)rr?rrrr@rrrOrr_rrrrrhrrrBrgs r$ addModulez FirewallDConfigService.addModules ,   _ -^^OR8Ff}S1 ')9)96B '((*+ Xa[  6 6? ? 6" Hr%ct|t}|jdr(|jdd}d|vr|jdd}t j d|j ||jj|t|j}||dvrttj||dj||j|y)Nrrrrz%s.removeModule('%s')r)rr?rrrr@rrrOrr_rrrrwrhrs r$ removeModulez#FirewallDConfigService.removeModule,s ,   _ -^^OR8Ff}S1 *D,<,.>G '((*+ ! $ 2 2F; ;{6""r%ct|t}t|t}tjd|j|||j j |t|j}||dvr,|d||k(r!ttjd|d|d||d|<|j|y)Nz%s.setDestination('%s', '%s')r'z': ') rr?rr@rrrOrr_rrrrhrraddressrBrgs r$setDestinationz%FirewallDConfigService.setDestinationqs , #. 2D4D4DfgV '((*+ Xa[ Xa[%8G%C&&(H & F Hr%c>t|t}tjd|j||j j |t|j}||dvrttj||d|=|j|y)Nz%s.removeDestination('%s')r) rr?rr@rrrOrr_rrrrhrs r$removeDestinationz(FirewallDConfigService.removeDestinations , /1A1A6J '((*+ ! $ 2 2F; ; QK  Hr%ct|t}t|t}tjd|j|||j }||dvxr ||d|k(S)Nz%s.queryDestination('%s', '%s')rrrs r$queryDestinationz'FirewallDConfigService.queryDestinationsf  , #. 4d6F6FPWX##%!$GHQK4G)GGr%ctjd|j|jj ||j j |j}d|vr|dSgS)Nz%s.getIncludes()includes)rr@rrrOrrar)rrBrgs r$ getIncludesz"FirewallDConfigService.getIncludessZ %t'7'78 ';;66txx@'1X'=x #E2Er%cJt|t}tjd|j||j j |d|ddi}|jj|j||_ |j|jjy)Nz%s.setIncludes('%s')r) rrrr@rrrOrrjrrer/)rrrBrgs r$ setIncludesz"FirewallDConfigService.setIncludessw"(D1 )4+;+;XF ' ,;;66txxJ TXX]]#r%ct|t}tjd|j||j j ||jj|j}|jdgj||jj|j||_ |j|jjy)Nz%s.addInclude('%s')r)rr?rr@rrrOrrar setdefaultrrjrer/rincluderBrgs r$ addIncludez!FirewallDConfigService.addIncludes!#. ($*:*:GD ';;66txx@J+227;;;66txxJ TXX]]#r%ct|t}tjd|j||j j ||jj|j}|dj||jj|j||_ |j|jjy)Nz%s.removeInclude('%s')r)rr?rr@rrrOrrarrwrjrer/rs r$ removeIncludez$FirewallDConfigService.removeIncludes!#. +T-=-=wG ';;66txx@##G,;;66txxJ TXX]]#r%ct|t}tjd|j||j j |j}d|vr||dvSdS)Nz%s.queryInclude('%s')rF)rr?rr@rrrarrs r$ queryIncludez#FirewallDConfigService.queryIncludes[ !#. *D,<,rsE  %2)e T.e Tr%