[users] Fix implementation so existing tests pass

main
Adriaan de Groot 5 years ago
parent e46d9f735d
commit ceeab7087c

@ -593,19 +593,39 @@ STATICTEST void
setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription >& defaultGroups ) setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription >& defaultGroups )
{ {
defaultGroups.clear(); defaultGroups.clear();
auto groupsFromConfig = map.value( "defaultGroups" ).toList();
cDebug() << groupsFromConfig; const QString key( "defaultGroups" );
#if 0 auto groupsFromConfig = map.value( key ).toList();
// '#' is not a valid group name; use that to distinguish an empty-list if ( groupsFromConfig.isEmpty() )
// in the configuration (which is a legitimate, if unusual, choice) {
// from a bad or missing configuration value. if ( map.contains( key ) && map.value( key ).isValid() && map.value( key ).canConvert( QVariant::List ) )
defaultGroups = CalamaresUtils::getStringList( map, QStringLiteral( "defaultGroups" ), QStringList { "#" } ); {
if ( defaultGroups.contains( QStringLiteral( "#" ) ) ) // Explicitly set, but empty: this is valid, but unusual.
{ cDebug() << key << "has explicit empty value.";
cWarning() << "Using fallback groups. Please check *defaultGroups* in users.conf"; }
defaultGroups = QStringList { "lp", "video", "network", "storage", "wheel", "audio" }; else
} {
#endif cWarning() << "Using fallback groups. Please check *defaultGroups* value in users.conf";
for ( const auto& s : { "lp", "video", "network", "storage", "wheel", "audio" } )
{
defaultGroups.append( GroupDescription( s ) );
}
}
}
else
{
for ( const auto& v : groupsFromConfig )
{
if ( v.type() == QVariant::String )
{
defaultGroups.append( GroupDescription( v.toString() ) );
}
else
{
cWarning() << "Unknown *defaultGroups* entry" << v;
}
}
}
} }
STATICTEST HostNameActions STATICTEST HostNameActions

Loading…
Cancel
Save