+
    	:i  c                   s   ^ RI Ht . R8Ot^ RIHtHt ^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHt ]! RR4      t]! RR	4      t/ t]P.                  R98  d   R
]R&   ]	P0                  ! R:R]R]/]B  ]	P2                  ! ]]R
R7      t ]P4                  t^ RIHt ^ RIH t H!t!H"t"H#t# ^ RI$5 ^ RIHt ^ RI$H%t% ^ RI&H't'H(t(H)t)H*t*H+t+H,t,H-t- ^ RI.H/t/H0t0H1t1H2t2 ^ RI3H4t4H5t5H6t6 ^ RI7H8t8H9t9H:t:H;t;H<t<H=t=H>t> ]<! R4       R t?R t@R tAR tB]! RR4      tC]! RR4      tD]! RR 4      tE]P                  ! 4       tG]GP                  ]C4       R! tIRsJRsKRsL]! R"R#4      tM]! RR$4      sN]! RR%4      tO]! RR&4      tP]A! 4       tQ ! R' R]R4      tS]S! 4       tT ! R( R)] 4      tU ! R* R]/4      tV ! R+ R,]V]4]5]64      tW ! R- R.]R4      tX^ RIY5 ^ RI7tZ ! R/ R0]P                  P                  4      t]R1 t^ ! R2 R34      t_^ RI`t`^ RIaHbtb R4 tc]P                  ! 4       teR5 tfR;R6 ltg]hR78X  d
   ]g! 4        R# R#   ] d    ]P                  t ELi ; i)<    )absolute_importClientConnectionHandlerConnectionPool)GObjectGLibN)parse_config_setting
