Re: Configuring DHCP
- From: "Tambet Ingo" <tambet gmail com>
- To: "Dan Williams" <dcbw redhat com>
- Cc: Nick Palamarchuk <lupinedreamer gmail com>, networkmanager-list gnome org
- Subject: Re: Configuring DHCP
- Date: Fri, 16 May 2008 13:38:59 +0300
On Fri, May 2, 2008 at 5:50 PM, Dan Williams <dcbw redhat com> 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 <tambet gmail com>
+
+ * 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 <tambet gmail com>
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]