[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>
This commit is contained in:
Hector Martin 2023-09-03 05:40:25 -04:00
parent 7fa8fa680c
commit a377df2e65

View File

@ -83,10 +83,10 @@ SetPasswordJob::exec()
if ( m_userName == "root" && m_newPassword.isEmpty() ) //special case for disabling root account 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 ) if ( ec )
return Calamares::JobResult::error( tr( "Cannot disable root account." ), return Calamares::JobResult::error( tr( "Cannot disable root account." ),
tr( "passwd terminated with error code %1." ).arg( ec ) ); tr( "usermod terminated with error code %1." ).arg( ec ) );
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }