Merge branch 'fix-shell'

This introduces configuration to allow switching between the
behavior noted in #964, and the desired behavior from PR #955.

For the Manjaro Openbox edition, this means they should add:
```
userShell:
```
To users.conf, while others will see the return of the previous
behavior of passing -s /bin/bash.

FIXES #964
This commit is contained in:
Adriaan de Groot 2018-05-23 07:33:24 -04:00
commit 745dc9ad00
5 changed files with 42 additions and 24 deletions

View File

@ -30,19 +30,11 @@
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "utils/YamlUtils.h" #include "utils/YamlUtils.h"
#include <QFile>
#include <QMap>
#include <QTextStream>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QNetworkReply> #include <QNetworkReply>
#include <QHeaderView> #include <QHeaderView>
#include <QtDebug>
#include <QtGlobal>
#include <QWidget>
#include <QSignalMapper>
#include <yaml-cpp/yaml.h> #include <yaml-cpp/yaml.h>

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -146,20 +147,21 @@ CreateUserJob::exec()
} }
} }
int ec = CalamaresUtils::System::instance()-> QStringList useradd{ "useradd", "-m", "-U" };
targetEnvCall( { "useradd", QString shell = gs->value( "userShell" ).toString();
"-m", if ( !shell.isEmpty() )
"-U", useradd << "-s" << shell;
"-c", useradd << "-c" << m_fullName;
m_fullName, useradd << m_userName;
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 ) );
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", targetEnvCall( { "usermod",
"-aG", "-aG",
defaultGroups, defaultGroups,

View File

@ -52,6 +52,12 @@ public:
void setAutologinDefault( bool checked ); void setAutologinDefault( bool checked );
void setReusePasswordDefault( 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 ); void addPasswordCheck( const QString& key, const QVariant& value );
protected slots: protected slots:

View File

@ -22,9 +22,11 @@
#include "UsersPage.h" #include "UsersPage.h"
#include "utils/CalamaresUtils.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "JobQueue.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h"
CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersViewStepFactory, registerPlugin<UsersViewStep>(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersViewStepFactory, registerPlugin<UsersViewStep>(); )
@ -181,5 +183,12 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
m_widget->addPasswordCheck( i.key(), i.value() ); 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 );
} }

View File

@ -72,5 +72,14 @@ passwordRequirements:
minLength: -1 # Password at least this many characters minLength: -1 # Password at least this many characters
maxLength: -1 # Password at most this many characters maxLength: -1 # Password at most this many characters
libpwquality: libpwquality:
- minlen=8 - minlen=0
- minclass=2 - 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