aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorRobert Millan <rmh@FreeBSD.org>2012-02-14 07:14:42 +0000
committerRobert Millan <rmh@FreeBSD.org>2012-02-14 07:14:42 +0000
commit9697f9f80138fbf8f0448b629baab2119fb89a0e (patch)
treeff4535cb627ff789cf92567cc5521142d1d7251a /sbin/ifconfig
parent2542e55879f88791c74e54f501469f339f95849b (diff)
downloadsrc-9697f9f80138fbf8f0448b629baab2119fb89a0e.tar.gz
src-9697f9f80138fbf8f0448b629baab2119fb89a0e.zip
Disable jail support in ifconfig when either building a rescue
image or MK_JAIL knob has been set to "no". Reviewed by: bz Approved by: adrian (mentor)
Notes
Notes: svn path=/head/; revision=231642
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/Makefile9
-rw-r--r--sbin/ifconfig/ifconfig.c8
2 files changed, 15 insertions, 2 deletions
diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile
index dafaea284e8f..a98840dde304 100644
--- a/sbin/ifconfig/Makefile
+++ b/sbin/ifconfig/Makefile
@@ -35,8 +35,8 @@ 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
SRCS+= carp.c # SIOC[GS]VH support
SRCS+= ifgroup.c # ...
@@ -56,6 +56,11 @@ SRCS+= af_ipx.c # IPX support
DPADD+= ${LIBIPX}
LDADD+= -lipx
.endif
+.if ${MK_JAIL} != "no" && !defined(RELEASE_CRUNCH) && !defined(RESCUE)
+CFLAGS+= -DJAIL
+DPADD+= ${LIBJAIL}
+LDADD+= -ljail
+.endif
MAN= ifconfig.8
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 0e3c3a30bae9..5eb71eadc0ca 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -66,7 +66,9 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef JAIL
#include <jail.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -255,6 +257,7 @@ main(int argc, char *argv[])
ifconfig(argc, argv, 1, NULL);
exit(0);
}
+#ifdef JAIL
/*
* NOTE: We have to special-case the `-vnet' command
* right here as we would otherwise fail when trying
@@ -268,6 +271,7 @@ main(int argc, char *argv[])
ifconfig(argc, argv, 0, NULL);
exit(0);
}
+#endif
errx(1, "interface %s does not exist", ifname);
}
}
@@ -688,6 +692,7 @@ deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
err(1, "SIOCDIFPHYADDR");
}
+#ifdef JAIL
static void
setifvnet(const char *jname, int dummy __unused, int s,
const struct afswtch *afp)
@@ -715,6 +720,7 @@ setifrvnet(const char *jname, int dummy __unused, int s,
if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0)
err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name);
}
+#endif
static void
setifnetmask(const char *addr, int dummy __unused, int s,
@@ -1173,8 +1179,10 @@ static struct cmd basic_cmds[] = {
DEF_CMD_ARG2("tunnel", settunnel),
DEF_CMD("-tunnel", 0, deletetunnel),
DEF_CMD("deletetunnel", 0, deletetunnel),
+#ifdef JAIL
DEF_CMD_ARG("vnet", setifvnet),
DEF_CMD_ARG("-vnet", setifrvnet),
+#endif
DEF_CMD("link0", IFF_LINK0, setifflags),
DEF_CMD("-link0", -IFF_LINK0, setifflags),
DEF_CMD("link1", IFF_LINK1, setifflags),