Blob Blame History Raw
From 6ac8ca300f59f7dc7f69e1bd4f5039b2c70f47e7 Mon Sep 17 00:00:00 2001
From: Hector Martin <marcan@marcan.st>
Date: Sun, 3 Sep 2023 05:40:25 -0400
Subject: [PATCH 09/11] [users] Use usermod to disable passwords

On Fedora 38 (and probably others), this step fails with:

passwd -dl root
passwd: Only one of -l, -u, -d, -S may be specified.

Use usermod to wipe and disable the root password instead, which should
work properly. We use '!' (opinions seem to differ on how to mark
disabled/unused accounts, but all of '*' '!' '!!' should have the same
effect in practice).

Signed-off-by: Hector Martin <marcan@marcan.st>
---
 src/modules/users/SetPasswordJob.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/users/SetPasswordJob.cpp b/src/modules/users/SetPasswordJob.cpp
index dd2fdc244..cb5b2c4d1 100644
--- a/src/modules/users/SetPasswordJob.cpp
+++ b/src/modules/users/SetPasswordJob.cpp
@@ -83,7 +83,7 @@ SetPasswordJob::exec()
 
     if ( m_userName == "root" && m_newPassword.isEmpty() )  //special case for disabling root account
     {
-        int ec = CalamaresUtils::System::instance()->targetEnvCall( { "passwd", "-dl", m_userName } );
+        int ec = CalamaresUtils::System::instance()->targetEnvCall( { "usermod", "-p", "!", m_userName } );
         if ( ec )
             return Calamares::JobResult::error( tr( "Cannot disable root account." ),
                                                 tr( "passwd terminated with error code %1." ).arg( ec ) );
-- 
2.41.0