Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

[FILE] cc_ansible.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apk_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_pipelining.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_bootcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_byobu.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ca_certs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_chef.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disable_ec2_metadata.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disk_setup.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_fan.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_final_message.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_growpart.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_grub_dpkg.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_install_hotplug.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keyboard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keys_to_console.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_landscape.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_locale.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_lxd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mcollective.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mounts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ntp.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_package_update_upgrade_install.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_phone_home.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_power_state_change.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_puppet.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_raspberry_pi.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_reset_rmc.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resizefs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resolv_conf.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rh_subscription.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rsyslog.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_runcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_salt_minion.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_boot.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_instance.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_once.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_user.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_vendor.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_seed_random.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_passwords.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_snap.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_spacewalk.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_authkey_fingerprints.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_import_id.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_timezone.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_autoinstall.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_drivers.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_pro.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_etc_hosts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_users_groups.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_wireguard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files_deferred.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_yum_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_zypper_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] modules.cpython-310.pyc [ edit | delete | rename ]
[FILE] schema.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_set_passwords.cpython-310.pyc

o

��iF)�
@s.UdZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZmZmZdd	lmZdd
lmZddlmZdegegd
�Zeed<e�e�Z de!de"de!fdd�Z#dede"de"fdd�Z$defdd�Z%de"dede
de!ddf
dd �Z&d$d"d#�Z'dS)%zFSet Passwords: Set user passwords and enable/disable SSH password auth�N)�List)�features�	lifecycle�subp�util)�Cloud)�Config)�
MetaSchema)�ALL_DISTROS�Distro�ug_util)�log_util)�PER_INSTANCE)�update_ssh_config�cc_set_passwords)�id�distros�	frequency�activate_by_schema_keys�meta�
users_list�pw_type�returncs|sgS�fdd�|D�S)zDeither password or type: RANDOM is required, user is always requiredcs0g|]}|�dd��kr|d|�dd�f�qS)�type�hash�name�password�RANDOM)�get)�.0�item�r��C/usr/lib/python3/dist-packages/cloudinit/config/cc_set_passwords.py�
<listcomp>(s
�z%get_users_by_type.<locals>.<listcomp>r")rrr"r!r#�get_users_by_type#s��
��r%�distro�service�
extra_argsc
GsZz|jd|g|�R�t�d�WdStjy,}z
t�d|�WYd}~dSd}~ww)N�restartzRestarted the SSH daemon.zm'ssh_pwauth' configuration may not be applied. Cloud-init was unable to restart SSH daemon due to error: '%s')�manage_service�LOG�debugr�ProcessExecutionError�warning)r&r'r(�er"r"r#�_restart_ssh_daemon0s���r0cCs|�dd�}d}t|t�rtjdddd�t�|�rd}n*t�|�r%d	}n"d
|�d�}|dus5|��d
kr>t	�
d||�dSt	�d||�dSt||i�}|sWt	�
d|�dS|�
�ryt�ddddd|g�j��}|��dvrwt||d�dSdSt||�dS)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�ssh�PasswordAuthenticationz-Using a string value for the 'ssh_pwauth' key�22.2z&Use a boolean value with 'ssh_pwauth'.��
deprecated�deprecated_version�
extra_message�yes�nozLeaving SSH config 'z' unchanged.N�	unchangedz%s ssh_pwauth=%sz$%s Unrecognized value: ssh_pwauth=%sz/No need to restart SSH service, %s not updated.�	systemctl�showz
--property�ActiveStatez--value)�active�
activating�	reloadingz--job-mode=ignore-dependencies)�
get_option�
isinstance�strr�	deprecater�is_true�is_false�lowerr+r,r.r�uses_systemdr�stdout�stripr0)�pw_authr&r'�cfg_name�cfg_val�bmsg�updated�stater"r"r#�handle_ssh_pwauth<sP
�

���	�

��rRr�cfg�cloud�argscCs|j}|r|d}d|vrd|dvr|dd=nt�|dd�}d}g}g}d|vrz|d}	tj|	dgd�}d|	vrs|	drstjdd	d
d�t|	dt�rZt�	d�t�|	d|�}ntjd
ddd�t�	d�t�|	d�}
|
rs|
�
�}t�|	d|�}|s�|s�|r�t�
||�\}}t�|�\}
}|
r�d|
|fg}nt�d�g}|s�|�r�t|d�}dd�|D�}t|d�}dd�|D�}g}t|d�D]\}
}t�}|�|
�|�|
|f�|�|
�d|���q�t�d�}|D]F}|�dd�\}}|�|�du�r
d|v�r
|�||f�|�|�q�|dk�s|dk�r#t�}|�d||f�|�||f�|�|�q�|�rbzt�	d|�|j|dd �Wnt�ya}z|�|�t�td!|�WYd}~nd}~ww|�r�zt�	d"|�|j|dd �Wnt�y�}z|�|�t�td#|�WYd}~nd}~wwt|��r�d$d%�|�f}tjd&|ddd'�|�r�|}tj�r�||7}g}|D]/}z
|� |�|�|�W�q�t�y�}z|�|�t�td(|�WYd}~�q�d}~ww|�r�t�	d)|�t!|�"d*�|�t|��r
t�	d+t|��|d,�dS)-Nr�chpasswd�listrT�users)�defaultzConfig key 'lists'z22.3zUse 'users' instead.r5z$Handling input for chpasswd as list.zThe chpasswd multiline stringr4zUse string type instead.z0Handling input for chpasswd as multiline string.�expirez%s:%sz2No default or defined user to change password for.�textcS�g|]\}}|�qSr"r"�r�user�_r"r"r#r$��zhandle.<locals>.<listcomp>rcSr\r"r"r]r"r"r#r$�r`r�:z\$(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���)#r&r�get_cfg_option_str�get_cfg_option_listrrErCrWr+r,�
splitlines�get_cfg_option_boolr�normalize_users_groups�extract_defaultr.r%�rand_user_password�append�re�compile�split�matchrV�	Exception�logexc�len�joinr
�	multi_logr�EXPIRE_APPLIES_TO_HASHED_USERS�
expire_passwdrRr)rrSrTrUr&rrZ�plistr�chfg�	multilinerX�_groupsr^�_user_config�errors�plist_in�hashed_plist_in�hashed_users�randlistr_�prog�line�u�pr/�blurb�users_to_expire�
expired_usersr"r"r#�handle~s�
��
�







���
���
�
�

��
�r��cCs�|dkrtd��t�tj�t�tj�t�tj�t�tj�g}|�t	t
j|t|�tjtjtjtjd���t�
|�d�|�S)N�z.Password length must be at least 4 characters.)�select_from�)�
ValueError�random�choice�string�digits�ascii_lowercase�ascii_uppercase�punctuation�extendrWr�rand_strrx�shufflery)�pwlen�
res_rand_listr"r"r#rps.



�
������

rp)r�)(�__doc__�loggingr�rrr��typingr�	cloudinitrrrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	�cloudinit.distrosr
rr�
cloudinit.logr
�cloudinit.settingsr�cloudinit.ssh_utilrr�__annotations__�	getLogger�__name__r+rWrDr%r0rRr�rpr"r"r"r#�<module>s4�

B	
Upload File: