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:
commit
745dc9ad00
@ -30,19 +30,11 @@
|
||||
#include "utils/Retranslator.h"
|
||||
#include "utils/YamlUtils.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QMap>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QSignalMapper>
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* 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
|
||||
* 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,
|
||||
|
@ -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:
|
||||
|
@ -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<UsersViewStep>(); )
|
||||
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user