summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-28 03:30:28 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-08-28 03:30:28 +0000
commit279469bd3c993a0b6cb7fa358976febb29ced99c (patch)
tree5298e40915e37c9a3f7c8f27d96e58371fa25553
parent3dfee6456d2c772e57a649ee455e7027e4ddda89 (diff)
fix systrace with chroot. from provos
-rw-r--r--bin/systrace/intercept.c17
-rw-r--r--bin/systrace/openbsd-syscalls.c5
2 files changed, 12 insertions, 10 deletions
diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c
index 0db979eb136..76c5c35d8e3 100644
--- a/bin/systrace/intercept.c
+++ b/bin/systrace/intercept.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intercept.c,v 1.28 2002/08/08 00:47:33 provos Exp $ */
+/* $OpenBSD: intercept.c,v 1.29 2002/08/28 03:30:27 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -527,19 +527,18 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp)
{
static char cwd[2*MAXPATHLEN];
char *name;
- int norescwd = 0;
name = intercept_get_string(fd, pid, addr);
if (name == NULL)
goto abort;
if (intercept.getcwd(fd, pid, cwd, sizeof(cwd)) == NULL) {
- if (name[0] != '/') {
- if (errno == EBUSY)
- goto abort;
- err(1, "%s: getcwd", __func__);
- }
- norescwd = 1;
+ if (errno == EBUSY)
+ goto abort;
+ if (strcmp(name, "/") == 0)
+ return (name);
+
+ err(1, "%s: getcwd", __func__);
}
if (name[0] != '/') {
@@ -619,7 +618,7 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp)
/* Restore working directory and change root space after realpath */
- if (!norescwd && intercept.restcwd(fd) == -1)
+ if (intercept.restcwd(fd) == -1)
err(1, "%s: restcwd", __func__);
return (name);
diff --git a/bin/systrace/openbsd-syscalls.c b/bin/systrace/openbsd-syscalls.c
index 4251625180f..24e223d08dc 100644
--- a/bin/systrace/openbsd-syscalls.c
+++ b/bin/systrace/openbsd-syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openbsd-syscalls.c,v 1.11 2002/08/07 21:27:15 provos Exp $ */
+/* $OpenBSD: openbsd-syscalls.c,v 1.12 2002/08/28 03:30:27 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -487,6 +487,9 @@ obsd_getcwd(int fd, pid_t pid, char *buf, size_t size)
return (NULL);
path = getcwd(buf, size);
+ if (path == NULL)
+ obsd_restcwd(fd);
+
return (path);
}