Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150794190
D24413.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D24413.diff
View Options
Index: head/usr.bin/sockstat/sockstat.c
===================================================================
--- head/usr.bin/sockstat/sockstat.c
+++ head/usr.bin/sockstat/sockstat.c
@@ -32,10 +32,11 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/file.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
-#include <sys/file.h>
+#include <sys/jail.h>
#include <sys/user.h>
#include <sys/un.h>
@@ -1218,7 +1219,8 @@
}
}
-static int set_default_protos(void)
+static int
+set_default_protos(void)
{
struct protoent *prot;
const char *pname;
@@ -1237,6 +1239,38 @@
return (pindex);
}
+/*
+ * Return the vnet property of the jail, or -1 on error.
+ */
+static int
+jail_getvnet(int jid)
+{
+ struct iovec jiov[6];
+ int vnet;
+
+ vnet = -1;
+ jiov[0].iov_base = __DECONST(char *, "jid");
+ jiov[0].iov_len = sizeof("jid");
+ jiov[1].iov_base = &jid;
+ jiov[1].iov_len = sizeof(jid);
+ jiov[2].iov_base = __DECONST(char *, "vnet");
+ jiov[2].iov_len = sizeof("vnet");
+ jiov[3].iov_base = &vnet;
+ jiov[3].iov_len = sizeof(vnet);
+ jiov[4].iov_base = __DECONST(char *, "errmsg");
+ jiov[4].iov_len = sizeof("errmsg");
+ jiov[5].iov_base = jail_errmsg;
+ jiov[5].iov_len = JAIL_ERRMSGLEN;
+ jail_errmsg[0] = '\0';
+ if (jail_get(jiov, nitems(jiov), 0) < 0) {
+ if (!jail_errmsg[0])
+ snprintf(jail_errmsg, JAIL_ERRMSGLEN,
+ "jail_get: %s", strerror(errno));
+ return (-1);
+ }
+ return (vnet);
+}
+
static void
usage(void)
{
@@ -1310,6 +1344,21 @@
if (argc > 0)
usage();
+
+ if (opt_j > 0) {
+ switch (jail_getvnet(opt_j)) {
+ case -1:
+ errx(2, "%s", jail_errmsg);
+ case JAIL_SYS_NEW:
+ if (jail_attach(opt_j) < 0)
+ errx(3, "%s", jail_errmsg);
+ /* Set back to -1 for normal output in vnet jail. */
+ opt_j = -1;
+ break;
+ default:
+ break;
+ }
+ }
if ((!opt_4 && !opt_6) && protos_defined != -1)
opt_4 = opt_6 = 1;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 2:37 AM (12 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30863154
Default Alt Text
D24413.diff (1 KB)
Attached To
Mode
D24413: sockstat: Attach to jail if in new vnet
Attached
Detach File
Event Timeline
Log In to Comment