Re: Configuring DHCP

2008-05-19 Thread Dan Williams
On Mon, 2008-05-19 at 11:12 +0300, Tambet Ingo wrote:
 On Tue, May 13, 2008 at 7:21 PM, Dan Williams [EMAIL PROTECTED] wrote:
  On Fri, 2008-05-16 at 13:38 +0300, Tambet Ingo wrote:
  Here's a patch to fix it. Uses /etc/dhclient-$iface.conf on redhat,
  /etc/dhclient.conf on suse and /etc/dhcp3/dhclient.conf on debian. Any
  additions?
 
  I'd rather key off the distro defined at configure time actually...
 
 Care to write a patch for it? :) Because of the way distro stuff is
 defined (a variable per distro) in configure.in, it's very
 inconvenient to test for the distro in .c file.

Sure, now on my list.

Dan


___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Configuring DHCP

2008-05-16 Thread Tambet Ingo
On Fri, May 2, 2008 at 5:50 PM, Dan Williams [EMAIL PROTECTED] wrote:
 BTW, if debian puts interface-specific dhclient config files somewhere
 else normally, I'm happy to have NM pass that location on the dhclient
 command line for debian-based distros
 instead.  /etc/dhcp3/dhclient-wlan0.conf perhaps?

Here's a patch to fix it. Uses /etc/dhclient-$iface.conf on redhat,
/etc/dhclient.conf on suse and /etc/dhcp3/dhclient.conf on debian. Any
additions?

Tambet
diff --git a/ChangeLog b/ChangeLog
index b9e50bc..24c05cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-16  Tambet Ingo  [EMAIL PROTECTED]
+
+	* src/dhcp-manager/nm-dhcp-manager.c (dhclient_find_conf_file): 
+	Implement.
+	(dhclient_run): Try to locate the dhclient.conf.
+
 2008-05-15  Tambet Ingo  [EMAIL PROTECTED]
 
 	Move crypto functions from nm-applet to libnm-util.
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index 3f338e0..16df573 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager
  *
  * Copyright (C) 2005 Dan Williams
@@ -590,6 +592,35 @@ dhclient_child_setup (gpointer user_data G_GNUC_UNUSED)
 	setpgid (pid, pid);
 }
 
+static char *
+dhclient_find_conf_file (const char *iface)
+{
+	char *file;
+
+	/* redhat */
+	file = g_strdup_printf (SYSCONFDIR /dhclient-%s.conf, iface);
+	if (g_file_test (file, G_FILE_TEST_IS_REGULAR))
+		return file;
+
+	g_free (file);
+
+	/* suse */
+	file = g_build_filename (SYSCONFDIR, dhclient.conf, NULL);
+	if (g_file_test (file, G_FILE_TEST_IS_REGULAR))
+		return file;
+
+	g_free (file);
+
+	/* debian */
+	file = g_build_filename (SYSCONFDIR, dhcp3, dhclient.conf, NULL);
+	if (g_file_test (file, G_FILE_TEST_IS_REGULAR))
+		return file;
+
+	g_free (file);
+
+	return NULL;
+}
+
 static gboolean
 dhclient_run (NMDHCPDevice *device)
 {
@@ -628,11 +659,9 @@ dhclient_run (NMDHCPDevice *device)
 		goto out;
 	}
 
