Date: Mon, 21 Mar 2011 14:31:28 -0400
From: Arnaud Lacombe <lacombar@gmail.com>
To: David Demelier <demelier.david@gmail.com>
Cc: Alexander Leidinger <Alexander@leidinger.net>, freebsd-current@freebsd.org, freebsd-jail@freebsd.org
Subject: Re: WITHOUT_JAIL and make delete-old{,-libs}
Message-ID: <AANLkTik=dT6=CudPVD=jSX-%2BeM5r02Migyym4aVvOUtv@mail.gmail.com>
In-Reply-To: <4D86EA62.9060506@gmail.com>
References: <4D85AE1B.7010407@gmail.com> <20110320173157.00002024@unknown> <4D86EA62.9060506@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
[added freebsd-jail@freebsd.org to CC: list]
On Mon, Mar 21, 2011 at 2:04 AM, David Demelier
<demelier.david@gmail.com> wrote:
> On 20/03/2011 17:31, Alexander Leidinger wrote:
>>
>> On Sun, 20 Mar 2011 08:34:51 +0100 David Demelier
>> <demelier.david@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I was surprised to see there is no ${MK_JAIL} conditional to remove
>>> old files on 8.2-RELEASE so I started to write it without watching if
>>> -CURRENT already make it in
>>> /usr/src/tools/build/mk/OptionalObsoleteFiles.inc.
>>>
>>> .if ${MK_JAIL} == no
>>> OLD_FILES+=usr/sbin/jail
>>> OLD_FILES+=usr/sbin/jexec
>>> OLD_FILES+=usr/sbin/jls
>>> OLD_FILES+=usr/share/man/man8/jail.8.gz
>>> OLD_FILES+=usr/share/man/man8/jexec.8.gz
>>> OLD_FILES+=usr/share/man/man8/jls.8.gz
>>> .endif
>>>
>>> I personnaly added more files :
>>>
>>> OLD_LIBS+=lib/libjail.so.1
>>> OLD_LIBS+=usr/lib/libjail.a
>>> OLD_LIBS+=usr/lib/libjail_p.a
>>> OLD_FILES+=usr/lib/libjail.so
>>> OLD_FILES+=etc/rc.d/jail
>>
>> So if you do an installworld, do those files you added show up again or
>> not? If they show up, they are wrong to be added there. Delete old is
>> supposed to delete stuff which does not get installed during an
>> installworld but was installed in some older version of FreeBSD. From
>> my reading of the Makefile in src/lib/ (on -current) it looks like at
>> least the libjail is installed regardless of the knob. I do not know if
>> this is a bug or by design, this would have to be discussed on the
>> mailinglist which is about FreeBSD jails.
>>
>> If those files are not installed during an installworld, it's obviously
>> a bug which needs to be fixed (and I would have misunderstood the
>> Makefile).
>>
>>> (/usr/lib/libjail.so is a symbolic link)
>>>
>>> I think they should be removed too, thus can you merge it to -STABLE
>>> if it's not already done? (sorry I'm not used to the cvs web
>>> interface and I don't have -STABLE right now)
>>>
>>> Cheers,
>>>
>>
>
> No I understood why, that's because a lot of userland programs that can
> handle jails processes are linked to the libjail such as top, ifconfig, ...
>
I happened to have made a patch for ifconfig, see attachment. AFAIT,
buildworld builds fine with WITHOUT_JAIL=1, so there should not be
further build dependency.
- Arnaud
[-- Attachment #2 --]
From dde1bcab63ba56a0202fee0b2dc4bd115aa192a3 Mon Sep 17 00:00:00 2001
From: Arnaud Lacombe <lacombar@gmail.com>
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 <lacombar@gmail.com>
---
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 <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <jail.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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 <sys/param.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include <net/if.h>
+#include <net/if_var.h>
+
+#include <err.h>
+#include <string.h>
+#include <jail.h>
+
+#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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTik=dT6=CudPVD=jSX-%2BeM5r02Migyym4aVvOUtv>
