HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/ipaplatform/base/__pycache__/tasks.cpython-39.pyc
a

}�fxD�@s�dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
e�e�Ze�d�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@sreZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd[d!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^dTdU�Z+dVdW�Z,dXdY�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.9/site-packages/ipaplatform/base/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.
        Nr	�r�fstore�
statestorerrr�backup_hostname<sz!BaseTaskNamespace.backup_hostnamecCs
t��dS)zu
        Reloads the systemwide CA store.

        Returns True if the operation succeeded, False otherwise.
        Nr	�rrrr�reload_systemwide_ca_storeFsz,BaseTaskNamespace.reload_systemwide_ca_storecCs:z|�|�r|��WSWnty4t�d�Yn0dS)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�rZca_certsrrr�(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.
        Nr	rrrrr_s	z*BaseTaskNamespace.platform_insert_ca_certscCs8z|��r|��WSWnty2t�d�Yn0dS)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_certsrrrrrrrr�(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.
        Nr	rrrrr|s	z*BaseTaskNamespace.platform_remove_ca_certscCstjS)z@
        Returns the path to the IPA service list file.
        )rZ
SVC_LIST_FILErrrr�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
        Frrrrr�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
        Nr	rrrr�check_selinux_status�sz&BaseTaskNamespace.check_selinux_statuscCs
t��dS)z*Check whether IPv6 kernel module is loadedNr	rrrr�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
        Nr	rrrr�detect_container�sz"BaseTaskNamespace.detect_containercCs
t��dS)zk
        Restores the original hostname as backed up in the
        backup_hostname platform task.
        Nr	rrrr�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
        Nr	)rrrZwas_sssd_installedZwas_sssd_configuredrrr�$restore_pre_ipa_client_configuration�s
z6BaseTaskNamespace.restore_pre_ipa_client_configurationcCs
t��dS)z:
        Sets the NIS domain name to 'nisdomain'.
        Nr	)rZ	nisdomainrrr�
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.
        Nr	)rZsssdZ	mkhomedirrZsudoZsubidrrr�modify_nsswitch_pam_stack�s	z+BaseTaskNamespace.modify_nsswitch_pam_stackcCs
t��dS)zG
        Configure pam stack to allow kerberos authentication.
        Nr	�rrrrr�modify_pam_to_use_krb5�sz(BaseTaskNamespace.modify_pam_to_use_krb5cCsdS)zN
        Check if the flag --no-sssd is supported for client install.
        Trrrrr�is_nosssd_supported�sz%BaseTaskNamespace.is_nosssd_supportedcCsdS)zP
        Check if the flag --mkhomedir is supported for client install.
        Trrrrr�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.
        Nr	�r�pathrrr�backup_auth_configuration�sz+BaseTaskNamespace.backup_auth_configurationcCs
t��dS)zt
        Restore backup of access control configuration.
        :param path: restore the backup from here.
        Nr	r,rrr�restore_auth_configuration�sz,BaseTaskNamespace.restore_auth_configurationcCsdS)z@
        Migrate pam stack configuration to authselect.
        Nrr(rrr�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.
        Nr	)rZrequired_settingsZbackup_funcrrr�set_selinux_booleans�sz&BaseTaskNamespace.set_selinux_booleanscCst|�S)z�
        :param version: textual version
        :return: object implementing proper __cmp__ method for version compare
        r)�versionrrr�parse_ipa_versionsz#BaseTaskNamespace.parse_ipa_versioncCs
t��dS)z}
        Set hostname for the system

        No return value expected, raise CalledProcessError when error occurred
        Nr	)r�hostnamerrr�set_hostnameszBaseTaskNamespace.set_hostnamecCs
