From 8c8bb7a3df0514e1df131f594e539e7eeef0676e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Sep 2024 18:00:37 +0200 Subject: [PATCH] [users] Pass the home permissions to useradd --- src/modules/users/CreateUserJob.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/users/CreateUserJob.cpp b/src/modules/users/CreateUserJob.cpp index 4e36c5081..f998aeefc 100644 --- a/src/modules/users/CreateUserJob.cpp +++ b/src/modules/users/CreateUserJob.cpp @@ -46,7 +46,7 @@ CreateUserJob::prettyStatusMessage() const } static Calamares::JobResult -createUser( const QString& loginName, const QString& fullName, const QString& shell ) +createUser( const QString& loginName, const QString& fullName, const QString& shell, int umask ) { QStringList useraddCommand; #ifdef __FreeBSD__ @@ -67,6 +67,10 @@ createUser( const QString& loginName, const QString& fullName, const QString& sh useraddCommand << "-s" << shell; } useraddCommand << "-c" << fullName; + if ( umask >= 0 ) + { + useraddCommand << "-K" << ( QStringLiteral( "UMASK=" ) + QString::number( umask, 8 ) ); + } useraddCommand << loginName; #endif @@ -136,7 +140,8 @@ CreateUserJob::exec() m_status = tr( "Creating user %1…", "@status" ).arg( m_config->loginName() ); emit progress( 0.5 ); - auto useraddResult = createUser( m_config->loginName(), m_config->fullName(), m_config->userShell() ); + auto useraddResult + = createUser( m_config->loginName(), m_config->fullName(), m_config->userShell(), m_config->homeUMask() ); if ( !useraddResult ) { return useraddResult;