Hi, Please find attached a patch against the current git which re-enables DHCP/DNS Name transmission including domain suffix as an option.
I have a rather dim DSL router with DHCP function which doesn't accept any domain specific options but allows for the transmission of a full hostname via the "send host-name" command. I use the domain name to distinguish between my VPN connection and the rest of the world. So I used to add the full hostname for NetworkManager. Now it chops off the domain suffix before transmission. The attached patch adds a property "dhcp-with-domain" to NetworkManager which disables this behaviour when true. In addition the ifcfg-rh plugin enables this feature if it finds the DHCP_WITH_DOMAIN=yes line in the corresponding ifcfg-xxx file. Cheers Sebastian
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index 4d14082..ef6bceb 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -258,6 +258,7 @@ global: nm_setting_ip4_config_get_dhcp_client_id; nm_setting_ip4_config_get_dhcp_hostname; nm_setting_ip4_config_get_dhcp_send_hostname; + nm_setting_ip4_config_get_dhcp_with_domain; nm_setting_ip4_config_get_dns; nm_setting_ip4_config_get_dns_search; nm_setting_ip4_config_get_ignore_auto_dns; diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c index 6b164ea..9c6b40f 100644 --- a/libnm-util/nm-setting-ip4-config.c +++ b/libnm-util/nm-setting-ip4-config.c @@ -101,6 +101,7 @@ typedef struct { gboolean ignore_auto_dns; char *dhcp_client_id; gboolean dhcp_send_hostname; + gboolean dhcp_with_domain; char *dhcp_hostname; gboolean never_default; gboolean may_fail; @@ -117,6 +118,7 @@ enum { PROP_IGNORE_AUTO_DNS, PROP_DHCP_CLIENT_ID, PROP_DHCP_SEND_HOSTNAME, + PROP_DHCP_WITH_DOMAIN, PROP_DHCP_HOSTNAME, PROP_NEVER_DEFAULT, PROP_MAY_FAIL, @@ -640,10 +642,18 @@ gboolean nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting) { g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE); - return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_send_hostname; } +gboolean +nm_setting_ip4_config_get_dhcp_with_domain (NMSettingIP4Config *setting) + +{ + g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE); + + return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_with_domain; +} + /** * nm_setting_ip4_config_get_dhcp_hostname: * @setting: the #NMSettingIP4Config @@ -890,6 +900,9 @@ set_property (GObject *object, guint prop_id, case PROP_DHCP_SEND_HOSTNAME: priv->dhcp_send_hostname = g_value_get_boolean (value); break; + case PROP_DHCP_WITH_DOMAIN: + priv->dhcp_with_domain = g_value_get_boolean (value); + break; case PROP_DHCP_HOSTNAME: g_free (priv->dhcp_hostname); priv->dhcp_hostname = g_value_dup_string (value); @@ -944,6 +957,9 @@ get_property (GObject *object, guint prop_id, case PROP_DHCP_SEND_HOSTNAME: g_value_set_boolean (value, nm_setting_ip4_config_get_dhcp_send_hostname (setting)); break; + case PROP_DHCP_WITH_DOMAIN: + g_value_set_boolean (value, nm_setting_ip4_config_get_dhcp_with_domain (setting)); + break; case PROP_DHCP_HOSTNAME: g_value_set_string (value, nm_setting_ip4_config_get_dhcp_hostname (setting)); break; @@ -1202,6 +1218,15 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class) TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + g_object_class_install_property + (object_class, PROP_DHCP_WITH_DOMAIN, + g_param_spec_boolean (NM_SETTING_IP4_CONFIG_DHCP_WITH_DOMAIN, + "Send DHCP hostname with domain suffix", + "If TRUE, a hostname sent to the DHCP server will include " + "the domain suffix if available. ", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + /** * NMSettingIP4Config:dhcp-hostname: * diff --git a/libnm-util/nm-setting-ip4-config.h b/libnm-util/nm-setting-ip4-config.h index 76dcf37..9dd2a55 100644 --- a/libnm-util/nm-setting-ip4-config.h +++ b/libnm-util/nm-setting-ip4-config.h @@ -69,8 +69,9 @@ GQuark nm_setting_ip4_config_error_quark (void); #define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes" #define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns" #define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id" -#define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname" #define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME "dhcp-hostname" +#define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname" +#define NM_SETTING_IP4_CONFIG_DHCP_WITH_DOMAIN "dhcp-with-domain" #define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT "never-default" #define NM_SETTING_IP4_CONFIG_MAY_FAIL "may-fail" @@ -208,7 +209,6 @@ void nm_setting_ip4_config_clear_addresses (NMSettingIP4Config * guint32 nm_setting_ip4_config_get_num_routes (NMSettingIP4Config *setting); NMIP4Route * nm_setting_ip4_config_get_route (NMSettingIP4Config *setting, guint32 i); -gboolean nm_setting_ip4_config_add_route (NMSettingIP4Config *setting, NMIP4Route *route); void nm_setting_ip4_config_remove_route (NMSettingIP4Config *setting, guint32 i); void nm_setting_ip4_config_clear_routes (NMSettingIP4Config *setting); @@ -217,7 +217,8 @@ gboolean nm_setting_ip4_config_get_ignore_auto_dns (NMSettingIP4Config * const char * nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting); gboolean nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting); const char * nm_setting_ip4_config_get_dhcp_hostname (NMSettingIP4Config *setting); - +gboolean nm_setting_ip4_config_add_route (NMSettingIP4Config *setting, NMIP4Route *route); +gboolean nm_setting_ip4_config_get_dhcp_with_domain (NMSettingIP4Config *setting); gboolean nm_setting_ip4_config_get_never_default (NMSettingIP4Config *setting); gboolean nm_setting_ip4_config_get_may_fail (NMSettingIP4Config *setting); diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c index caf90f1..57d2a1b 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c +++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c @@ -18,7 +18,6 @@ */ #include <config.h> - #include <glib.h> #include <glib/gi18n.h> #include <string.h> @@ -59,6 +58,7 @@ nm_dhcp_dhclient_create_config (const char *interface, GPtrArray *alsoreq; int i; + new_contents = g_string_new (_("# Created by NetworkManager\n")); alsoreq = g_ptr_array_sized_new (5); @@ -169,11 +169,14 @@ nm_dhcp_dhclient_create_config (const char *interface, char *plain_hostname, *dot; plain_hostname = g_strdup (hostname); - dot = strchr (plain_hostname, '.'); - /* get rid of the domain */ - if (dot) - *dot = '\0'; + if(nm_setting_ip4_config_get_dhcp_with_domain(s_ip4)==FALSE) + { + dot = strchr (plain_hostname, '.'); + /* get rid of the domain */ + if (dot) + *dot = '\0'; + } g_string_append_printf (new_contents, HOSTNAME_FORMAT "\n", plain_hostname); added = TRUE; diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 521a9d0..4ffd904 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -1316,6 +1316,10 @@ make_ip4_setting (shvarFile *ifcfg, g_free (value); } + g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_WITH_DOMAIN, + svTrueValue (ifcfg, "DHCP_WITH_DOMAIN", FALSE), + NULL); + /* DNS servers * Pick up just IPv4 addresses (IPv6 addresses are taken by make_ip6_setting()) */
_______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list