summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/login.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/utils/login.c b/utils/login.c
index 643869f4..aefc2187 100644
--- a/utils/login.c
+++ b/utils/login.c
@@ -406,7 +406,6 @@ main(int argc, char *argv[])
struct idvec parent_uids = IDVEC_INIT; /* Parent uids, -SETUID. */
struct idvec parent_gids = IDVEC_INIT; /* Parent gids, -SETGID. */
mach_port_t exec; /* The shell executable. */
- mach_port_t cwd; /* The child's CWD. */
mach_port_t root; /* The child's root directory. */
mach_port_t ports[INIT_PORT_MAX]; /* Init ports for the new process. */
int ints[INIT_INT_MAX]; /* Init ints for it. */
@@ -703,11 +702,10 @@ main(int argc, char *argv[])
if (err)
error (40, err, "Port reauth failure");
- /* These are the default values for the child's root/cwd. We don't want to
+ /* These are the default values for the child's root. We don't want to
modify PORTS just yet, because we use it to do child-authenticated
lookups. */
root = ports[INIT_PORT_CRDIR];
- cwd = ports[INIT_PORT_CWDIR];
/* Find the shell executable (we copy the name, as ARGS may be changed). */
if (shell_arg && sh_args && *sh_args)
@@ -762,13 +760,15 @@ main(int argc, char *argv[])
arg = envz_get (args, args_len, "HOME");
if (arg && *arg)
{
- cwd = child_lookup (arg, 0, O_RDONLY);
+ mach_port_t cwd = child_lookup (arg, 0, O_RDONLY);
if (cwd == MACH_PORT_NULL)
{
error (0, errno, "%s", arg);
error (0, 0, "Using HOME=/");
envz_add (&args, &args_len, "HOME", "/");
}
+ else
+ ports[INIT_PORT_CWDIR] = cwd;
}
arg = envz_get (args, args_len, "ROOT");
@@ -855,9 +855,8 @@ main(int argc, char *argv[])
}
/* Now that we don't need to use PORTS for lookups anymore, put the correct
- ROOT and CWD in. */
+ ROOT in. */
ports[INIT_PORT_CRDIR] = root;
- ports[INIT_PORT_CWDIR] = cwd;
/* Get rid of any accumulated null entries in env. */
envz_strip (&env, &env_len);