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/redhat/__pycache__/authconfig.cpython-39.pyc
a

}�f>4�@s�ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlZddlZgd�Z
e�e�Zdd�Ze�ej�Gd	d
�d
��ZGdd�de�ZGd
d�de�ZdS)�)�absolute_importN)�paths)�ipautil)�ScriptError)�passwd�groupZshadowZgshadowcCst�S�N)�RedHatAuthSelect�r
r
�A/usr/lib/python3.9/site-packages/ipaplatform/redhat/authconfig.py�
get_auth_tool%src@sTeZdZejd
dd��Zejdd��Zejdd��Zejdd	��Zejd
d��Z	dS)�RedHatAuthToolBaseTcCsdSrr
��self�sssd�	mkhomedir�
statestore�sudor
r
r�	configure,szRedHatAuthToolBase.configurecCsdSrr
�r�fstorer�was_sssd_installed�was_sssd_configuredr
r
r�unconfigure0szRedHatAuthToolBase.unconfigurecCsdS)z�
        Backup the system authentication resources configuration
        :param path: directory where the backup will be stored
        Nr
�r�pathr
r
r�backup6szRedHatAuthToolBase.backupcCsdS)z�
        Restore the system authentication resources configuration from a backup
        :param path: directory where the backup is stored
        Nr
rr
r
r�restore=szRedHatAuthToolBase.restorecCsdSrr
�r�	nisdomainr
r
r�
set_nisdomainDsz RedHatAuthToolBase.set_nisdomainN)T)
�__name__�
__module__�__qualname__�abc�abstractmethodrrrrr r
r
r
rr
)s


r
c@sHeZdZdd�Zddd�Zddd	�Zd
d�Zdd
�Zdd�Zdd�Z	dS)r	cCsBzt�tjddg�}Wn tjy6t�d�YdS0|j��S)N�currentz--rawz/Current configuration not managed by authselect)	r�runr�
AUTHSELECT�CalledProcessError�logger�debugZ
raw_output�decode)rr&r
r
r�_get_authselect_current_outputKs
�
z/RedHatAuthSelect._get_authselect_current_outputNcCsR|dur|��}|durdS|��}|s,dS|�d�}|d}|dd�}||fS)z�
        Parses the output_text to extract the profile and options.
        When no text is provided, runs the 'authselect profile' command to
        generate the text to be parsed.
        N� r�)r-�strip�split)rZoutput_textZoutput_items�profile�featuresr
r
r�_parse_authselect_outputUs
z)RedHatAuthSelect._parse_authselect_outputTFcCs�d�t�d��}|�dd|�tjddg}|rF|�d�|�ddd	�|rT|�d
�|rb|�d�|�d�|�d
�|��t�|�dS)Nzpre_ipaclient_{}z%Y%m%d%H%M%S�
authselectr�selectrzwith-mkhomedirrTz	with-sudoz
with-subid�--forcez--backup={})	�format�time�strftime�backup_staterr(�appendrr')rrrrrZsubidZbackup_name�cmdr
r
rrhs



zRedHatAuthSelect.configurec
Cs<|�dd�}|dur&|s&|�d�s&dS|�d�stt�d�t�}|�||||�|��}t�dd�|��d}g}	np|�dd�}|s�d}|�dd	�}
|�	dd
�|�
tj�r�t�
d�|�tj�|
dur�dd
�|
�d�D�}	ng}	|�dd�}|�rtjd|g}t�|�n*tjd|g}|�|	�|�d�t�|�dS)NZinstallation�completer5z�WARNING: Unable to revert to the pre-installation state ('authconfig' tool has been deprecated in favor of 'authselect'). The default sssd profile will be used instead.z7The authconfig arguments would have been: authconfig %sr.rr2Z
features_listrzRestoring user-nsswitch.confcSsg|]}|��r|���qSr
)r0��.0�fr
r
r�
<listcomp>�sz0RedHatAuthSelect.unconfigure.<locals>.<listcomp>rzbackup-restorer6r7)Z	get_state�	has_stater*Zwarning�RedHatAuthConfig�prepare_unconfigure�
build_args�join�
restore_stateZdelete_stateZhas_filerZ
NSSWITCH_CONF�infoZrestore_filer1r(rr'�extendr<)
rrrrrr>�
authconfig�argsr2r3Zfeatures_staterr=r
r
rr�sV�
�	���
�

zRedHatAuthSelect.unconfigurecCsl|��}|durdStj�|�s*t�|�ttj�|d�d��}|�|�Wd�n1s^0YdS)N�authselect.backup�w)r-�osr�exists�makedirs�openrG�write)rrr&rAr
r
rr�s
zRedHatAuthSelect.backupcCs�ttj�|d�d��}|�|���}Wd�n1s80Y|r||d}tjd|g}|�|d�|�	d�t
�|�dS)NrM�rrr6r/r7)rRrOrrGr4�readrr(rJr<rr')rrrAZcfgr2r=r
r
rr�s,
zRedHatAuthSelect.restorecCs�z>ttjd��}dd�|D�}Wd�n1s20YWntyTg}Yn0|�d�|��ttjd��}|�|�Wd�n1s�0YdS)NrTcSs"g|]}|�����d�s|�qS)Z	NISDOMAIN)r0�upper�
startswith)r@�liner
r
rrB�s�z2RedHatAuthSelect.set_nisdomain.<locals>.<listcomp>z
NISDOMAIN={}
rN)rRrZSYSCONF_NETWORK�IOErrorr<r8�
writelines)rrrAZcontentr
r
rr �s�(
zRedHatAuthSelect.set_nisdomain)N)TF)
r!r"r#r-r4rrrrr r
r
r
rr	Is

