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:
@@ -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,42 +931,63 @@ 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);
|
||||
|
||||
/* write out yp.conf and restart the daemon */
|
||||
if (num_nis_servers > 0)
|
||||
{
|
||||
struct stat sb;
|
||||
buf = svGetValue (file, "DHCLIENT_MODIFY_NIS_CONF");
|
||||
if (!buf)
|
||||
goto out_close;
|
||||
|
||||
ypconf = fopen ("/etc/yp.conf", "w");
|
||||
|
||||
if (ypconf)
|
||||
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)
|
||||
{
|
||||
fprintf (ypconf, "# generated by NetworkManager, do not edit!\n\n");
|
||||
for (i = 0; i < num_nis_servers; i++) {
|
||||
temp_addr.s_addr = nm_ip4_config_get_nis_server (config, i);
|
||||
fprintf (ypconf, "domain %s server %s\n", nis_domain, inet_ntoa (temp_addr));
|
||||
struct stat sb;
|
||||
|
||||
ypconf = fopen ("/etc/yp.conf", "w");
|
||||
|
||||
if (ypconf)
|
||||
{
|
||||
fprintf (ypconf, "# generated by NetworkManager, do not edit!\n\n");
|
||||
for (i = 0; i < num_nis_servers; i++) {
|
||||
temp_addr.s_addr = nm_ip4_config_get_nis_server (config, i);
|
||||
fprintf (ypconf, "domain %s server %s\n", nis_domain, inet_ntoa (temp_addr));
|
||||
}
|
||||
fprintf (ypconf, "\n");
|
||||
fclose (ypconf);
|
||||
} else
|
||||
nm_warning ("Could not commit NIS changes to /etc/yp.conf.");
|
||||
|
||||
if (stat ("/usr/sbin/rcypbind", &sb) != -1)
|
||||
{
|
||||
nm_info ("Restarting ypbind.");
|
||||
nm_spawn_process ("/usr/sbin/rcypbind restart");
|
||||
}
|
||||
if (stat ("/usr/sbin/rcautofs", &sb) != -1)
|
||||
{
|
||||
nm_info ("Restarting autofs.");
|
||||
nm_spawn_process ("/usr/sbin/rcautofs restart");
|
||||
}
|
||||
fprintf (ypconf, "\n");
|
||||
fclose (ypconf);
|
||||
} else
|
||||
nm_warning ("Could not commit NIS changes to /etc/yp.conf.");
|
||||
|
||||
if (stat ("/usr/sbin/rcypbind", &sb) != -1)
|
||||
{
|
||||
nm_info ("Restarting ypbind.");
|
||||
nm_spawn_process ("/usr/sbin/rcypbind restart");
|
||||
}
|
||||
if (stat ("/usr/sbin/rcautofs", &sb) != -1)
|
||||
{
|
||||
nm_info ("Restarting autofs.");
|
||||
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user