ifcfg-rh: support the DHCP_FQDN variable

Add support for the DHCP_FQDN ifcfg-rh variable which maps to the
ipv4.dhcp-fqdn property.
This commit is contained in:
Beniamino Galvani 2015-10-16 11:55:58 +02:00
parent cb40194532
commit 5002342d94
3 changed files with 25 additions and 2 deletions

View file

@ -630,7 +630,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
/* ---ifcfg-rh---
* property: dhcp-hostname
* variable: DHCP_HOSTNAME
* description: Hostname to send to the DHCP server.
* description: Hostname to send to the DHCP server. When both DHCP_HOSTNAME and
* DHCP_FQDN are specified only the latter is used.
* ---end---
*/
@ -711,6 +712,14 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
*
* Since: 1.2
*/
/* ---ifcfg-rh---
* property: dhcp-fqdn
* variable: DHCP_FQDN
* description: FQDN to send to the DHCP server. When both DHCP_HOSTNAME and
* DHCP_FQDN are specified only the latter is used.
* example: DHCP_FQDN=foo.bar.com
* ---end---
*/
g_object_class_install_property
(object_class, PROP_DHCP_FQDN,
g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_FQDN, "", "",

View file

@ -1021,10 +1021,19 @@ make_ip4_setting (shvarFile *ifcfg,
/* Handle DHCP settings */
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE);
if (value && strlen (value))
if (value && *value)
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL);
g_free (value);
value = svGetValue (ifcfg, "DHCP_FQDN", FALSE);
if (value && *value) {
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL,
NM_SETTING_IP4_CONFIG_DHCP_FQDN, value,
NULL);
}
g_free (value);
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE),
NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXUINT32, 0),

View file

@ -2141,6 +2141,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (value)
svSetValue (ifcfg, "DHCP_HOSTNAME", value, FALSE);
value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4));
if (value)
svSetValue (ifcfg, "DHCP_FQDN", value, FALSE);
/* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly
* in that case, because it is NM-specific variable
*/
@ -2784,6 +2788,7 @@ write_connection (NMConnection *connection,
if (!utils_ignore_ip_config (connection)) {
svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE);
svSetValue (ifcfg, "DHCP_FQDN", NULL, FALSE);
if (!write_ip4_setting (connection, ifcfg, error))
goto out;