diff -uwrP wu-ftpd-2.6.2.SPLIT/config.h.in wu-ftpd-2.6.2/config.h.in --- wu-ftpd-2.6.2.SPLIT/config.h.in 2002-12-13 17:25:52.000000000 -0500 +++ wu-ftpd-2.6.2/config.h.in 2002-12-13 18:05:32.000000000 -0500 @@ -125,6 +125,14 @@ #undef DISABLE_SITE /* + * USE_LASTLOG + * Track logins via lastlog file. + * 2000/10/19 Sylvain Robitaille + */ + +#undef USE_LASTLOG + +/* * SKEY * Add SKEY support -- REQUIRES SKEY libraries * See FIXES-2.4-HOBBIT for more information on this option. diff -uwrP wu-ftpd-2.6.2.SPLIT/configure wu-ftpd-2.6.2/configure --- wu-ftpd-2.6.2.SPLIT/configure 2002-12-16 11:10:19.000000000 -0500 +++ wu-ftpd-2.6.2/configure 2002-12-16 11:05:33.000000000 -0500 @@ -680,6 +680,7 @@ --disable-checksum don't support SITE CHECKSUM" --disable-site don't support any SITE commands" --enable-paranoid disable some "questionable" features + --disable-lastlog disable lastlog logging --enable-quota add QUOTA support (if your OS supports it) --enable-pam add PAM support (needs PAM library) --enable-skey add S/KEY support (needs SKEY libraries) @@ -2693,6 +2694,14 @@ paranoid=no fi; +# Check whether --enable-lastlog or --disable-lastlog was given. +if test "${enable_lastlog+set}" = set; then + enableval="$enable_lastlog" + lastlog=$enableval +else + lastlog=yes +fi + # Check whether --enable-quota or --disable-quota was given. if test "${enable_quota+set}" = set; then enableval="$enable_quota" @@ -5450,6 +5459,13 @@ EOF fi +if test $lastlog = yes; then + cat >> confdefs.h <<\EOF +#define USE_LASTLOG 1 +EOF + +fi + if test $quota != no; then for ac_header in sys/quota.h sys/fs/ufs_quota.h ufs/quota.h jfs/quota.h ufs/ufs/quota.h linux/quota.h diff -uwrP wu-ftpd-2.6.2.SPLIT/configure.in wu-ftpd-2.6.2/configure.in --- wu-ftpd-2.6.2.SPLIT/configure.in 2002-12-16 11:09:29.000000000 -0500 +++ wu-ftpd-2.6.2/configure.in 2002-12-13 18:58:41.000000000 -0500 @@ -174,6 +174,10 @@ [ --enable-paranoid disable some "questionable" features], [ paranoid=$enableval ], [ paranoid=no ]) +AC_ARG_ENABLE(lastlog, + [ --disable-lastlog keep track of logins via the lastlog file], + [ lastlog=$enableval ], [ lastlog=yes ]) + AC_ARG_ENABLE(quota, [ --enable-quota add QUOTA support (if your OS supports it)], [ quota=$enableval ], [ quota=no ]) diff -uwrP wu-ftpd-2.6.2.SPLIT/src/Makefile.in wu-ftpd-2.6.2/src/Makefile.in --- wu-ftpd-2.6.2.SPLIT/src/Makefile.in 2000-07-01 14:04:21.000000000 -0400 +++ wu-ftpd-2.6.2/src/Makefile.in 2002-12-13 18:04:35.000000000 -0500 @@ -43,12 +43,12 @@ SRCS = ${UTIL_OBJS} ftpd.c ftpcmd.c glob.c logwtmp.c popen.c access.c \ extensions.c realpath.c acl.c private.c authenticate.c conversions.c \ rdservers.c paths.c hostacc.c sigfix.c auth.c routevector.c \ - restrict.c domain.c wu_fnmatch.c timeout.c getpwnam.c + restrict.c domain.c wu_fnmatch.c timeout.c getpwnam.c lastlog.c OBJS = ${UTIL_OBJS} ftpd.o ftpcmd.o glob.o logwtmp.o popen.o access.o \ extensions.o realpath.o acl.o private.o authenticate.o conversions.o \ rdservers.o paths.o hostacc.o sigfix.o auth.o routevector.o \ - restrict.o domain.o wu_fnmatch.o timeout.o getpwnam.o + restrict.o domain.o wu_fnmatch.o timeout.o getpwnam.o lastlog.o .c.o: $(CC) $(CFLAGS) -I.. -I../support -c -o $@ $< diff -uwrP wu-ftpd-2.6.2.SPLIT/src/ftpd.c wu-ftpd-2.6.2/src/ftpd.c --- wu-ftpd-2.6.2.SPLIT/src/ftpd.c 2002-12-13 17:27:14.000000000 -0500 +++ wu-ftpd-2.6.2/src/ftpd.c 2002-12-13 18:04:01.000000000 -0500 @@ -2909,6 +2909,10 @@ #endif wu_logwtmp(ttyline, pw->pw_name, remotehost, 1); } +#ifdef USE_LASTLOG + /* 2000/10/19 Sylvain Robitaille: Update lastlog file */ + update_lastlog(pw->pw_uid, remotehost); +#endif logged_in = 1; expand_id(); diff -uwrP wu-ftpd-2.6.2.SPLIT/src/lastlog.c wu-ftpd-2.6.2/src/lastlog.c --- wu-ftpd-2.6.2.SPLIT/src/lastlog.c 1969-12-31 19:00:00.000000000 -0500 +++ wu-ftpd-2.6.2/src/lastlog.c 2002-07-16 14:50:24.000000000 -0400 @@ -0,0 +1,66 @@ +/*********************************************************** + * * + * File: lastlog.c * + * * + * Description: Records user login in the lastlog file. * + * * + * Author: Sylvain Robitaille * + * * + * Date: 2000/10/19: adapted from patch to IMAPd * + * * + ***********************************************************/ + +/*********************************************************** + * * + * Include files * + * * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "pathnames.h" + +/*************************************************************** + * * + * Function: update_lastlog(uid_t uid) * + * * + * Description: records the user's activity in the system * + * lastlog file. * + * * + * Author: Sylvain Robitaille * + * * + * Date: 1997/11/21: borrowed code from ssh source. * + * 2000/07/31: Call with the uid as a parameter * + * 2000/10/19: Add to Wu-Ftpd-2.6.0, hostname parameter * + * * + ***************************************************************/ +void update_lastlog(uid_t uid, char *host) { + + int fd; /* file descriptor */ + struct lastlog ll; /* lastlog information held here */ + + const char *lastlog = _PATH_LASTLOG; + + /* Initialize the lastlog structure */ + memset(&ll, 0, sizeof(ll)); + + /* Fill in the data */ + ll.ll_time = time(NULL); + strncpy(ll.ll_line, "ftp", sizeof(ll.ll_line)); + strncpy(ll.ll_host, host, sizeof(ll.ll_host)); + + /* + * Now update the lastlog file. + */ + fd = open(lastlog, O_RDWR); + if(fd >= 0) { + lseek(fd, (off_t)(uid * sizeof(ll)), 0); + if(write(fd, &ll, sizeof(ll)) != sizeof(ll)) + syslog(LOG_INFO, "Could not write %.100s: %.100s", + lastlog, strerror(errno)); + close(fd); + } +}