get_configZgeneralZi18n_text_domainZi18n_locale_dirTZunicodedomain	localedir)r   r	   Zfallback)ServerAccess)PluginReportReceiverSETroubleshootDatabaseTestPluginReportReceiverAnalyzeThread)*)r   )AuditRecordReceiver)ProgramErrorERR_NOT_AUTHENTICATEDERR_USER_LOOKUPERR_USER_PROHIBITEDERR_USER_PERMISSIONERR_FILE_OPENERR_DATABASE_NOT_FOUND)
RpcChannelConnectionStateget_socket_list_from_configListeningServer)SETroubleshootServerInterface%SETroubleshootDatabaseNotifyInterfaceSEAlertInterface)get_hostnamemake_database_filepath!assure_file_ownership_permissionsget_identitylog_init	log_debugsyslog_tracesetroubleshootd_logc                 s    \        R V ,          4       ^ RIHp V \        P                  8X  d   \        R4       VP                  4        R# R# )received signal=%sNzreloading configuration file)r$   setroubleshoot.configconfigsignalSIGHUPZconfig_init)signumframer)      && :/usr/lib/python3.14/site-packages/setroubleshoot/server.py
sighandlerr0   m   s<    "V+,*01     c                 s    \        R V ,          4       \        P                  ! \        P                  R4       \        P                  ! ^4       R# )r'   z=/sys/fs/selinux/policy is in use by another process. Exiting!N)r$   syslogLOG_ERRosZ_exitr,   r-      &&r/   polling_failed_handlerr7   v   s.    "V+,
MM&.."abHHQKr1   c                  s    ^ RI p \        4       p\        P                  ! 4       p\	        V P                  4       4      pV: RV: RV: 2# )r    NZ:)timer   r4   Zgetpidstr)r8   ZhostnamepidZstamps       r/   make_instance_idr;   }   s4    ~H
))+C		E!3..r1   c                  s    \         # N)host_database r1   r/   get_host_databaser?      s    r1   Zsystem_dbusZbus_nameobject_pathZ	interfacec                 sH   \         P                  P                  \        \        R 4      pVP                  V P                  4       VP                  V P                  4       \        P                  V4       \        P                  R4       F  pVP                  V 4       K  	  R# )alertsealertN)dbusZlowlevelZSignalMessagedbus_system_object_pathdbus_system_interfaceappendlevellocal_id
system_busZsend_messageconnection_poolclientsrA   )siginforA   clients   &  r/   send_alert_notificationrN      sn    MM''(?AVX_`E	LL	LL!!"E"!)))4W 5r1   ZemailZrecipients_filepathpkg_namepkg_versionrpc_versionc                   sF   a  ] tR t^t o R tR tR tRR ltRR ltRt	V t
R# )	r   c                s    / V n         R # r<   client_poolself   &r/   __init__ZConnectionPool.__init__   s
    r1   c                sl    WP                   9   d   \        R V,          4       R# RV P                   V&   R# )z.add_client: client (%s) already in client poolNrS   r$   rU   Zhandlerr6   r/   
add_clientZConnectionPool.add_client   s/    &&&FPQ$(!r1   c                sh    WP                   9  d   \        R V,          4       R# V P                   V R# )z-remove_client: client (%s) not in client poolNrX   rY   r6   r/   remove_clientZConnectionPool.remove_client   s-    ***EOPW%r1   Nc              #  sv   "   V P                    F$  pVf   Vx  K  VP                  V8X  g   K   Vx  K&  	  R # 5ir<   )rS   channel_typerU   r\   rM   r.   r/   rK   ZConnectionPool.clients   s3     &&F#$$4	 's   (9
9c                sr    V P                    F&  pVP                  V8X  g   K  VP                  4        K(  	  R # r<   )rS   r\   Zclose_connectionr]   r.   r/   	close_allZConnectionPool.close_all   s,    &&F""l2'') 'r1   rR   r<   )__name__
__module____qualname____firstlineno__rW   rZ   r[   rK   r^   __static_attributes____classdictcell____classdict__   @r/   r   r      s#     )'* *r1   c                   s>   a a ] tR t^t oV 3R ltV 3R ltRtVtV ;t# )AlertPluginReportReceiverc                s.   < \         \        V `  V4       R # r<   )superrh   rW   )rU   database	__class__s   &&r/   rW   Z"AlertPluginReportReceiver.__init__   s    '7Ar1   c                s`  < \         \        V `  V4      p\        e   . p\        P                   Fq  pRVP
                  ,          pVP                  WCP                  4      pVR8w  g   K:  \        RVP                  ,          4       VP                  VP
                  4       Ks  	  \        V4      '       d   ^ RIHp V! W4       V P                  P                  4        \        R4       ^ RIHp \$        P$                  ! \$        P&                  VP)                  4       \+        R4      VP,                  ,          ,           4       VP.                  P0                   F)  pVP2                  R8X  g   K  VP4                  R	,          p	 M	  \7        R
R\8        4      '       d5   \:        P<                  P?                  VPA                  4       X	\B        R7       VPD                   FC  p
V
PF                  R,          R8X  d   K  VP                  V
PF                  4      pVR8X  g   KA  Vu # 	  \I        V4       V# )Nzemail:%signorezEmail: siginfo.sig=%s)email_alertzsending alert to all clients)html_to_textz1 For complete SELinux messages run: sealert -l %sAVCr:   r&   Zlog_full_report)Z
OBJECT_PIDZSYSLOG_IDENTIFIER:r    i   Nzemail:)%ri   rh   report_problememail_recipientsZrecipient_listZaddressevaluate_filter_for_userfilter_typer$   sigrF   ZlenZsetroubleshoot.email_alertrm   rj   Zmark_modifiedZsetroubleshoot.html_utilrn   r2   r3   summary_rH   audit_eventrecordsrecord_typefieldsr   boolsystemdZjournalZsendZformat_textrO   ZusersusernamerN   )rU   rL   Zto_addrsZ	recipientr}   actionrm   rn   audit_recordr:   Zurk   s   &&         r/   rp   Z(AlertPluginReportReceiver.report_problem   s   14GP'H-<<	%	(9(99 99(DYDYZX%5CDOOI$5$56 = 8}}BG.MM'')019fnngoo&7!<o:psz  tD  tD  ;D  'D  	E#//77L''50"))%0 8 +->EEOO  !4!4!63Zb cAzz#(*55ajjAF!  	 (r1   r>   )	r_   r`   ra   rb   rW   rp   rc   rd   Z__classcell__)rk   rf   s   @@r/   rh   rh      s     B& &r1   rh   c                   s2   a  ] tR t^t o R tR tR tRtV tR# )r   c                s    \         P                  ! V R 4       VP                  4       V n        V P                  P                  RV P                  4       R# )rB   ZchangedN)r   rW   Zcopysocket_addressconnection_stateZconnecton_connection_state_changerU   r   r6   r/   rW   Z ClientConnectionHandler.__init__   s?    D),,113%%i1P1PQr1   c                s   \        V P                  P                  : R V: RVP                  V4      : RVP                  V4      : RV P                  : 2	4       V\
        P                  ,          '       d   \        P                  V 4       V\
        P                  ,          '       d   \        P                  V 4       R# R# )..on_connection_state_change: connection_state= flags_added= flags_removed=	 address=N)
r$   rk   r_   flags_to_stringr   r   OPENrJ   r[   rZ   rU   r   flagsZflags_addedZflags_removed   &&&&&r/   r   Z2ClientConnectionHandler.on_connection_state_change  s    uy  vD  vD  vM  vM  O_  aq  aA  aA  BM  aN  P`  Pp  Pp  q~  P  AE  AT  AT  U  	V?////))$/----&&t, .r1   c                   V P                   P                  \        P                  ,          '       d   R # WP                  n        V P                   P                  \        P                  4       V P                  V P                  4       R# TN	r   r   r   r   r   socketupdateZio_watch_addZhandle_client_iorU   r   r      &&&r/   openZClientConnectionHandler.open  \      &&)=)===%+"$$_%9%9:$//0r1   )r   N)	r_   r`   ra   rb   rW   r   r   rc   rd   re   rg   r/   r   r      s     R
-1 1r1   c                   sx   a  ] tR tRt o 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R ltR tRtV tR# )&SetroubleshootdClientConnectionHandleri  c                s    \         P                  W4       \        4       V n        V P	                  R V 4       V P	                  RV 4       \        4       V n        RV n        RV n        RV n	        R# )ZSETroubleshootServerr   N)
r   rW   r?   rj   Zconnect_rpc_interfacer
   accessr}   uidgidr   r6   r/   rW   Z/SetroubleshootdClientConnectionHandler.__init__  sZ    ((>)+""#94@""#;TB"nr1   c                sz   \        V P                  P                  : R V: RVP                  V4      : RVP                  V4      : RV P                  : 2	4       V\
        P                  ,          '       d   \        P                  V 4       V\
        P                  ,          '       d   V P                  P                  V P                  P                  4      w  V n        V n        \        V P                  P                  : RV P                  : RV P                  : 24       \        P                  V 4       R# R# )r   r   r   r   z;.on_connection_state_change: open, socket credentials: uid=z gid=N)r$   rk   r_   r   r   r   r   rJ   r[   r   Zget_credentialsr   r   r   rZ   r   r   r/   r   ZASetroubleshootdClientConnectionHandler.on_connection_state_change(  sB   uy  vD  vD  vM  vM  O_  aq  aA  aA  BM  aN  P`  Pp  Pp  q~  P  AE  AT  AT  U  	V?////))$/----!%!<!<T=P=P=W=W!XDHdhbfbpbpbyby{  |D  |D  FJ  FN  FN  O  P&&t, .r1   c                r   r   r   r   r   r/   r   Z+SetroubleshootdClientConnectionHandler.open3  r   r1   c                s   V P                   P                  \        P                  ,          '       g   \	        \
        4      h\        4       pVP                  P                  V8X  d   VP                  .# \	        \        R V,          4      h)zdatabase (%s) not found)
r   r   r   AUTHENTICATEDr   r   r?   
propertiesZnamer   )rU   Zdatabase_namer=   r.   r/   database_bindZ4SetroubleshootdClientConnectionHandler.database_bind<  sj    %%++o.K.KKK455)+##((M9!,,--13L}3\]]r1   c                sD   \        R V : RV: RV: 24       V\        V P                  4      8w  d%   \        \        RV P                  : RV: R2R7      hVR8X  d   RpMR	pV P
                  P                  WB4      '       g   \        \        4      hWn        W n	        W n
        V P                  P                  V4      V n        V P                  f   V P                  P                  V4       V P                  P!                  \"        P$                  4       \&        \(        .# )
zlogon(z) type=z
 username=zuid=z  does not match logon username (Z)ZdetailrB   rM   N)r$   r"   r   r   r   r   Zuser_allowedr   r\   channel_namer}   rj   Zget_useruserZadd_userr   r   r   r   rP   rQ   )rU   typer}   ZpasswordZ	privilege   &&&& r/   logonZ,SetroubleshootdClientConnectionHandler.logonE  s    T4JK|DHH--fjfnfnpx7yzz9 II{{''	<<233 $ MM**84	99MM""8,$$_%B%BC[))r1   c                s    V P                   P                  \        P                  ,          '       g   \	        \
        4      h\        .# r<   )r   r   r   r   r   r   rq   rT   rV   r/   query_email_recipientsZ=SetroubleshootdClientConnectionHandler.query_email_recipients]  s4    %%++o.K.KKK455 !!r1   c                s    \        R V,          4       V P                  P                  \        P                  ,          '       g   \        \        4      hVs\        P                  \        4       R# )zset_email_recipients: %sN)
r$   r   r   r   r   r   r   rq   Zwrite_recipient_fileemail_recipients_filepath)rU   Z
recipientsr6   r/   set_email_recipientsZ;SetroubleshootdClientConnectionHandler.set_email_recipientsc  sP     	,z9:%%++o.K.KKK455%--.GHr1   c                s    \        R V,          4       V P                  P                  \        P                  ,          '       g   \        \        4      hV P                  P                  V4      pR# )zdelete_signature: sig=%sN)	r$   r   r   r   r   r   r   rj   delete_signature)rU   rt   rL   r.   r/   r   Z7SetroubleshootdClientConnectionHandler.delete_signaturep  sP    ,s23%%++o.K.KKK455--005r1   c                s    \        R 4       V P                  P                  \        P                  ,          '       g   \        \        4      hV P                  P                  4       pV.# )get_properties)	r$   r   r   r   r   r   r   rj   r   )rU   r   s   & r/   r   Z5SetroubleshootdClientConnectionHandler.get_propertiesy  sN    "#%%++o.K.KKK455]]113
|r1   c                s    \        R V: RV: 24       V P                  P                  \        P                  ,          '       g   \        \        4      hV P                  P                  W4      pV.# )z evaluate_alert_filter: username=z sig=)	r$   r   r   r   r   r   r   rj   evaluate_alert_filter)rU   rt   r}   r~      &&& r/   r   Z<SetroubleshootdClientConnectionHandler.evaluate_alert_filter  sS    3OP%%++o.K.KKK45544SCxr1   c                    \        R V,          4       V P                  P                  \        P                  ,          '       g   \        \        4      hV P                  P                  V4      pV.# )zlookup_local_id: %s)	r$   r   r   r   r   r   r   rj   lookup_local_id)rU   rH   rL   r.   r/   r   Z6SetroubleshootdClientConnectionHandler.lookup_local_id  sU    '(23%%++o.K.KKK455--//9yr1   c                r   )zquery_alerts: criteria=%s)	r$   r   r   r   r   r   r   rj   query_alerts)rU   Zcriteriasigsr.   r/   r   Z3SetroubleshootdClientConnectionHandler.query_alerts  sT    -89%%++o.K.KKK455}}))(3vr1   c                sf   \        R V: RV: RV: 24       V P                  P                  \        P                  ,          '       g   \        \        4      hW P                  8w  d.   \        \        \        R4      V P                  V3,          R7      hV P                  P                  WW44       R# )zset_filter: username=z filter_type= sig=
z)The user (%s) cannot modify data for (%s)r   N)r$   r   r   r   r   r   r   r}   r   rv   rj   
set_filter)rU   rt   r}   rs   datar   r/   r   Z1SetroubleshootdClientConnectionHandler.set_filter  s    xQ\^abc%%++o.K.KKK455}}$21=h;imqmzmz  }E  mF  <F  G  G  Br1   c           
     s    \        R V: RV: RV: RV: 24       V P                  P                  \        P                  ,          '       g   \        \        4      hV P                  P                  WW44       R# )zset_user_data: username=z item=z data=r   N)	r$   r   r   r   r   r   r   rj   set_user_data)rU   rt   r}   itemr   r   r/   r   Z4SetroubleshootdClientConnectionHandler.set_user_data  sV    8UY[_adef%%++o.K.KKK455##C4>r1   )r   r   r\   rj   r   r   r   r}   N) )r_   r`   ra   rb   rW   r   r   r   r   r   r   r   r   r   r   r   r   r   rc   rd   re   rg   r/   r   r     sR     	-1^*0"	I
 r1   r   c                   ,   a  ] tR tRt o R tR tRtV tR# )ClientNotifieri  c                s    Wn         R # r<   rJ   )rU   rJ   r6   r/   rW   ZClientNotifier.__init__  s    .r1   c                sl    V P                   P                  R 4       F  pVP                  W4       K  	  R# )rB   N)rJ   rK   signatures_updated)rU   r   r   rM   r   r/   r   Z!ClientNotifier.signatures_updated  s+    **229=F%%d1 >r1   r   N)r_   r`   ra   rb   rW   r   rc   rd   re   rg   r/   r   r     s     /