-	conffile = g_strdup_printf (SYSCONFDIR /dhclient-%s.conf, device-iface);
-	if (!conffile) {
-		nm_warning (%s: not enough memory for dhclient options., device-iface);
-		goto out;
-	}
+	conffile = dhclient_find_conf_file (device-iface);
+	if (!conffile)
+		nm_warning (%s: Could not find dhclient configuration file., device-iface);
 
 	/* Kill any existing dhclient bound to this interface */
 	if (g_file_get_contents (pidfile, pid_contents, NULL, NULL)) {
@@ -657,8 +686,10 @@ dhclient_run (NMDHCPDevice *device)
 	g_ptr_array_add (dhclient_argv, (gpointer) -lf);	/* Set lease file */
 	g_ptr_array_add (dhclient_argv, (gpointer) leasefile);
 
-	g_ptr_array_add (dhclient_argv, (gpointer) -cf);	/* Set interface config file */
-	g_ptr_array_add (dhclient_argv, (gpointer) conffile);
+	if (conffile) {
+		g_ptr_array_add (dhclient_argv, (gpointer) -cf);	/* Set interface config file */
+		g_ptr_array_add (dhclient_argv, (gpointer) conffile);
+	}
 
 	g_ptr_array_add (dhclient_argv, (gpointer) device-iface);
 	g_ptr_array_add (dhclient_argv, NULL);
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Configuring DHCP

2008-05-16 Thread Dan Williams
On Fri, 2008-05-16 at 13:38 +0300, Tambet Ingo wrote:
 On Fri, May 2, 2008 at 5:50 PM, Dan Williams [EMAIL PROTECTED] wrote:
  BTW, if debian puts interface-specific dhclient config files somewhere
  else normally, I'm happy to have NM pass that location on the dhclient
  command line for debian-based distros
  instead.  /etc/dhcp3/dhclient-wlan0.conf perhaps?
 
 Here's a patch to fix it. Uses /etc/dhclient-$iface.conf on redhat,
 /etc/dhclient.conf on suse and /etc/dhcp3/dhclient.conf on debian. Any
 additions?

I'd rather key off the distro defined at configure time actually...

dan

___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Configuring DHCP

2008-05-02 Thread Dan Williams
On Fri, 2008-05-02 at 01:07 +0300, Hristo Hristov wrote:
 Hi,
 I traced thar NM v0.7 calls dhclient with these parameters for me:
 -d -sf /usr/lib/NetworkManager/nm-dhcp-client.action
 -pf /var/run/dhclient-wlan0.pid -lf /var/run/dhclient-wlan0.lease 
 -cf /etc/dhclient-wlan0.conf wlan0
 So you can specify the options for dhclient in /etc/dhclient-wlan0.conf
 , changing wlan0 with the interface you have, instead of 
 /etc/dhcp3/dhclient.conf

BTW, if debian puts interface-specific dhclient config files somewhere
else normally, I'm happy to have NM pass that location on the dhclient
command line for debian-based distros
instead.  /etc/dhcp3/dhclient-wlan0.conf perhaps?

dan

 BR,
 Hristo
 
 On Fri, 2 May 2008 00:57:24 +0300
 Nick Palamarchuk [EMAIL PROTECTED] wrote:
 
  Hello all,
  
  DHCP server on my network sends routes in rfc3442 format. So I have to
  configure NetworkManager to understand this format.
  
  My /etc/dhcp3/dhclient.conf looks like this:
  
  option rfc3442-classless-static-routes code 121 = array of unsigned integer
  8;
  
  request subnet-mask, broadcast-address, routers,
  domain-name, domain-name-servers, host-name,
  netbios-name-servers, netbios-scope,
  rfc3442-classless-static-routes;
  
  I also have script for setting this routes in
  /etc/dhcp3/dhclient-exit-hooks.d
  
  But NetworkManager dont use this options. I found only way for making it
  work: to re-run dhclient by hand (or by script in /etc/network/if-up.d/ )
  
  Tell me plz if there is better way.
 
 
 --
 Hristo Hristov
 VAS Engineer
 Opencode Systems Ltd
 Tel : +359 2 971 8314
 Mob : +359 89 6890522
 Fax : +359 2 971 8231
 www.opencode.com
 ___
 NetworkManager-list mailing list
 NetworkManager-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/networkmanager-list

___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Configuring DHCP

2008-05-01 Thread Nick Palamarchuk
Hello all,

DHCP server on my network sends routes in rfc3442 format. So I have to
configure NetworkManager to understand this format.

My /etc/dhcp3/dhclient.conf looks like this:

option rfc3442-classless-static-routes code 121 = array of unsigned integer
8;

request subnet-mask, broadcast-address, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope,
rfc3442-classless-static-routes;

I also have script for setting this routes in
/etc/dhcp3/dhclient-exit-hooks.d

But NetworkManager dont use this options. I found only way for making it
work: to re-run dhclient by hand (or by script in /etc/network/if-up.d/ )

Tell me plz if there is better way.
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: Configuring DHCP

2008-05-01 Thread Hristo Hristov
Hi,
I traced thar NM v0.7 calls dhclient with these parameters for me:
-d -sf /usr/lib/NetworkManager/nm-dhcp-client.action
-pf /var/run/dhclient-wlan0.pid -lf /var/run/dhclient-wlan0.lease 
-cf /etc/dhclient-wlan0.conf wlan0
So you can specify the options for dhclient in /etc/dhclient-wlan0.conf
, changing wlan0 with the interface you have, instead of 
/etc/dhcp3/dhclient.conf

BR,
Hristo

On Fri, 2 May 2008 00:57:24 +0300
Nick Palamarchuk [EMAIL PROTECTED] wrote:

 Hello all,
 
 DHCP server on my network sends routes in rfc3442 format. So I have to
 configure NetworkManager to understand this format.
 
 My /etc/dhcp3/dhclient.conf looks like this:
 
 option rfc3442-classless-static-routes code 121 = array of unsigned integer
 8;
 
 request subnet-mask, broadcast-address, routers,
 domain-name, domain-name-servers, host-name,
 netbios-name-servers, netbios-scope,
 rfc3442-classless-static-routes;
 
 I also have script for setting this routes in
 /etc/dhcp3/dhclient-exit-hooks.d
 
 But NetworkManager dont use this options. I found only way for making it
 work: to re-run dhclient by hand (or by script in /etc/network/if-up.d/ )
 
 Tell me plz if there is better way.


--
Hristo Hristov
VAS Engineer
Opencode Systems Ltd
Tel : +359 2 971 8314
Mob : +359 89 6890522
Fax : +359 2 971 8231
www.opencode.com
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list