From 22673e4df80cd3a11dda7cd9efb38903c437609c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sat, 25 Apr 2009 16:25:36 +0000 Subject: [PATCH] Hide home directory when chrooted or guest. From Ake Holmlund git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25129 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftpd/extern.h | 1 + appl/ftp/ftpd/ftpcmd.y | 8 ++++++-- appl/ftp/ftpd/popen.c | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/appl/ftp/ftpd/extern.h b/appl/ftp/ftpd/extern.h index db40f2fdd..fb4852728 100644 --- a/appl/ftp/ftpd/extern.h +++ b/appl/ftp/ftpd/extern.h @@ -129,6 +129,7 @@ extern struct sockaddr *data_dest; extern int logged_in; extern struct passwd *pw; extern int guest; +extern int dochroot; extern int logging; extern int type; extern off_t file_size; diff --git a/appl/ftp/ftpd/ftpcmd.y b/appl/ftp/ftpd/ftpcmd.y index 6ec03d665..eb672fdbb 100644 --- a/appl/ftp/ftpd/ftpcmd.y +++ b/appl/ftp/ftpd/ftpcmd.y @@ -352,8 +352,12 @@ cmd } | CWD CRLF check_login { - if ($3) - cwd(pw->pw_dir); + if ($3) { + const char *path = pw->pw_dir; + if (dochroot || guest) + path = "/"; + cwd(path); + } } | CWD SP pathname CRLF check_login { diff --git a/appl/ftp/ftpd/popen.c b/appl/ftp/ftpd/popen.c index abf4aa442..916e32f75 100644 --- a/appl/ftp/ftpd/popen.c +++ b/appl/ftp/ftpd/popen.c @@ -73,8 +73,6 @@ RCSID("$Id$"); static int *pids; static int fds; -extern int dochroot; - /* return path prepended with ~ftp if that file exists, otherwise * return path unchanged */