2 2r1   r   c                   s  a  ] tR tRt o R!R ltR t]P                  P                  ]	4      R 4       t
]P                  P                  ]	RR7      R 4       t]P                  P                  ]	4      R 4       t]P                  P                  ]	R	R
RR7      R 4       tR"R lt]P                  P                  ]	R	RRR7      R 4       t]P                  P                  ]	R	RRR7      R 4       t]P                  P                  ]	R	RRR7      R 4       tR t]P                  P                  ]	R	R
RR7      R 4       t]P                  P                  ]	R	RRR7      R 4       t]P                  P                  ]	R	R
RR7      R 4       t]P                  P                  ]	R
R
R7      R 4       t]P                  P                  ]	4      R 4       tR!R ltRtV tR # )#SetroubleshootdDBusObjecti  c                s   \         P                  P                  P                  V \         P                  ! 4       V4       ^ V n        W@n        V P                  V P                  4       \        RV,          4       W n	        W0n
        \        \        P                  4      V n        \        4       V n        \         P"                  P%                  4       V n        R# )r    zdbus __init__ %s calledN)rC   serviceObjectrW   	SystemBusconn_ctrtimeoutalarmr$   queuereceiverZAuditRecordReaderZTEXT_FORMATrecord_readerr   record_receiversetroubleshootutilZget_store_root
store_root)rU   r@   analysis_queuealert_receiverr   r   r/   rW   Z"SetroubleshootdDBusObject.__init__  s    $$T4>>+;[I