�
<r	c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
d dd�Zd!dd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)"rDaE
    AuthConfig class implements system-independent interface to configure
    system authentication resources. In Red Hat systems this is done with
    authconfig(8) utility.

    AuthConfig class is nothing more than a tool to gather configuration
    options and execute their processing. These options then converted by
    an actual implementation to series of a system calls to appropriate
    utilities performing real configuration.

    If you need to re-use existing AuthConfig instance for multiple runs,
    make sure to call 'AuthConfig.reset()' between the runs.
    cCs
i|_dSr��
parameters�rr
r
r�__init__�szRedHatAuthConfig.__init__cCsd|j|<|S)NTr[�r�optionr
r
r�enable�s
zRedHatAuthConfig.enablecCsd|j|<|S)NFr[r_r
r
r�disable�s
zRedHatAuthConfig.disablecCsd|j|<|Srr[r_r
r
r�
add_options
zRedHatAuthConfig.add_optioncCs|g|j|<|Srr[)rr`�valuer
r
r�
add_parameterszRedHatAuthConfig.add_parametercCs
i|_|Srr[r]r
r
r�reset
szRedHatAuthConfig.resetcCs�g}|j��D]�\}}t|�turF|r6|�d|�q�|�d|�qt|�ttfvrx|�d|�|�d|d�q|dur�|�d|�q|�d||f�q|S)Nz
--enable%sz--disable%sz--%sz%srz--%s%s)r\�items�type�boolr<�tuple�list)rrLr`rdr
r
rrFszRedHatAuthConfig.build_argsTcCsN|r|�d�|��}zt�tjg|�WntjyHtd��Yn0dS)N�update�$Failed to execute authconfig command)rcrFrr'r�
AUTHCONFIGr)r)rrlrLr
r
r�execute!s
zRedHatAuthConfig.executecCs�|r6|�ddd�|�ddd�|�d�|�d�nD|�ddd�|�d�|�d�|�ddd�|�d�|�d�|r�|�dd	d�|�d	�|��|��dS)
NrKrT�sssdauth�ldapZforcelegacy�krb5Znostartr)r;rarcrorfrr
r
rr+s 





zRedHatAuthConfig.configurecCsl|�d�r8dD]&}|�d|�}|r|dkr|�|�qn0|�d�|�d�|rT|s^|�d�|�d�dS)NrK)rqrrrrprrrqrrrpr)rCrHrb)rrrrrZconfZcnfr
r
rrEAs



z$RedHatAuthConfig.prepare_unconfigurecCs$|�||||�|��|��dSr)rErorfrr
r
rrYs
�zRedHatAuthConfig.unconfigurec	svzt�tjd�g�Wntjy2td��Yn0�fdd�tD�}|D]&}zt�|�WqJt	ynYqJ0qJdS)Nz--savebackuprmcsg|]}tj��|��qSr
)rOrrGr?�rr
rrBj�z+RedHatAuthConfig.backup.<locals>.<listcomp>)
rr'rrnr)r�FILES_TO_NOT_BACKUPrO�remove�OSError)rrZfiles_to_remove�filenamer
rsrraszRedHatAuthConfig.backupcCs8zt�tjd|g�Wntjy2td��Yn0dS)Nz--restorebackuprm)rr'rrnr)rrr
r
rrqszRedHatAuthConfig.restorecCs |��|�d|�|��dS)Nr)rfrerorr
r
rr wszRedHatAuthConfig.set_nisdomainN)T)T)r!r"r#�__doc__r^rarbrcrerfrFrorrErrrr r
r
r
rrD�s


rD)Z
__future__rZloggingZsixr$Zipaplatform.pathsrZ	ipapythonrZipapython.admintoolrrOr9ruZ	getLoggerr!r*rZ
add_metaclass�ABCMetar
r	rDr
r
r
r�<module>s