Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/ftp/bsdftpd-ssl/files/patch-ftpd-logwtmp.c
18878 views
1
--- ftpd/logwtmp.c.orig 2004-12-19 18:44:42 UTC
2
+++ ftpd/logwtmp.c
3
@@ -48,13 +48,18 @@ __FBSDID("$FreeBSD: src/libexec/ftpd/log
4
#include <arpa/inet.h>
5
#include <sys/socket.h>
6
7
+#include <sys/param.h>
8
+#if __FreeBSD_version < 900007
9
#include <fcntl.h>
10
#include <time.h>
11
-#if 0 /* Original FreeBSD 5.0 code */
12
+#if 1 /* Original FreeBSD 5.0 code */
13
#include <timeconv.h>
14
#endif
15
#include <netdb.h>
16
#include <utmp.h>
17
+#else
18
+#include <utmpx.h>
19
+#endif
20
#include <unistd.h>
21
#include <stdio.h>
22
#include <string.h>
23
@@ -63,6 +68,7 @@ __FBSDID("$FreeBSD: src/libexec/ftpd/log
24
25
#include <port_base.h>
26
27
+#ifndef _UTMPX_H_
28
static int fd = -1;
29
30
/*
31
@@ -94,7 +100,7 @@ ftpd_logwtmp(line, name, addr)
32
(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
33
(void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
34
(void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
35
-#if 0 /* Original FreeBSD 5.0 code */
36
+#if 1 /* Original FreeBSD 5.0 code */
37
ut.ut_time = _time_to_time32(time(NULL));
38
#else /* Portable code from FreeBSD 4.8 */
39
(void)time(&ut.ut_time);
40
@@ -104,3 +110,31 @@ ftpd_logwtmp(line, name, addr)
41
(void)ftruncate(fd, buf.st_size);
42
}
43
}
44
+#else /* Original FreeBSD 9.0 code */
45
+void
46
+ftpd_logwtmp(char *id, char *user, struct sockaddr *addr)
47
+{
48
+ struct utmpx ut;
49
+
50
+ memset(&ut, 0, sizeof(ut));
51
+
52
+ if (user != NULL) {
53
+ /* Log in. */
54
+ ut.ut_type = USER_PROCESS;
55
+ (void)strncpy(ut.ut_user, user, sizeof(ut.ut_user));
56
+ if (addr != NULL)
57
+ realhostname_sa(ut.ut_host, sizeof(ut.ut_host),
58
+ addr, addr->sa_len);
59
+ } else {
60
+ /* Log out. */
61
+ ut.ut_type = DEAD_PROCESS;
62
+ }
63
+
64
+ ut.ut_pid = getpid();
65
+ gettimeofday(&ut.ut_tv, NULL);
66
+ (void)strncpy(ut.ut_id, id, sizeof(ut.ut_id));
67
+ (void)strncpy(ut.ut_line, "ftpd", sizeof(ut.ut_line));
68
+
69
+ pututxline(&ut);
70
+}
71
+#endif
72
73