summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-01-18 23:28:25 +0000
committered <ed@FreeBSD.org>2010-01-18 23:28:25 +0000
commitda06e492c798e27099c66f9cb88d369912cdb8c7 (patch)
tree3d7ae6e665c9d60ca180e51a118a53d6511e1ed3
parent8459369f843d8c74a1532de5711f1d26a96a7f38 (diff)
downloadFreeBSD-src-da06e492c798e27099c66f9cb88d369912cdb8c7.zip
FreeBSD-src-da06e492c798e27099c66f9cb88d369912cdb8c7.tar.gz
Really disable wtmp logging when chrooting.
Also perform a small cleanup to ftpd_logwtmp(). Just use a NULL parameter for the username to indicate a logout, instead of an empty string. Reported by: Alexey Shuvaev <shuvaev physik uni-wuerzburg de>
-rw-r--r--libexec/ftpd/ftpd.c13
-rw-r--r--libexec/ftpd/logwtmp.c2
2 files changed, 9 insertions, 6 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 681fdc3..119c575 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1178,8 +1178,8 @@ end_login(void)
#endif
(void) seteuid(0);
- if (logged_in && dowtmp && !dochroot)
- ftpd_logwtmp(wtmpid, "", NULL);
+ if (logged_in && dowtmp)
+ ftpd_logwtmp(wtmpid, NULL, NULL);
pw = NULL;
#ifdef LOGIN_CAP
setusercontext(NULL, getpwuid(0), 0,
@@ -1482,7 +1482,10 @@ skip:
;
chrootdir = NULL;
- if (dowtmp && !dochroot)
+ /* Disable wtmp logging when chrooting. */
+ if (dochroot || guest)
+ dowtmp = 0;
+ if (dowtmp)
ftpd_logwtmp(wtmpid, pw->pw_name,
(struct sockaddr *)&his_addr);
logged_in = 1;
@@ -2730,9 +2733,9 @@ void
dologout(int status)
{
- if (logged_in && dowtmp && !dochroot) {
+ if (logged_in && dowtmp) {
(void) seteuid(0);
- ftpd_logwtmp(wtmpid, "", NULL);
+ ftpd_logwtmp(wtmpid, NULL, NULL);
}
/* beware of flushing buffers after a SIGPIPE */
_exit(status);
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
index 3d810dd..82683f5 100644
--- a/libexec/ftpd/logwtmp.c
+++ b/libexec/ftpd/logwtmp.c
@@ -60,7 +60,7 @@ ftpd_logwtmp(char *id, char *user, struct sockaddr *addr)
memset(&ut, 0, sizeof(ut));
- if (*user != '\0') {
+ if (user != NULL) {
/* Log in. */
ut.ut_type = USER_PROCESS;
(void)strncpy(ut.ut_user, user, sizeof(ut.ut_user));
OpenPOWER on IntegriCloud