| From 07d9434867adf70d7efca532ca67d842f72ee181 Mon Sep 17 00:00:00 2001 |
| From: Peter Qiu <zqiu@chromium.org> |
| Date: Wed, 27 May 2015 15:58:00 -0700 |
| Subject: [PATCH] Add ability to disable hook scripts |
| |
| This allow dhcpcd to be installed without hook scripts and bypassing |
| the hook script processing code. |
| --- |
| Makefile | 10 +++++++--- |
| configure | 8 ++++++++ |
| script-stub.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ |
| 3 files changed, 64 insertions(+), 3 deletions(-) |
| create mode 100644 script-stub.c |
| |
| diff --git a/Makefile b/Makefile |
| index f277750..e52e7cc 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -2,7 +2,7 @@ |
| |
| PROG= dhcpcd |
| SRCS= common.c control.c dhcpcd.c duid.c eloop.c |
| -SRCS+= if.c if-options.c script.c rpc-stub.c |
| +SRCS+= if.c if-options.c rpc-stub.c |
| SRCS+= dhcp-common.c |
| |
| CFLAGS?= -O2 |
| @@ -36,7 +36,11 @@ CLEANFILES+= dhcpcd-run-hooks |
| FILES= dhcpcd.conf |
| FILESDIR= ${SYSCONFDIR} |
| |
| -SUBDIRS= dhcpcd-hooks ${MKDIRS} |
| +SUBDIRS= ${MKDIRS} |
| + |
| +ifeq ($(HOOK_SUPPORT),yes) |
| +SUBDIRS+= dhcpcd-hooks |
| +endif |
| |
| SED_RUNDIR= -e 's:@RUNDIR@:${RUNDIR}:g' |
| SED_DBDIR= -e 's:@DBDIR@:${DBDIR}:g' |
| @@ -114,7 +118,7 @@ _scriptsinstall: ${SCRIPTS} |
| ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR} |
| ${INSTALL} -m ${BINMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR} |
| |
| -proginstall: _proginstall _scriptsinstall ${EMBEDDEDINSTALL} |
| +proginstall: _proginstall ${SCRIPTSINSTALL} ${EMBEDDEDINSTALL} |
| for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done |
| |
| _maninstall: ${MAN5} ${MAN8} |
| diff --git a/configure b/configure |
| index b13c232..0d80876 100755 |
| --- a/configure |
| +++ b/configure |
| @@ -406,6 +406,14 @@ if [ -z "$INET6" -o "$INET6" = yes ]; then |
| echo "DHCPCD_SRCS+= ipv6.c ipv6nd.c dhcp6.c" >>$CONFIG_MK |
| fi |
| |
| +if [ -z "$HOOKSCRIPTS" ]; then |
| + echo "DHCPCD_SRCS+= script-stub.c" >>$CONFIG_MK |
| +else |
| + echo "HOOK_SUPPORT= yes" >>$CONFIG_MK |
| + echo "SCRIPTSINSTALL= _scriptsinstall" >>$CONFIG_MK |
| + echo "DHCPCD_SRCS+= script.c" >>$CONFIG_MK |
| +fi |
| + |
| echo "Using compiler .. $CC" |
| # Add CPPFLAGS and CFLAGS to CC for testing features |
| XCC="$CC `$SED -n -e 's/CPPFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`" |
| diff --git a/script-stub.c b/script-stub.c |
| new file mode 100644 |
| index 0000000..ed2a474 |
| --- /dev/null |
| +++ b/script-stub.c |
| @@ -0,0 +1,49 @@ |
| +/* |
| + * dhcpcd - DHCP client daemon |
| + * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> |
| + * All rights reserved |
| + |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions |
| + * are met: |
| + * 1. Redistributions of source code must retain the above copyright |
| + * notice, this list of conditions and the following disclaimer. |
| + * 2. Redistributions in binary form must reproduce the above copyright |
| + * notice, this list of conditions and the following disclaimer in the |
| + * documentation and/or other materials provided with the distribution. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| + * SUCH DAMAGE. |
| + */ |
| + |
| +#include "common.h" |
| +#include "script.h" |
| + |
| +void |
| +if_printoptions(void) |
| +{ |
| + /* Stub implementation. */ |
| +} |
| + |
| +int |
| +send_interface(struct fd_list *fd, const struct interface *ifp) |
| +{ |
| + /* Stub implementation. */ |
| + return 0; |
| +} |
| + |
| +int |
| +script_runreason(const struct interface *ifp, const char *reason) |
| +{ |
| + /* Stub implementation. */ |
| + return 0; |
| +} |
| -- |
| 2.2.0.rc0.207.ga3a616c |
| |