aboutsummaryrefslogtreecommitdiff
path: root/libexec/ftpd/ftpd.c
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2004-11-18 14:15:32 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2004-11-18 14:15:32 +0000
commit215a9f9de5295970d140c4d2f46c60fd76867d22 (patch)
tree389c68e1d1a5b0849e12f8ef078a6bb4b0a6beb6 /libexec/ftpd/ftpd.c
parent2b7eb1c0765cc4f0cb513435696f0e9e4999b2cc (diff)
downloadsrc-215a9f9de5295970d140c4d2f46c60fd76867d22.tar.gz
src-215a9f9de5295970d140c4d2f46c60fd76867d22.zip
Make chrootdir global and use it in log messages
regarding restricted users. MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=137862
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r--libexec/ftpd/ftpd.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 2e791e98ef60..4202518a6a86 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -130,6 +130,7 @@ int paranoid = 1; /* be extra careful about security */
int anon_only = 0; /* Only anonymous ftp allowed */
int guest;
int dochroot;
+char *chrootdir;
int dowtmp = 1;
int stats;
int statfd = -1;
@@ -1328,7 +1329,6 @@ pass(char *passwd)
#ifdef USE_PAM
int e;
#endif
- char *chrootdir;
char *residue = NULL;
char *xpasswd;
@@ -1468,7 +1468,7 @@ skip:
if (chrootdir[0] != '/')
asprintf(&chrootdir, "%s/%s", pw->pw_dir, chrootdir);
else
- chrootdir = strdup(chrootdir); /* so it can be freed */
+ chrootdir = strdup(chrootdir); /* make it permanent */
if (chrootdir == NULL)
fatalerror("Ran out of memory.");
}
@@ -1487,9 +1487,6 @@ skip:
if ((homedir = strstr(chrootdir, "/./")) != NULL) {
*(homedir++) = '\0'; /* wipe '/' */
homedir++; /* skip '.' */
- /* so chrootdir can be freed later */
- if ((homedir = strdup(homedir)) == NULL)
- fatalerror("Ran out of memory.");
} else {
/*
* We MUST do a chdir() after the chroot. Otherwise
@@ -1593,8 +1590,6 @@ skip:
#ifdef LOGIN_CAP
login_close(lc);
#endif
- if (chrootdir)
- free(chrootdir);
if (residue)
free(residue);
return;
@@ -1603,8 +1598,6 @@ bad:
#ifdef LOGIN_CAP
login_close(lc);
#endif
- if (chrootdir)
- free(chrootdir);
if (residue)
free(residue);
end_login();
@@ -3188,6 +3181,8 @@ logcmd(char *cmd, char *file1, char *file2, off_t cnt)
appendf(&msg, " = %jd bytes", (intmax_t)cnt);
if (wd[0])
appendf(&msg, " (wd: %s)", wd);
+ if (guest || dochroot)
+ appendf(&msg, " (chroot: %s)", chrootdir);
syslog(LOG_INFO, "%s", msg);
free(msg);
}