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