summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-10-16 14:43:34 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-10-16 14:43:34 +0000
commite0a16d26d6e3fd1b83b87e2e312caed5b59a3258 (patch)
tree55167286e6d9d227d6d9fa81e63154672b22f3c2 /bin
parent7b5f02a009fbeddbdb4ae728e95e78d2e72bba3c (diff)
translation for socket system call
from provos
Diffstat (limited to 'bin')
-rw-r--r--bin/systrace/register.c6
-rw-r--r--bin/systrace/systrace-translate.c85
-rw-r--r--bin/systrace/systrace.h4
3 files changed, 92 insertions, 3 deletions
diff --git a/bin/systrace/register.c b/bin/systrace/register.c
index 222d33560d2..62698e00340 100644
--- a/bin/systrace/register.c
+++ b/bin/systrace/register.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: register.c,v 1.11 2002/08/05 14:49:27 provos Exp $ */
+/* $OpenBSD: register.c,v 1.12 2002/10/16 14:43:33 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -146,6 +146,10 @@ systrace_initcb(void)
X(intercept_register_sccb("native", "setegid", trans_cb, NULL));
intercept_register_translation("native", "setegid", 0, &gidt);
+ X(intercept_register_sccb("native", "socket", trans_cb, NULL));
+ intercept_register_translation("native", "socket", 0, &sockdom);
+ intercept_register_translation("native", "socket", 1, &socktype);
+
X(intercept_register_sccb("linux", "open", trans_cb, NULL));
tl = intercept_register_translink("linux", "open", 0);
intercept_register_translation("linux", "open", 1, &linux_oflags);
diff --git a/bin/systrace/systrace-translate.c b/bin/systrace/systrace-translate.c
index ddfb35400d6..b845556329f 100644
--- a/bin/systrace/systrace-translate.c
+++ b/bin/systrace/systrace-translate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: systrace-translate.c,v 1.11 2002/09/30 03:45:39 itojun Exp $ */
+/* $OpenBSD: systrace-translate.c,v 1.12 2002/10/16 14:43:33 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/tree.h>
+#include <sys/socket.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
@@ -171,6 +172,78 @@ print_number(char *buf, size_t buflen, struct intercept_translate *tl)
}
static int
+print_sockdom(char *buf, size_t buflen, struct intercept_translate *tl)
+{
+ int domain = (intptr_t)tl->trans_addr;
+ char *what = NULL;
+
+ switch (domain) {
+ case AF_UNIX:
+ what = "AF_UNIX";
+ break;
+ case AF_INET:
+ what = "AF_INET";
+ break;
+ case AF_INET6:
+ what = "AF_INET6";
+ break;
+ case AF_ISO:
+ what = "AF_ISO";
+ break;
+ case AF_NS:
+ what = "AF_NS";
+ break;
+ case AF_IPX:
+ what = "AF_IPX";
+ break;
+ case AF_IMPLINK:
+ what = "AF_IMPLINK";
+ break;
+ default:
+ snprintf(buf, buflen, "AF_UNKNOWN(%d)", domain);
+ break;
+ }
+
+ if (what != NULL)
+ strlcpy(buf, what, buflen);
+
+ return (0);
+}
+
+static int
+print_socktype(char *buf, size_t buflen, struct intercept_translate *tl)
+{
+ int type = (intptr_t)tl->trans_addr;
+ char *what = NULL;
+
+ switch (type) {
+ case SOCK_STREAM:
+ what = "SOCK_STREAM";
+ break;
+ case SOCK_DGRAM:
+ what = "SOCK_DGRAM";
+ break;
+ case SOCK_RAW:
+ what = "SOCK_RAW";
+ break;
+ case SOCK_SEQPACKET:
+ what = "SOCK_SEQPACKET";
+ break;
+ case SOCK_RDM:
+ what = "SOCK_RDM";
+ break;
+ default:
+ snprintf(buf, buflen, "SOCK_UNKNOWN(%d)", type);
+ break;
+ }
+
+ if (what != NULL)
+ strlcpy(buf, what, buflen);
+
+ return (0);
+}
+
+static int
print_uname(char *buf, size_t buflen, struct intercept_translate *tl)
{
struct passwd *pw;
@@ -272,3 +345,13 @@ struct intercept_translate fdt = {
"fd",
NULL, print_number,
};
+
+struct intercept_translate sockdom = {
+ "sockdom",
+ NULL, print_sockdom,
+};
+
+struct intercept_translate socktype = {
+ "socktype",
+ NULL, print_socktype,
+};
diff --git a/bin/systrace/systrace.h b/bin/systrace/systrace.h
index bb18ff51f0d..bba1ae1d710 100644
--- a/bin/systrace/systrace.h
+++ b/bin/systrace/systrace.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: systrace.h,v 1.16 2002/10/09 03:52:10 itojun Exp $ */
+/* $OpenBSD: systrace.h,v 1.17 2002/10/16 14:43:33 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -216,6 +216,8 @@ extern struct intercept_translate uidt;
extern struct intercept_translate uname;
extern struct intercept_translate gidt;
extern struct intercept_translate trargv;
+extern struct intercept_translate sockdom;
+extern struct intercept_translate socktype;
extern struct intercept_translate linux_oflags;