From 0d24c1db6ce843392e5dab672bb0a0b4d3bc7b64 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 23 May 2018 05:23:46 -0400 Subject: [PATCH] [users] Introduce userShell setting - Add a *userShell* key, which can be left out (default, backwards- compatible) to retain the old /bin/bash behavior, or explicitly set to empty to defer to useradd-configuration, or explicitly set to something non-empty to use that shell. --- src/modules/users/CreateUserJob.cpp | 4 +++- src/modules/users/UsersViewStep.cpp | 11 ++++++++++- src/modules/users/users.conf | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/modules/users/CreateUserJob.cpp b/src/modules/users/CreateUserJob.cpp index 96b14c365..7d4ded545 100644 --- a/src/modules/users/CreateUserJob.cpp +++ b/src/modules/users/CreateUserJob.cpp @@ -147,7 +147,9 @@ CreateUserJob::exec() } QStringList useradd{ "useradd", "-m", "-U" }; - // TODO: shell-settings + QString shell = gs->value( "userShell" ).toString(); + if ( !shell.isEmpty() ) + useradd << "-s" << shell; useradd << "-c" << m_fullName; useradd << m_userName; diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index 015d7e997..37d86819e 100644 --- a/src/modules/users/UsersViewStep.cpp +++ b/src/modules/users/UsersViewStep.cpp @@ -22,9 +22,11 @@ #include "UsersPage.h" +#include "utils/CalamaresUtils.h" #include "utils/Logger.h" -#include "JobQueue.h" + #include "GlobalStorage.h" +#include "JobQueue.h" CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersViewStepFactory, registerPlugin(); ) @@ -181,5 +183,12 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_widget->addPasswordCheck( i.key(), i.value() ); } } + + QString shell( QLatin1Literal( "/bin/bash" ) ); // as if it's not set at all + if ( configurationMap.contains( "userShell" ) ) + shell = CalamaresUtils::getString( configurationMap, "userShell" ); + // Now it might be explicitly set to empty, which is ok + + Calamares::JobQueue::instance()->globalStorage()->insert( "userShell", shell ); } diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index be0221c8b..0c40faeff 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -74,3 +74,12 @@ passwordRequirements: libpwquality: - minlen=0 - minclass=0 + +# Shell to be used for the regular user of the target system. +# There are three possible kinds of settings: +# - unset (i.e. commented out, the default), act as if set to /bin/bash +# - empty (explicit), don't pass shell information to useradd at all +# and rely on a correct configuration file in /etc/default/useradd +# - set, non-empty, use that path as shell. No validation is done +# that the shell actually exists or is executable. +# userShell: /bin/bash