Author: ed
Date: Mon Jan 18 23:28:25 2010
New Revision: 202604
URL: http://svn.freebsd.org/changeset/base/202604

Log:
  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>

Modified:
  head/libexec/ftpd/ftpd.c
  head/libexec/ftpd/logwtmp.c

Modified: head/libexec/ftpd/ftpd.c
==============================================================================
--- head/libexec/ftpd/ftpd.c    Mon Jan 18 23:13:22 2010        (r202603)
+++ head/libexec/ftpd/ftpd.c    Mon Jan 18 23:28:25 2010        (r202604)
@@ -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);

Modified: head/libexec/ftpd/logwtmp.c
==============================================================================
--- head/libexec/ftpd/logwtmp.c Mon Jan 18 23:13:22 2010        (r202603)
+++ head/libexec/ftpd/logwtmp.c Mon Jan 18 23:28:25 2010        (r202604)
@@ -60,7 +60,7 @@ ftpd_logwtmp(char *id, char *user, struc
 
        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));
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to