2006-01-23 Robert Love <rml@novell.com>
* dhcp-manager/nm-dhcp-manager.c, nm-device.c, nm-ip4-config.c, nm-ip4-config.h, NetworkManagerSystem.h: Save the hostname reported by DHCP and pass it to the backends, allowing distribution-specific behavior with respect to the DHCP-supplied hostname (if nothing else, some distributions might not want to set the hostname). * backends/NetworkManagerSuSE.c: Set the hostname if the variable DHCLIENT_SET_HOSTNAME is set to "yes" in /etc/sysconfig/network/dhcp. Also update our NIS behavior. * backends/NetworkManagerDebian.c, backends/NetworkManagerGentoo.c, backends/NetworkManagerRedHat.c, backends/NetworkManagerSlackware.c: Add stub functions. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1382 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
2006-01-23 Robert Love <rml@novell.com>
|
||||
|
||||
* dhcp-manager/nm-dhcp-manager.c, nm-device.c, nm-ip4-config.c,
|
||||
nm-ip4-config.h, NetworkManagerSystem.h: Save the hostname reported
|
||||
by DHCP and pass it to the backends, allowing distribution-specific
|
||||
behavior with respect to the DHCP-supplied hostname (if nothing else,
|
||||
some distributions might not want to set the hostname).
|
||||
* backends/NetworkManagerSuSE.c: Set the hostname if the variable
|
||||
DHCLIENT_SET_HOSTNAME is set to "yes" in /etc/sysconfig/network/dhcp.
|
||||
Also update our NIS behavior.
|
||||
* backends/NetworkManagerDebian.c, backends/NetworkManagerGentoo.c,
|
||||
backends/NetworkManagerRedHat.c, backends/NetworkManagerSlackware.c:
|
||||
Add stub functions.
|
||||
|
||||
2006-01-23 Robert Love <rml@novell.com>
|
||||
|
||||
* Makefile.am, nm-applet.desktop: Add autostart .desktop file, now that
|
||||
|
@@ -78,6 +78,7 @@ void nm_system_deactivate_all_dialup (GSList *list);
|
||||
gboolean nm_system_activate_dialup (GSList *list, const char *dialup);
|
||||
gboolean nm_system_deactivate_dialup (GSList *list, const char *dialup);
|
||||
|
||||
void nm_system_set_hostname (NMIP4Config *config);
|
||||
void nm_system_activate_nis (NMIP4Config *config);
|
||||
void nm_system_shutdown_nis (void);
|
||||
|
||||
|
@@ -780,3 +780,13 @@ void nm_system_shutdown_nis (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_set_hostname
|
||||
*
|
||||
* set the hostname
|
||||
*
|
||||
*/
|
||||
void nm_system_set_hostname (NMIP4Config *config)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -552,3 +552,13 @@ void nm_system_shutdown_nis (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_set_hostname
|
||||
*
|
||||
* set the hostname
|
||||
*
|
||||
*/
|
||||
void nm_system_set_hostname (NMIP4Config *config)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -891,3 +891,13 @@ void nm_system_shutdown_nis (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_set_hostname
|
||||
*
|
||||
* set the hostname
|
||||
*
|
||||
*/
|
||||
void nm_system_set_hostname (NMIP4Config *config)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -404,3 +404,13 @@ void nm_system_shutdown_nis (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_set_hostname
|
||||
*
|
||||
* set the hostname
|
||||
*
|
||||
*/
|
||||
void nm_system_set_hostname (NMIP4Config *config)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -921,7 +921,8 @@ out_gfree:
|
||||
*/
|
||||
void nm_system_activate_nis (NMIP4Config *config)
|
||||
{
|
||||
gchar *nis_domain = NULL;
|
||||
shvarFile *file;
|
||||
gchar *nis_domain, *name, *buf = NULL;
|
||||
int num_nis_servers = 0;
|
||||
struct in_addr temp_addr;
|
||||
int i;
|
||||
@@ -930,12 +931,26 @@ void nm_system_activate_nis (NMIP4Config *config)
|
||||
g_return_if_fail (config != NULL);
|
||||
|
||||
nis_domain = nm_ip4_config_get_nis_domain(config);
|
||||
num_nis_servers = nm_ip4_config_get_num_nis_servers(config);
|
||||
|
||||
/* set the nis domain */
|
||||
if (nis_domain && setdomainname (nis_domain, strlen (nis_domain)) < 0)
|
||||
name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
|
||||
file = svNewFile (name);
|
||||
if (!file)
|
||||
goto out_gfree;
|
||||
|
||||
buf = svGetValue (file, "DHCLIENT_SET_DOMAINNAME");
|
||||
if (!buf)
|
||||
goto out_close;
|
||||
|
||||
if ((!strcmp (buf, "yes")) && nis_domain && (setdomainname (nis_domain, strlen (nis_domain)) < 0))
|
||||
nm_warning ("Could not set nis domain name.");
|
||||
free (buf);
|
||||
|
||||
buf = svGetValue (file, "DHCLIENT_MODIFY_NIS_CONF");
|
||||
if (!buf)
|
||||
goto out_close;
|
||||
|
||||
if (!strcmp (buf, "yes")) {
|
||||
num_nis_servers = nm_ip4_config_get_num_nis_servers(config);
|
||||
/* write out yp.conf and restart the daemon */
|
||||
if (num_nis_servers > 0)
|
||||
{
|
||||
@@ -966,6 +981,13 @@ void nm_system_activate_nis (NMIP4Config *config)
|
||||
nm_spawn_process ("/usr/sbin/rcautofs restart");
|
||||
}
|
||||
}
|
||||
}
|
||||
free (buf);
|
||||
|
||||
out_close:
|
||||
svCloseFile (file);
|
||||
out_gfree:
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
|
||||
@@ -990,3 +1012,39 @@ void nm_system_shutdown_nis (void)
|
||||
nm_spawn_process ("/usr/sbin/rcautofs restart");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_set_hostname
|
||||
*
|
||||
* set the hostname
|
||||
*
|
||||
*/
|
||||
void nm_system_set_hostname (NMIP4Config *config)
|
||||
{
|
||||
shvarFile *file;
|
||||
gchar *name, *buf, *hostname = NULL;
|
||||
|
||||
g_return_if_fail (config != NULL);
|
||||
|
||||
name = g_strdup_printf (SYSCONFDIR"/sysconfig/network/dhcp");
|
||||
file = svNewFile (name);
|
||||
if (!file)
|
||||
goto out_gfree;
|
||||
|
||||
buf = svGetValue (file, "DHCLIENT_SET_HOSTNAME");
|
||||
if (!buf)
|
||||
goto out_close;
|
||||
|
||||
if (!strcmp (buf, "yes")) {
|
||||
hostname = nm_ip4_config_get_hostname (config);
|
||||
if (hostname && sethostname (hostname, strlen (hostname)) < 0)
|
||||
nm_warning ("Could not set hostname.");
|
||||
}
|
||||
free (buf);
|
||||
|
||||
out_close:
|
||||
svCloseFile (file);
|
||||
out_gfree:
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
|
@@ -421,6 +421,11 @@ static gboolean get_ip4_string (NMDHCPManager *manager, NMDevice *dev, const cha
|
||||
|
||||
dbus_error_init (&error);
|
||||
if ((reply = dbus_connection_send_with_reply_and_block (manager->data->dbus_connection, message, -1, &error)))
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
|
||||
dbus_message_iter_init (reply, &iter);
|
||||
if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_STRING)
|
||||
{
|
||||
char *dbus_string;
|
||||
|
||||
@@ -431,6 +436,20 @@ static gboolean get_ip4_string (NMDHCPManager *manager, NMDevice *dev, const cha
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY)
|
||||
{
|
||||
char *byte_array = NULL;
|
||||
int len = 0;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (dbus_message_get_args (reply, &error, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &byte_array, &len, DBUS_TYPE_INVALID))
|
||||
{
|
||||
*string = g_strdup (byte_array);
|
||||
*string[len] = '\0';
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dbus_error_is_set (&error))
|
||||
{
|
||||
@@ -480,6 +499,7 @@ NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActReque
|
||||
guint32 * ip4_gateway = NULL;
|
||||
guint32 num_ip4_nameservers = 0;
|
||||
guint32 num_ip4_nis_servers = 0;
|
||||
char * hostname = NULL;
|
||||
char * domain_names = NULL;
|
||||
char * nis_domain = NULL;
|
||||
guint32 * ip4_nis_servers = NULL;
|
||||
@@ -524,6 +544,7 @@ NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActReque
|
||||
goto out;
|
||||
}
|
||||
|
||||
get_ip4_string (manager, dev, "host_name", &hostname, TRUE);
|
||||
get_ip4_uint32s (manager, dev, "domain_name_servers", &ip4_nameservers, &num_ip4_nameservers, FALSE);
|
||||
get_ip4_string (manager, dev, "domain_name", &domain_names, FALSE);
|
||||
get_ip4_string (manager, dev, "nis_domain", &nis_domain, TRUE);
|
||||
@@ -555,6 +576,12 @@ NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, NMActReque
|
||||
nm_info (" nameserver %s", inet_ntoa (temp_addr));
|
||||
}
|
||||
|
||||
if (hostname)
|
||||
{
|
||||
nm_ip4_config_set_hostname (ip4_config, hostname);
|
||||
nm_info (" hostname '%s'", hostname);
|
||||
}
|
||||
|
||||
if (domain_names)
|
||||
{
|
||||
char **searches = g_strsplit (domain_names, " ", 0);
|
||||
|
@@ -1223,6 +1223,7 @@ nm_device_activate_stage5_ip_config_commit (NMActRequest *req)
|
||||
nm_device_update_ip4_address (self);
|
||||
nm_system_device_add_ip6_link_address (self);
|
||||
nm_system_restart_mdns_responder ();
|
||||
nm_system_set_hostname (self->priv->ip4_config);
|
||||
nm_system_activate_nis (self->priv->ip4_config);
|
||||
if (NM_DEVICE_GET_CLASS (self)->update_link)
|
||||
NM_DEVICE_GET_CLASS (self)->update_link (self);
|
||||
|
@@ -44,6 +44,7 @@ struct NMIP4Config
|
||||
GSList * nameservers;
|
||||
GSList * domains;
|
||||
|
||||
gchar * hostname;
|
||||
gchar * nis_domain;
|
||||
GSList * nis_servers;
|
||||
|
||||
@@ -80,6 +81,7 @@ NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
|
||||
dst_config->ip4_netmask = nm_ip4_config_get_netmask (src_config);
|
||||
dst_config->ip4_broadcast = nm_ip4_config_get_broadcast (src_config);
|
||||
|
||||
dst_config->hostname = g_strdup (nm_ip4_config_get_hostname (src_config));
|
||||
dst_config->nis_domain = g_strdup (nm_ip4_config_get_nis_domain (src_config));
|
||||
|
||||
len = nm_ip4_config_get_num_nameservers (src_config);
|
||||
@@ -111,6 +113,7 @@ void nm_ip4_config_unref (NMIP4Config *config)
|
||||
config->refcount--;
|
||||
if (config->refcount <= 0)
|
||||
{
|
||||
g_free (config->hostname);
|
||||
g_free (config->nis_domain);
|
||||
g_slist_free (config->nameservers);
|
||||
g_slist_foreach (config->domains, (GFunc) g_free, NULL);
|
||||
@@ -269,6 +272,24 @@ void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
|
||||
config->domains = g_slist_append (config->domains, g_strdup (domain));
|
||||
}
|
||||
|
||||
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname)
|
||||
{
|
||||
g_return_if_fail (config != NULL);
|
||||
g_return_if_fail (hostname != NULL);
|
||||
|
||||
if (!strlen (hostname))
|
||||
return;
|
||||
|
||||
config->hostname = g_strdup (hostname);
|
||||
}
|
||||
|
||||
gchar *nm_ip4_config_get_hostname (NMIP4Config *config)
|
||||
{
|
||||
g_return_val_if_fail (config != NULL, NULL);
|
||||
|
||||
return config->hostname;
|
||||
}
|
||||
|
||||
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
|
||||
{
|
||||
g_return_if_fail (config != NULL);
|
||||
|
@@ -58,6 +58,9 @@ void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server);
|
||||
guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i);
|
||||
guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config);
|
||||
|
||||
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname);
|
||||
gchar *nm_ip4_config_get_hostname (NMIP4Config *config);
|
||||
|
||||
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain);
|
||||
gchar *nm_ip4_config_get_nis_domain (NMIP4Config *config);
|
||||
|
||||
|
Reference in New Issue
Block a user