4<< +k9:#
&./@/L/LM24(--<<>r1   c                s   \         P                  ! 4       ^,          p\         P                  ! 4       : V: R2V P                  : RV: R23 FP  p\        P
                  P                  V4      '       g   K*  \        P                  ! \        P                  R4        R# 	  \        V4      pV F<  p\        V4      '       g   K  V P                  P                  WPP                  34       K>  	  R# )   z!/modules/active/disable_dontauditZ/z/active/disable_dontauditzsSetroubleshoot can not analyze AVCs while dontaudit rules are disabled, 'semodule -B' will turn on dontaudit rules.N)selinuxZselinux_getpolicytypeZselinux_pathr   r4   ZpathZexistsr2   r3   Zcompute_avcsZ
verify_avcr   Zputr   )rU   rw   Zpolicy_typeZ
store_pathZavcsavcs   &&    r/   add_audit_eventZ)SetroubleshootdDBusObject.add_audit_event  s    335a87>7K7K7M{[04M
J ww~~j))fnn  /d  e
 K(C#

]]34 r1   c                    R # r<   r>   )rU   reasonr6   r/   restartZ!SetroubleshootdDBusObject.restart      r1   Zss)Z	signaturec                r   r<   r>   )rU   rG   rH   r   r/   rA   ZSetroubleshootdDBusObject.alert  r   r1   c                s    V P                  ^ 4       V ;P                  ^,          un        \        RV P                  ,          4       \        R4      # )r    z)dbus iface start() called: %d ConnectionsZStarted)r   r   r$   rv   rT   rV   r/   startZSetroubleshootdDBusObject.start  s7    

1=MN|r1   sendersZii)Zsender_keywordin_signatureout_signaturec                s   \        V P                  P                  V4      4      p\        4       pR p. pVP	                  R4      P                  4        F.  pVP                  V4      pVR8w  g   K  VP                  V4       K0  	  VP                  \        R7       ^ p	^ p
V F=  pV	^,          p	VP                  R8X  d
   V
