AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_set_passwords.cpython-310.pyc
o

x[hF)�
@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	

Anon7 - 2022
AnonSec Team