From 20883bd7de7097936fe87e5fce4d08033ea6c88c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 24 May 2014 02:09:52 +0200 Subject: cpu: remove duplicate environment and chdir($home) code (thanks qrstuv) newns() (called by auth_chuid()) already prepares the environment variables and puts us in a sane working directory (as specified by the namespace file). --- sys/src/cmd/cpu.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'sys/src/cmd/cpu.c') diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c index 53a4bb846..361f568b2 100644 --- a/sys/src/cmd/cpu.c +++ b/sys/src/cmd/cpu.c @@ -335,7 +335,7 @@ old9p(int fd) void remoteside(int old) { - char user[MaxStr], home[MaxStr], buf[MaxStr], xdir[MaxStr], cmd[MaxStr]; + char user[MaxStr], buf[MaxStr], xdir[MaxStr], cmd[MaxStr]; int i, n, fd, badchdir, gotcmd; rfork(RFENVG); @@ -364,11 +364,6 @@ remoteside(int old) if(fd < 0) fatal("srvauth: %r"); - /* Set environment values for the user */ - putenv("user", user); - snprint(home, sizeof(home), "/usr/%s", user); - putenv("home", home); - /* Now collect invoking cpu's current directory or possibly a command */ gotcmd = 0; if(readstr(fd, xdir, sizeof(xdir)) < 0) @@ -380,15 +375,11 @@ remoteside(int old) fatal("dir: %r"); } - /* Establish the new process at the current working directory of the - * gnot */ + /* Establish the new process at the current working directory of the gnot */ badchdir = 0; - if(strcmp(xdir, "NO") == 0) - chdir(home); - else if(chdir(xdir) < 0) { - badchdir = 1; - chdir(home); - } + if(strcmp(xdir, "NO") != 0) + if(chdir(xdir) < 0) + badchdir = 1; /* Start the gnot serving its namespace */ writestr(fd, "FS", "FS", 0); -- cgit v1.2.3