summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2008-02-10 22:48:55 +1100
committerDamien Miller <djm@mindrot.org>2008-02-10 22:48:55 +1100
commit54e3773ccb55500087fc722c79869679700dc318 (patch)
tree0cc1094b6c810d313c3d5ad237bd9ce992632487 /session.c
parentcdb6e65175fab4346be5b74b2527e4f28437e5fe (diff)
downloadopenssh-git-54e3773ccb55500087fc722c79869679700dc318.tar.gz
- djm@cvs.openbsd.org 2008/02/10 10:54:29
[servconf.c session.c] delay ~ expansion for ChrootDirectory so it expands to the logged-in user's home, rather than the user who starts sshd (probably root)
Diffstat (limited to 'session.c')
-rw-r--r--session.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/session.c b/session.c
index 1768c8c2..545e27fb 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.226 2008/02/08 23:24:07 djm Exp $ */
+/* $OpenBSD: session.c,v 1.227 2008/02/10 10:54:29 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -1359,6 +1359,8 @@ safely_chroot(const char *path, uid_t uid)
void
do_setusercontext(struct passwd *pw)
{
+ char *chroot_path, *tmp;
+
#ifndef HAVE_CYGWIN
if (getuid() == 0 || geteuid() == 0)
#endif /* HAVE_CYGWIN */
@@ -1442,11 +1444,12 @@ do_setusercontext(struct passwd *pw)
if (options.chroot_directory != NULL &&
strcasecmp(options.chroot_directory, "none") != 0) {
- char *chroot_path;
-
- chroot_path = percent_expand(options.chroot_directory,
- "h", pw->pw_dir, "u", pw->pw_name, (char *)NULL);
+ tmp = tilde_expand_filename(options.chroot_directory,
+ pw->pw_uid);
+ chroot_path = percent_expand(tmp, "h", pw->pw_dir,
+ "u", pw->pw_name, (char *)NULL);
safely_chroot(chroot_path, pw->pw_uid);
+ free(tmp);
free(chroot_path);
}