2005-12-14 Robert Love <rml@novell.com>
Patch from Stefan Scheler <sscheler@suse.de>: * src/NetworkManagerDevice.c: call backend code to activate and deactivate NIS. * src/NetworkManagerSystem.h: add new NIS interfaces. * src/backends/NetworkManagerDebian.c, src/backends/NetworkManagerGentoo.c, src/backends/NetworkManagerRedHat.c, src/backends/NetworkManagerSlackware.c: add stub functions for NIS support. * src/backends/NetworkManagerSuSE.c: add NIS support, baby. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1186 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -822,3 +822,64 @@ out_gfree:
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_activate_nis
|
||||
*
|
||||
* set up the nis domain and write a yp.conf
|
||||
*
|
||||
*/
|
||||
void nm_system_activate_nis (NMIP4Config *config)
|
||||
{
|
||||
gchar *nis_domain = NULL;
|
||||
int num_nis_servers = 0;
|
||||
struct in_addr temp_addr;
|
||||
int i, ret;
|
||||
FILE *ypconf = NULL;
|
||||
|
||||
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)
|
||||
nm_warning ("Could not set nis domain name.");
|
||||
|
||||
/* write out yp.conf and restart the daemon */
|
||||
if (num_nis_servers > 0)
|
||||
{
|
||||
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.");
|
||||
nm_info ("Restarting ypbind.");
|
||||
nm_spawn_process ("/usr/sbin/rcypbind restart");
|
||||
nm_info ("Restarting autofs.");
|
||||
nm_spawn_process ("/usr/sbin/rcautofs restart");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_shutdown_nis
|
||||
*
|
||||
* shutdown ypbind
|
||||
*
|
||||
*/
|
||||
void nm_system_shutdown_nis (void)
|
||||
{
|
||||
nm_info ("Stopping ypbind.");
|
||||
nm_spawn_process ("/usr/sbin/rcypbind stop");
|
||||
nm_info ("Restarting autofs.");
|
||||
nm_spawn_process ("/usr/sbin/rcautofs restart");
|
||||
}
|
||||
|
Reference in New Issue
Block a user