def _inject_admin_password_into_fs(admin_passwd, fs):
 LOG.debug('Inject admin password fs=%(fs)s admin_passwd=<SANITIZED>', {'fs': fs})
 admin_user = 'root'
 passwd_path = os.path.join('etc', 'passwd')
 shadow_path = os.path.join('etc', 'shadow')
 passwd_data = fs.read_file(passwd_path)
 shadow_data = fs.read_file(shadow_path)
 new_shadow_data = _set_passwd(admin_user, admin_passwd, passwd_data, shadow_data)
 fs.replace_file(shadow_path, new_shadow_data)

def _inject_admin_password_into_fs ( admin_passwd , fs ) : LOG . debug ( 'Inject admin password fs=%(fs)s admin_passwd=<SANITIZED>' , { 'fs' : fs } ) admin_user = 'root' passwd_path = os . path . join ( 'etc' , 'passwd' ) shadow_path = os . path . join ( 'etc' , 'shadow' ) passwd_data = fs . read_file ( passwd_path ) shadow_data = fs . read_file ( shadow_path ) new_shadow_data = _set_passwd ( admin_user , admin_passwd , passwd_data , shadow_data ) fs . replace_file ( shadow_path , new_shadow_data )
set the root password to admin_passwd admin_password is a root password fs is the path to the base of the filesystem into which to inject the key .