%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/SSSDConfig/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/SSSDConfig/__pycache__/ipachangeconf.cpython-312.pyc

�

AcfpJ��\�dZddlZddlZddlZddlZdd�ZGd�de�ZGd�de�Zy)	a
ipachangeconf - configuration file manipulation classes and functions
partially based on authconfig code
Copyright (c) 1999-2007 Red Hat, Inc.
Author: Simo Sorce <ssorce@redhat.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
�Nc��d}tj}|r|tjz}	tj|||�}t	j
|tj�tj|d�S#t$rK}|j\}}|dk7r&	tj|�n#t$rYnwxYwt||��d}~wwxYw)N���zr+)�os�O_RDWR�O_CREAT�open�fcntl�lockf�LOCK_EX�OSError�args�close�IOError�fdopen)�filename�perms�create�fd�flags�err�errno�strerrs        �:/usr/lib/python3/dist-packages/SSSDConfig/ipachangeconf.py�
openLockedrs���	�B��I�I�E�
���
�
�"��
%�
�W�W�X�u�e�
,��
���B��
�
�&��9�9�R������%����
��v�
��8�
��������
��
���e�V�$�$��%�s;�;A:�:	C�C	�B.�-C	�.	B:�7C	�9B:�:C	�	Cc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zed��Zdd�Zd�Zdd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
IPAChangeConfc���||_d|_d|_|jd|_d|_|jd|_d|_|jd|_d|_d|_	d|_
y)	N)�rr)z = �=r)�#)�
)�[�])�{�}z.ipabkp)�progname�indent�assign�dassign�comment�dcomment�eol�deol�
sectnamdel�
subsectdel�
backup_suffix��self�names  r�__init__zIPAChangeConf.__init__2sh����
�"���"����{�{�1�~���������Q���
�����H�H�Q�K��	�$���$���&���c��||_y�N)r&r1s  r�setProgNamezIPAChangeConf.setProgName?s	����
r5c�~�t|�tur||_yt|�tur	|f|_yt	d��)Nz Indent must be a list of strings)�type�tupler'�str�
ValueError)r2r's  r�	setIndentzIPAChangeConf.setIndentBs6����<�5� � �D�K�
�&�\�S�
 �!�*�D�K��?�@�@r5c�n�t|�tur||_n|f|_|jd|_y�Nr)r:r;r(r))r2r(s  r�setOptionAssignmentz!IPAChangeConf.setOptionAssignmentJs-����<�5� � �D�K�!�*�D�K��{�{�1�~��r5c�n�t|�tur||_n|f|_|jd|_yr@)r:r;r*r+)r2r*s  r�setCommentPrefixzIPAChangeConf.setCommentPrefixQs-����=�E�!�"�D�L�#�;�D�L����Q���
r5c�n�t|�tur||_n|f|_|jd|_yr@)r:r;r,r-)r2r,s  r�
setEndLinezIPAChangeConf.setEndLineXs-����9����D�H��w�D�H��H�H�Q�K��	r5c��||_yr7)r.�r2�delimss  r�setSectionNameDelimitersz&IPAChangeConf.setSectionNameDelimiters_�	�� ��r5c��||_yr7)r/rGs  r�setSubSectionDelimitersz%IPAChangeConf.setSubSectionDelimitersbrJr5c��|jD]?}|j�j|�s�#|j�t|�dcSy)NF)r*�lstrip�
startswith�len)r2�line�vs   r�matchCommentzIPAChangeConf.matchCommentesE�����	.�A��{�{�}�'�'��*��{�{�}�S��V�W�-�-�	.�r5c�,�|j�dk(ryy)NrTF)�strip�r2rQs  r�
matchEmptyzIPAChangeConf.matchEmptyks���:�:�<�2���r5c�n�dj|j�j��}t|j�dk7ry|j|jd�sy|j
|jd�sy|t|jd�t|jd�S)Nr�Fr�)�joinrU�splitrPr.rO�endswith)r2rQ�cls   r�matchSectionzIPAChangeConf.matchSectionps���
�W�W�T�Z�Z�\�'�'�)�
*���t����1�$���}�}�T�_�_�Q�/�0���{�{�4�?�?�1�-�.���#�d�o�o�a�(�)�3�t���q�/A�+B�*B�C�Cr5c���|j|�ry|j|jd�}t|�dkry|dj	�|j
dk(r|dj	�Sy)NFrZrYr)rSr\r)rPrUr/)r2rQ�partss   r�matchSubSectionzIPAChangeConf.matchSubSectionzse�����T�"���
�
�4�<�<��+���u�:��>����8�>�>��t���q�1�1���8�>�>�#�#�r5c�j�|j|�ry|j�|jdk(ryy)NFrZT)rSrUr/rVs  r�matchSubSectionEndz IPAChangeConf.matchSubSectionEnd�s0�����T�"���:�:�<�4�?�?�1�-�-��r5c��t|j�dk7r|S|jd|z|jdz|jzS)NrYrrZ)rPr.r-)r2�sections  r�getSectionLinezIPAChangeConf.getSectionLine�sC���t����1�$��N����q�!�G�+�d�o�o�a�.@�@�4�9�9�L�Lr5c�&�|dkDrt|�}|S)N�)�hex)�values r�_get_debug_level_valz"IPAChangeConf._get_debug_level_val�s���2�:���J�E��r5c��d}|t|j�k\rt|j�dz
}|D�]�}|ddk(rQ||jd|dz|jdz|jzz
}||j	|d|dz�z
}�]|ddk(r�||j||dz|j
z|jdz|jzz
}||j	|d|dz�z
}||j||jdz|jzz
}��|dd	k(r:||j||dz|j
z|dz|jzz
}��4|dd
k(r$||j|dz|jzz
}��`|ddk(r||jz
}��ytd|dzd
z��|S)NrrZr:rfrr3rk�
subsection�optionr*�empty�Unknown type: [r#)	rPr'r.r-�dumpr)r/r+�SyntaxError)r2�options�level�output�os     rrrzIPAChangeConf.dump�s������C����$�$�����$�q�(�E��	C�A���y�I�%��$�/�/�!�,�q��y�8�4�?�?�1�;M�M�PT�PY�PY�Y�Y���$�)�)�A�g�J���	�:�:�����y�L�(��$�+�+�e�,�q��y�8�4�<�<�G�$�/�/�Z[�J\�\�_c�_h�_h�h�h���$�)�)�A�g�J���	�:�:���$�+�+�e�,�t���q�/A�A�D�I�I�M�M�����y�H�$��$�+�+�e�,�q��y�8�4�<�<�G�!�G�*�T�W[�W`�W`�`�`�����y�I�%��$�-�-�!�G�*�4�t�y�y�@�@�����y�G�#��$�)�)�#����/�!�F�)�;�c�A�B�B�'	C�*�
r5c�6�|j|�rddd�S|j|�}|rdd|j�d�S|j|jd�}t|�dkrt
d��|dj�d	|dj�d�S)
Nrp�r3r:r*�r3r:rkrZrY�!Syntax Error: Unknown line formatrro)rWrS�rstripr\r)rPrsrU)r2rQrkras    r�	parseLinezIPAChangeConf.parseLine�s����?�?�4� �#�W�5�5��!�!�$�'���%�y�5�<�<�>�R�R��
�
�4�<�<��+���u�:��>��A�B�B��a����(�(�U�1�X�_�_�EV�W�Wr5c��d}|D]5}|d|k(r|d|k(r||fcS|r|ddk(s|ddk(r|dfcS|dz
}�7|dfS)Nrr:r3rfrnrZ�)r2�optsr:r3�exclude_sections�numrws       r�findOptszIPAChangeConf.findOpts�sn�����	�A���y�D� �Q�v�Y�$�%6��Q�x���Q�v�Y�)�%;�q��y�L�?X��T�{�"��1�H�C�	��T�{�r5c��g}|t|j�k\rt|j�dz
}|D�]�}|ddk(rx|j|d|dz�}|j|jdz|dz|jdz}|jdd|d��|D]}|j|����|dd	k(r�|j|d|dz�}|j||dz|jz|jdz}|jdd|d��|D]}|j|��|j||jdz}|jdd|d����9|dd
k(r?|j||dz|jz|dz}|jdd|d�����|ddk(r|j|����|ddk(r|jdddd�����td
|dzdz��|S)NrZr:rfrkrr3r*rzrnrorprrqr#)	rPr'�commentOptsr+r.�appendr)r/rs)r2�inoptsrur�rw�no�val�ns        rr�zIPAChangeConf.commentOpts�s�����C����$�$�����$�q�(�E��	C�A���y�I�%��%�%�a��j�%�!�)�<���m�m�d�o�o�a�&8�8�1�V�9�D�t���WX�GY�Y�����Y�	�C�P�Q��#�A��K�K��N�#����y�L�(��%�%�a��j�%�!�)�<���k�k�%�(�1�V�9�4�t�|�|�C�d�o�o�VW�FX�X�����Y�	�C�P�Q��#�A��K�K��N�#��k�k�%�(�4�?�?�1�+=�=�����Y�	�C�P�Q����y�H�$��k�k�%�(�1�V�9�4�t�|�|�C�a��j�P�����Y�	�C�P�Q����y�I�%����A�����y�G�#����Y�	�B�O�P���/�!�F�)�;�c�A�B�B�7	C�:�r5c���g}|D�]�}|ddk(s|ddk(r�|j||d|d�\}}|s|j|��D|ddk(r4|j|d|d�}|j|d|d|d����|dd	k(r-|j|d�}|D]}	|j|	����|dd
k(r��t	d|dzdz��|dd	k(s|dd
k(r|j|���|ddk(r�|j|d|dd�\}}|s|j|���+|dd	k(s|dd
k(re|d�|d|dk7r|j|���^|dd	k(r8|jd	d	|j
|dz|jz|dzd�����|ddk(r|j|����t	d|dzdz��t	d|dzdz��|S)Nr:rfrnr3�action�setrkrzr*�removezUnknown action: [r#rproTrq)r�r��mergeOldr�rsr+r))
r2�oldopts�newoptsr�rwr�r��mo�co�cs
          rr�zIPAChangeConf.mergeOld�sE�����)	C�A���y�I�%��6��l�)B� �M�M�'�1�V�9�a��i�H�	��b���K�K��N���h�<�5�(����q��z�2�g�;�?�B��K�K��6��A�f�I�PR� S�T���h�<�9�,��)�)�!�G�*�5�B��'�����A��'���h�<�8�+��!�"5��8��"D�s�"J�K�K���y�I�%��6��g�)=����A�����y�H�$� �M�M�'�8�Q�v�Y��M�	��b���K�K��N���h�<�9�,��8���0H��'�{�.�1�W�:��G��3L����A�� ��(�|�y�0����Y�	�.2�m�m�a��i�.G�$�,�,�.V�YZ�[b�Yc�.c�%e�f���h�<�5�(��K�K��O��!�"5��(��"C�c�"I�J�J��/�!�F�)�;�c�A�B�B�S)	C�V�r5c��d}|D]�}|ddk(s|ddk(r_|j||d|d�\}}|s|ddk(r|j|��K|ddk(r|j|d|d��l|d	z}�r|dd
k(r?|j||d|dd�\}}|s|ddk(r|j|���|d	z}��|ddk(s|dd
k(r|j||�|d	z
}��t	d|dzdz��y)Nrr:rfrnr3r�r�rkrZroTr*rprqr#)r�r��mergeNew�insertrs)r2r�r��cliner�r�rws       rr�zIPAChangeConf.mergeNew)s;�����	D�B��&�z�Y�&�"�V�*��*D��=�=��r�&�z�2�f�:�F���a���(�|�u�,����B����h�<�5�(��M�M�!�G�*�b��k�:���a�����&�z�X�%��=�=��r�&�z�2�f�:�t�L���a���(�|�u�,����B����a�����&�z�Y�&�"�V�*��*?����E�2�&���
����/�"�V�*�<�s�B�C�C�9	Dr5c�N�|j||�}|j||�|S)ax
        Use a two pass strategy
        First we create a new opts tree from oldopts removing/commenting
         the options as indicated by the contents of newopts
        Second we fill in the new opts tree with options as indicated
         in the newopts tree (this is because entire (sub)sections may
         exist in the newopts that do not exist in oldopts)
        )r�r�)r2r�r�r�s    r�mergezIPAChangeConf.mergeKs'���}�}�W�g�.���
�
�d�G�$��r5c���g}g}d}g}d}|}|}|D]�}	|j|	�}
|
r |�|j|d|d��g}|}|}|
}�6|j|	�}
|
r|�td��g}|}|
}�]|j	|	�}
|
r'|�td��|j|d|d��d}|}��|j|j|	����|r|j|d|d��|S)Nrfrzz(nested subsections are not supported yetz)Unmatched end subsection terminator foundrn)r_r�rbrsrdr})r2�fr��sectoptsrf�subsectoptsrn�curopts�
fatheroptsrQrks           r�parsezIPAChangeConf.parseYs2�����������
����
��!	1�D��%�%�d�+�E���&��K�K��)�h� W�X���"��%�
�����(�(��.�E���)�%�&P�Q�Q� ��%��"�
���+�+�D�1�E���%�%�&Q�R�R��!�!�:�|�Va�"b�c�!�
�$���
�N�N�4�>�>�$�/�0�C!	1�H��K�K��)�h�O�P��r5c���d}d}	tj|||jz�t|d�}|j	|�}|j||�}|j
|�}|jd�|jd�|j|�	|r|j�y#t$rYywxYw#	|r|j�ww#t$rYwwxYwxYw)z�Write settings to configuration file
        file is a path
        options is a set of dictionaries in the form:
            [{'name': 'foo', 'value': 'bar', 'action': 'set/comment'}]
            section is a section name like 'global'
        rN�rT)�shutil�copy2r0rr�r�rr�seek�truncate�writerr)r2�filer�rvr�r�rts       r�
changeConfzIPAChangeConf.changeConf�s�������	��L�L��t�d�&8�&8�8�9��4��'�A��j�j��m�G��j�j��'�2�G��Y�Y�w�'�F�
�F�F�1�I�
�J�J�q�M�
�G�G�F�O�
���G�G�I����
���
��
���G�G�I����
��
�sB�BB?�B0�0	B<�;B<�?C$�C�C$�	C!�C$� C!�!C$c���d}d}		tj|||jz�t|d�}|j
d�|jd�|j|�}|j|�	|r|j�y#t$r}|jdk(r	Yd}~��d}~wwxYw#t$rYywxYw#	|r|j�ww#t$rYwwxYwxYw)z�Write settings to new file, backup old
        file is a path
        options is a set of dictionaries in the form:
            [{'name': 'foo', 'value': 'bar', 'action': 'set/comment'}]
            section is a section name like 'global'
        rNrYr�rT)r�r�r0rrrr�r�rrr�r)r2r�rtrvr�rs      r�newConfzIPAChangeConf.newConf�s�������	�
����T�4�$�*<�*<�#<�=��4��'�A�
�F�F�1�I�
�J�J�q�M��Y�Y�w�'�F�
�G�G�F�O�
���G�G�I���)�
��9�9��>����
��$�
���
��
���G�G�I����
��
�se�#B�AC�;B4�	B1�B,�'C�,B1�1C�4	C�?C�C(�C�C(�	C%�"C(�$C%�%C(N�r�F)�__name__�
__module__�__qualname__r4r8r>rArCrErIrLrSrWr_rbrdrg�staticmethodrlrrr}r�r�r�r�r�r�r�r�rr5rrr0s���'��A�&�(� �!�!���
D���M�
�����8
X�	�$�L/�b D�D�2�h�B r5rc��eZdZdZej
d�Zd�Zd�Zd�Z	d�Z
d�Zd�Zdd	�Z
d
�Zd�Zd�Zd
�Zdd�Zdd�Zd�Zd�Zdd�Zy)�SSSDChangeConfz*An SSSD-specific subclass of IPAChangeConfz1\s*(?P<option>[^:=\s][^:=]*)\s*=\s*(?P<value>.*)$c�Z�tj|d�d|_d|_g|_y)N�SSSD)r �;z.bak)rr4r*r0r�)r2s rr4zSSSDChangeConf.__init__�s(�����t�V�,�!���#�����	r5c�l�|j|�rddd�S|j|�}|rdd|j�d�S|jj	|�}|std��	|j
dd�\}}|j�d|j�d�S#t$rtd��wxYw)z�
        Overrides IPAChangeConf parseLine so that lines are split
        using any separator in self.assign, not just the default one
        rpryr*rzr{rork)	rWrSr|�OPTCRE�matchrs�group�
IndexErrorrU)r2rQrkr�r3s     rr}zSSSDChangeConf.parseLine�s����?�?�4� �#�W�5�5��!�!�$�'���%�y�5�<�<�>�R�R�
�[�[�
�
�t�
$����A�B�B�	C��(�(�8�W�5�K�D�%��
�
��h�����O�O���	C��A�B�B�	C�s�'B�B3c�X�|jj|j|��yr7)r��extendr�)r2rs  r�readfpzSSSDChangeConf.readfp�s���	�	������B��(r5c�^�t|d�}|j|�|j�y)N�r)rr�r)r2rrs   r�readzSSSDChangeConf.read�s"��
�(�C�
 �����B��
���
r5c�<�|j||�\}}|r|dSy)Nrk��get_option_index�r2rfr3�index�items     r�getzSSSDChangeConf.gets*���+�+�G�T�:���t����=� �r5c�b�d|d||dd�gdd�}|j|j|g�|_y)Nrfror�)r:r3rkr�)r�r�)r2rfr3rk�modkws     rr�zSSSDChangeConf.setsD��"� �%�!�#�$�	��!�	���J�J�t�y�y�5�'�2��	r5c�p�|jddd��d||d�}|jj||�y)Nrp)r:rkrf)r:r3rk)r�r�r�)r2r3�optkwr��addkws     r�add_sectionzSSSDChangeConf.add_sections9��
���g��8�9�"���!��	
�	�	�����&r5c�(�|jd|�y)Nrf)�
delete_optionr1s  r�delete_sectionzSSSDChangeConf.delete_sections�����9�d�+r5c�R�|jD�cgc]
}|ddk(s�|��c}Scc}w)Nr:rf�r�)r2rws  r�sectionszSSSDChangeConf.sectionss%���9�9�?�a��&�	�Y�(>��?�?��?s�
$�$c�|�t|jD�cgc]}|ddk(s�|d|k(s�|��c}�dkDScc}w)Nr:rfr3r)rPr�)r2rfrws   r�has_sectionzSSSDChangeConf.has_section s<���t�y�y�[�!�A�f�I��,B�a��i�SZ�FZ�A�[�\�_`�`�`��[s�
9�9�9c�V�|jD]}|ddk(s�|d|k(s�|dcSy)Nr:rfr3rkr�)r2rf�opts   rrtzSSSDChangeConf.options#s6���9�9�	$�C��6�{�i�'�C��K�7�,B��7�|�#�	$r5c�<�|j|j||�Sr7)�delete_option_subtreer�)r2r:r3r�s    rr�zSSSDChangeConf.delete_option(s���)�)�$�)�)�T�4�@�@r5c�>�|j||||�\}}|r||=|Sr7)r�)r2�subtreer:r3r�r�r�s       rr�z$SSSDChangeConf.delete_option_subtree+s*���m�m�G�T�4�9I�J���t������r5c�>�|j||�\}}|dk7r|�yy)NrTFr�r�s     r�
has_optionzSSSDChangeConf.has_option1s*���+�+�G�T�:���t��B�;�4�+��r5c�J�g}|D]}|ddvr�|j|��|S)Nr:)r*rp)r�)r2�optlist�retlistr�s    r�strip_comments_emptyz#SSSDChangeConf.strip_comments_empty7s9�����	 �C��6�{�2�2���N�N�3��	 ��r5c��d}|r)|j|jd|�\}}|sy|d}n|j}|j|||�S)Nrf)rNrk)r�r�)r2�parent_namer3r:r��pindex�pdatas       rr�zSSSDChangeConf.get_option_index?sO����� �M�M�$�)�)�Y��L�M�F�E��!��G�n�G��i�i�G��}�}�W�d�D�1�1r5Nr�r�)ro)r�r�r��__doc__�re�compiler�r4r}r�r�r�r�r�r�r�r�rtr�r�r�r�r�rr5rr�r��sn��4�
�R�Z�Z�	��F��P�0)��
!�
3�'�,�@�a�$�
A����	2r5r�)T)	r�r	rr�r�r�objectrr�rr5r�<module>r�s:���(
�	�
�	��*^�F�^�B
w2�]�w2r5

Zerion Mini Shell 1.0