HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/ipaplatform/base/__pycache__/tasks.cpython-36.opt-1.pyc
3

�d[e2D�@s�dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
eje�Zejd�ZGd	d
�d
�Ze�ZdS)zQ
This module contains default platform-specific implementations of system tasks.
�)�absolute_importN)�
parse_version)�paths)�ipautil)�
IPAChangeConfz�
    # auto-generated by IPA installer
    [Resolve]
    # use local BIND instance
    DNS=127.0.0.1
    # make local BIND default DNS server, add search suffixes
    Domains=~. {searchdomains}
c@sxeZdZdYdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdZd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd[d0d1�Zed2d3��Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dd/dH�dIdJ�Z&d\dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*d d ffdSdT�Z+dUdV�Z,dWdX�Z-d/S)]�BaseTaskNamespaceFcCs
t��dS)zcRestore SELinux security context on the given filepath.

        No return value expected.
        N)�NotImplementedError)�self�filepath�force�r�/usr/lib/python3.6/tasks.py�restore_context5sz!BaseTaskNamespace.restore_contextcCs
t��dS)z�
        Backs up the current hostname in the statestore (so that it can be
        restored by the restore_hostname platform task).

        No return value expected.
        N)r)r	�fstore�
statestorerrr
�backup_hostname<sz!BaseTaskNamespace.backup_hostnamecCs
t��dS)zu
        Reloads the systemwide CA store.

        Returns True if the operation succeeded, False otherwise.
        N)r)r	rrr
�reload_systemwide_ca_storeFsz,BaseTaskNamespace.reload_systemwide_ca_storecCs:y|j|�r|j�SWntk
r4tjd�YnXdS)z�
        Adds CA certificates from 'ca_certs' to the systemwide CA store
        (if available on the platform).

        Returns True if the operation succeeded, False otherwise.
        z&Could not populate systemwide CA storeF)�platform_insert_ca_certsr�	Exception�logger�	exception)r	�ca_certsrrr
�(insert_ca_certs_into_systemwide_ca_storeOs
z:BaseTaskNamespace.insert_ca_certs_into_systemwide_ca_storecCs
t��dS)z�
        Platform implementations override this method to implement
        population of the systemwide CA store.

        Returns True if changes were made to the CA store, False otherwise.

        Raises Exception if something went wrong.
        N)r)r	rrrr
r_s	z*BaseTaskNamespace.platform_insert_ca_certscCs8y|j�r|j�SWntk
r2tjd�YnXdS)z�
        Removes IPA CA certificates from the systemwide CA store
        (if available on the platform).

        Returns True if the operation succeeded, False otherwise.
        z6Could not remove certificates from systemwide CA storeF)�platform_remove_ca_certsrrrr)r	rrr
�(remove_ca_certs_from_systemwide_ca_storejsz:BaseTaskNamespace.remove_ca_certs_from_systemwide_ca_storecCs
t��dS)a

        Platform implementations override this method to implement
        removal of certificates from the systemwide CA store.

        Returns True if changes were made to the CA store, False otherwise.

        Raises Exception if something went wrong.
        N)r)r	rrr
r|s	z*BaseTaskNamespace.platform_remove_ca_certscCstjS)z@
        Returns the path to the IPA service list file.
        )rZ
SVC_LIST_FILE)r	rrr
�get_svc_list_file�sz#BaseTaskNamespace.get_svc_list_filecCsdS)zmCheck if SELinux is available and enabled

        :return: True if SELinux is available and enabled
        Fr)r	rrr
�is_selinux_enabled�sz$BaseTaskNamespace.is_selinux_enabledcCs
t��dS)a�Checks if SELinux is available on the platform.

        If it is, this task also makes sure that restorecon tool is available.

        If SELinux is available, but restorcon tool is not installed, raises
        an RuntimeError, which suggest installing the package containing
        restorecon and rerunning the installation.

        :return: True if SELinux is available and enabled
        N)r)r	rrr
�check_selinux_status�sz&BaseTaskNamespace.check_selinux_statuscCs
t��dS)z*Check whether IPv6 kernel module is loadedN)r)r	rrr
�check_ipv6_stack_enabled�sz*BaseTaskNamespace.check_ipv6_stack_enabledcCst�dS)zsCheck if running inside a container

        :returns: container runtime or None
        :rtype: str, None
        N)r)r	rrr
�detect_container�sz"BaseTaskNamespace.detect_containercCs
t��dS)zk
        Restores the original hostname as backed up in the
        backup_hostname platform task.
        N)r)r	rrrrr
�restore_hostname�sz"BaseTaskNamespace.restore_hostnamecCs
t��dS)z�
        Restores the pre-ipa-client configuration that was modified by the
        following platform tasks:
            modify_nsswitch_pam_stack
            modify_pam_to_use_krb5
        N)r)r	rrZwas_sssd_installedZwas_sssd_configuredrrr
�$restore_pre_ipa_client_configuration�s
z6BaseTaskNamespace.restore_pre_ipa_client_configurationcCs
t��dS)z:
        Sets the NIS domain name to 'nisdomain'.
        N)r)r	Z	nisdomainrrr
�
set_nisdomain�szBaseTaskNamespace.set_nisdomainTcCs
t��dS)z�
        If sssd flag is true, configure pam and nsswitch so that SSSD is used
        for retrieving user information and authentication.

        Otherwise, configure pam and nsswitch to leverage pure LDAP.
        N)r)r	ZsssdZ	mkhomedirrZsudoZsubidrrr
�modify_nsswitch_pam_stack�s	z+BaseTaskNamespace.modify_nsswitch_pam_stackcCs
t��dS)zG
        Configure pam stack to allow kerberos authentication.
        N)r)r	rrrr
�modify_pam_to_use_krb5�sz(BaseTaskNamespace.modify_pam_to_use_krb5cCsdS)zN
        Check if the flag --no-sssd is supported for client install.
        Tr)r	rrr
�is_nosssd_supported�sz%BaseTaskNamespace.is_nosssd_supportedcCsdS)zP
        Check if the flag --mkhomedir is supported for client install.
        Tr)r	rrr
�is_mkhomedir_supported�sz(BaseTaskNamespace.is_mkhomedir_supportedcCs
t��dS)z�
        Create backup of access control configuration.
        :param path: store the backup here. This will be passed to
        restore_auth_configuration as well.
        N)r)r	�pathrrr
�backup_auth_configuration�sz+BaseTaskNamespace.backup_auth_configurationcCs
t��dS)zt
        Restore backup of access control configuration.
        :param path: restore the backup from here.
        N)r)r	r'rrr
�restore_auth_configuration�sz,BaseTaskNamespace.restore_auth_configurationcCsdS)z@
        Migrate pam stack configuration to authselect.
        Nr)r	rrrr
�migrate_auth_configuration�sz,BaseTaskNamespace.migrate_auth_configurationNcCs
t��dS)atSet the specified SELinux booleans

        :param required_settings: A dictionary mapping the boolean names
                                  to desired_values.
                                  The desired value can be 'on' or 'off',
                                  or None to leave the setting unchanged.

        :param backup_func: A function called for each boolean with two
                            arguments: the name and the previous value

        If SELinux is disabled, return False; on success returns True.

        If setting the booleans fails,
        an ipapython.errors.SetseboolError is raised.
        N)r)r	Zrequired_settingsZbackup_funcrrr
�set_selinux_booleans�sz&BaseTaskNamespace.set_selinux_booleanscCst|�S)z�
        :param version: textual version
        :return: object implementing proper __cmp__ method for version compare
        )r)�versionrrr
�parse_ipa_versionsz#BaseTaskNamespace.parse_ipa_versioncCs
t��dS)z}
        Set hostname for the system

        No return value expected, raise CalledProcessError when error occurred
        N)r)r	Zhostnamerrr
�set_hostnameszBaseTaskNamespace.set_hostnamecCs
t��dS)z(Configure httpd service to work with IPAN)r)r	rrr
� configure_httpd_service_ipa_confsz2BaseTaskNamespace.configure_httpd_service_ipa_confcCs
t��dS)N)r)r	Zipauserrrr
�configure_http_gssproxy_conf#sz.BaseTaskNamespace.configure_http_gssproxy_confcCs
t��dS)z,Remove configuration of httpd service of IPAN)r)r	rrr
�remove_httpd_service_ipa_conf&sz/BaseTaskNamespace.remove_httpd_service_ipa_confcCs
t��dS)z)Configure WSGI for correct Python versionN)r)r	rrr
�configure_httpd_wsgi_conf*sz+BaseTaskNamespace.configure_httpd_wsgi_confcCs
t��dS)z!Configure TLS protocols in ApacheN)r)r	rrr
�configure_httpd_protocol.sz*BaseTaskNamespace.configure_httpd_protocolcCsdS)NFr)r	rrr
�is_fips_enabled2sz!BaseTaskNamespace.is_fips_enabledcCsltjd||�tjdd||g}ytj|�tjd�Wn0tjk
rf}ztjd|�WYdd}~XnXdS)NzAdding user %s to group %sz-az-GzDone adding user to groupzFailed to add user to group: %s)r�debugrZUSERMODrZrunZCalledProcessError)r	�user�group�args�errr
�add_user_to_group5s
z#BaseTaskNamespace.add_user_to_groupcCs
t��dS)N)r)r	rrr
�setup_httpd_logging>sz%BaseTaskNamespace.setup_httpd_loggingcCst�dS)z#Tell systemd to reload config filesN)r)r	rrr
�systemd_daemon_reloadAsz'BaseTaskNamespace.systemd_daemon_reload)�resolve1_enabledrc	Cs�|r�ddlm}tjjtj�}tjj|�sNtj|�tj	|d�|j
|dd�tjdj
|�d�}ttjd�� }tj|j�d	�|j|�Wd
QRX|j
tjdd�|dj�d
S)aConfigure global DNS resolver (e.g. /etc/resolv.conf)

        :param nameservers: list of IP addresses
        :param searchdomains: list of search domaons
        :param resolve1_enabled: is systemd-resolved enabled?
        :param fstore: optional file store for backup
        r)�
knownservicesi�T)r� )�
searchdomains�wi�Nzsystemd-resolved)�ipaplatform.servicesr>�osr'�dirnamer�SYSTEMD_RESOLVED_IPA_CONF�isdir�mkdir�chmodr�RESOLVE1_IPA_CONF�format�join�open�fchmod�fileno�write�reload_or_restart)	r	Znameserversr@r=rr>ZconfdZcfg�frrr
�configure_dns_resolverEs	
z(BaseTaskNamespace.configure_dns_resolvercCsV|dk	r |jtj�r |jtj�tjjtj�rRddlm	}tj
tj�|dj�dS)zxUnconfigure global DNS resolver (e.g. /etc/resolv.conf)

        :param fstore: optional file store for restore
        Nr)r>zsystemd-resolved)�has_filerZRESOLV_CONFZrestore_filerCr'�isfilerErBr>�unlinkrP)r	rr>rrr
�unconfigure_dns_resolverfsz*BaseTaskNamespace.unconfigure_dns_resolvercCst�dS)a�Disable p11-kit modules

        The p11-kit configuration injects p11-kit-proxy into all NSS
        databases. Amongst other p11-kit loads SoftHSM2 PKCS#11 provider.
        This interferes with 389-DS, certmonger, Dogtag and other services.
        For example certmonger tries to open OpenDNSSEC's SoftHSM2 token,
        although it doesn't use it at all. It also breaks Dogtag HSM support
        testing with SoftHSM2.

        IPA server does neither need nor use SoftHSM2 proxied by p11-kit.
        N)r)r	rrrr
�configure_pkcs11_modulesusz*BaseTaskNamespace.configure_pkcs11_modulescCst�dS)z/Restore global p11-kit modules for NSS
        N)r)r	rrrr
�restore_pkcs11_modules�sz(BaseTaskNamespace.restore_pkcs11_modulescCsfS)z=Return the list of module config files setup by IPA.
        r)r	rrr
�get_pkcs11_modules�sz$BaseTaskNamespace.get_pkcs11_modulesc
s|jtj�s|jtj�td�}|jd�|r�ttjd��"}|j|�}	|j|	d|�d}
WdQRX|
spt	|��n|
dj
�j���fdd	�|D�}|r�d
d
j�|�}q�d
d
j|��}nd
d
j|�}|j
||�|j�g}	|jtj|	�tjd|tj�dS)ac
        Edits the specified nsswitch.conf database (e.g. passwd, group,
        sudoers) to use the specified service(s).

        Arguments:
            fstore - FileStore to backup the nsswitch.conf
            database - database configuration that should be ammended,
                       e.g. 'sudoers'
            service - list of services that should be added, e.g. ['sss']
            preserve - if True, the already configured services will be
                       preserved

        The next arguments modify the behaviour if preserve=True:
            append - if True, the services will be appended, if False,
                     prepended
            default_value - list of services that are considered as default (if
                            the database is not mentioned in nsswitch.conf),
                            e.g. ['files']
        z
IPA Installer�:�r�option�N�valuecsg|]}|�kr|�qSrr)�.0�s)�configured_servicesrr
�
<listcomp>�szABaseTaskNamespace.configure_nsswitch_database.<locals>.<listcomp>r?zConfigured %s in %s)rSr�
NSSWITCH_CONFZbackup_filer�setOptionAssignmentrL�parseZfindOpts�list�strip�splitrKZ	setOptionZ	emptyLine�
changeConfr�info)
r	rZdatabaseZservicesZpreserve�append�
default_value�confrQ�optsZraw_database_entryZadded_servicesZ	new_valuer)rar
�configure_nsswitch_database�s.




z-BaseTaskNamespace.configure_nsswitch_databasecCs|j|ddgdgd�dS)z,Configure nsswitch.conf to use sssd for sudoZsudoersZsss�files)rlN)ro)r	rrrr
�enable_sssd_sudo�sz"BaseTaskNamespace.enable_sssd_sudocCs�|jdd�dkrVtd�}|jd�|jd�g}|jtj|�|jtj�|jdd�nl|jdd�dk	r�|jdd�}ddd	|d
�ddd�g}td�}|jd�|jtj|�|jtj�|jdd�dS)
zDisable automount using LDAPzipa-client-automount-nsswitchzprevious-automountFzIPA automount installerrZZ	automountNr\�set)�name�type�actionr^�empty)rsrt)	Z	get_staterrdZrmOptionrirrcrZdelete_state)r	rrmZchangesZ	nss_valuernrrr
�disable_ldap_automount�s4


z(BaseTaskNamespace.disable_ldap_automount)F)TF)N)N).�__name__�
__module__�__qualname__rrrrrrrrrrrrr r!r"r#r$r%r&r(r)r*r+�staticmethodr-r.r/r0r1r2r3r4r:r;r<rRrVrWrXrYrorqrwrrrr
r3sV

	



	 
Fr)�__doc__Z
__future__rrCZlogging�textwrapZ
pkg_resourcesrZipaplatform.pathsrZ	ipapythonrZipapython.ipachangeconfrZ	getLoggerrxr�dedentrIrZtasksrrrr
�<module>s 
Q