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: //lib/python3.6/site-packages/ipaplatform/redhat/__pycache__/authconfig.cpython-36.pyc
3

�d[e>4�@s�ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlZddlZdddd	gZ
eje�Zd
d�Zejej�Gdd
�d
��ZGdd�de�ZGdd�de�ZdS)�)�absolute_importN)�paths)�ipautil)�ScriptErrorZpasswd�groupZshadowZgshadowcCst�S)N)�RedHatAuthSelect�rr� /usr/lib/python3.6/authconfig.py�
get_auth_tool%sr
c@sTeZdZejd
dd��Zejdd��Zejdd��Zejdd	��Zejd
d��Z	dS)�RedHatAuthToolBaseTcCsdS)Nr)�self�sssd�	mkhomedir�
statestore�sudorrr	�	configure,szRedHatAuthToolBase.configurecCsdS)Nr)r�fstorer�was_sssd_installed�was_sssd_configuredrrr	�unconfigure0szRedHatAuthToolBase.unconfigurecCsdS)z�
        Backup the system authentication resources configuration
        :param path: directory where the backup will be stored
        Nr)r�pathrrr	�backup6szRedHatAuthToolBase.backupcCsdS)z�
        Restore the system authentication resources configuration from a backup
        :param path: directory where the backup is stored
        Nr)rrrrr	�restore=szRedHatAuthToolBase.restorecCsdS)Nr)r�	nisdomainrrr	�
set_nisdomainDsz RedHatAuthToolBase.set_nisdomainN)T)
�__name__�
__module__�__qualname__�abc�abstractmethodrrrrrrrrr	r)src@sHeZdZdd�Zddd�Zddd	�Zd
d�Zdd
�Zdd�Zdd�Z	dS)rcCsBytjtjddg�}Wn tjk
r6tjd�dSX|jj�S)N�currentz--rawz/Current configuration not managed by authselect)	r�runr�
AUTHSELECT�CalledProcessError�logger�debugZ
raw_output�decode)rr rrr	�_get_authselect_current_outputKs
z/RedHatAuthSelect._get_authselect_current_outputNcCsR|dkr|j�}|dkrdS|j�}|s,dS|jd�}|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)rZoutput_textZoutput_items�profile�featuresrrr	�_parse_authselect_outputUs
z)RedHatAuthSelect._parse_authselect_outputTFcCs�djtjd��}|jdd|�tjddg}|rF|jd�|jddd	�|rT|jd
�|rb|jd�|jd�|jd
j|��tj|�dS)Nzpre_ipaclient_{}z%Y%m%d%H%M%S�
authselectr�selectr
zwith-mkhomedirrTz	with-sudoz
with-subidz--forcez--backup={})	�format�timeZstrftime�backup_staterr"�appendrr!)rr
rrrZsubidZbackup_name�cmdrrr	rhs



zRedHatAuthSelect.configurec
Cs@|jdd�}|dk	r*|r*|jd�r*dS|jd�sxtjd�t�}|j||||�|j�}tjddj|��d}g}	np|jdd�}|s�d}|jdd	�}
|j	dd
�|j
tj�r�tj
d�|jtj�|
dk	r�dd
�|
jd�D�}	ng}	|jdd�}|�rtjd|g}tj|�n*tjd|g}|j|	�|jd�tj|�dS)NZinstallation�completer/z�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(r
r,Z
features_listrzRestoring user-nsswitch.confcSsg|]}|j�r|j��qSr)r*)�.0�frrr	�
<listcomp>�sz0RedHatAuthSelect.unconfigure.<locals>.<listcomp>rzbackup-restorer0z--force)Z	get_state�	has_stater$Zwarning�RedHatAuthConfig�prepare_unconfigure�
build_args�join�
restore_stateZdelete_stateZhas_filerZ
NSSWITCH_CONF�infoZrestore_filer+r"rr!�extendr4)
rrrrrr6�
authconfig�argsr,r-Zfeatures_staterr5rrr	r�sH



