change CWD handling. CWD is fixed to the CWD of the systrace process.
This commit is contained in:
parent
9c0942bc88
commit
43914d5f2f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: filter.c,v 1.22 2003/06/03 04:33:44 provos Exp $ */
|
||||
/* $NetBSD: filter.c,v 1.23 2003/08/02 14:24:30 provos Exp $ */
|
||||
/* $OpenBSD: filter.c,v 1.16 2002/08/08 21:18:20 provos Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -30,7 +30,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: filter.c,v 1.22 2003/06/03 04:33:44 provos Exp $");
|
||||
__RCSID("$NetBSD: filter.c,v 1.23 2003/08/02 14:24:30 provos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
@ -701,13 +701,14 @@ filter_expand(char *data)
|
||||
char *
|
||||
filter_dynamicexpand(struct intercept_pid *icpid, char *data)
|
||||
{
|
||||
extern char cwd[];
|
||||
static char expand[2*MAXPATHLEN];
|
||||
|
||||
strlcpy(expand, data, sizeof(expand));
|
||||
|
||||
filter_replace(expand, sizeof(expand), "$HOME", icpid->home);
|
||||
filter_replace(expand, sizeof(expand), "$USER", icpid->username);
|
||||
filter_replace(expand, sizeof(expand), "$CWD", icpid->cwd);
|
||||
filter_replace(expand, sizeof(expand), "$CWD", cwd);
|
||||
|
||||
return (expand);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intercept.c,v 1.14 2003/06/03 04:33:44 provos Exp $ */
|
||||
/* $NetBSD: intercept.c,v 1.15 2003/08/02 14:24:30 provos Exp $ */
|
||||
/* $OpenBSD: intercept.c,v 1.29 2002/08/28 03:30:27 itojun Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -30,7 +30,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: intercept.c,v 1.14 2003/06/03 04:33:44 provos Exp $");
|
||||
__RCSID("$NetBSD: intercept.c,v 1.15 2003/08/02 14:24:30 provos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -252,8 +252,6 @@ intercept_setpid(struct intercept_pid *icpid, uid_t uid, gid_t gid)
|
||||
|
||||
icpid->uid = uid;
|
||||
icpid->gid = gid;
|
||||
if (getcwd(icpid->cwd, sizeof(icpid->cwd)) == NULL)
|
||||
err(1, "getcwd");
|
||||
if ((pw = getpwuid(icpid->uid)) == NULL) {
|
||||
snprintf(icpid->username, sizeof(icpid->username),
|
||||
"unknown(%d)", icpid->uid);
|
||||
@ -574,7 +572,6 @@ char *
|
||||
intercept_filename(int fd, pid_t pid, void *addr, int userp)
|
||||
{
|
||||
static char cwd[2*MAXPATHLEN];
|
||||
struct intercept_pid *icpid;
|
||||
char *name;
|
||||
int havecwd = 0;
|
||||
|
||||
@ -598,13 +595,6 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp)
|
||||
havecwd = 1;
|
||||
}
|
||||
|
||||
if (havecwd) {
|
||||
/* Update cwd for process */
|
||||
icpid = intercept_getpid(pid);
|
||||
if (strlcpy(icpid->cwd, cwd, sizeof(icpid->cwd)) >= sizeof(icpid->cwd))
|
||||
errx(1, "cwd too long");
|
||||
}
|
||||
|
||||
/* Need concatenated path for simplifypath */
|
||||
if (havecwd && name[0] != '/') {
|
||||
if (strlcat(cwd, "/", sizeof(cwd)) >= sizeof(cwd))
|
||||
@ -861,7 +851,6 @@ intercept_child_info(pid_t opid, pid_t npid)
|
||||
inpid->gid = ipid->gid;
|
||||
strlcpy(inpid->username, ipid->username, sizeof(inpid->username));
|
||||
strlcpy(inpid->home, ipid->home, sizeof(inpid->home));
|
||||
strlcpy(inpid->cwd, ipid->cwd, sizeof(inpid->cwd));
|
||||
|
||||
/* XXX - keeps track of emulation */
|
||||
intercept.clonepid(ipid, inpid);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intercept.h,v 1.10 2003/06/03 04:33:44 provos Exp $ */
|
||||
/* $NetBSD: intercept.h,v 1.11 2003/08/02 14:24:30 provos Exp $ */
|
||||
/* $OpenBSD: intercept.h,v 1.11 2002/08/04 04:15:50 provos Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -101,7 +101,6 @@ struct intercept_pid {
|
||||
|
||||
char username[LOGIN_NAME_MAX];
|
||||
char home[MAXPATHLEN]; /* current home dir for uid */
|
||||
char cwd[MAXPATHLEN]; /* current working directory */
|
||||
|
||||
void *data;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user