x[hv \ddlZddlZddlmZmZej eZGddZy)N) atomic_helpersubpceZdZdZdZdZy)PasswordConfiguratorzv Class for changing configurations related to passwords in a VM. Includes setting and expiring passwords. ctjd|rtj|}g}t ddD]=}|j dddk(s|j |j dd?g}t ddD],}|j dd}||vs|j |.|r'tjd |jd ||r|j|tjd y ) 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.configures 23 "''/F , 8Dzz#q!S(##DJJsOA$67 8 , *D::c?1%D|###D) *  HH- .   ff -     - 01cNtjd|D]} tjdd|gy #tj$rZ}tj j drtjddd|gntjd||Yd }~d }~wwxYw) 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  8Z67 -- 77>>"23IIwc489KKI  s7B$ ABB$N)__name__ __module__ __qualname____doc__rrrrrrs 28rr) loggingr# cloudinitrr getLoggerr)r rr-rrr1s, )g!44r