Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146116486
D48618.1779243025.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48618.1779243025.diff
View Options
diff --git a/sbin/sysctl/Makefile b/sbin/sysctl/Makefile
--- a/sbin/sysctl/Makefile
+++ b/sbin/sysctl/Makefile
@@ -6,6 +6,11 @@
WARNS?= 3
MAN= sysctl.8
+.if ${MK_JAIL} != "no" && !defined(RESCUE)
+CFLAGS+= -DJAIL
+LIBADD+= jail
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
--- a/sbin/sysctl/sysctl.8
+++ b/sbin/sysctl/sysctl.8
@@ -36,12 +36,14 @@
.Nd get or set kernel state
.Sh SYNOPSIS
.Nm
+.Op Fl j Ar jail
.Op Fl bdeFhiJlNnoqTtVWx
.Op Fl B Ar bufsize
.Op Fl f Ar filename
.Ar name Ns Op = Ns Ar value Ns Op , Ns Ar value
.Ar ...
.Nm
+.Op Fl j Ar jail
.Op Fl bdeFhJlNnoqTtVWx
.Op Fl B Ar bufsize
.Fl a
@@ -113,6 +115,10 @@
are necessarily running exactly the same software) easier.
.It Fl J
Display only jail prision sysctl variables (CTLFLAG_PRISON).
+.It Fl j Ar jail
+Perform the actions inside the
+.Ar jail
+(by jail id or jail name).
.It Fl l
Show the length of variables along with their values.
This option cannot be combined with the
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -33,6 +33,9 @@
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
+#ifdef JAIL
+#include <sys/jail.h>
+#endif
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <dev/evdev/input.h>
@@ -51,6 +54,9 @@
#include <err.h>
#include <errno.h>
#include <inttypes.h>
+#ifdef JAIL
+#include <jail.h>
+#endif
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
@@ -121,8 +127,8 @@
{
(void)fprintf(stderr, "%s\n%s\n",
- "usage: sysctl [-bdeFhiJlNnoqTtVWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
- " sysctl [-bdeFhJlNnoqTtVWx] [ -B <bufsize> ] -a");
+ "usage: sysctl [-j jail] [-bdeFhiJlNnoqTtVWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
+ " sysctl [-j jail] [-bdeFhJlNnoqTtVWx] [ -B <bufsize> ] -a");
exit(1);
}
@@ -131,12 +137,15 @@
{
int ch;
int warncount = 0;
+#ifdef JAIL
+ int jid;
+#endif
setlocale(LC_NUMERIC, "");
setbuf(stdout,0);
setbuf(stderr,0);
- while ((ch = getopt(argc, argv, "AaB:bdeFf:hiJlNnoqTtVWwXx")) != -1) {
+ while ((ch = getopt(argc, argv, "AaB:bdeFf:hiJj:lNnoqTtVWwXx")) != -1) {
switch (ch) {
case 'A':
/* compatibility */
@@ -172,6 +181,19 @@
case 'J':
Jflag = true;
break;
+ case 'j':
+#ifdef JAIL
+ if (optarg == NULL)
+ usage();
+ jid = jail_getid(optarg);
+ if (jid == -1)
+ errx(1, "jail not found");
+ if (jail_attach(jid) != 0)
+ errx(1, "cannot attach to jail");
+#else
+ errx(1, "not built with jail support");
+#endif
+ break;
case 'l':
lflag = true;
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 20, 2:10 AM (3 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28751453
Default Alt Text
D48618.1779243025.diff (2 KB)
Attached To
Mode
D48618: sysctl: Teach sysctl to attach and run itself in a jail
Attached
Detach File
Event Timeline
Log In to Comment