3 Qf.S#@sddlmZyddlmZejWn YnXddddddgZdd lZdd lZdd lZydd l m Z Wn e k rdd l m Z YnXdd l Z d aejjd d d Zddddd ddddddddddddddd dddddddddddddddd dddddddd d d!d"did#d$dd%d&dd'd(dd)d*d+ddid,dddd-dddd.dddd/d,dddd-dddd.dddd/d0ddd ddd1d2ddd3dd4d5d6ddiejjd7d8dddd9d:dd;ejjd7d8dddddddd?d@dAddBdCddDdEd@dFdidGdHddIdJddKdLdMddNdOddPdQddRdSdejjd0dTdUddVdWdXddYdZdd[d\d]d^ddid_Zd`dZdadbZd{dcddZd|dedZd}dfdZdgdZe jdhZdidZdjdZd~dkdlZdmdnZedokrdpdqZ y$ejej!drd dsdtdug\Z"Z#Wn(ej$k rle ej%dvYnXdZ&x8e"D]0\Z'Z(e'dkrdZ&e'dkrxe ej%qxWe&reened S))print_function)standard_library config_init get_config get_option set_configparse_config_settingconfig_has_sectionN)SafeConfigParserz/etc/setroubleshootz%s.confZsetroubleshootz/var/run/setroubleshootd.pidF)value descriptionreadOnlyTz3.3.26z https://pagure.io/setroubleshootzURL of project website)r r z1.1z/internationalization (i18n) translation catalogz/usr/share/localez9internationalization (i18n) translation catalog directoryzutf-8z.internationalization (i18n) encoding (codeset)z/usr/share/setroubleshootZsetroubleshoot_icon) Zpid_fileZpkg_nameZ pkg_versionZ project_urlZ rpc_versionZi18n_text_domainZi18n_locale_dirZ i18n_encodingZdata_dirZ config_dirZ icon_nameZweb_browser_launcherz/usr/bin/xdg-openz1Helper application to launch web browser on a URLz/var/run/audit_eventszLunix domain socket used to listen for audit messages (binary audit protocol)z/var/run/audispd_eventszNunix domain socket used to listen for audit messages (textural audit protocol)Z60zgnumber of seconds to wait before trying to connect to audit socket again in the event of socket failure)Zbinary_protocol_socket_pathZtext_protocol_socket_pathZretry_intervalZ plugin_dirz!/usr/share/setroubleshoot/pluginsz!org.fedoraproject.Setroubleshootdz"/org/fedoraproject/Setroubleshootdz&org.fedoraproject.SetroubleshootdIface)Zbus_nameZ object_pathZ interfacez/var/lib/setroubleshootZ50z Keep no more than this many alerts in the database. Oldest alerts based on the alert's last seen date will be purged first. Zero implies no limita; Purge any alerts whose age based on its last seen date exceeds this threshold. Age may be specified as a sequence of integer unit pairs. Units may be one of year,month,week,day,hour,minute,second and may optionally be plural. Example: '2 weeks 1 day' sets the threshold at 15 days. An empty string implies no limit)Z database_dirfilenameZ max_alertsZ max_alert_ageZ default_portZ69783z/var/run/setroubleshootZsetroubleshoot_serverz{unix}%(path)sa_ List of socket addresses server should listen on for client connections. Addresses should not contain any whitespace. Each address is of the form "[{family}]address[:port]" where [] indicates the value is optional. Valid values for family are inet or unix, if the family is absent it defaults to inet. If the family is unix the address is interpreted as a file path. If the family is inet the address is interpreted as either a host name or IP address. As a special case if the inet address is "hostname" the current hostname will be substituted. If the family is inet the address may optionally be followed by a colon (:) and a port number. If the port number is absent in the address it defaults to the port specified in this config section. Example, to listen on the local unix domain socket and provide remote connections use this "{unix}%(path)s, hostname" )pathZ address_listz{unix}%(path)s hostnameZ20485)Zbuf_sizeZtimeoutZwarningz setroubleshootd logging level. Levels are the same as in the python logging module, but are case insenstive. The defined levels in severity order are:[CRITICAL, ERROR, WARNING, INFO, DEBUG]Truez/True|False, log full report analysis to journal)levelZlog_full_reportrz sealert logging level. Levels are the same as in the python logging module, but are case insenstive. The defined levels in severity order are: [CRITICAL, ERROR, WARNING, INFO, DEBUG]*z Comma-separated list of users allowed to run the client and connect to the local fault server and therefore see security denials. Also accepts '*' to allow all users to connect.roota| Comma-separated list of users allowed to run the fix commands with root privileges. Members of this list can execute the fix commands specified in any alert. The command is executed with root privileges so you should be very caeful who you add to this list as you are granting them significant power to alter the security settings of this system. The wildcard '*' is NOT allowed.)Z client_usersZ fix_cmd_usersZ localhostzThe SMTP server addressZ25zThe SMTP server portZSELinux_TroubleshootzThe From: email headerzSELinux AVC AlertzThe Subject: email headerZemail_alert_recipientsz{Path name of file with email recipients. One address per line, optionally followed by enable flag. Comment character is #. )Z smtp_hostZ smtp_portZ from_addressZsubjectZrecipients_filepathz&https://pagure.io/docs/setroubleshoot/zURL to user help informationz1http://bugzilla.redhat.com/bugzilla/enter_bug.cgizURL used to report bugs)Zhelp_urlZbug_report_urlZanalyzeFalsezPrint plugin report)ZgeneralZ helper_appsZauditZpluginsZ session_dbusZ system_dbusZdatabaseZ connectionZlisten_for_clientZclient_connect_toZsocketZsetroubleshootd_logZ sealert_logaccessZemailhelpZtestcCs ttadS)N)read_configurationdefaults_cfgrr/usr/lib/python3.6/config.pyrZsc Cst}y|jtWn6tk rJ}ztdt|ftjddSd}~XnXt|j}x|D]}|j |sv|j |xtt||j D]`\}}|d}|j dd}|j ||s|j|||q|rtd||ftjd|j|||qWq^W|S)Nz"error parsing config file (%s): %s)filer rFz*error [%s] %s cannot be set in config file)r readCFG_FILE Exceptionprintsysstderrlistkeys has_section add_sectionitemsgetZ has_optionset) rcfgeZdefault_sectionsZdefault_sectionZdefault_option propertiesr rrrrr_s&      rcCs\y|dks|tkr|S|tkr(t|S|tkr~t|tr>|St|trPt|S|jdkr`dS|jdkrpd Std |nf|tkrt|S|dkr|Syddlm}|j d||Wn*t k rt d||ft j dYnXWnptk rV}zRyddlm}|j d||Wn,t k rDt d||ft j dYnXWYdd}~XnXdS)NtruetyesyonTfalsefnonoffFzcannot convert %s to booleanrawr)log_cfgzunknown type %s for option %sz#error unknown type %s for option %s)r)r/r0r1r2r3)r4r5r6r7r8)strintbool isinstancelower ValueErrorfloatsetroubleshoot.logr:error ImportErrorr"r#r$r!)r cfg_typer:r-rrrconvert_cfg_typezs<       rFcCsFd}|dk r"||kr"t||}nt|r6t|||}|dkrB|}|S)N)rFr r)sectionnameZ default_valuekwdsZ option_typer rrrrs cCsFtdkr dSy|dks|tkr*tj||S|tkr>tj||S|tkrRtj||S|tkrftj||S|dkr~tj||ddSy ddl m }|j d|||Wn,t k rt d|||ftjdYnXWnrtk r@}zTy ddl m }|j d |||Wn.t k r0t d |||ftjdYnXdSd}~XnXdS) Nr9T)r9r)r:z5unknown type = %s getting %s option in %s section: %sz;error unknown type = %s getting %s option in %s section: %s)rz&cannot get %s option in %s section: %sz,error cannot get %s option in %s section: %s)rr;r*r<Zgetintr=Z getbooleanrAZgetfloatrBr:rCrDr"r#r$r!)rGoptionrEr:r-rrrrs2     " cCshy2tdkrdStj|s"tj|tj|||Wn0tk rb}ztjd|||dSd}~XnXdS)NFz6Cannot set config: section='%s' option='%s' value='%s'T)rr'r(r+r!Z log_programZ exception)rGrJr r-rrrrs  z%([^.=]+?)\s*\.\s*([^.=]+?)\s*=\s*(.*)cCstj|}|r.|jd}|jd}|jd}nHyddlm}|jd|Wn&tk rptd|tj dYnXd Sy ddlm}|j d |||Wn,tk rtd |||ftj dYnXt |||d S) Nr)r:z4could not parse '%s', must be 'section.option=value'z;error: could not parse '%s', must be 'section.option=value')rFz3setting config: section='%s' option='%s' value='%s'T) config_setting_researchgrouprBr:rCrDr"r#r$debugr)Z cfg_settingmatchrGrJr r:rrrrs$       cCstdkr dSy tj|Stk r}zNyddlm}|jd||Wn*tk rptd||ftj dYnXdSd}~XnXdS)Nr)r:zconfig_has_section(%s): %sz!error: config_has_section(%s): %s)rF) rr'r!rBr:rCrDr"r#r$)rGr-r:rrrr s  c Cs$ddl}|jdddd}t|j}|jx|D]}d}x:t||jD]&\}}|jdd} |sj| rL|d7}qLW|dkr2td|xt||jD]|\}}|d } |jdd} |jd d } | r| rq| sd } t|jd || | rtd| ntd|| ftqWq2WdS)NrNz# )widthZinitial_indentZsubsequent_indentrFrKz[%s]r r r zNo Description Availablez%s: z# READ ONLY, default = "%s"z%s = %s) textwrapZ TextWrapperr%r&sortr)r*r"Zfill) rZ showReadOnlyrUZwrapsectionsrGZvisibleOptionsrJr.rr r rrr dump_defaults s4          rXcCsd|j}|jxN|D]F}|j|}|jx(|D] }t||}td|||fq2WtqWdS)Nz [%s] %s = %s)rWrVoptionsrr")r,rWrGrYrJr rrrdump_configuration+s    rZ__main__cCs tddS)Nz5 -d generate default config file -h help )r"rrrrusage;sr\rKZdhrrrL-d --defaults-h--help)N)NNN)N)F)r]r^)r_r`))Z __future__rZfuturerZinstall_aliases__all__Zgetoptr#osZ configparserr rDZ ConfigParserrerrjoinr rrrrFrrrcompilerNrr rXrZ__name__r\argvZoptsargsZ GetoptErrorexitZdo_dump_defaultsoarrrrsN                   & "  ! $