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>
This commit is contained in:
Ed Schouten 2010-01-18 23:28:25 +00:00
parent 12a91a4387
commit 9f37b1a2b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=202604
2 changed files with 9 additions and 6 deletions

View File

@ -1178,8 +1178,8 @@ end_login(void)
#endif #endif
(void) seteuid(0); (void) seteuid(0);
if (logged_in && dowtmp && !dochroot) if (logged_in && dowtmp)
ftpd_logwtmp(wtmpid, "", NULL); ftpd_logwtmp(wtmpid, NULL, NULL);
pw = NULL; pw = NULL;
#ifdef LOGIN_CAP #ifdef LOGIN_CAP
setusercontext(NULL, getpwuid(0), 0, setusercontext(NULL, getpwuid(0), 0,
@ -1482,7 +1482,10 @@ skip:
; ;
chrootdir = NULL; chrootdir = NULL;
if (dowtmp && !dochroot) /* Disable wtmp logging when chrooting. */
if (dochroot || guest)
dowtmp = 0;
if (dowtmp)
ftpd_logwtmp(wtmpid, pw->pw_name, ftpd_logwtmp(wtmpid, pw->pw_name,
(struct sockaddr *)&his_addr); (struct sockaddr *)&his_addr);
logged_in = 1; logged_in = 1;
@ -2730,9 +2733,9 @@ void
dologout(int status) dologout(int status)
{ {
if (logged_in && dowtmp && !dochroot) { if (logged_in && dowtmp) {
(void) seteuid(0); (void) seteuid(0);
ftpd_logwtmp(wtmpid, "", NULL); ftpd_logwtmp(wtmpid, NULL, NULL);
} }
/* beware of flushing buffers after a SIGPIPE */ /* beware of flushing buffers after a SIGPIPE */
_exit(status); _exit(status);

View File

@ -60,7 +60,7 @@ ftpd_logwtmp(char *id, char *user, struct sockaddr *addr)
memset(&ut, 0, sizeof(ut)); memset(&ut, 0, sizeof(ut));
if (*user != '\0') { if (user != NULL) {
/* Log in. */ /* Log in. */
ut.ut_type = USER_PROCESS; ut.ut_type = USER_PROCESS;
(void)strncpy(ut.ut_user, user, sizeof(ut.ut_user)); (void)strncpy(ut.ut_user, user, sizeof(ut.ut_user));