]> git.pld-linux.org Git - packages/proftpd.git/blob - proftpd-wtmp.patch
use pam patch
[packages/proftpd.git] / proftpd-wtmp.patch
1 diff -ur proftpd-1.2.0rc2.orig/src/log.c proftpd-1.2.0rc2/src/log.c
2 --- proftpd-1.2.0rc2.orig/src/log.c     Sat Sep  2 00:36:20 2000
3 +++ proftpd-1.2.0rc2/src/log.c  Sat Sep  2 01:01:59 2000
4 @@ -530,59 +530,22 @@
5  
6  int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip)
7  {
8 -  struct stat buf;
9    struct utmp ut;
10    int res = 0;
11 -  static int fd = -1;
12 -
13 -#if (defined(SVR4) || defined(__SVR4)) && \
14 -    !(defined(LINUX) || defined(__hpux) || defined (_AIX))
15 -  /* This "auxilliary" utmp doesn't exist under linux. */
16 -  struct utmpx utx;
17 -  static int fdx = -1;
18 -
19 -  if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
20 -    log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
21 -    return -1;
22 -  }
23 +  static int washere = 0;
24  
25 +  if (!washere) {
26 +    utmpname(_PATH_WTMP);
27 +    washere = 1;
28 +  } else
29 +    washere = 0;
30    /* Unfortunately, utmp string fields are terminated by '\0' if they are
31     * shorter than the size of the field, but if they are exactly the size of
32     * the field they don't have to be terminated at all.  Frankly, this sucks.
33     * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
34     * the side of caution and always null-terminate our strings.
35     */
36 -  if(fstat(fdx,&buf) == 0) {
37 -    memset(&utx,0,sizeof(utx));
38 -    sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
39 -    sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
40 -    sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
41 -    sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
42 -    utx.ut_syslen = strlen(utx.ut_host)+1;
43 -    utx.ut_pid = getpid();
44 -    time(&utx.ut_tv.tv_sec);
45 -    if(*name)
46 -      utx.ut_type = USER_PROCESS;
47 -    else
48 -      utx.ut_type = DEAD_PROCESS;
49 -    utx.ut_exit.e_termination = 0;
50 -    utx.ut_exit.e_exit = 0;
51 -    if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
52 -      ftruncate(fdx, buf.st_size);
53 -  } else {
54 -    log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
55 -    res = -1;
56 -  }
57 -
58 -#else /* Non-SVR4 systems */
59 -
60 -  if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
61 -    log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
62 -    return -1;
63 -  }
64
65 -  if(fstat(fd,&buf) == 0) {
66 -    memset(&ut,0,sizeof(ut));
67 +  memset(&ut,0,sizeof(ut));
68  #ifdef HAVE_UTMAXTYPE
69  #ifdef LINUX
70      if(ip)
71 @@ -612,13 +575,12 @@
72  #endif /* HAVE_UT_UT_HOST */
73  
74      time(&ut.ut_time);
75 -    if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
76 -      ftruncate(fd,buf.st_size);
77 -  } else {
78 -    log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
79 -    res = -1;
80 -  }
81 -#endif /* SVR4 */
82 +
83 +  setutent();
84 +  while ((getutent())) ;
85 +  pututline(&ut);
86 +  if (!washere)
87 +    endutent();
88  
89    return res;
90  }
This page took 0.051136 seconds and 3 git commands to generate.