From db3f7af4893fcda42c32b8d16fcb06b25c9f0e85 Mon Sep 17 00:00:00 2001 From: Bernhard Landauer Date: Fri, 20 Jan 2017 07:38:46 +0100 Subject: [PATCH] disable root password if setRootPassword is false --- src/modules/users/jobs/SetPasswordJob.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/users/jobs/SetPasswordJob.cpp b/src/modules/users/jobs/SetPasswordJob.cpp index d3d4b3669..f90600c17 100644 --- a/src/modules/users/jobs/SetPasswordJob.cpp +++ b/src/modules/users/jobs/SetPasswordJob.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2014-2017, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,20 @@ SetPasswordJob::exec() return Calamares::JobResult::error( tr( "Bad destination system path." ), tr( "rootMountPoint is %1" ).arg( destDir.absolutePath() ) ); + if ( m_userName == "root" && + m_newPassword.isEmpty() ) //special case for disabling root account + { + int ec = CalamaresUtils::System::instance()-> + targetEnvCall( { "passwd", + "-dl", + m_userName } ); + if ( ec ) + return Calamares::JobResult::error( tr( "Cannot disable root account." ), + tr( "passwd terminated with error code %1." ) + .arg( ec ) ); + return Calamares::JobResult::ok(); + } + QString encrypted = QString::fromLatin1( crypt( m_newPassword.toLatin1(), QString( "$6$%1$" )