zRedHatAuthSelect.unconfigurec	CsX|j�}|dkrdStjj|�s*tj|�ttjj|d�d��}|j|�WdQRXdS)Nzauthselect.backup�w)r'�osr�exists�makedirs�openr>�write)rrr r8rrr	r�s
zRedHatAuthSelect.backupc
Cslttjj|d�d��}|j|j��}WdQRX|rh|d}tjd|g}|j|d�|j	d�t
j|�dS)Nzauthselect.backup�rrr0r)z--force)rHrErr>r.�readrr"rAr4rr!)rrr8Zcfgr,r5rrr	r�s
zRedHatAuthSelect.restorecCszy*ttjd��}dd�|D�}WdQRXWntk
rBg}YnX|jdj|��ttjd��}|j|�WdQRXdS)NrJcSs"g|]}|j�j�jd�s|�qS)Z	NISDOMAIN)r*�upper�
startswith)r7�linerrr	r9�sz2RedHatAuthSelect.set_nisdomain.<locals>.<listcomp>z
NISDOMAIN={}
rD)rHrZSYSCONF_NETWORK�IOErrorr4r1�
writelines)rrr8Zcontentrrr	r�s
zRedHatAuthSelect.set_nisdomain)N)TF)
rrrr'r.rrrrrrrrr	rIs


<rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
d dd�Zd!dd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)"r;aE
    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|_dS)N)�
parameters)rrrr	�__init__�szRedHatAuthConfig.__init__cCsd|j|<|S)NT)rQ)r�optionrrr	�enable�s
zRedHatAuthConfig.enablecCsd|j|<|S)NF)rQ)rrSrrr	�disable�s
zRedHatAuthConfig.disablecCsd|j|<|S)N)rQ)rrSrrr	�
add_options
zRedHatAuthConfig.add_optioncCs|g|j|<|S)N)rQ)rrS�valuerrr	�
add_parameterszRedHatAuthConfig.add_parametercCs
i|_|S)N)rQ)rrrr	�reset
szRedHatAuthConfig.resetcCs�g}x�|jj�D]�\}}t|�tkrH|r8|jd|�q�|jd|�qt|�ttfkrz|jd|�|jd|d�q|dkr�|jd|�q|jd||f�qW|S)Nz
--enable%sz--disable%sz--%sz%srz--%s%s)rQ�items�type�boolr4�tuple�list)rrCrSrWrrr	r=szRedHatAuthConfig.build_argsTcCsP|r|jd�|j�}ytjtjg|�Wntjk
rJtd��YnXdS)N�updatez$Failed to execute authconfig command)rVr=rr!r�
AUTHCONFIGr#r)rr_rCrrr	�execute!s
zRedHatAuthConfig.executecCs�|r6|jddd�|jddd�|jd�|jd�nD|jddd�|jd�|jd�|jddd�|jd�|jd�|r�|jdd	d�|jd	�|j�|j�dS)
NrBr
T�sssdauth�ldapZforcelegacy�krb5Znostartr)r3rTrVrarY)rr
rrrrrr	r+s 





zRedHatAuthConfig.configurecCsp|jd�r<x`dD]&}|jd|�}|r|dkr|j|�qWn0|jd�|jd�|oV|sb|jd�|jd�dS)NrBrcrdr
rbr)rcrdr
rbr)r:r?rU)rrrrrZconfZcnfrrr	r<As




z$RedHatAuthConfig.prepare_unconfigurecCs$|j||||�|j�|j�dS)N)r<rarY)rrrrrrrr	rYszRedHatAuthConfig.unconfigurecs~ytjtjd�g�Wntjk
r4td��YnX�fdd�tD�}x0|D](}ytj|�WqNt	k
rtYqNXqNWdS)Nz--savebackupz$Failed to execute authconfig commandcsg|]}tjj�|��qSr)rErr>)r7r8)rrr	r9jsz+RedHatAuthConfig.backup.<locals>.<listcomp>)
rr!rr`r#r�FILES_TO_NOT_BACKUPrE�remove�OSError)rrZfiles_to_remove�filenamer)rr	ras
zRedHatAuthConfig.backupcCs:ytjtjd|g�Wntjk
r4td��YnXdS)Nz--restorebackupz$Failed to execute authconfig command)rr!rr`r#r)rrrrr	rqszRedHatAuthConfig.restorecCs |j�|jd|�|j�dS)Nr)rYrXra)rrrrr	rwszRedHatAuthConfig.set_nisdomainN)T)T)rrr�__doc__rRrTrUrVrXrYr=rarr<rrrrrrrr	r;�s



r;)Z
__future__rZloggingZsixrZipaplatform.pathsrZ	ipapythonrZipapython.admintoolrrEr2reZ	getLoggerrr$r
Z
add_metaclass�ABCMetarrr;rrrr	�<module>s