[users] Ensure the basic forbidden-names are always forbidden by the constructor

This commit is contained in:
Adriaan de Groot 2022-05-09 15:24:11 +02:00
parent 824d706a20
commit 9196f696ea

View File

@ -96,8 +96,22 @@ hostnameActionNames()
return names;
}
static QStringList
alwaysForbiddenLoginNames()
{
return { "root", "nobody" };
}
static QStringList
alwaysForbiddenHostNames()
{
return { "localhost" };
}
Config::Config( QObject* parent )
: Calamares::ModuleSystem::Config( parent )
, m_forbiddenHostNames( alwaysForbiddenHostNames() )
, m_forbiddenLoginNames( alwaysForbiddenLoginNames() )
{
emit readyChanged( m_isReady ); // false
@ -887,7 +901,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
setUserShell( shell );
m_forbiddenLoginNames = CalamaresUtils::getStringList( userSettings, "forbidden_names" );
m_forbiddenLoginNames << QStringLiteral( "root" ) << QStringLiteral( "nobody" );
m_forbiddenLoginNames << alwaysForbiddenLoginNames();
tidy( m_forbiddenLoginNames );
}
@ -909,7 +923,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
= CalamaresUtils::getString( hostnameSettings, "template", QStringLiteral( "${first}-${product}" ) );
m_forbiddenHostNames = CalamaresUtils::getStringList( hostnameSettings, "forbidden_names" );
m_forbiddenHostNames << QStringLiteral( "localhost" );
m_forbiddenHostNames << alwaysForbiddenHostNames();
tidy( m_forbiddenHostNames );
}