Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149897222
D40377.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D40377.diff
View Options
diff --git a/sbin/route/Makefile b/sbin/route/Makefile
--- a/sbin/route/Makefile
+++ b/sbin/route/Makefile
@@ -25,6 +25,11 @@
CFLAGS+=-DWITHOUT_NETLINK
.endif
+.if ${MK_JAIL} != "no" && !defined(RESCUE)
+CFLAGS+= -DJAIL
+LIBADD+= jail
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/sbin/route/route.8 b/sbin/route/route.8
--- a/sbin/route/route.8
+++ b/sbin/route/route.8
@@ -28,7 +28,7 @@
.\" @(#)route.8 8.3 (Berkeley) 3/19/94
.\" $FreeBSD$
.\"
-.Dd March 14, 2023
+.Dd June 13, 2023
.Dt ROUTE 8
.Os
.Sh NAME
@@ -36,6 +36,7 @@
.Nd manually manipulate the routing tables
.Sh SYNOPSIS
.Nm
+.Op Fl j Ar jail
.Op Fl dnqtv
.Ar command
.Oo
@@ -91,6 +92,8 @@
and
.Cm flush
commands.
+.It Fl j Ar jail
+Run inside a jail.
.El
.Pp
The
diff --git a/sbin/route/route.c b/sbin/route/route.c
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -48,6 +48,9 @@
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#ifdef JAIL
+#include <sys/jail.h>
+#endif
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/queue.h>
@@ -63,6 +66,9 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#ifdef JAIL
+#include <jail.h>
+#endif
#include <paths.h>
#include <signal.h>
#include <stdbool.h>
@@ -91,6 +97,9 @@
};
int verbose, debugonly;
+#ifdef JAIL
+char * jail_name;
+#endif
static struct sockaddr_storage so[RTAX_MAX];
static int pid, rtm_addrs;
static int nflag, af, aflen, qflag, tflag;
@@ -172,7 +181,7 @@
{
if (cp != NULL)
warnx("bad keyword: %s", cp);
- errx(EX_USAGE, "usage: route [-46dnqtv] command [[modifiers] args]");
+ errx(EX_USAGE, "usage: route [-j jail] [-46dnqtv] command [[modifiers] args]");
/* NOTREACHED */
}
@@ -180,12 +189,15 @@
main(int argc, char **argv)
{
int ch;
+#ifdef JAIL
+ int jid;
+#endif
size_t len;
if (argc < 2)
usage(NULL);
- while ((ch = getopt(argc, argv, "46nqdtv")) != -1)
+ while ((ch = getopt(argc, argv, "46nqdtvj:")) != -1)
switch(ch) {
case '4':
#ifdef INET
@@ -218,6 +230,15 @@
case 'd':
debugonly = 1;
break;
+ case 'j':
+#ifdef JAIL
+ if (optarg == NULL)
+ usage(NULL);
+ jail_name = optarg;
+#else
+ errx(1, "Jail support is not compiled in");
+#endif
+ break;
case '?':
default:
usage(NULL);
@@ -227,6 +248,17 @@
pid = getpid();
uid = geteuid();
+
+#ifdef JAIL
+ if (jail_name != NULL) {
+ jid = jail_getid(jail_name);
+ if (jid == -1)
+ errx(1, "Jail not found");
+ if (jail_attach(jid) != 0)
+ errx(1, "Cannot attach to jail");
+ }
+#endif
+
#ifdef WITHOUT_NETLINK
if (tflag)
s = open(_PATH_DEVNULL, O_WRONLY, 0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 28, 11:30 PM (18 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30497867
Default Alt Text
D40377.diff (2 KB)
Attached To
Mode
D40377: Teach route(8) to run in jails
Attached
Detach File
Event Timeline
Log In to Comment