1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
From d39fda772235d967266a25159b877596d636c048 Mon Sep 17 00:00:00 2001
From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Date: Thu, 12 Aug 2010 22:52:20 +0000
Subject: dhcp: don't fail with dhclient v3
---
diff --git a/configure.ac b/configure.ac
index cfc2122..efdef27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -319,21 +319,30 @@ AC_SUBST(PPPD_PLUGIN_DIR)
AC_ARG_WITH([dhclient], AS_HELP_STRING([--with-dhclient=yes|no|path], [Enable dhclient 4.x support]))
# If a full path is given, use that and do not test if it works or not.
case "${with_dhclient}" in
+ # NM only works with ISC dhclient - other derivatives don't have
+ # the same userland. dhclient 4.x is required for IPv6 support;
+ # with older versions NM won't be able to use DHCPv6.
+
/*)
DHCLIENT_PATH="${with_dhclient}"
+ DHCLIENT_VERSION=4
+ if test -x "${with_dhclient}"; then
+ case `"${with_dhclient}" --version 2>&1` in
+ "isc-dhclient-4"*) DHCLIENT_VERSION=4; break;;
+ "isc-dhclient-V3"*) DHCLIENT_VERSION=3; break;;
+ esac
+ fi
AC_MSG_NOTICE(using dhclient at ${DHCLIENT_PATH})
;;
no) AC_MSG_NOTICE(dhclient support disabled)
;;
*)
AC_MSG_CHECKING(for dhclient)
- # NM only works with ISC dhclient - other derivatives don't have
- # the same userland. NM also requires dhclient 4.x since older
- # versions do not have IPv6 support.
for path in /sbin /usr/sbin /usr/pkg/sbin /usr/local/sbin; do
test -x "${path}/dhclient" || continue
case `"$path/dhclient" --version 2>&1` in
- "isc-dhclient-4"*) DHCLIENT_PATH="$path/dhclient"; break;;
+ "isc-dhclient-4"*) DHCLIENT_PATH="$path/dhclient"; DHCLIENT_VERSION=4; break;;
+ "isc-dhclient-V3"*) DHCLIENT_PATH="$path/dhclient"; DHCLIENT_VERSION=3; break;;
esac
done
if test -n "${DHCLIENT_PATH}"; then
@@ -554,6 +563,7 @@ echo
if test -n "${DHCLIENT_PATH}"; then
echo ISC dhclient support: ${DHCLIENT_PATH}
+ echo ISC dhclient version: ${DHCLIENT_VERSION}
else
echo ISC dhclient support: no
fi
diff --git a/src/dhcp-manager/Makefile.am b/src/dhcp-manager/Makefile.am
index f75e6b3..4c54087 100644
--- a/src/dhcp-manager/Makefile.am
+++ b/src/dhcp-manager/Makefile.am
@@ -29,6 +29,7 @@ libdhcp_manager_la_CPPFLAGS = \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DLOCALSTATEDIR=\"$(localstatedir)\" \
-DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \
+ -DDHCLIENT_V$(DHCLIENT_VERSION) \
-DDHCPCD_PATH=\"$(DHCPCD_PATH)\"
libdhcp_manager_la_LIBADD = \
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index cae7df2..13caa02 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -45,7 +45,11 @@ G_DEFINE_TYPE (NMDHCPDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT)
#define NM_DHCP_DHCLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_DHCLIENT, NMDHCPDhclientPrivate))
#if defined(TARGET_DEBIAN) || defined(TARGET_SUSE) || defined(TARGET_MANDRIVA)
+#if defined(DHCLIENT_V3)
+#define NM_DHCLIENT_LEASE_DIR LOCALSTATEDIR "/lib/dhcp3"
+#else
#define NM_DHCLIENT_LEASE_DIR LOCALSTATEDIR "/lib/dhcp"
+#endif
#else
#define NM_DHCLIENT_LEASE_DIR LOCALSTATEDIR "/lib/dhclient"
#endif
@@ -437,7 +441,11 @@ create_dhclient_config (const char *iface,
#if defined(TARGET_SUSE)
orig = g_strdup (SYSCONFDIR "/dhclient.conf");
#elif defined(TARGET_DEBIAN) || defined(TARGET_GENTOO)
+#if defined(DHCLIENT_V3)
+ orig = g_strdup (SYSCONFDIR "/dhcp3/dhclient.conf");
+#else
orig = g_strdup (SYSCONFDIR "/dhcp/dhclient.conf");
+#endif
#else
orig = g_strdup_printf (SYSCONFDIR "/dhclient-%s.conf", iface);
#endif
@@ -499,12 +507,20 @@ dhclient_start (NMDHCPClient *client,
guint log_domain;
g_return_val_if_fail (priv->pid_file == NULL, -1);
- g_return_val_if_fail (ip_opt != NULL, -1);
iface = nm_dhcp_client_get_iface (client);
uuid = nm_dhcp_client_get_uuid (client);
ipv6 = nm_dhcp_client_get_ipv6 (client);
+#if defined(DHCLIENT_V3)
+ if (ipv6) {
+ nm_log_warn (log_domain, "(%s): ISC dhcp3 does not support IPv6", iface);
+ return -1;
+ }
+#else
+ g_return_val_if_fail (ip_opt != NULL, -1);
+#endif
+
log_domain = ipv6 ? LOGD_DHCP6 : LOGD_DHCP4;
priv->pid_file = g_strdup_printf (LOCALSTATEDIR "/run/dhclient%s-%s.pid",
@@ -536,10 +552,11 @@ dhclient_start (NMDHCPClient *client,
g_ptr_array_add (argv, (gpointer) "-d");
+#if !defined(DHCLIENT_V3)
g_ptr_array_add (argv, (gpointer) ip_opt);
-
if (mode_opt)
g_ptr_array_add (argv, (gpointer) mode_opt);
+#endif
g_ptr_array_add (argv, (gpointer) "-sf"); /* Set script file */
g_ptr_array_add (argv, (gpointer) ACTION_SCRIPT_PATH );
--
|