aboutsummaryrefslogtreecommitdiffstats
path: root/ftp/tnftpd/files/patch-src-ftpd.c
blob: 209da1d8188455821bae07171998ad17d46a10c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Rewrite utmpx support.

--- src/ftpd.c.orig 2009-11-07 04:26:48.000000000 +0100
+++ src/ftpd.c  2009-11-07 04:26:48.000000000 +0100
@@ -504,9 +504,6 @@
        confdir = _DEFAULT_CONFDIR;
 
    if (dowtmp) {
-#ifdef SUPPORT_UTMPX
-       ftpd_initwtmpx();
-#endif
 #ifdef SUPPORT_UTMP
        ftpd_initwtmp();
 #endif
@@ -1320,23 +1317,18 @@
    (void)gettimeofday(&tv, NULL);
 #endif
 #ifdef SUPPORT_UTMPX
-   if (doutmp) {
+   if (doutmp || dowtmp) {
        (void)memset(&utmpx, 0, sizeof(utmpx));
        utmpx.ut_tv = tv;
        utmpx.ut_pid = getpid();
-       utmpx.ut_id[0] = 'f';
-       utmpx.ut_id[1] = 't';
-       utmpx.ut_id[2] = 'p';
-       utmpx.ut_id[3] = '*';
+       snprintf(utmpx.ut_id, sizeof(utmpx.ut_id), "%xftp",
+           utmpx.ut_pid);
        utmpx.ut_type = USER_PROCESS;
-       (void)strncpy(utmpx.ut_name, name, sizeof(utmpx.ut_name));
+       (void)strncpy(utmpx.ut_user, name, sizeof(utmpx.ut_user));
        (void)strncpy(utmpx.ut_line, line, sizeof(utmpx.ut_line));
        (void)strncpy(utmpx.ut_host, host, sizeof(utmpx.ut_host));
-       (void)memcpy(&utmpx.ut_ss, &haddr->si_su, haddr->su_len);
-       ftpd_loginx(&utmpx);
+       (void)pututxline(&utmpx);
    }
-   if (dowtmp)
-       ftpd_logwtmpx(line, name, host, haddr, 0, USER_PROCESS);
 #endif
 #ifdef SUPPORT_UTMP
    if (doutmp) {
@@ -1356,17 +1348,23 @@
 logout_utmp(void)
 {
 #ifdef SUPPORT_UTMPX
-   int okwtmpx = dowtmp;
+   struct timeval tv;
+   (void)gettimeofday(&tv, NULL);
 #endif
 #ifdef SUPPORT_UTMP
    int okwtmp = dowtmp;
 #endif
    if (logged_in) {
 #ifdef SUPPORT_UTMPX
-       if (doutmp)
-           okwtmpx &= ftpd_logoutx(ttyline, 0, DEAD_PROCESS);
-       if (okwtmpx)
-           ftpd_logwtmpx(ttyline, "", "", NULL, 0, DEAD_PROCESS);
+       if (doutmp || dowtmp) {
+           (void)memset(&utmpx, 0, sizeof(utmpx));
+           utmpx.ut_tv = tv;
+           utmpx.ut_pid = getpid();
+           snprintf(utmpx.ut_id, sizeof(utmpx.ut_id), "%xftp",
+               utmpx.ut_pid);
+           utmpx.ut_type = DEAD_PROCESS;
+           (void)pututxline(&utmpx);
+       }
 #endif
 #ifdef SUPPORT_UTMP
        if (doutmp)