[users] Put hostname settings in a *hostname* key
Move settings into a structured setting for *hostname*, with suitable sub-keys. Legacy settings remain supported, produce a warning.
This commit is contained in:
parent
55dcd831bc
commit
04f38ea661
@ -738,7 +738,7 @@ STATICTEST HostNameActions
|
|||||||
getHostNameActions( const QVariantMap& configurationMap )
|
getHostNameActions( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
HostNameAction setHostName = HostNameAction::EtcHostname;
|
HostNameAction setHostName = HostNameAction::EtcHostname;
|
||||||
QString hostnameActionString = CalamaresUtils::getString( configurationMap, "setHostname" );
|
QString hostnameActionString = CalamaresUtils::getString( configurationMap, "location" );
|
||||||
if ( !hostnameActionString.isEmpty() )
|
if ( !hostnameActionString.isEmpty() )
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -826,6 +826,17 @@ either( T ( *f )( const QVariantMap&, const QString&, U ),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
copyLegacy( const QVariantMap& source, const QString& sourceKey, QVariantMap& target, const QString& targetKey )
|
||||||
|
{
|
||||||
|
if ( source.contains( sourceKey ) )
|
||||||
|
{
|
||||||
|
const QVariant legacyValue = source.value( sourceKey );
|
||||||
|
cWarning() << "Legacy *users* key" << sourceKey << "overrides hostname-settings.";
|
||||||
|
target.insert( targetKey, legacyValue );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
@ -844,7 +855,15 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
? SudoStyle::UserAndGroup
|
? SudoStyle::UserAndGroup
|
||||||
: SudoStyle::UserOnly;
|
: SudoStyle::UserOnly;
|
||||||
|
|
||||||
m_hostNameActions = getHostNameActions( configurationMap );
|
// Handle *hostname* key and subkeys and legacy settings
|
||||||
|
{
|
||||||
|
bool ok = false; // Ignored
|
||||||
|
QVariantMap hostnameSettings = CalamaresUtils::getSubMap( configurationMap, "hostname", ok );
|
||||||
|
|
||||||
|
copyLegacy( configurationMap, "setHostname", hostnameSettings, "location" );
|
||||||
|
copyLegacy( configurationMap, "writeHostsFile", hostnameSettings, "writeHostsFile" );
|
||||||
|
m_hostNameActions = getHostNameActions( hostnameSettings );
|
||||||
|
}
|
||||||
|
|
||||||
setConfigurationDefaultGroups( configurationMap, m_defaultGroups );
|
setConfigurationDefaultGroups( configurationMap, m_defaultGroups );
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ UserTests::testHostActions()
|
|||||||
QVariantMap m;
|
QVariantMap m;
|
||||||
if ( set )
|
if ( set )
|
||||||
{
|
{
|
||||||
m.insert( "setHostname", string );
|
m.insert( "location", string );
|
||||||
}
|
}
|
||||||
QCOMPARE( getHostNameActions( m ),
|
QCOMPARE( getHostNameActions( m ),
|
||||||
HostNameActions( result ) | HostNameAction::WriteEtcHosts ); // write bits default to true
|
HostNameActions( result ) | HostNameAction::WriteEtcHosts ); // write bits default to true
|
||||||
|
@ -149,19 +149,33 @@ allowWeakPasswordsDefault: false
|
|||||||
# that the shell actually exists or is executable.
|
# that the shell actually exists or is executable.
|
||||||
userShell: /bin/bash
|
userShell: /bin/bash
|
||||||
|
|
||||||
# Hostname setting
|
# Hostname settings
|
||||||
#
|
#
|
||||||
# The user can enter a hostname; this is configured into the system
|
# The user can enter a hostname; this is configured into the system
|
||||||
# in some way; pick one of:
|
# in some way. There are settings for how a hostname is guessed (as
|
||||||
|
# a default / suggestion) and where (or how) the hostname is set in
|
||||||
|
# the target system.
|
||||||
|
#
|
||||||
|
# Key *hostname* has the following sub-keys (just one):
|
||||||
|
#
|
||||||
|
# - *location* How the hostname is set in the target system:
|
||||||
# - *None*, to not set the hostname at all
|
# - *None*, to not set the hostname at all
|
||||||
# - *EtcFile*, to write to `/etc/hostname` directly
|
# - *EtcFile*, to write to `/etc/hostname` directly
|
||||||
# - *Hostnamed*, to use systemd hostnamed(1) over DBus
|
# - *Hostnamed*, to use systemd hostnamed(1) over DBus
|
||||||
# The default is *EtcFile*.
|
# The default is *EtcFile*. Setting this to *None* will
|
||||||
|
# hide the hostname field.
|
||||||
|
# - *writeHostsFile* Should /etc/hosts be written with a hostname for
|
||||||
|
# this machine (also adds localhost and some ipv6 standard entries).
|
||||||
|
# Defaults to *true*.
|
||||||
|
hostname:
|
||||||
|
location: EtcFile
|
||||||
|
writeHostsFile: true
|
||||||
|
|
||||||
|
# This is a legacy setting for hostname.location; if it is set
|
||||||
|
# at all, and there is no setting for hostname.location, it is used.
|
||||||
setHostname: EtcFile
|
setHostname: EtcFile
|
||||||
|
|
||||||
# Should /etc/hosts be written with a hostname for this machine
|
# This is a legacy setting for hostname.writeHostsFile
|
||||||
# (also adds localhost and some ipv6 standard entries).
|
|
||||||
# Defaults to *true*.
|
|
||||||
writeHostsFile: true
|
writeHostsFile: true
|
||||||
|
|
||||||
presets:
|
presets:
|
||||||
|
Loading…
Reference in New Issue
Block a user