
    x[hv	                     \    S SK r S SKrS SKJrJr  \ R
                  " \5      r " S S5      rg)    N)atomic_helpersubpc                   $    \ rS rSrSrS rS rSrg)PasswordConfigurator   zj
Class for changing configurations related to passwords in a VM. Includes
setting and expiring passwords.
c                 D   [         R                  S5        U(       a  [        R                  " U5      n/ n[	        SS5       H@  nUR                  S5      S   S:X  d  M  UR                  UR                  S5      S   5        MB     / n[	        SS5       H/  nUR                  S5      S   nXt;   d  M  UR                  U5        M1     U(       a'  [         R                  S	5        UR                  S
U5        U(       a  U R                  U5        [         R                  S5        g)z
Main method to perform all functionalities based on configuration file
inputs.
@param passwd: encoded admin password.
@param resetPasswd: boolean to determine if password needs to be reset.
@return cfg: dict to be used by cloud-init set_passwd code.
zStarting password configurationz/etc/passwdr:   0r   z/etc/shadowzSetting admin passwordrootzConfigure Password completed!N)	LOGinfor   b64dopensplitappend
set_passwdreset_password)selfpasswdresetPasswddistroallRootUserslineuidUsersListusers           T/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/config_passwd.py	configurePasswordConfigurator.configure   s     	23"''/F,Dzz#q!S(##DJJsOA$67 - ,D::c?1%D###D) - HH-.ff--01    c                 n   [         R                  S5        U H  n [        R                  " SSU/5        M     g	! [        R                   af  n[        R
                  R                  S5      (       a   [        R                  " SSSU/5         S	nAMz  [         R                  SUU5         S	nAM  S	nAff = f)
z
Method to reset password. Use passwd --expire command. Use chage if
not succeeded using passwd command. Log failure message otherwise.
@param: list of users for which to expire password.
zExpiring password.r   z--expirez/usr/bin/chagechagez-dr   z/Failed to expire password for %s with error: %sN)r   r   r   ProcessExecutionErrorospathexistswarning)r   uidUserListr   es       r   r   #PasswordConfigurator.reset_password3   s     	%&D
		8Z67   -- 77>>"233IIwc4899KKI 	s   :B4>B/B//B4 N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r,   r!   r   r   r      s    
28r!   r   )	loggingr%   	cloudinitr   r   	getLoggerr-   r   r   r,   r!   r   <module>r6      s*     	 )!4 4r!   