From daee5b7148086a66a3c414f92c0169b705d42b34 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 19 Aug 2015 16:55:50 +0200 Subject: [PATCH] Escape the encrypted password after calling crypt with the right salt. --- src/modules/users/SetPasswordJob.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/users/SetPasswordJob.cpp b/src/modules/users/SetPasswordJob.cpp index 757cb01d0..55a5f5b5c 100644 --- a/src/modules/users/SetPasswordJob.cpp +++ b/src/modules/users/SetPasswordJob.cpp @@ -59,12 +59,17 @@ SetPasswordJob::exec() return Calamares::JobResult::error( tr( "Bad destination system path." ), tr( "rootMountPoint is %1" ).arg( destDir.absolutePath() ) ); - QByteArray data = crypt( m_newPassword.toLatin1(), QString( "\\$6\\$%1\\$" ).arg( m_userName ).toLatin1() ); + QString encrypted = QString::fromLatin1( + crypt( m_newPassword.toLatin1(), + QString( "$6$%1$" ) + .arg( m_userName ) + .toLatin1() ) ); + encrypted = encrypted.replace( '$', "\\$" ); int ec = CalamaresUtils::System::instance()-> targetEnvCall( { "usermod", "-p", - QString::fromLatin1( data ), + encrypted, m_userName } ); if ( ec ) return Calamares::JobResult::error( tr( "Cannot set password for user %1." )