diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2002-07-14 22:34:56 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2002-07-14 22:34:56 +0000 |
commit | f59f397c7a7bc9103bdb67343084d04e85f48b73 (patch) | |
tree | 4e98057cc0c34de20ff135d28c6abe6efe3c5f38 /bin/systrace | |
parent | a460d7805b6afbb011d926a232e21b3c70d23189 (diff) |
argv translation for exeve
Diffstat (limited to 'bin/systrace')
-rw-r--r-- | bin/systrace/intercept-translate.c | 5 | ||||
-rw-r--r-- | bin/systrace/register.c | 3 | ||||
-rw-r--r-- | bin/systrace/systrace-translate.c | 57 | ||||
-rw-r--r-- | bin/systrace/systrace.h | 3 |
4 files changed, 64 insertions, 4 deletions
diff --git a/bin/systrace/intercept-translate.c b/bin/systrace/intercept-translate.c index 8409ddd8f3b..43b01f596f4 100644 --- a/bin/systrace/intercept-translate.c +++ b/bin/systrace/intercept-translate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intercept-translate.c,v 1.5 2002/07/13 08:53:02 provos Exp $ */ +/* $OpenBSD: intercept-translate.c,v 1.6 2002/07/14 22:34:55 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -145,6 +145,9 @@ ic_get_string(struct intercept_translate *trans, int fd, pid_t pid, void *addr) char *name; int len; + if (addr == NULL) + return (-1); + name = intercept_get_string(fd, pid, addr); if (name == NULL) return (-1); diff --git a/bin/systrace/register.c b/bin/systrace/register.c index 7ab397c0576..b4e14d1bb42 100644 --- a/bin/systrace/register.c +++ b/bin/systrace/register.c @@ -1,4 +1,4 @@ -/* $OpenBSD: register.c,v 1.3 2002/07/13 08:54:10 provos Exp $ */ +/* $OpenBSD: register.c,v 1.4 2002/07/14 22:34:55 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -75,6 +75,7 @@ systrace_initcb(void) &ic_translate_connect); X(intercept_register_sccb("native", "execve", trans_cb, NULL)); intercept_register_transfn("native", "execve", 0); + intercept_register_translation("native", "execve", 1, &argv); X(intercept_register_sccb("native", "stat", trans_cb, NULL)); tl = intercept_register_transfn("native", "stat", 0); alias = systrace_new_alias("native", "stat", "native", "fsread"); diff --git a/bin/systrace/systrace-translate.c b/bin/systrace/systrace-translate.c index afde4e3189b..9b10685fba6 100644 --- a/bin/systrace/systrace-translate.c +++ b/bin/systrace/systrace-translate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace-translate.c,v 1.4 2002/07/13 08:54:10 provos Exp $ */ +/* $OpenBSD: systrace-translate.c,v 1.5 2002/07/14 22:34:55 provos 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 <limits.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -171,6 +172,60 @@ print_uname(char *buf, size_t buflen, struct intercept_translate *tl) return (0); } +int +get_argv(struct intercept_translate *trans, int fd, pid_t pid, void *addr) +{ + char *arg; + char buf[_POSIX2_LINE_MAX], *p; + int i, off = 0, len; + extern struct intercept_system intercept; + + buf[0] = '\0'; + while (1) { + if (intercept.io(fd, pid, INTERCEPT_READ, addr + off, + (void *)&arg, sizeof(char *)) == -1) { + warn("%s: ioctl", __func__); + return (NULL); + } + if (arg == NULL) + break; + + p = intercept_get_string(fd, pid, arg); + if (p == NULL) + return (-1); + + if (i > 0) + strlcat(buf, " ", sizeof(buf)); + strlcat(buf, p, sizeof(buf)); + + off += sizeof(char *); + } + + len = strlen(buf) + 1; + trans->trans_data = malloc(len); + if (trans->trans_data == NULL) + return (-1); + + /* XXX - No argument replacement */ + trans->trans_size = 0; + memcpy(trans->trans_data, buf, len); + + return (0); +} + +int +print_argv(char *buf, size_t buflen, struct intercept_translate *tl) +{ + snprintf(buf, buflen, "%s", (char *)tl->trans_data); + + return (0); +} + +struct intercept_translate argv = { + "argv", + get_argv, print_argv, +}; + struct intercept_translate oflags = { "oflags", NULL, print_oflags, diff --git a/bin/systrace/systrace.h b/bin/systrace/systrace.h index 9112118b827..423af432b11 100644 --- a/bin/systrace/systrace.h +++ b/bin/systrace/systrace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.h,v 1.8 2002/07/13 08:54:10 provos Exp $ */ +/* $OpenBSD: systrace.h,v 1.9 2002/07/14 22:34:55 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -172,6 +172,7 @@ extern struct intercept_translate fdt; extern struct intercept_translate uidt; extern struct intercept_translate uname; extern struct intercept_translate gidt; +extern struct intercept_translate argv; extern struct intercept_translate linux_oflags; #endif /* _SYSTRACE_H_ */ |