diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2002-06-05 15:59:53 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2002-06-05 15:59:53 +0000 |
commit | e0baa21aed63316fff785fe18e5e881453ba85be (patch) | |
tree | 2d74b6405656790471d758fc88bbf6418ef9cac1 /bin | |
parent | 02adc26c119b40a4e702f3a3a77a4cba9d45a068 (diff) |
know about CWD. will make some filter rules simpler.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/systrace/filter.c | 8 | ||||
-rw-r--r-- | bin/systrace/systrace.c | 8 |
2 files changed, 13 insertions, 3 deletions
diff --git a/bin/systrace/filter.c b/bin/systrace/filter.c index 237df9146de..7a005211105 100644 --- a/bin/systrace/filter.c +++ b/bin/systrace/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.3 2002/06/04 19:15:54 deraadt Exp $ */ +/* $OpenBSD: filter.c,v 1.4 2002/06/05 15:59:52 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -29,6 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/tree.h> @@ -44,6 +45,7 @@ #include "systrace.h" extern int connected; +extern char cwd[]; int filter_match(struct intercept_tlq *tls, struct logic *logic) @@ -385,7 +387,7 @@ filter_replace(char *buf, size_t buflen, char *match, char *repl) char * filter_expand(char *data) { - static char expand[1024]; + static char expand[2*MAXPATHLEN]; char *what; if (data != NULL) @@ -398,6 +400,8 @@ filter_expand(char *data) if (what != NULL) filter_replace(expand, sizeof(expand), "$USER", what); + filter_replace(expand, sizeof(expand), "$CWD", cwd); + return (expand); } diff --git a/bin/systrace/systrace.c b/bin/systrace/systrace.c index c7d37833b63..7ec5c124f22 100644 --- a/bin/systrace/systrace.c +++ b/bin/systrace/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.9 2002/06/04 22:45:25 provos Exp $ */ +/* $OpenBSD: systrace.c,v 1.10 2002/06/05 15:59:52 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -30,6 +30,7 @@ */ #include <sys/types.h> +#include <sys/param.h> #include <sys/wait.h> #include <sys/tree.h> #include <sys/socket.h> @@ -52,6 +53,7 @@ int inherit = 0; /* Inherit policy to childs */ int automatic = 0; /* Do not run interactively */ int userpolicy = 1; /* Permit user defined policies */ char *username = NULL; /* Username in automatic mode */ +char cwd[MAXPATHLEN]; /* Current working directory of process */ short trans_cb(int fd, pid_t pid, int policynr, @@ -423,6 +425,10 @@ main(int argc, char **argv) if (argc == 0) usage(); + /* Determine current working directory for filtering */ + if (getcwd(cwd, sizeof(cwd)) == NULL) + err(1, "getcwd"); + if ((args = malloc((argc + 1) * sizeof(char *))) == NULL) err(1, "malloc"); |