]> git.pld-linux.org Git - packages/proftpd.git/commitdiff
- rewritten in a clean way
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 20 Aug 2007 12:09:45 +0000 (12:09 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    proftpd-wtmp.patch -> 1.21

proftpd-wtmp.patch

index 7d0a62c56e71c4701f3691c768497336900fdb13..4a47c1df00764eef17de96e1b4b04b8f5bd48c73 100644 (file)
@@ -1,14 +1,76 @@
---- proftpd-1.3.0/src/log.c    2005-11-14 18:33:06.000000000 +0200
-+++ proftpd-1.3.0.utmp/src/log.c       2006-04-29 14:17:55.023163252 +0300
-@@ -54,32 +54,12 @@
+diff -ur proftpd-1.3.1rc2/configure.in proftpd-1.3.1rc2.utmpx/configure.in
+--- proftpd-1.3.1rc2/configure.in      2007-08-20 14:07:40.000000000 +0200
++++ proftpd-1.3.1rc2.utmpx/configure.in        2007-08-20 14:07:28.000000000 +0200
+@@ -1056,7 +1056,7 @@
+ AC_CHECK_HEADERS(sys/stat.h errno.h sys/socket.h sys/termios.h sys/termio.h)
+ AC_CHECK_HEADERS(sys/statvfs.h sys/un.h sys/vfs.h sys/select.h)
+ AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h sys/dir.h vmsdir.h)
+-AC_CHECK_HEADERS(ucontext.h utime.h utmpx.h)
++AC_CHECK_HEADERS(ucontext.h utime.h)
+ AC_CHECK_HEADERS(regex.h)
+ AC_CHECK_HEADER(syslog.h,have_syslog_h="yes",)
+ AC_CHECK_HEADERS(curses.h ncurses.h)
+@@ -1119,10 +1119,10 @@
  
- int log_wtmp(char *line, const char *name, const char *host,
-     pr_netaddr_t *ip) {
--  struct stat buf;
-   struct utmp ut;
+ if test $have_utmp; then
+   AC_CACHE_CHECK(whether your struct utmp has ut_user,
+-              pr_cv_header_utmaxtype,
++              pr_cv_header_ut_user,
+       AC_EGREP_HEADER([ *ut_user.*;],utmp.h,
+-                      pr_cv_header_utmaxtype="yes",
+-                      pr_cv_header_utmaxtype="no"))
++                      pr_cv_header_ut_user="yes",
++                      pr_cv_header_ut_user="no"))
+   AC_CACHE_CHECK(whether your struct utmp has ut_host,
+               pr_cv_header_ut_host,
+       AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
+@@ -1133,8 +1133,8 @@
+       AC_EGREP_HEADER([ *ut_exit.*;],utmp.h,
+                       pr_cv_header_ut_exit="yes",
+                       pr_cv_header_ut_exit="no"))
+-  if test "$pr_cv_header_utmaxtype" = "yes"; then
+-    AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
++  if test "$pr_cv_header_ut_user" = "yes"; then
++    AC_DEFINE(HAVE_UT_UT_USER, 1, [If struct utmp has ut_user.])
+   fi
+   if test "$pr_cv_header_ut_host" = "yes"; then
+     AC_DEFINE(HAVE_UT_UT_HOST, 1, [If struct utmp has ut_host.])
+@@ -1144,6 +1144,28 @@
+   fi
+ fi
++dnl See what type of utmp exists
++AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
++
++if test $have_utmpx; then
++  AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
++              pr_cv_header_utx_exit,
++      AC_EGREP_HEADER([ *ut_exit.*;],utmpx.h,
++                      pr_cv_header_utx_exit="yes",
++                      pr_cv_header_utx_exit="no"))
++  AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
++              pr_cv_header_utx_syslen,
++      AC_EGREP_HEADER([ *ut_syslen.*;],utmpx.h,
++                      pr_cv_header_utx_syslen="yes",
++                      pr_cv_header_utx_syslen="no"))
++  if test "$pr_cv_header_utx_exit" = "yes"; then
++    AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
++  fi
++  if test "$pr_cv_header_utx_syslen" = "yes"; then
++    AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
++  fi
++fi
++
+ dnl See if various LOG_ macros are defined
+ if test "$have_syslog_h" = "yes"; then
+   AC_DEFINE(HAVE_SYSLOG_H)
+diff -ur proftpd-1.3.1rc2/src/log.c proftpd-1.3.1rc2.utmpx/src/log.c
+--- proftpd-1.3.1rc2/src/log.c 2006-12-11 20:53:43.000000000 +0100
++++ proftpd-1.3.1rc2.utmpx/src/log.c   2007-08-20 14:07:30.000000000 +0200
+@@ -59,119 +59,116 @@
    int res = 0;
