From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 21 23:00:02 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96C3D106564A for ; Mon, 21 Mar 2011 23:00:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 511998FC0C for ; Mon, 21 Mar 2011 23:00:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2LN0248034976 for ; Mon, 21 Mar 2011 23:00:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2LN02aZ034975; Mon, 21 Mar 2011 23:00:02 GMT (envelope-from gnats) Resent-Date: Mon, 21 Mar 2011 23:00:02 GMT Resent-Message-Id: <201103212300.p2LN02aZ034975@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Arnaud Lacombe Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDD4B106566B for ; Mon, 21 Mar 2011 22:54:26 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id DCB488FC15 for ; Mon, 21 Mar 2011 22:54:26 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2LMsQGc009566 for ; Mon, 21 Mar 2011 22:54:26 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p2LMsQYl009565; Mon, 21 Mar 2011 22:54:26 GMT (envelope-from nobody) Message-Id: <201103212254.p2LMsQYl009565@red.freebsd.org> Date: Mon, 21 Mar 2011 22:54:26 GMT From: Arnaud Lacombe To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/155765: [patch]`buildworld' does not honors WITHOUT_JAIL X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2011 23:00:02 -0000 >Number: 155765 >Category: misc >Synopsis: [patch]`buildworld' does not honors WITHOUT_JAIL >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 21 23:00:01 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Arnaud Lacombe >Release: 9-current >Organization: n/a >Environment: >Description: When building world with WITHOUT_JAIL defined in make.conf, libjail remains built. This is due to a hard dependency in ifconfig(8) toward libjail. >How-To-Repeat: # make -DWITHOUT_JAIL buildworld >Fix: see attached patch, only build tested so far. Patch attached with submission follows: >From dde1bcab63ba56a0202fee0b2dc4bd115aa192a3 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Fri, 18 Mar 2011 17:34:23 -0400 Subject: [PATCH] Honors WITHOUT_JAIL This patch fixes buildworld when libjail is not included in the build, as it should be if WITHOUT_JAIL defined. Compile-tested, not runtime check done. Signed-off-by: Arnaud Lacombe --- lib/Makefile | 6 +++- sbin/ifconfig/Makefile | 10 ++++- sbin/ifconfig/ifconfig.c | 31 ---------------- sbin/ifconfig/vnet.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 sbin/ifconfig/vnet.c diff --git a/lib/Makefile b/lib/Makefile index 4fef1bb..9d88880 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -77,7 +77,7 @@ SUBDIR= ${SUBDIR_ORDERED} \ ${_librpcsec_gss} \ libipsec \ ${_libipx} \ - libjail \ + ${_libjail} \ libkiconv \ liblzma \ libmagic \ @@ -165,6 +165,10 @@ _libiconv_modules= libiconv_modules _libipx= libipx .endif +.if ${MK_JAIL} != "no" +_libjail= libjail +.endif + .if ${MK_LIBTHR} != "no" _libthr= libthr .endif diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 77491f2..5ff9208 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -28,8 +28,14 @@ SRCS+= ifgre.c # GRE keys etc SRCS+= ifgif.c # GIF reversed header workaround SRCS+= ifieee80211.c regdomain.c # SIOC[GS]IEEE80211 support -DPADD+= ${LIBBSDXML} ${LIBJAIL} ${LIBSBUF} -LDADD+= -lbsdxml -ljail -lsbuf +DPADD+= ${LIBBSDXML} ${LIBSBUF} +LDADD+= -lbsdxml -lsbuf + +.if ${MK_JAIL} != "no" +SRCS+= vnet.c +DPADD+= ${LIBJAIL} +LDADD+= -ljail +.endif SRCS+= ifcarp.c # SIOC[GS]VH support SRCS+= ifgroup.c # ... diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 7c5d351..00c8d9f 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -66,7 +66,6 @@ static const char rcsid[] = #include #include #include -#include #include #include #include @@ -664,34 +663,6 @@ deletetunnel(const char *vname, int param, int s, const struct afswtch *afp) } static void -setifvnet(const char *jname, int dummy __unused, int s, - const struct afswtch *afp) -{ - struct ifreq my_ifr; - - memcpy(&my_ifr, &ifr, sizeof(my_ifr)); - my_ifr.ifr_jid = jail_getid(jname); - if (my_ifr.ifr_jid < 0) - errx(1, "%s", jail_errmsg); - if (ioctl(s, SIOCSIFVNET, &my_ifr) < 0) - err(1, "SIOCSIFVNET"); -} - -static void -setifrvnet(const char *jname, int dummy __unused, int s, - const struct afswtch *afp) -{ - struct ifreq my_ifr; - - memcpy(&my_ifr, &ifr, sizeof(my_ifr)); - my_ifr.ifr_jid = jail_getid(jname); - if (my_ifr.ifr_jid < 0) - errx(1, "%s", jail_errmsg); - if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0) - err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name); -} - -static void setifnetmask(const char *addr, int dummy __unused, int s, const struct afswtch *afp) { @@ -1133,8 +1104,6 @@ static struct cmd basic_cmds[] = { DEF_CMD_ARG2("tunnel", settunnel), DEF_CMD("-tunnel", 0, deletetunnel), DEF_CMD("deletetunnel", 0, deletetunnel), - DEF_CMD_ARG("vnet", setifvnet), - DEF_CMD_ARG("-vnet", setifrvnet), DEF_CMD("link0", IFF_LINK0, setifflags), DEF_CMD("-link0", -IFF_LINK0, setifflags), DEF_CMD("link1", IFF_LINK1, setifflags), diff --git a/sbin/ifconfig/vnet.c b/sbin/ifconfig/vnet.c new file mode 100644 index 0000000..d386d14 --- /dev/null +++ b/sbin/ifconfig/vnet.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + */ + +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "ifconfig.h" + +static void +setifvnet(const char *jname, int dummy __unused, int s, + const struct afswtch *afp) +{ + struct ifreq my_ifr; + + memcpy(&my_ifr, &ifr, sizeof(my_ifr)); + my_ifr.ifr_jid = jail_getid(jname); + if (my_ifr.ifr_jid < 0) + errx(1, "%s", jail_errmsg); + if (ioctl(s, SIOCSIFVNET, &my_ifr) < 0) + err(1, "SIOCSIFVNET"); +} + +static void +setifrvnet(const char *jname, int dummy __unused, int s, + const struct afswtch *afp) +{ + struct ifreq my_ifr; + + memcpy(&my_ifr, &ifr, sizeof(my_ifr)); + my_ifr.ifr_jid = jail_getid(jname); + if (my_ifr.ifr_jid < 0) + errx(1, "%s", jail_errmsg); + if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0) + err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name); +} + +static struct cmd vnet_cmds[] = +{ + DEF_CMD_ARG("vnet", setifvnet), + DEF_CMD_ARG("-vnet", setifrvnet), +}; + +static __constructor void +vnet_ctor(void) +{ +#define N(a) (sizeof(a) / sizeof(a[0])) + size_t i; + + for (i = 0; i < N(vnet_cmds); i++) + cmd_register(&vnet_cmds[i]); +#undef N +} -- 1.7.4.1.313.gd7c59.dirty >Release-Note: >Audit-Trail: >Unformatted: