diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 37c489135..5272d83fd 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -30,19 +30,11 @@ #include "utils/Retranslator.h" #include "utils/YamlUtils.h" -#include -#include -#include - #include #include #include #include -#include -#include -#include -#include #include diff --git a/src/modules/users/CreateUserJob.cpp b/src/modules/users/CreateUserJob.cpp index d4d299e39..119028059 100644 --- a/src/modules/users/CreateUserJob.cpp +++ b/src/modules/users/CreateUserJob.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2016, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -146,20 +147,21 @@ CreateUserJob::exec() } } - int ec = CalamaresUtils::System::instance()-> - targetEnvCall( { "useradd", - "-m", - "-U", - "-c", - m_fullName, - m_userName } ); - if ( ec ) - return Calamares::JobResult::error( tr( "Cannot create user %1." ) - .arg( m_userName ), - tr( "useradd terminated with error code %1." ) - .arg( ec ) ); + QStringList useradd{ "useradd", "-m", "-U" }; + QString shell = gs->value( "userShell" ).toString(); + if ( !shell.isEmpty() ) + useradd << "-s" << shell; + useradd << "-c" << m_fullName; + useradd << m_userName; - ec = CalamaresUtils::System::instance()-> + auto pres = CalamaresUtils::System::instance()->targetEnvCommand( useradd ); + if ( pres.getExitCode() ) + { + cError() << "useradd failed" << pres.getExitCode(); + return pres.explainProcess( useradd, 10 /* bogus timeout */ ); + } + + int ec = CalamaresUtils::System::instance()-> targetEnvCall( { "usermod", "-aG", defaultGroups, diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h index 5990d8693..817f73d0b 100644 --- a/src/modules/users/UsersPage.h +++ b/src/modules/users/UsersPage.h @@ -52,6 +52,12 @@ public: void setAutologinDefault( bool checked ); void setReusePasswordDefault( bool checked ); + /** @brief Process entries in the passwordRequirements config entry + * + * Called once for each item in the config entry, which should + * be a key-value pair. What makes sense as a value depends on + * the key. Supported keys are documented in users.conf. + */ void addPasswordCheck( const QString& key, const QVariant& value ); protected slots: 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 6111a6e80..0c40faeff 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -72,5 +72,14 @@ passwordRequirements: minLength: -1 # Password at least this many characters maxLength: -1 # Password at most this many characters libpwquality: - - minlen=8 - - minclass=2 + - 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