Re: [patch]NIS support



On Tue, Jun 22, 2010 at 5:20 PM, Dan Williams <dcbw redhat com> wrote:
> On Tue, 2010-06-22 at 16:19 +0800, Bin Li wrote:
>> Dan,
>>
>>  Any idea about this patch?
>
> Sorry, got back from vacation late last week and still catching up.  The
> patch looks fine.  Will review a bit more closely tomorrow and commit.
>
> Thanks!
> Dan
Thanks! And I update the patch again for compiling warning with g_free().
Please use the new patch.

>
>> On Tue, Jun 15, 2010 at 2:30 PM, Bin Li <libin charles gmail com> wrote:
>> > Hi,
>> >
>> >  This patch support the NIS configuration, and I don't expand the
>> > NMIP4ConfigPrivate for the nis_domain, nis_servers. For simple, just
>> > use g_object_set_data_full to bind the data with the ip4_config
>> > object.
>> >
>> > Sincerely Yours,
>> >
>> > Bin Li
>> >
>> > http://cn.opensuse.org
>> >
>> _______________________________________________
>> networkmanager-list mailing list
>> networkmanager-list gnome org
>> http://mail.gnome.org/mailman/listinfo/networkmanager-list
>
>
>
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 5cebaa8..9e32403 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -891,6 +891,18 @@ ip4_options_to_config (NMDHCPClient *self)
 			nm_ip4_config_set_mtu (ip4_config, int_mtu);
 	}
 
+	str = g_hash_table_lookup (priv->options, "new_nis_domain");
+	if (str) {
+		nm_log_info (LOGD_DHCP4, "  NIS domain '%s'", str);
+		g_object_set_data_full (G_OBJECT (ip4_config), "NISDOMAIN", g_strdup (str), g_free);
+	}
+
+	str = g_hash_table_lookup (priv->options, "new_nis_servers");
+	if (str) {
+		nm_log_info (LOGD_DHCP4, "  NIS servers '%s'", str);
+		g_object_set_data_full (G_OBJECT (ip4_config), "NISSERVERS", g_strdup (str), g_free);
+	}
+
 	return ip4_config;
 
 error:
diff --git a/src/named-manager/nm-named-manager.c b/src/named-manager/nm-named-manager.c
index fc3b6e2..08f5ce3 100644
--- a/src/named-manager/nm-named-manager.c
+++ b/src/named-manager/nm-named-manager.c
@@ -98,6 +98,8 @@ typedef struct {
 	GPtrArray *nameservers;
 	const char *domain;
 	GPtrArray *searches;
+	const char *nis_domain;
+	const char *nis_servers;
 } NMResolvConfData;
 
 static void
@@ -148,6 +150,18 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src)
 	num = nm_ip4_config_get_num_searches (src);
 	for (i = 0; i < num; i++)
 		add_string_item (rc->searches, nm_ip4_config_get_search (src, i));
+
+	if (!rc->nis_domain && !rc->nis_servers) {
+		const char *tmp;
+
+		tmp = g_object_get_data (G_OBJECT (src), "NISDOMAIN");
+		if (tmp)
+			rc->nis_domain = g_strdup (tmp);
+
+		tmp = g_object_get_data (G_OBJECT (src), "NISSERVERS");
+		if (tmp)
+			rc->nis_servers = g_strdup (tmp);
+	}
 }
 
 static void
@@ -240,6 +254,8 @@ dispatch_netconfig (const char *domain,
                     char **searches,
                     char **nameservers,
                     const char *iface,
+                    const char *nis_domain,
+                    const char *nis_servers,
                     GError **error)
 {
 	char *str;
@@ -283,6 +299,12 @@ dispatch_netconfig (const char *domain,
 		g_free (str);
 	}
 
+	if (nis_domain)
+		write_to_netconfig (fd, "NISDOMAIN", nis_domain);
+
+	if (nis_servers)
+		write_to_netconfig (fd, "NISSERVERS", nis_servers);
+
 	close (fd);
 
 	/* Wait until the process exits */
@@ -515,6 +537,8 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 	rc.nameservers = g_ptr_array_new ();
 	rc.domain = NULL;
 	rc.searches = g_ptr_array_new ();
+	rc.nis_domain = NULL;
+	rc.nis_servers = NULL;
 
 	if (priv->ip4_vpn_config)
 		merge_one_ip4_config (&rc, priv->ip4_vpn_config);
@@ -575,7 +599,10 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 
 #ifdef TARGET_SUSE
 	if (success == FALSE)
-		success = dispatch_netconfig (domain, searches, nameservers, iface, error);
+		success = dispatch_netconfig (domain, searches, nameservers, iface,
+				rc.nis_domain,
+				rc.nis_servers,
+				error);
 #endif
 
 	if (success == FALSE)
@@ -589,6 +616,11 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 	if (nameservers)
 		g_strfreev (nameservers);
 
+	if (rc.nis_domain)
+		g_free ((gpointer)rc.nis_domain);
+	if (rc.nis_servers)
+		g_free ((gpointer)rc.nis_servers);
+
 	return success;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]