summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-01-16 13:35:38 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-01-16 13:35:38 +0100
commit3d8aba71b6170148c7271fb828fc106721e18602 (patch)
treeb2dc06a225c5a1a1f9e004dd07a6634b6c473c97 /utils
parent4cdc3e179a5397ca8a5bfe980fede23477ff98e7 (diff)
Fix child lookups relative to new homedir
* utils/login.c (main): Update `ports[INIT_PORT_CWDIR]' as soon as new cwd is determined according to HOME, since child lookups need to be relative to new homedir (e.g. for .hushlogin).
Diffstat (limited to 'utils')
-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);