܍~c{ `ddlZddlZddlmZmZejeZGddZdS)N)subputilceZdZdZdZdZdS)PasswordConfiguratorzv Class for changing configurations related to passwords in a VM. Includes setting and expiring passwords. ctd|rtj|}g}t ddD]O}|dddkr.||ddPg}t ddD]6}|dd}||vr||7|r0td |d ||r||td d S) a+ 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. zStarting password configurationz /etc/passwdr:0rz /etc/shadowzSetting admin passwordrootzConfigure Password completed!N) LOGinforb64dopensplitappend set_passwdreset_password)selfpasswd resetPasswddistro allRootUsersline uidUsersListusers T/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/config_passwd.py configurezPasswordConfigurator.configuresB 2333  'Yv&&F ,, 8 8Dzz#q!S((##DJJsOOA$6777 ,, * *D::c??1%D|####D)))  . HH- . . .   ff - - -  .    - - - 011111cTtd|D]} tjdd|g#tj$r^}tjdrtjddd|gntd||Yd }~d }~wwxYwd S) 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. zExpiring password.rz--expirez/usr/bin/chagechagez-dr z/Failed to expire password for %s with error: %sN)r rrProcessExecutionErrorospathexistswarning)r uidUserListres rrz#PasswordConfigurator.reset_password3s %&&&  D  8Z67777-   7>>"233Iwc489999KKI    s8B%AB  B%N)__name__ __module__ __qualname____doc__rrrrrrs< 2228rr) loggingr# cloudinitrr getLoggerr)r rr-rrr1su g!!4444444444r