^,          p
VP                  V8X  g   K9  ^ p
^ p	K?  	  W3# )r   r   rl   )Zkeyred)r"   
connectionget_unix_userr?   r   siginfosrr   rF   Zsortcompare_sigrG   rH   )rU   Zlast_seen_idr   r}   rj   r   Z
signaturesrt   r~   Zcountr   s   &&&        r/   check_for_newZ'SetroubleshootdDBusObject.check_for_new  s     = =f EF$&
((-668C11(;F!!!#& 9
 	K(CQJEyyE!q|||+  zr1   c                s   \        V P                  P                  V4      4      p\        4       p\        P
                  P                  \        VR ,          4      4      pVP                  R4      P                  p. pV Fd  p	V	P                  V8  d   K  V	P                  V4      V8X  g   K.  VP                  V	P                  V	P                  4       V	P                  34       Kf  	  V# )@B r   )r"   r   r   r?   r   r   Z	TimeStampZfloatr   signature_listlast_seen_daterr   rF   rH   ru   report_count)
rU   sincer   alert_actionr}   rj   Zsince_alertsdatabase_alertsZalertsrA   s
   &&&&      r/   _get_all_alerts_sinceZ/SetroubleshootdDBusObject._get_all_alerts_since  s     = =f EF$&%**44U57?5KL"//4CC$E##l2--h7<Gu~~u}}@R@RST	 %
 r1   Ztza(ssi)c                s$    V P                  W4      # r<   r   )rU   r   r   r   r/   get_all_alerts_sinceZ.SetroubleshootdDBusObject.get_all_alerts_since  s    ))%88r1   r   c                s&    V P                  ^ V4      # )a  
Return array of *local_id*'s, *summary*'s, and *report_count*'s of all current alerts in a setroubleshoot database

returns list of:
* `local_id(s)`: a report id in a setroubleshoot database
* `summary(s)`: a brief description of an alert. E.g. `"SELinux is preventing /usr/bin/bash from ioctl access on the unix_stream_socket unix_stream_socket."`
* `report_count(i)`: count of reports of this alert
r   rU   r   r6   r/   get_all_alertsZ(SetroubleshootdDBusObject.get_all_alerts  s     ))!V44r1   c                s*    V P                  ^ VRR7      # )a  
Return array of *local_id*'s, *summary*'s, and *report_count*'s of all alerts which a user set to be ignored by a user

returns list of:
* `local_id(s)`: a report id in a setroubleshoot database
* `summary(s)`: a brief description of an alert. E.g. `"SELinux is preventing /usr/bin/bash from ioctl access on the unix_stream_socket unix_stream_socket."`
* `report_count(i)`: count of reports of this alert
rl   )r   r   r   r6   r/   get_all_alerts_ignoredZ0SetroubleshootdDBusObject.get_all_alerts_ignored)  s     ))!V()KKr1   c                s     VP                  V4      pTP                  4       P                  4       pT#   \         d   pThR p?ii ; ir<   )r   r   r   Z__next__)rU   rH   rj   r   erA   s   &&&   r/   
_get_alertZ$SetroubleshootdDBusObject._get_alert5  sL    	&33H=O  ((*335  	G	s   3 AA  Azssiasa(ssssbbi)ttsc                s   \        V P                  P                  V4      4      p\        4       pV P	                  W4      pVP                  4        VP                  P                  pV Uu. uF  qwP                  4       NK  	  ppVP                  4       w  r. pV
 F  w  rVP                  VP                  VP                  Wm4      4      VP                  VP                  Wm4      4      VP                  VP                  Wm4      4      VP                  VP                   VP"                  VP$                  34       K  	  VP&                  VP)                  4       VP*                  Y\-        VP.                  P1                  R4      4      R,          \-        VP2                  P1                  R4      4      R,          VP4                  ;'       g    R3# u upi )ar  
Return an alert with summary, audit events, fix suggestions

##### arguments

* `local_id(s)`: an alert id

##### return values

* `local_id(s)`: an alert id
* `summary(s)`: a brief description of an alert. E.g. `"SELinux is preventing /usr/bin/bash from
  ioctl access on the unix_stream_socket unix_stream_socket."`
* `report_count(i)`: count of reports of this alert
* `audit_event(as)`: an array of audit events (AVC, SYSCALL) connected to the alert
* `plugin_analysis(a(ssssbb)`: an array of plugin analysis structure
 * `if_text(s)`:
 * `then_text(s)`
 * `do_text(s)`
 * `analysis_id(s)`: plugin id. It can be used in `org.fedoraproject.SetroubleshootFixit.run_fix()`
 * `fixable(b)`: True when an alert is fixable by a plugin
 * `report_bug(b)`: True when an alert should be reported to bugzilla
 * `priority(i)`:  An analysis priority. Typically the value is between 1 - 100.
* `first_seen_date(t)`: when the alert was seen for the first time, number of microseconds since the Epoch
* `last_seen_date(t)`: when the alert was seen for the last time, number of microseconds since the Epoch
* `level(s)`: "green", "yellow" or "red"
z%sr   r   )r"   r   r   r?   r   Z%update_derived_template_substitutionsrw   rx   Zto_textZget_pluginsrF   Z
substituteZget_if_textZget_then_textZget_do_textZanalysis_idZfixableZ
report_bugZpriorityrH   ru   r   ZintZfirst_seen_dateZformatr   rG   )rU   rH   r   r}   rj   rA   r   ZeventZaudit_eventsZtotal_priorityZalert_pluginsZpluginsZpluginZargss   &&&           r/   	get_alertZ#SetroubleshootdDBusObject.get_alert=  s|   8   = =f EF$&3335''589SES9(-(9(9(;%)LFNN  !3!3C!>?  !5!5c!@A  !3!3C!>?""!!!  * 1C1CE))0067'AE((//56@!!r	 	 :s   *GZbc                s     \        V P                  P                  V4      4      p\        4       pV P	                  W4      p^ RIHp VP                  VP                  WGV,          R4       R#     R# ; i)z
Sets a filter on an alert. The alert can be "always" filtered, "never" filtered or "after_first" filtered.

##### arguments

* `local_id(s)`: an alert id
* `filter_type(s)`: "always", "never", "after_first"

##### return values

* `success(b)`:
)map_filter_name_to_valueNTF)	r"   r   r   r?   r   setroubleshoot.signaturer   r   rt   )rU   rH   rs   r   r}   rj   rA   r   s   &&&&    r/   r   Z$SetroubleshootdDBusObject.set_filteru  sb    	#DOO$A$A&$IJH(*HOOH7EI		8k5Z\`a	s   A)A- -A2c                s     \        4       pV P                  W4      pVP                  VP                  4       R#     R# ; i)zz
Deletes an alert from the database.

##### arguments

* `local_id(s)`: an alert id

##### return values

* `success(b)`:
TF)r?   r   r   rt   )rU   rH   r   rj   rA   s   &&&  r/   delete_alertZ&SetroubleshootdDBusObject.delete_alert  s<    	(*HOOH7E%%eii0	s   6: ?)r   r   c                s   \        V4      p V ;P                  ^,          un        V P                  ^ 4       \        RWP                  3,          4       V P                  P                  V4       FW  w  r#rEp\        W#WEV4      pVP                  4        V P                  P                  V4       F  pV P                  V4       K  	  KY  	  V P                  P                  ^ 4       F  pV P                  V4       K  	  V ;P                  ^,          un        V P                  V P                  4       \        R4      #   T ;P                  ^,          un        T P                  T P                  4       i ; i)r   z#dbus avc(%s) called: %d Connectionsro   )r9   r   r   r$   r   ZfeedZAuditRecordZaudispd_rectifyr   r   Zflushr   rv   )	rU   r   ry   Zevent_idZ	body_textrz   Zline_numberr   rw   s	   &&       r/   r   ZSetroubleshootdDBusObject.avc  s   4y	%MMQMJJqM;t]]>SSTKOK]K]KbKbcgKhG	;*;)U`a,,.#'#7#7#<#<\#JK((5 $K	 Li  $3399!<$$[1  = MMQMJJt||$x MMQMJJt||$s   C0D< <6E2c                s    V ;P                   ^,          un         \        RV P                   ,          4       V P                  V P                  4       R# )r   z*dbus iface finish() called: %d Connectionsr   )r   r$   r   r   rT   rV   r/   finishZ SetroubleshootdDBusObject.finish  s5    >NO

4<< r1   c                sf    V P                   ^ 8X  g   V^ 8X  d   \        P                  ! V4       R# R# )r    N)r   r*   r   )rU   r   r6   r/   r   ZSetroubleshootdDBusObject.alarm  s%    ==AALL! ".r1   )r   r   r   r   r   r   r   Ni
   )Zdisplay)r_   r`   ra   rb   rW   r   rC   r   r*   rE   r   rA   Zmethodr   r   r   r   r   r   r   r   r   r   r   r   r   rc   rd   re   rg   r/   r   r     s9    
?5  
\\./ 0 
\\.$? @ 
\\./ 0 
\\.xVYimn o0 
\\.xVYiqr9 s9 
\\.xVXhpq	5 r	5 
\\.xVXhpq	L r	L 
\\.xVYi}~5 5n 
\\.xVZjmn o. 
\\.xVYilm n( 
\\.SPST U0 
\\./ 0" "r1   r   c                 s    V P                   # r<   )r   )ZarV   r/   r   r     s    r1   c                   r   )SetroubleshootdDBusi  c                s     \        R \        : R\        : R\        : 24       \	        \        WV4      V n        R#   \         d4   p\        P                  ! \        P                  RT,          4       ThRp?ii ; i)zcreating system dbus: bus_name=z object_path=z interface=z$cannot start system DBus service: %sN)	r$   dbus_system_bus_namerD   rE   r   dbus_obj	Exceptionr2   r3   )rU   r   r   r   r   r   r/   rW   ZSetroubleshootdDBus.__init__  sg    	Ym  pG  I^  _  `56M~ovwDM 	MM&..*PST*TUG	s   9= A;.A66A;c                s<    V P                   P                  R 4       R# )zdaemon requestT)r   r   rT   rV   r/   
do_restartZSetroubleshootdDBus.do_restart  s    ./r1   )r   N)r_   r`   ra   rb   rW   r   rc   rd   re   rg   r/   r   r     s      r1   r   c                 sP    V P                  4        \        P                  ! 4        R # r<   )save	audit2whyr   )rj   rV   r/   goodbyer     s    MMOr1   c                 sD    \        R 4       \        P                  4        R# )z SIGALRM raised in RunFaultServerN)r$   	main_loopZquitr5   r6   r/   alarm_handlerr     s    01NNr1   c           
      s   \         P                  ! V 4       \         P                   ! \         P                  \        4         \        P
                  ! 4        \         P                  ! ^ 4        \         P                   ! \         P                  \        4       \         P                   ! \         P                  \        4        \        P                  ! \        4       \!        \"        4      p\%        RR4      p\'        T4      p\)        TRR4       \+        YC\-        R	4      R
7      s\.        P1                  T4       \2        P4                  ! \6        \.        4       Rp\.        P8                  P:                   EF;  p\        P<                  ! \        TP>                  P@                  4      \        TP>                  PB                  4      \        TP>                  PD                  4      TP>                  PF                  4      w  rxT\        PH                  \        PJ                  \        PL                  \        PN                  \        PP                  \        PR                  39   g   K  T\        PH                  8X  d   Rp	MT\        PJ                  8X  d   Rp	MT\        PL                  8X  d   RTP>                  P@                  ,          p	MT\        PN                  8X  d   RTP>                  PB                  ,          p	M_T\        PP                  8X  d   RTP>                  PD                  ,          p	M,RRPU                  TP>                  PF                  4      ,          p	\        P                  ! \        PV                  RTPX                  : RT	: R24       R p\.        P[                  TP>                  4       EK>  	  T'       d   \.        P]                  R R7       \%        RR\^        4      '       g   \a        \.        4      p
M\c        \.        4      p
^ RI2pTPg                  ^ 4      s4\k        \h        T 4      pTPm                  R 4       TPo                  4        ^ RI8H9p T! 4       s:\)        \v        RR4        \t        Py                  \v        4       \        R4      pT F#  p\        T\        4      pTP                  4        K%  	  \        P                  P                  4        \        \h        Y4      p\        P                  4        R#   \         d   pR\        T4      9   d    Rp?EK  ThRp?i\         d*   pR\        \        TRR4      4      9   d    Rp?EK  ThRp?ii ; i  \z         d8   pTP|                  \~        8X  d   \        TP                  4        Rp?ELThRp?ii ; i  \         d   p\        R4        Rp?R# Rp?i\         d   p\        R4        Rp?R# Rp?i\         ds   p^ RIOp\        TP                  4       4       \        P                  ! \        P                  RTP                  P                  : R\        T4      : 24        Rp?R# Rp?ii ; i)Tz%unable to open /sys/fs/selinux/policyNZ__context__r   rj   Zfilenamei  r   zAudit Listener)Zfriendly_nameFzit is allowedzit is dontaudit'dzsource context %s is undefinedztarget context %s is undefinedzsecurity class %s is undefinedzpermission %s is undefinedZ,zDeleting alert z, z in current policy)ZpruneZtestanalyze)SEEmailRecipientSetZlisten_for_clientz#KeyboardInterrupt in RunFaultServerz$raising SystemExit in RunFaultServerz
exception z: )Ur*   r   ZSIGALRMr7   r   ZinitZ
ValueErrorr9   ZSystemErrorZgetattrr   r+   r0   r2   ZopenlogrO   r   rJ   r   r    r!   r   rv   r=   Z
set_notifyatexitZregisterr   r   r   r   rt   ZscontextZtcontextZtclassr   ZALLOWZ	DONTAUDITZBADSCONZBADTCONZ	BADTCLASSZBADPERMZjoinZ
LOG_NOTICErH   r   r   r{   rh   r   r   ZQueuer   r   Z	setDaemonr   r   r   rq   r   Zparse_recipient_filer   Zerrnor   r$   Zstrerrorr   r   r   r   rC   ZglibZinit_threadsr   r   ZrunZKeyboardInterruptZ
SystemExitr   	tracebackr%   Z
format_excr3   rk   r_   )r   r   Zclient_notifierZdatabase_filenameZdatabase_filepathZdeletedZiZwhyZboolsr   r   r   Zanalyze_threadr   Zlisten_addressesZlisten_addressZlistening_serverZsetroubleshootd_dbusr   s   &                  r/   RunFaultServerr     su   
LL
MM&.."89
	NNLLO& MM&..-0
MM&--,o[ 	x  )9 'z:>23DE)*;UDTU./@=>?O=PR  1/##22A"**3quu~~+>AEENN@SUXYZY^Y^YeYeUfhihmhmhthtuJCy	(;(;Y=N=NPYPaPaclcvcv  yB  yJ  yJ  K  K)//),FI///0FI---=NFI---=NFI///&F&UV9CHHQUU\\<RRFf//^_^h^hjp1qr..quu5# 3$ T* &)T226}EN5mDN 	Q '~w?  & 	A.0)*CUL\]	112KL 77JK.N.~?ef!!# / 			 2>>[u  	 7#a&@G 	
 7#gaXZ>[:\\G	J  	ww-'!**%%		"  9788 :899 [Y))+,fnnAKK<P<PRUVWRX&YZZ[s   +S> FV! !EV! <B0V! -U A6V! >U	T" T""U/U0UUUV'*VV! VVV! !Y,V==Y
YWY)Y*A'YYZ__main__)r   r   r?   rN   r   )i   r>   r   )iZ
__future__r   Z__all__Zgi.repositoryr   r   rC   Zdbus.serviceZ	dbus.glibZgettextr4   r*   r   Zsysr2   Zsystemd.journalr|   r(   r   r   r   r	   ZkwargsZversion_infoZinstallZtranslationZugettextrv   ZAttributeErrorZsetroubleshoot.access_controlr
   Zsetroubleshoot.analyzer   r   r   r   Zsetroubleshoot.avc_auditr   Zsetroubleshoot.errcoder   r   r   r   r   r   r   Zsetroubleshoot.rpcr   r   r   r   Zsetroubleshoot.rpc_interfacesr   r   r   Zsetroubleshoot.utilr   r    r!   r"   r#   r$   r%   r0   r7   r;   r?   r   rD   rE   r   rI   Zrequest_namerN   r=   r   rq   r   rO   rP   rQ   Zinstance_idZobjectr   rJ   rh   r   r   r   Zsetroubleshoot.audit_datar   r   r   r   r   r   r   Zselinux.audit2whyr   r   ZMainLoopr   r   r   r_   r>   r1   r/   <module>r      s   &, (     	   
   C	I1	2y"34		dF9  v # !!,5+/1A
 7& &
 ' , 8& & &" "- -# # # 		 
/ "-< $]MB "=+> ^^
 
  , -
  &w0EF i,M2M2 
*V *: !"
+ 4 +`1j 14[-D-J-R-=[@	2V 	2 ( ~" 3 3 ~"B   %
 MMO	
O[b z w  As   H5 5II