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)
- 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 1768c8c2f..545e27fb7 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.226 2008/02/08 23:24:07 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.227 2008/02/10 10:54:29 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -1359,6 +1359,8 @@ safely_chroot(const char *path, uid_t uid)
1359void 1359void
1360do_setusercontext(struct passwd *pw) 1360do_setusercontext(struct passwd *pw)
1361{ 1361{
1362 char *chroot_path, *tmp;
1363
1362#ifndef HAVE_CYGWIN 1364#ifndef HAVE_CYGWIN
1363 if (getuid() == 0 || geteuid() == 0) 1365 if (getuid() == 0 || geteuid() == 0)
1364#endif /* HAVE_CYGWIN */ 1366#endif /* HAVE_CYGWIN */
@@ -1442,11 +1444,12 @@ do_setusercontext(struct passwd *pw)
1442 1444
1443 if (options.chroot_directory != NULL && 1445 if (options.chroot_directory != NULL &&
1444 strcasecmp(options.chroot_directory, "none") != 0) { 1446 strcasecmp(options.chroot_directory, "none") != 0) {
1445 char *chroot_path; 1447 tmp = tilde_expand_filename(options.chroot_directory,
1446 1448 pw->pw_uid);
1447 chroot_path = percent_expand(options.chroot_directory, 1449 chroot_path = percent_expand(tmp, "h", pw->pw_dir,
1448 "h", pw->pw_dir, "u", pw->pw_name, (char *)NULL); 1450 "u", pw->pw_name, (char *)NULL);
1449 safely_chroot(chroot_path, pw->pw_uid); 1451 safely_chroot(chroot_path, pw->pw_uid);
1452 free(tmp);
1450 free(chroot_path); 1453 free(chroot_path);
1451 } 1454 }
1452 1455