--  static int fd = -1;
--
+   static int fd = -1;
 -#if ((defined(SVR4) || defined(__SVR4)) || \
 -    (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
 -    !(defined(LINUX) || defined(__hpux) || defined (_AIX))
 -  struct utmpx utx;
 -#endif
 -  static int fdx = -1;
++#if defined(HAVE_UTMPX_H)
  
  #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
  # define WTMPX_FILE _PATH_WTMPX
  #endif
--
++  if (access(WTMPX_FILE, F_OK) == 0) {
++#if defined(__sparcv9) && !defined(__NetBSD__)
++    struct futmpx utx;
++#else
++    struct utmpx utx;
++    time_t t;
++#endif
++    static int fdx = -1;
 -  if (fdx < 0 &&
 -      (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
 -    pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
 -    return -1;
 -  }
-   /* Unfortunately, utmp string fields are terminated by '\0' if they are
-    * shorter than the size of the field, but if they are exactly the size of
-@@ -87,52 +69,7 @@
-    * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
-    * the side of caution and always null-terminate our strings.
-    */
+-
+-  /* Unfortunately, utmp string fields are terminated by '\0' if they are
+-   * shorter than the size of the field, but if they are exactly the size of
+-   * the field they don't have to be terminated at all.  Frankly, this sucks.
+-   * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
+-   * the side of caution and always null-terminate our strings.
+-   */
 -  if (fstat(fdx, &buf) == 0) {
 -    memset(&utx, 0, sizeof(utx));
--
++    if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
++      pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
++      return -1;
++    }
 -    sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
 -    sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
 -    sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
 -    time(&utx.ut_tv.tv_sec);
 -#  endif
 -#endif /* SVR4 */
--
++    /* Unfortunately, utmp string fields are terminated by '\0' if they are
++     * shorter than the size of the field, but if they are exactly the size of
++     * the field they don't have to be terminated at all.  Frankly, this sucks.
++     * Insane if you ask me.  Unless there's massive uproar, I prefer to err on
++     * the side of caution and always null-terminate our strings.
++     */
++    if (fstat(fdx, &buf) == 0) {
++      memset(&utx, 0, sizeof(utx));
 -    if (*name)
 -      utx.ut_type = USER_PROCESS;
 -    else
 -#ifdef HAVE_UT_UT_EXIT
 -    utx.ut_exit.e_termination = 0;
 -    utx.ut_exit.e_exit = 0;
--#endif /* HAVE_UT_UT_EXIT */
++      if (name && *name) {
++        sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
++        utx.ut_type = USER_PROCESS;
++      } else {
++        utx.ut_type = DEAD_PROCESS;
++      }
++      utx.ut_pid = getpid();
++      sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
++      sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
++      if (host && *host)
++        sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
++#ifdef HAVE_UTX_UT_EXIT
++      utx.ut_exit.e_termination = 0;
++      utx.ut_exit.e_exit = 0;
+ #endif /* HAVE_UT_UT_EXIT */
 -    if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
 -      ftruncate(fdx, buf.st_size);
--
 -  } else {
 -    pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
 -    res = -1;
 -  }
--
++#ifdef HAVE_UTX_UT_SYSLEN
++      utx.ut_syslen = strlen(utx.ut_host)+1;
++#endif
++#if defined(__NetBSD__)
++      memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
++      gettimeofday(&utx.ut_tv, NULL);
++#else
++      time(&t);
++      utx.ut_tv.tv_sec = (time32_t)t;
++#endif
 -#else /* Non-SVR4 systems */
--
++      if (ip)
++#ifndef PR_USE_IPV6
++        memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
++#else
++        memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
++#endif /* !PR_USE_IPV6 */
 -  if (fd < 0 &&
 -      (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
--    pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
--    return -1;
--  }
++      if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
++        ftruncate(fdx, buf.st_size);
++    } else {
++      pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
++      res = -1;
++    }
++
++    return res;
++  }
++#else /* HAVE_UTMPX_H */
++  if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
+     pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
+     return -1;
+   }
  
--  if (fstat(fd, &buf) == 0) {
+   if (fstat(fd, &buf) == 0) {
      memset(&ut, 0, sizeof(ut));
- #ifdef HAVE_UTMAXTYPE
- # ifdef LINUX
-@@ -169,15 +106,8 @@
+-#ifdef HAVE_UTMAXTYPE
+-# ifdef LINUX
+-    if (ip)
+-#  ifndef PR_USE_IPV6
+-      memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
+-#  else
+-      memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
+-#  endif /* !PR_USE_IPV6 */
+-# else
+-    sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
+-#  ifdef HAVE_UT_UT_EXIT
+-    ut.ut_exit.e_termination = 0;
+-    ut.ut_exit.e_exit = 0;
+-#  endif /* !HAVE_UT_UT_EXIT */
+-# endif /* !LINUX */
+-    sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
+-    if (name && *name)
++    if (name && *name) {
++#ifdef HAVE_UT_UT_USER
+       sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
+-    ut.ut_pid = getpid();
+-    if (name && *name)
++#else
++      sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
++#endif
+       ut.ut_type = USER_PROCESS;
+-    else
++    } else {
+       ut.ut_type = DEAD_PROCESS;
+-#else  /* !HAVE_UTMAXTYPE */
++    }
++    ut.ut_pid = getpid();
+     sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
+-    if (name && *name)
+-      sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
+-#endif /* HAVE_UTMAXTYPE */
+-
++    sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
+ #ifdef HAVE_UT_UT_HOST
+     if (host && *host)
+       sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
  #endif /* HAVE_UT_UT_HOST */
+-
++#ifdef HAVE_UT_UT_EXIT
++    ut.ut_exit.e_termination = 0;
++    ut.ut_exit.e_exit = 0;
++#endif /* !HAVE_UT_UT_EXIT */
      time(&ut.ut_time);
--    if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
--      ftruncate(fd, buf.st_size);
++    if (ip)
++#ifndef PR_USE_IPV6
++      memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
++#else
++      memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
++#endif /* !PR_USE_IPV6 */
++
+     if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
+       ftruncate(fd, buf.st_size);
 -
--  } else {
--    pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
--    res = -1;
--  }
--#endif /* SVR4 */
-+  updwtmpx(WTMPX_FILE, &ut);
-   return res;
- }
+   } else {
+     pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
+     res = -1;
This page took 0.060212 seconds and 4 git commands to generate.