t��dS)z(Configure httpd service to work with IPANr	rrrr� configure_httpd_service_ipa_confsz2BaseTaskNamespace.configure_httpd_service_ipa_confcCs
t��dS�Nr	)rZipauserrrr�configure_http_gssproxy_conf#sz.BaseTaskNamespace.configure_http_gssproxy_confcCs
t��dS)z,Remove configuration of httpd service of IPANr	rrrr�remove_httpd_service_ipa_conf&sz/BaseTaskNamespace.remove_httpd_service_ipa_confcCs
t��dS)z)Configure WSGI for correct Python versionNr	rrrr�configure_httpd_wsgi_conf*sz+BaseTaskNamespace.configure_httpd_wsgi_confcCs
t��dS)z!Configure TLS protocols in ApacheNr	rrrr�configure_httpd_protocol.sz*BaseTaskNamespace.configure_httpd_protocolcCsdS)NFrrrrr�is_fips_enabled2sz!BaseTaskNamespace.is_fips_enabledc
Csnt�d||�tjdd||g}zt�|�t�d�Wn2tjyh}zt�d|�WYd}~n
d}~00dS)NzAdding user %s to group %sz-az-GzDone adding user to groupzFailed to add user to group: %s)r�debugrZUSERMODr�runZCalledProcessError)r�user�group�args�errr�add_user_to_group5s
z#BaseTaskNamespace.add_user_to_groupcCs
t��dSr7r	rrrr�setup_httpd_logging>sz%BaseTaskNamespace.setup_httpd_loggingcCst�dS)z#Tell systemd to reload config filesNr	rrrr�systemd_daemon_reloadAsz'BaseTaskNamespace.systemd_daemon_reload)�resolve1_enabledrc	Cs�|r�ddlm}tj�tj�}tj�|�sNt�|�t�	|d�|j
|dd�tjd�
|�d�}ttjd��*}t�|��d	�|�|�Wd
�n1s�0Y|j
tjdd�|d��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�N�systemd-resolved)�ipaplatform.servicesrH�osr-�dirnamer�SYSTEMD_RESOLVED_IPA_CONF�isdir�mkdir�chmodr�RESOLVE1_IPA_CONF�format�join�open�fchmod�fileno�write�reload_or_restart)	rZnameserversrJrFrrHZconfdZcfg�frrr�configure_dns_resolverEs"	
�(�z(BaseTaskNamespace.configure_dns_resolvercCsb|dur |�tj�r |�tj�tj�tj�r^ddlm	}t�
tj�|d��t�
tj�dS)zxUnconfigure global DNS resolver (e.g. /etc/resolv.conf)

        :param fstore: optional file store for restore
        NrrGrL)�has_filerZRESOLV_CONFZrestore_filerNr-�isfilerPrMrH�unlinkr[rZremove_directoryZSYSTEMD_RESOLVED_CONF_DIR)rrrHrrr�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.
        Nr	�rrrrr�configure_pkcs11_modulesvsz*BaseTaskNamespace.configure_pkcs11_modulescCst�dS)z/Restore global p11-kit modules for NSS
        Nr	rbrrr�restore_pkcs11_modules�sz(BaseTaskNamespace.restore_pkcs11_modulescCsdS)z=Return the list of module config files setup by IPA.
        rrrrrr�get_pkcs11_modules�sz$BaseTaskNamespace.get_pkcs11_modulesrc
s|�tj�s|�tj�td�}|�d�|r�ttjd��,}|�|�}	|�|	d|�d}
Wd�n1sl0Y|
s�t	|��n|
d�
�����fdd	�|D�}|r�d
d
��|�}q�d
d
�|��}nd
d
�|�}|�
||�|��g}	|�tj|	�t�d|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|]}|�vr|�qSrr)�.0�s�Zconfigured_servicesrr�
<listcomp>�s�zABaseTaskNamespace.configure_nsswitch_database.<locals>.<listcomp>rIzConfigured %s in %s)r^r�
NSSWITCH_CONFZbackup_filer�setOptionAssignmentrW�parseZfindOpts�list�strip�splitrVZ	setOptionZ	emptyLine�
changeConfr�info)
rrZdatabaseZservicesZpreserve�append�
default_value�confr\�optsZraw_database_entryZadded_servicesZ	new_valuerrmr�configure_nsswitch_database�s6

0
��
�

�z-BaseTaskNamespace.configure_nsswitch_databasecCs|j|ddgdgd�dS)z,Configure nsswitch.conf to use sssd for sudoZsudoersZsss�files)rxN)r{rbrrr�enable_sssd_sudo�s�z"BaseTaskNamespace.enable_sssd_sudocCs�|�dd�durVtd�}|�d�|�d�g}|�tj|�|�tj�|�dd�nl|�dd�dur�|�dd�}ddd	|d
�ddd�g}td�}|�d�|�tj|�|�tj�|�dd�dS)
zDisable automount using LDAPzipa-client-automount-nsswitchzprevious-automountFzIPA automount installerrfZ	automountNrh�set)�name�type�actionrj�empty)rr�)	Z	get_staterrpZrmOptionrurrorZdelete_state)rrryZchangesZ	nss_valuerzrrr�disable_ldap_automount�sF��
������	
�z(BaseTaskNamespace.disable_ldap_automount)F)TF)N)N)TTr).�__name__�
__module__�__qualname__rrrrrrrrr r!r"r#r$r%r&r'r)r*r+r.r/r0r1�staticmethodr3r5r6r8r9r:r;r<rCrDrEr]rarcrdrer{r}r�rrrrr3s^

	
�


	�!
�
Hr)�__doc__Z
__future__rrNZlogging�textwrapZ
pkg_resourcesrZipaplatform.pathsrZ	ipapythonrZipapython.ipachangeconfrZ	getLoggerr�r�dedentrTrZtasksrrrr�<module>s


R