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).
This commit is contained in:
parent
2185188f83
commit
20883bd7de
1 changed files with 5 additions and 14 deletions
|
@ -335,7 +335,7 @@ old9p(int fd)
|
||||||
void
|
void
|
||||||
remoteside(int old)
|
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;
|
int i, n, fd, badchdir, gotcmd;
|
||||||
|
|
||||||
rfork(RFENVG);
|
rfork(RFENVG);
|
||||||
|
@ -364,11 +364,6 @@ remoteside(int old)
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
fatal("srvauth: %r");
|
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 */
|
/* Now collect invoking cpu's current directory or possibly a command */
|
||||||
gotcmd = 0;
|
gotcmd = 0;
|
||||||
if(readstr(fd, xdir, sizeof(xdir)) < 0)
|
if(readstr(fd, xdir, sizeof(xdir)) < 0)
|
||||||
|
@ -380,15 +375,11 @@ remoteside(int old)
|
||||||
fatal("dir: %r");
|
fatal("dir: %r");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Establish the new process at the current working directory of the
|
/* Establish the new process at the current working directory of the gnot */
|
||||||
* gnot */
|
|
||||||
badchdir = 0;
|
badchdir = 0;
|
||||||
if(strcmp(xdir, "NO") == 0)
|
if(strcmp(xdir, "NO") != 0)
|
||||||
chdir(home);
|
if(chdir(xdir) < 0)
|
||||||
else if(chdir(xdir) < 0) {
|
badchdir = 1;
|
||||||
badchdir = 1;
|
|
||||||
chdir(home);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Start the gnot serving its namespace */
|
/* Start the gnot serving its namespace */
|
||||||
writestr(fd, "FS", "FS", 0);
|
writestr(fd, "FS", "FS", 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue