2011-01-27 16:06:55 +00:00
|
|
|
diff -up dhcp-4.2.1b1/client/dhclient.8.capability dhcp-4.2.1b1/client/dhclient.8
|
|
|
|
--- dhcp-4.2.1b1/client/dhclient.8.capability 2011-01-28 08:05:51.000000000 +0100
|
|
|
|
+++ dhcp-4.2.1b1/client/dhclient.8 2011-01-28 08:24:48.000000000 +0100
|
|
|
|
@@ -115,6 +115,9 @@ dhclient - Dynamic Host Configuration Pr
|
|
|
|
.B -w
|
2010-02-16 11:06:49 +00:00
|
|
|
]
|
|
|
|
[
|
|
|
|
+.B -nc
|
|
|
|
+]
|
|
|
|
+[
|
2011-01-27 16:06:55 +00:00
|
|
|
.B -B
|
2010-02-16 11:06:49 +00:00
|
|
|
]
|
|
|
|
[
|
2011-01-27 16:06:55 +00:00
|
|
|
@@ -293,6 +296,32 @@ has been added or removed, so that the c
|
|
|
|
address on that interface.
|
2010-02-03 17:48:51 +00:00
|
|
|
|
|
|
|
.TP
|
|
|
|
+.BI \-nc
|
|
|
|
+Do not drop capabilities.
|
|
|
|
+
|
|
|
|
+Normally, if
|
|
|
|
+.B dhclient
|
|
|
|
+was compiled with libcap-ng support,
|
|
|
|
+.B dhclient
|
|
|
|
+drops most capabilities immediately upon startup. While more secure,
|
|
|
|
+this greatly restricts the additional actions that hooks in
|
|
|
|
+.B dhclient-script (8)
|
|
|
|
+can take. (For example, any daemons that
|
|
|
|
+.B dhclient-script (8)
|
|
|
|
+starts or restarts will inherit the restricted capabilities as well,
|
|
|
|
+which may interfere with their correct operation.) Thus, the
|
|
|
|
+.BI \-nc
|
|
|
|
+option can be used to prevent
|
|
|
|
+.B dhclient
|
|
|
|
+from dropping capabilities.
|
|
|
|
+
|
|
|
|
+The
|
|
|
|
+.BI \-nc
|
|
|
|
+option is ignored if
|
|
|
|
+.B dhclient
|
|
|
|
+was not compiled with libcap-ng support.
|
|
|
|
+
|
|
|
|
+.TP
|
2011-01-27 16:06:55 +00:00
|
|
|
.BI \-B
|
|
|
|
Set the BOOTP broadcast flag in request packets so servers will always
|
|
|
|
broadcast replies.
|
|
|
|
diff -up dhcp-4.2.1b1/client/dhclient.c.capability dhcp-4.2.1b1/client/dhclient.c
|
|
|
|
--- dhcp-4.2.1b1/client/dhclient.c.capability 2011-01-28 08:05:51.000000000 +0100
|
|
|
|
+++ dhcp-4.2.1b1/client/dhclient.c 2011-01-28 08:05:51.000000000 +0100
|
2010-07-21 16:56:35 +00:00
|
|
|
@@ -39,6 +39,10 @@
|
2009-08-19 01:14:35 +00:00
|
|
|
#include <limits.h>
|
2010-07-21 16:56:35 +00:00
|
|
|
#include <dns/result.h>
|
|
|
|
|
2009-08-19 01:14:35 +00:00
|
|
|
+#ifdef HAVE_LIBCAP_NG
|
|
|
|
+#include <cap-ng.h>
|
|
|
|
+#endif
|
2010-07-21 16:56:35 +00:00
|
|
|
+
|
2009-08-19 01:14:35 +00:00
|
|
|
/*
|
|
|
|
* Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
|
2010-07-21 16:56:35 +00:00
|
|
|
* that when building ISC code.
|
2011-01-27 16:06:55 +00:00
|
|
|
@@ -91,6 +95,9 @@ int wanted_ia_ta = 0;
|
2010-02-02 12:30:33 +00:00
|
|
|
int wanted_ia_pd = 0;
|
|
|
|
char *mockup_relay = NULL;
|
|
|
|
int bootp_broadcast_always = 0;
|
|
|
|
+#ifdef HAVE_LIBCAP_NG
|
|
|
|
+static int keep_capabilities = 0;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
extern u_int32_t default_requested_options[];
|
|
|
|
|
2011-01-27 16:06:55 +00:00
|
|
|
@@ -399,6 +406,10 @@ main(int argc, char **argv) {
|
2010-02-02 12:30:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dhclient_request_options = argv[i];
|
|
|
|
+ } else if (!strcmp(argv[i], "-nc")) {
|
2010-02-03 17:48:51 +00:00
|
|
|
+#ifdef HAVE_LIBCAP_NG
|
2010-02-02 12:30:33 +00:00
|
|
|
+ keep_capabilities = 1;
|
|
|
|
+#endif
|
|
|
|
} else if (argv[i][0] == '-') {
|
|
|
|
usage();
|
|
|
|
} else if (interfaces_requested < 0) {
|
2011-01-27 16:06:55 +00:00
|
|
|
@@ -447,6 +458,19 @@ main(int argc, char **argv) {
|
2009-08-19 01:14:35 +00:00
|
|
|
path_dhclient_script = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef HAVE_LIBCAP_NG
|
|
|
|
+ /* Drop capabilities */
|
2010-02-02 12:30:33 +00:00
|
|
|
+ if (!keep_capabilities) {
|
|
|
|
+ capng_clear(CAPNG_SELECT_CAPS);
|
|
|
|
+ capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
|
|
|
|
+ CAP_DAC_OVERRIDE); // Drop this someday
|
|
|
|
+ capng_updatev(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED,
|
|
|
|
+ CAP_NET_ADMIN, CAP_NET_RAW,
|
|
|
|
+ CAP_NET_BIND_SERVICE, CAP_SYS_ADMIN, -1);
|
|
|
|
+ capng_apply(CAPNG_SELECT_CAPS);
|
|
|
|
+ }
|
2009-08-19 01:14:35 +00:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/* Set up the initial dhcp option universe. */
|
|
|
|
initialize_common_option_spaces();
|
|
|
|
|
2011-01-27 16:06:55 +00:00
|
|
|
diff -up dhcp-4.2.1b1/client/dhclient-script.8.capability dhcp-4.2.1b1/client/dhclient-script.8
|
|
|
|
--- dhcp-4.2.1b1/client/dhclient-script.8.capability 2011-01-28 08:05:51.000000000 +0100
|
|
|
|
+++ dhcp-4.2.1b1/client/dhclient-script.8 2011-01-28 08:05:51.000000000 +0100
|
2010-06-02 14:09:12 +00:00
|
|
|
@@ -239,6 +239,16 @@ repeatedly initialized to the values pro
|
|
|
|
the other. Assuming the information provided by both servers is
|
|
|
|
valid, this shouldn't cause any real problems, but it could be
|
|
|
|
confusing.
|
|
|
|
+.PP
|
|
|
|
+Normally, if dhclient was compiled with libcap-ng support,
|
|
|
|
+dhclient drops most capabilities immediately upon startup.
|
|
|
|
+While more secure, this greatly restricts the additional actions that
|
|
|
|
+hooks in dhclient-script can take. For example, any daemons that
|
|
|
|
+dhclient-script starts or restarts will inherit the restricted
|
|
|
|
+capabilities as well, which may interfere with their correct operation.
|
|
|
|
+Thus, the
|
|
|
|
+.BI \-nc
|
|
|
|
+option can be used to prevent dhclient from dropping capabilities.
|
|
|
|
.SH SEE ALSO
|
|
|
|
dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and
|
|
|
|
dhclient.leases(5).
|
2011-01-27 16:06:55 +00:00
|
|
|
diff -up dhcp-4.2.1b1/client/Makefile.am.capability dhcp-4.2.1b1/client/Makefile.am
|
|
|
|
--- dhcp-4.2.1b1/client/Makefile.am.capability 2010-09-15 00:32:36.000000000 +0200
|
|
|
|
+++ dhcp-4.2.1b1/client/Makefile.am 2011-01-28 08:05:51.000000000 +0100
|
2009-08-19 01:14:35 +00:00
|
|
|
@@ -5,7 +5,7 @@ dhclient_SOURCES = clparse.c dhclient.c
|
|
|
|
scripts/netbsd scripts/nextstep scripts/openbsd \
|
|
|
|
scripts/solaris scripts/openwrt
|
2010-07-21 16:56:35 +00:00
|
|
|
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a \
|
|
|
|
- ../bind/lib/libdns.a ../bind/lib/libisc.a
|
|
|
|
+ ../bind/lib/libdns.a ../bind/lib/libisc.a $(CAPNG_LDADD)
|
2009-08-19 01:14:35 +00:00
|
|
|
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
|
|
|
|
EXTRA_DIST = $(man_MANS)
|
|
|
|
|
2011-01-27 16:06:55 +00:00
|
|
|
diff -up dhcp-4.2.1b1/configure.ac.capability dhcp-4.2.1b1/configure.ac
|
|
|
|
--- dhcp-4.2.1b1/configure.ac.capability 2011-01-28 08:05:51.000000000 +0100
|
|
|
|
+++ dhcp-4.2.1b1/configure.ac 2011-01-28 08:26:11.000000000 +0100
|
|
|
|
@@ -425,6 +425,41 @@ AC_TRY_LINK(
|
2009-08-19 01:14:35 +00:00
|
|
|
# Look for optional headers.
|
|
|
|
AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
|
|
|
|
|
|
|
|
+# look for capabilities library
|
2010-02-02 12:30:33 +00:00
|
|
|
+AC_ARG_WITH(libcap-ng,
|
|
|
|
+ [ --with-libcap-ng=[auto/yes/no] Add Libcap-ng support [default=auto]],,
|
|
|
|
+ with_libcap_ng=auto)
|
|
|
|
+
|
|
|
|
+# Check for Libcap-ng API
|
|
|
|
+#
|
|
|
|
+# libcap-ng detection
|
|
|
|
+if test x$with_libcap_ng = xno ; then
|
|
|
|
+ have_libcap_ng=no;
|
|
|
|
+else
|
|
|
|
+ # Start by checking for header file
|
|
|
|
+ AC_CHECK_HEADER(cap-ng.h, capng_headers=yes, capng_headers=no)
|
|
|
|
+
|
|
|
|
+ # See if we have libcap-ng library
|
|
|
|
+ AC_CHECK_LIB(cap-ng, capng_clear,
|
|
|
|
+ CAPNG_LDADD=-lcap-ng,)
|
|
|
|
+
|
|
|
|
+ # Check results are usable
|
|
|
|
+ if test x$with_libcap_ng = xyes -a x$CAPNG_LDADD = x ; then
|
|
|
|
+ AC_MSG_ERROR(libcap-ng support was requested and the library was not found)
|
|
|
|
+ fi
|
|
|
|
+ if test x$CAPNG_LDADD != x -a $capng_headers = no ; then
|
|
|
|
+ AC_MSG_ERROR(libcap-ng libraries found but headers are missing)
|
|
|
|
+ fi
|
|
|
|
+fi
|
|
|
|
+AC_SUBST(CAPNG_LDADD)
|
|
|
|
+AC_MSG_CHECKING(whether to use libcap-ng)
|
|
|
|
+if test x$CAPNG_LDADD != x ; then
|
|
|
|
+ AC_DEFINE(HAVE_LIBCAP_NG,1,[libcap-ng support])
|
|
|
|
+ AC_MSG_RESULT(yes)
|
|
|
|
+else
|
|
|
|
+ AC_MSG_RESULT(no)
|
|
|
|
+fi
|
2009-08-19 01:14:35 +00:00
|
|
|
+
|
2011-01-27 16:06:55 +00:00
|
|
|
# Solaris needs some libraries for functions
|
|
|
|
AC_SEARCH_LIBS(socket, [socket])
|
|
|
|
AC_SEARCH_LIBS(inet_ntoa, [nsl])
|