]> git.pld-linux.org Git - packages/proftpd.git/blob - proftpd-wtmp.patch
- updated for 1.2.4
[packages/proftpd.git] / proftpd-wtmp.patch
1 --- ./src/log.c.org     Sun Oct 21 21:11:04 2001
2 +++ ./src/log.c Sun Oct 21 21:20:07 2001
3 @@ -594,26 +594,16 @@
4  
5  int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip)
6  {
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 +  static int washere = 0;
23  
24 -  if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
25 -    log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
26 -    return -1;
27 -  }
28 +  if (!washere) {
29 +    utmpname(_PATH_WTMP);
30 +    washere = 1;
31 +  } else
32 +    washere = 0;
33  
34    /* Unfortunately, utmp string fields are terminated by '\0' if they are
35     * shorter than the size of the field, but if they are exactly the size of
36 @@ -621,42 +611,8 @@
37     * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
38     * the side of caution and always null-terminate our strings.
39     */
40 -  if(fstat(fdx,&buf) == 0) {
41 -    memset(&utx,0,sizeof(utx));
42 -    sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
43 -    sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
44 -    sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
45 -    sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
46 -    utx.ut_syslen = strlen(utx.ut_host)+1;
47 -    utx.ut_pid = getpid();
48 -#ifdef __sparcv9
49 -    time(&t);
50 -    utx.ut_tv.tv_sec = (time32_t)t;
51 -#else
52 -    time(&utx.ut_tv.tv_sec);
53 -#endif
54 -    if(*name)
55 -      utx.ut_type = USER_PROCESS;
56 -    else
57 -      utx.ut_type = DEAD_PROCESS;
58 -    utx.ut_exit.e_termination = 0;
59 -    utx.ut_exit.e_exit = 0;
60 -    if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
61 -      ftruncate(fdx, buf.st_size);
62 -  } else {
63 -    log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
64 -    res = -1;
65 -  }
66 -
67 -#else /* Non-SVR4 systems */
68 -
69 -  if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
70 -    log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
71 -    return -1;
72 -  }
73
74 -  if(fstat(fd,&buf) == 0) {
75 -    memset(&ut,0,sizeof(ut));
76 +
77 +   memset(&ut,0,sizeof(ut));
78  #ifdef HAVE_UTMAXTYPE
79  #ifdef LINUX
80      if(ip)
81 @@ -686,13 +642,12 @@
82  #endif /* HAVE_UT_UT_HOST */
83  
84      time(&ut.ut_time);
85 -    if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
86 -      ftruncate(fd,buf.st_size);
87 -  } else {
88 -    log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
89 -    res = -1;
90 -  }
91 -#endif /* SVR4 */
92 +
93 +  setutent();
94 +  while ((getutent())) ;
95 +  pututline(&ut);
96 +  if (!washere)
97 +    endutent();
98  
99    return res;
100  }
This page took 0.042142 seconds and 4 git commands to generate.