Path: blob/main/ftp/bsdftpd-ssl/files/patch-ftpd-logwtmp.c
18878 views
--- ftpd/logwtmp.c.orig 2004-12-19 18:44:42 UTC1+++ ftpd/logwtmp.c2@@ -48,13 +48,18 @@ __FBSDID("$FreeBSD: src/libexec/ftpd/log3#include <arpa/inet.h>4#include <sys/socket.h>56+#include <sys/param.h>7+#if __FreeBSD_version < 9000078#include <fcntl.h>9#include <time.h>10-#if 0 /* Original FreeBSD 5.0 code */11+#if 1 /* Original FreeBSD 5.0 code */12#include <timeconv.h>13#endif14#include <netdb.h>15#include <utmp.h>16+#else17+#include <utmpx.h>18+#endif19#include <unistd.h>20#include <stdio.h>21#include <string.h>22@@ -63,6 +68,7 @@ __FBSDID("$FreeBSD: src/libexec/ftpd/log2324#include <port_base.h>2526+#ifndef _UTMPX_H_27static int fd = -1;2829/*30@@ -94,7 +100,7 @@ ftpd_logwtmp(line, name, addr)31(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));32(void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));33(void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));34-#if 0 /* Original FreeBSD 5.0 code */35+#if 1 /* Original FreeBSD 5.0 code */36ut.ut_time = _time_to_time32(time(NULL));37#else /* Portable code from FreeBSD 4.8 */38(void)time(&ut.ut_time);39@@ -104,3 +110,31 @@ ftpd_logwtmp(line, name, addr)40(void)ftruncate(fd, buf.st_size);41}42}43+#else /* Original FreeBSD 9.0 code */44+void45+ftpd_logwtmp(char *id, char *user, struct sockaddr *addr)46+{47+ struct utmpx ut;48+49+ memset(&ut, 0, sizeof(ut));50+51+ if (user != NULL) {52+ /* Log in. */53+ ut.ut_type = USER_PROCESS;54+ (void)strncpy(ut.ut_user, user, sizeof(ut.ut_user));55+ if (addr != NULL)56+ realhostname_sa(ut.ut_host, sizeof(ut.ut_host),57+ addr, addr->sa_len);58+ } else {59+ /* Log out. */60+ ut.ut_type = DEAD_PROCESS;61+ }62+63+ ut.ut_pid = getpid();64+ gettimeofday(&ut.ut_tv, NULL);65+ (void)strncpy(ut.ut_id, id, sizeof(ut.ut_id));66+ (void)strncpy(ut.ut_line, "ftpd", sizeof(ut.ut_line));67+68+ pututxline(&ut);69+}70+#endif717273