ifcfg-rh: support the DHCP_FQDN variable
authorBeniamino Galvani <bgalvani@redhat.com>
Fri, 16 Oct 2015 09:55:58 +0000 (11:55 +0200)
committerBeniamino Galvani <bgalvani@redhat.com>
Mon, 23 Nov 2015 21:08:22 +0000 (22:08 +0100)
Add support for the DHCP_FQDN ifcfg-rh variable which maps to the
ipv4.dhcp-fqdn property.

libnm-core/nm-setting-ip4-config.c
src/settings/plugins/ifcfg-rh/reader.c
src/settings/plugins/ifcfg-rh/writer.c

index 15949db..7708b6c 100644 (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, "", "",
index df2a447..bcb726a 100644 (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),
index 1ea932e..5770d66 100644 (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;