]> git.pld-linux.org Git - packages/proftpd.git/blob - proftpd-wtmp.patch
- updated to 1.2.10rc3
[packages/proftpd.git] / proftpd-wtmp.patch
1 --- proftpd-1.2.10rc3/src/log.c.orig    2004-04-20 04:05:41.000000000 +0200
2 +++ proftpd-1.2.10rc3/src/log.c 2004-09-01 08:26:12.959741640 +0200
3 @@ -54,27 +54,16 @@
4  
5  int log_wtmp(char *line, const char *name, const char *host,
6      pr_netaddr_t *ip) {
7 -  struct stat buf;
8    struct utmp ut;
9    int res = 0;
10 -  static int fd = -1;
11  
12 -#if (defined(SVR4) || defined(__SVR4)) && \
13 -    !(defined(LINUX) || defined(__hpux) || defined (_AIX))
14 -  /* This "auxilliary" utmp doesn't exist under linux. */
15 -#ifdef __sparcv9
16 -  struct futmpx utx;
17 -  time_t t;
18 -#else
19 -  struct utmpx utx;
20 -#endif
21 -  static int fdx = -1;
22 -
23 -  if (fdx < 0 &&
24 -      (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
25 -    pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
26 -    return -1;
27 -  }
28 +  static int washere = 0;
29 +  
30 +  if (!washere) {
31 +    utmpname(_PATH_WTMP);
32 +    washere = 1;
33 +  } else
34 +    washere = 0;
35  
36    /* Unfortunately, utmp string fields are terminated by '\0' if they are
37     * shorter than the size of the field, but if they are exactly the size of
38 @@ -82,46 +71,6 @@
39     * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
40     * the side of caution and always null-terminate our strings.
41     */
42 -  if (fstat(fdx, &buf) == 0) {
43 -    memset(&utx, 0, sizeof(utx));
44 -
45 -    sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
46 -    sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
47 -    sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
48 -    sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
49 -    utx.ut_syslen = strlen(utx.ut_host)+1;
50 -    utx.ut_pid = getpid();
51 -#ifdef __sparcv9
52 -    time(&t);
53 -    utx.ut_tv.tv_sec = (time32_t)t;
54 -#else
55 -    time(&utx.ut_tv.tv_sec);
56 -#endif
57 -    if (*name)
58 -      utx.ut_type = USER_PROCESS;
59 -    else
60 -      utx.ut_type = DEAD_PROCESS;
61 -#ifdef HAVE_UT_UT_EXIT
62 -    utx.ut_exit.e_termination = 0;
63 -    utx.ut_exit.e_exit = 0;
64 -#endif /* HAVE_UT_UT_EXIT */
65 -    if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
66 -      ftruncate(fdx, buf.st_size);
67 -
68 -  } else {
69 -    pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
70 -    res = -1;
71 -  }
72 -
73 -#else /* Non-SVR4 systems */
74 -
75 -  if (fd < 0 &&
76 -      (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
77 -    pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
78 -    return -1;
79 -  }
80 -
81 -  if (fstat(fd, &buf) == 0) {
82      memset(&ut, 0, sizeof(ut));
83  #ifdef HAVE_UTMAXTYPE
84  # ifdef LINUX
85 @@ -158,15 +107,12 @@
86  #endif /* HAVE_UT_UT_HOST */
87  
88      time(&ut.ut_time);
89 -    if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
90 -      ftruncate(fd, buf.st_size);
91 -
92 -  } else {
93 -    pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
94 -    res = -1;
95 -  }
96 -#endif /* SVR4 */
97  
98 +  setutent();
99 +  while ((getutent())) ;
100 +  pututline(&ut);
101 +  if (!washere)
102 +    endutent();
103    return res;
104  }
105  
This page took 0.103904 seconds and 3 git commands to generate.