404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.117.104.4: ~ $
3

\�me�+�	@sHUdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZdd	lmZmZdd
lmZmZmZddlmZddlmZd
Zdddeegeed�ed�ggd�Zeee�Zeje �Z!dj"dd�eeD��Z#e$e%e$d�dd�Z&dd�Z'ed�dd�Z(e%eee$dd�d d!�Z)d%d#d$�Z*dS)&zFSet Passwords: Set user passwords and enable/disable SSH password auth�N)�
ascii_letters�digits)�dedent)�List)�features�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``.
Zcc_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�descriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keys�cCsg|]}|dkr|�qS)ZloLOI01�)�.0�xrr�&/usr/lib/python3.6/cc_set_passwords.py�
<listcomp>]sr)�
users_list�pw_type�returncs|sgS�fdd�|D�S)zDeither password or type: RANDOM is required, user is always requiredcs0g|](}|jdd��kr|d|jdd�f�qS)�type�hashr�password�RANDOM)�get)r�item)rrrrfsz%get_users_by_type.<locals>.<listcomp>r)rrr)rr�get_users_by_type`s
r%cCsPy|jd|�tjd�Wn0tjk
rJ}ztjd|�WYdd}~XnXdS)NZrestartzRestarted the SSH daemon.zm'ssh_pwauth' configuration may not be applied. Cloud-init was unable to restart SSH daemon due to error: '%s')Zmanage_service�LOG�debugrZProcessExecutionError�warning)�distro�service�errr�_restart_ssh_daemonmsr,)r)cCs�|jdd�}d}t|t�r*tjdddd�tj|�r:d}nRtj|�rJd	}nBd
|�d�}|dksj|j�d
krztj	d||�ntj
d||�dSt||i�}|s�tj	d|�dS|j�r�t
j
ddddd|g�jj�}|j�dkr�t||�n
t||�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: NoneZssh_svcnameZsshZPasswordAuthenticationz-Using a string value for the 'ssh_pwauth' keyz22.2z&Use a boolean value with 'ssh_pwauth'.)�
deprecated�deprecated_version�
extra_message�yes�nozLeaving SSH config 'z' unchanged.NZ	unchangedz%s ssh_pwauth=%sz$%s Unrecognized value: ssh_pwauth=%sz/No need to restart SSH service, %s not updated.Z	systemctlZshowz
--propertyZActiveStatez--value�active�
activating�	reloading)r2r3r4)Z
get_option�
isinstance�strr�	deprecateZis_trueZis_false�lowerr&r'r(rZuses_systemdr�stdout�stripr,)Zpw_authr)r*Zcfg_nameZcfg_valZbmsg�updated�staterrr�handle_ssh_pwauthys>


r=)r�cfg�cloud�argsrc-Cs2|j}|r2|d}d|kr@d|dkr@|dd=ntj|dd�}d}g}g}d|kr�|d}	tj|	dgd�}d|	kr�|	dr�tjdd	d
d�t|	dt�r�tjd�tj|	d|�}n2tjd
ddd�tjd�tj|	d�}
|
r�|
j	�}tj
|	d|�}|p�|�rD|�rDtj||�\}}tj
|�\}
}|
�r:d|
|fg}n
tjd�g}|�sT|�r�t|d�}dd�|D�}t|d�}dd�|D�}g}xJt|d�D]<\}
}t�}|j|
�|j|
|f�|j|
�d|����q�Wtjd�}x�|D]�}|jdd�\}}|j|�dk	�r,d|k�r,|j||f�|j|�nD|dk�s@|dk�rXt�}|jd||f�|j||f�|j|��q�W|�r�ytjd|�|j|dd �Wn<tk
�r�}z|j|�tjtd!|�WYdd}~XnX|�r:ytjd"|�|j|dd �Wn<tk
�r8}z|j|�tjtd#|�WYdd}~XnXt|��rfd$d%j|�f}tjd&|ddd'�|�r�|}tj�r�||7}g}xd|D]\}y|j|�|j|�Wn<tk
�r�}z|j|�tjtd(|�WYdd}~XnX�q�W|�r�tjd)|�t|j d*�|�t|��r.tjd+t|��|d,�dS)-Nr�chpasswd�listr!T�users)�defaultzConfig key 'lists'z22.3zUse 'users' instead.)r-r.r/z$Handling input for chpasswd as list.zThe chpasswd multiline stringz22.2zUse string type instead.z0Handling input for chpasswd as multiline string.�expirez%s:%sz2No default or defined user to change password for.�textcSsg|]\}}|�qSrr)r�user�_rrrr�szhandle.<locals>.<listcomp>r cSsg|]\}}|�qSrr)rrGrHrrrr�sr"�:z\$(1|2a|2y|5|6)(\$.+){2}��RzChanging password for %s:F)Zhashedz,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
)�stderrZfallback_to_stdoutzFailed to set 'expire' for %szExpired passwords for: %s usersZ
ssh_pwauthz+%s errors occurred, re-raising the last one���)!r)rZget_cfg_option_strZget_cfg_option_listr7r5rBr&r'�
splitlinesZget_cfg_option_boolrZnormalize_users_groupsZextract_defaultr(r%�rand_user_password�append�re�compile�split�matchrA�	ExceptionZlogexc�len�joinZ	multi_logrZEXPIRE_APPLIES_TO_HASHED_USERSZ
expire_passwdr=r#)rr>r?r@r)r!rEZplistrZchfgZ	multilinerCZ_groupsrGZ_user_config�errorsZplist_inZhashed_plist_inZhashed_usersZrandlistrH�prog�line�u�pr+ZblurbZusers_to_expireZ
expired_usersrrr�handle�s�













&
r^�cCstj|td�S)N)Zselect_from)rZrand_str�PW_SET)ZpwlenrrrrP5srP)r_)+�__doc__ZloggingrR�stringrr�textwraprZtypingrZ	cloudinitrrrZcloudinit.cloudr	Zcloudinit.configr
Zcloudinit.config.schemarrZcloudinit.distrosr
rrZcloudinit.settingsrZcloudinit.ssh_utilrZMODULE_DESCRIPTION�metaZ	getLogger�__name__r&rXr`rBr6r%r,r=r^rPrrrr�<module>sB

4	

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 128 B 0644
__init__.cpython-36.pyc File 128 B 0644
cc_ansible.cpython-36.opt-1.pyc File 8.63 KB 0644
cc_ansible.cpython-36.pyc File 8.63 KB 0644
cc_apk_configure.cpython-36.opt-1.pyc File 4.51 KB 0644
cc_apk_configure.cpython-36.pyc File 4.51 KB 0644
cc_apt_configure.cpython-36.opt-1.pyc File 30.42 KB 0644
cc_apt_configure.cpython-36.pyc File 30.42 KB 0644
cc_apt_pipelining.cpython-36.opt-1.pyc File 2.44 KB 0644
cc_apt_pipelining.cpython-36.pyc File 2.44 KB 0644
cc_bootcmd.cpython-36.opt-1.pyc File 2.51 KB 0644
cc_bootcmd.cpython-36.pyc File 2.51 KB 0644
cc_byobu.cpython-36.opt-1.pyc File 3.04 KB 0644
cc_byobu.cpython-36.pyc File 3.04 KB 0644
cc_ca_certs.cpython-36.opt-1.pyc File 7.05 KB 0644
cc_ca_certs.cpython-36.pyc File 7.05 KB 0644
cc_chef.cpython-36.opt-1.pyc File 9.13 KB 0644
cc_chef.cpython-36.pyc File 9.13 KB 0644
cc_disable_ec2_metadata.cpython-36.opt-1.pyc File 1.72 KB 0644
cc_disable_ec2_metadata.cpython-36.pyc File 1.72 KB 0644
cc_disk_setup.cpython-36.opt-1.pyc File 23.1 KB 0644
cc_disk_setup.cpython-36.pyc File 23.1 KB 0644
cc_fan.cpython-36.opt-1.pyc File 2.74 KB 0644
cc_fan.cpython-36.pyc File 2.74 KB 0644
cc_final_message.cpython-36.opt-1.pyc File 3.07 KB 0644
cc_final_message.cpython-36.pyc File 3.07 KB 0644
cc_growpart.cpython-36.opt-1.pyc File 15.91 KB 0644
cc_growpart.cpython-36.pyc File 15.91 KB 0644
cc_grub_dpkg.cpython-36.opt-1.pyc File 4.92 KB 0644
cc_grub_dpkg.cpython-36.pyc File 4.92 KB 0644
cc_install_hotplug.cpython-36.opt-1.pyc File 3.25 KB 0644
cc_install_hotplug.cpython-36.pyc File 3.25 KB 0644
cc_keyboard.cpython-36.opt-1.pyc File 1.98 KB 0644
cc_keyboard.cpython-36.pyc File 1.98 KB 0644
cc_keys_to_console.cpython-36.opt-1.pyc File 3.11 KB 0644
cc_keys_to_console.cpython-36.pyc File 3.11 KB 0644
cc_landscape.cpython-36.opt-1.pyc File 4.71 KB 0644
cc_landscape.cpython-36.pyc File 4.71 KB 0644
cc_locale.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_locale.cpython-36.pyc File 1.58 KB 0644
cc_lxd.cpython-36.opt-1.pyc File 13.04 KB 0644
cc_lxd.cpython-36.pyc File 13.04 KB 0644
cc_mcollective.cpython-36.opt-1.pyc File 4.24 KB 0644
cc_mcollective.cpython-36.pyc File 4.24 KB 0644
cc_migrator.cpython-36.opt-1.pyc File 2.92 KB 0644
cc_migrator.cpython-36.pyc File 2.92 KB 0644
cc_mounts.cpython-36.opt-1.pyc File 14.08 KB 0644
cc_mounts.cpython-36.pyc File 14.08 KB 0644
cc_ntp.cpython-36.opt-1.pyc File 13.15 KB 0644
cc_ntp.cpython-36.pyc File 13.15 KB 0644
cc_package_update_upgrade_install.cpython-36.opt-1.pyc File 3.78 KB 0644
cc_package_update_upgrade_install.cpython-36.pyc File 3.78 KB 0644
cc_phone_home.cpython-36.opt-1.pyc File 4.1 KB 0644
cc_phone_home.cpython-36.pyc File 4.1 KB 0644
cc_power_state_change.cpython-36.opt-1.pyc File 6.24 KB 0644
cc_power_state_change.cpython-36.pyc File 6.24 KB 0644
cc_puppet.cpython-36.opt-1.pyc File 9.46 KB 0644
cc_puppet.cpython-36.pyc File 9.46 KB 0644
cc_reset_rmc.cpython-36.opt-1.pyc File 3.59 KB 0644
cc_reset_rmc.cpython-36.pyc File 3.59 KB 0644
cc_resizefs.cpython-36.opt-1.pyc File 7.02 KB 0644
cc_resizefs.cpython-36.pyc File 7.02 KB 0644
cc_resolv_conf.cpython-36.opt-1.pyc File 4.27 KB 0644
cc_resolv_conf.cpython-36.pyc File 4.27 KB 0644
cc_rh_subscription.cpython-36.opt-1.pyc File 12.06 KB 0644
cc_rh_subscription.cpython-36.pyc File 12.06 KB 0644
cc_rightscale_userdata.cpython-36.opt-1.pyc File 2.77 KB 0644
cc_rightscale_userdata.cpython-36.pyc File 2.77 KB 0644
cc_rsyslog.cpython-36.opt-1.pyc File 10.34 KB 0644
cc_rsyslog.cpython-36.pyc File 10.34 KB 0644
cc_runcmd.cpython-36.opt-1.pyc File 2.43 KB 0644
cc_runcmd.cpython-36.pyc File 2.43 KB 0644
cc_salt_minion.cpython-36.opt-1.pyc File 4.36 KB 0644
cc_salt_minion.cpython-36.pyc File 4.36 KB 0644
cc_scripts_per_boot.cpython-36.opt-1.pyc File 1.4 KB 0644
cc_scripts_per_boot.cpython-36.pyc File 1.4 KB 0644
cc_scripts_per_instance.cpython-36.opt-1.pyc File 1.57 KB 0644
cc_scripts_per_instance.cpython-36.pyc File 1.57 KB 0644
cc_scripts_per_once.cpython-36.opt-1.pyc File 1.51 KB 0644
cc_scripts_per_once.cpython-36.pyc File 1.51 KB 0644
cc_scripts_user.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_scripts_user.cpython-36.pyc File 1.58 KB 0644
cc_scripts_vendor.cpython-36.opt-1.pyc File 2.04 KB 0644
cc_scripts_vendor.cpython-36.pyc File 2.04 KB 0644
cc_seed_random.cpython-36.opt-1.pyc File 4.07 KB 0644
cc_seed_random.cpython-36.pyc File 4.07 KB 0644
cc_set_hostname.cpython-36.opt-1.pyc File 4 KB 0644
cc_set_hostname.cpython-36.pyc File 4 KB 0644
cc_set_passwords.cpython-36.opt-1.pyc File 8.4 KB 0644
cc_set_passwords.cpython-36.pyc File 8.4 KB 0644
cc_snap.cpython-36.opt-1.pyc File 5.94 KB 0644
cc_snap.cpython-36.pyc File 5.94 KB 0644
cc_spacewalk.cpython-36.opt-1.pyc File 2.87 KB 0644
cc_spacewalk.cpython-36.pyc File 2.87 KB 0644
cc_ssh.cpython-36.opt-1.pyc File 11.02 KB 0644
cc_ssh.cpython-36.pyc File 11.02 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.opt-1.pyc File 3.54 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.pyc File 3.54 KB 0644
cc_ssh_import_id.cpython-36.opt-1.pyc File 3.85 KB 0644
cc_ssh_import_id.cpython-36.pyc File 3.85 KB 0644
cc_timezone.cpython-36.opt-1.pyc File 1.24 KB 0644
cc_timezone.cpython-36.pyc File 1.24 KB 0644
cc_ubuntu_advantage.cpython-36.opt-1.pyc File 12.42 KB 0644
cc_ubuntu_advantage.cpython-36.pyc File 12.42 KB 0644
cc_ubuntu_autoinstall.cpython-36.opt-1.pyc File 3.89 KB 0644
cc_ubuntu_autoinstall.cpython-36.pyc File 3.89 KB 0644
cc_ubuntu_drivers.cpython-36.opt-1.pyc File 3.63 KB 0644
cc_ubuntu_drivers.cpython-36.pyc File 3.63 KB 0644
cc_update_etc_hosts.cpython-36.opt-1.pyc File 4.3 KB 0644
cc_update_etc_hosts.cpython-36.pyc File 4.3 KB 0644
cc_update_hostname.cpython-36.opt-1.pyc File 3.01 KB 0644
cc_update_hostname.cpython-36.pyc File 3.01 KB 0644
cc_users_groups.cpython-36.opt-1.pyc File 7.58 KB 0644
cc_users_groups.cpython-36.pyc File 7.58 KB 0644
cc_wireguard.cpython-36.opt-1.pyc File 8.39 KB 0644
cc_wireguard.cpython-36.pyc File 8.39 KB 0644
cc_write_files.cpython-36.opt-1.pyc File 5.61 KB 0644
cc_write_files.cpython-36.pyc File 5.61 KB 0644
cc_write_files_deferred.cpython-36.opt-1.pyc File 1.73 KB 0644
cc_write_files_deferred.cpython-36.pyc File 1.73 KB 0644
cc_yum_add_repo.cpython-36.opt-1.pyc File 6.03 KB 0644
cc_yum_add_repo.cpython-36.pyc File 6.03 KB 0644
cc_zypper_add_repo.cpython-36.opt-1.pyc File 5.66 KB 0644
cc_zypper_add_repo.cpython-36.pyc File 5.66 KB 0644
modules.cpython-36.opt-1.pyc File 7.31 KB 0644
modules.cpython-36.pyc File 7.31 KB 0644
schema.cpython-36.opt-1.pyc File 39.45 KB 0644
schema.cpython-36.pyc File 39.45 KB 0644