snmp/snmp.patch

Thu, 04 Oct 2012 20:30:05 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Oct 2012 20:30:05 +0200
changeset 715
c10fb90893b9
parent 589
6db023bc5512
permissions
-rw-r--r--

Correct out of date build configuration, porting to Solaris 11 network
link infrastructure and new libpcap logic. This additionally allows for
device drivers in subdirectories of /dev. Correct packaged nmap
personalities and signatures to work out of the box. Finally, hack
arpd logic to properly close sockets and quit on TERM by repeating
signaling in the run command script. Sadly, all this fails to correct
the run time behaviour of honeyd which fails to bind to the IP layer.

     1 Index: agent/auto_nlist.c
     2 diff -Nau agent/auto_nlist.c.orig agent/auto_nlist.c
     3 --- agent/auto_nlist.c.orig	2011-07-02 00:35:46.000000000 +0200
     4 +++ agent/auto_nlist.c	2011-09-15 09:22:50.256627584 +0200
     5 @@ -53,6 +53,7 @@
     6      }
     7      if (*ptr == 0) {
     8          *ptr = (struct autonlist *) malloc(sizeof(struct autonlist));
     9 +	memset(*ptr, 0, sizeof(struct autonlist));
    10          it = *ptr;
    11          it->left = 0;
    12          it->right = 0;
    13 Index: agent/mibgroup/mibII/tcp.c
    14 diff -Nau agent/mibgroup/mibII/tcp.c.orig agent/mibgroup/mibII/tcp.c
    15 --- agent/mibgroup/mibII/tcp.c.orig	2011-07-02 00:35:46.000000000 +0200
    16 +++ agent/mibgroup/mibII/tcp.c	2011-09-15 09:22:50.258135285 +0200
    17 @@ -88,7 +88,7 @@
    18                   * But only define it under FreeBSD, since it
    19                   *   breaks other systems (notable AIX)
    20                   */
    21 -#ifdef freebsd4
    22 +#if defined (freebsd4) || defined (__NetBSD__)
    23  int  hz = 1000;
    24  #endif
    26 Index: agent/mibgroup/mibII/tcpTable.c
    27 diff -Nau agent/mibgroup/mibII/tcpTable.c.orig agent/mibgroup/mibII/tcpTable.c
    28 --- agent/mibgroup/mibII/tcpTable.c.orig	2011-07-02 00:35:46.000000000 +0200
    29 +++ agent/mibgroup/mibII/tcpTable.c	2011-09-15 09:22:50.260414149 +0200
    30 @@ -110,6 +110,11 @@
    31  #define	TCPTABLE_REMOTEPORT	pcb.inp_fport
    32  #define	TCPTABLE_IS_LINKED_LIST
    34 +#if defined(__FreeBSD__)
    35 +#undef  INP_NEXT_SYMBOL
    36 +#define INP_NEXT_SYMBOL inp_next
    37 +#endif
    38 +
    39  #endif                          /* linux */
    40  #endif                          /* WIN32 cygwin */
    41  #endif                          /* solaris2 */
    42 @@ -892,12 +897,17 @@
    43          nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
    44          if (!nnew)
    45              break;
    46 +#if defined(__FreeBSD__)
    47 +        memcpy(&(nnew->pcb), &(((struct xinpcb *) xig)->xi_inp),
    48 +                           sizeof(struct inpcb));
    49 +#else
    50          nnew->state = StateMap[((NS_ELEM *) xig)->xt_tp.t_state];
    51          if (nnew->state == 5 /* established */ ||
    52              nnew->state == 8 /*  closeWait  */ )
    53              tcp_estab++;
    54          memcpy(&(nnew->pcb), &(((NS_ELEM *) xig)->xt_inp),
    55                             sizeof(struct inpcb));
    56 +#endif
    58  	if (nnew->pcb.inp_vflag & INP_IPV6)
    59  	    free(nnew);
    60 Index: agent/mibgroup/ucd-snmp/diskio.c
    61 diff -Nau agent/mibgroup/ucd-snmp/diskio.c.orig agent/mibgroup/ucd-snmp/diskio.c
    62 --- agent/mibgroup/ucd-snmp/diskio.c.orig	2011-07-02 00:35:46.000000000 +0200
    63 +++ agent/mibgroup/ucd-snmp/diskio.c	2011-09-15 09:22:50.263188251 +0200
    64 @@ -800,6 +800,20 @@
    65      case DISKIO_DEVICE:
    66          *var_len = strlen(stat->dinfo->devices[indx].device_name);
    67          return (u_char *) stat->dinfo->devices[indx].device_name;
    68 +#if defined(freebsd5) && (__FreeBSD_version >= 500107)
    69 +    case DISKIO_NREAD:
    70 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    71 +        return (u_char *) & long_ret;
    72 +    case DISKIO_NWRITTEN:
    73 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_WRITE];
    74 +        return (u_char *) & long_ret;
    75 +    case DISKIO_READS:
    76 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_READ];
    77 +        return (u_char *) & long_ret;
    78 +    case DISKIO_WRITES:
    79 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_WRITE];
    80 +        return (u_char *) & long_ret;
    81 +#else
    82      case DISKIO_NREAD:
    83  #if defined(freebsd5) && __FreeBSD_version >= 500107
    84          long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    85 @@ -857,6 +871,7 @@
    86      case DISKIO_LA15:
    87          long_ret = devloads[indx].la15;
    88          return (u_char *) & long_ret;
    89 +#endif
    91      default:
    92          ERROR_MSG("diskio.c: don't know how to handle this request.");
    93 Index: agent/mibgroup/ucd-snmp/memory_solaris2.c
    94 diff -Nau agent/mibgroup/ucd-snmp/memory_solaris2.c.orig agent/mibgroup/ucd-snmp/memory_solaris2.c
    95 --- agent/mibgroup/ucd-snmp/memory_solaris2.c.orig	2011-07-02 00:35:46.000000000 +0200
    96 +++ agent/mibgroup/ucd-snmp/memory_solaris2.c	2011-09-15 09:22:50.264370106 +0200
    97 @@ -1,3 +1,4 @@
    98 +#undef _FILE_OFFSET_BITS /* swapctl doesn't support 64bit off_t */
    99  #include <net-snmp/net-snmp-config.h>   /* local SNMP configuration details */
   100  #if HAVE_STRING_H
   101  #include <string.h>
   102 Index: agent/mibgroup/ucd-snmp/proc.c
   103 diff -Nau agent/mibgroup/ucd-snmp/proc.c.orig agent/mibgroup/ucd-snmp/proc.c
   104 --- agent/mibgroup/ucd-snmp/proc.c.orig	2011-07-02 00:35:46.000000000 +0200
   105 +++ agent/mibgroup/ucd-snmp/proc.c	2011-09-15 09:22:50.265801863 +0200
   106 @@ -1,3 +1,6 @@
   107 +#ifdef solaris2
   108 +#undef _FILE_OFFSET_BITS /* solaris procfs doesn't support 64bit off_t */
   109 +#endif
   110  #include <net-snmp/net-snmp-config.h>
   111  #include <net-snmp/net-snmp-features.h>
   113 Index: agent/mibgroup/util_funcs.c
   114 diff -Nau agent/mibgroup/util_funcs.c.orig agent/mibgroup/util_funcs.c
   115 --- agent/mibgroup/util_funcs.c.orig	2011-07-02 00:35:46.000000000 +0200
   116 +++ agent/mibgroup/util_funcs.c	2011-09-15 09:22:50.267863457 +0200
   117 @@ -477,6 +477,9 @@
   118      int             fd[2][2], i, cnt;
   119      char            ctmp[STRMAX], *cptr1, *cptr2, argvs[STRMAX], **argv,
   120          **aptr;
   121 +
   122 +    *pid = -1;  /* open_persist_pipe ignores return code but checks *pid */
   123 +
   124      /*
   125       * Setup our pipes 
   126       */
   127 Index: agent/mibgroup/host/hrh_filesys.c
   128 diff -Nau agent/mibgroup/host/hrh_filesys.c.orig agent/mibgroup/host/hrh_filesys.c
   129 --- agent/mibgroup/host/hrh_filesys.c.orig	2011-09-28 06:53:47.000000000 +0200
   130 +++ agent/mibgroup/host/hrh_filesys.c	2012-10-04 14:04:40.672808452 +0200
   131 @@ -298,9 +298,9 @@
   132      } else {     
   133          HRFS_entry = netsnmp_fsys_get_first();
   134      }
   135 -    /* Skip "inactive" entries */
   136 -    while ( HRFS_entry && !(HRFS_entry->flags & NETSNMP_FS_FLAG_ACTIVE))
   137 -        HRFS_entry = netsnmp_fsys_get_next( HRFS_entry );
   138 +    /* Skip "inactive" entries - Edit: Avoid ignoring ZFS! */
   139 +    /*while ( HRFS_entry && !(HRFS_entry->flags & NETSNMP_FS_FLAG_ACTIVE))
   140 +        HRFS_entry = netsnmp_fsys_get_next( HRFS_entry );*/
   142      HRFS_index = (HRFS_entry ? HRFS_entry->idx.oids[0] : -1 );
   143      return HRFS_index;
   144 Index: agent/snmpd.c
   145 diff -Nau agent/snmpd.c.orig agent/snmpd.c
   146 --- agent/snmpd.c.orig	2011-07-02 00:35:46.000000000 +0200
   147 +++ agent/snmpd.c	2011-09-15 09:22:41.994430685 +0200
   148 @@ -440,7 +440,7 @@
   149      int             log_set = 0;
   150      int             uid = 0, gid = 0;
   151      int             agent_mode = -1;
   152 -    char           *pid_file = NULL;
   153 +    char           *pid_file = "@l_prefix@/var/snmp/snmpd.pid";
   154      char            option_compatability[] = "-Le";
   155  #if HAVE_GETPID
   156      int fd;
   157 Index: apps/snmptrapd.c
   158 diff -Nau apps/snmptrapd.c.orig apps/snmptrapd.c
   159 --- apps/snmptrapd.c.orig	2011-07-02 00:35:46.000000000 +0200
   160 +++ apps/snmptrapd.c	2011-09-15 09:22:50.270293197 +0200
   161 @@ -653,6 +653,7 @@
   162       */
   163  #if HAVE_GETPID
   164      strcat(options, "p:");
   165 +    parse_config_pidFile(NULL, "@l_prefix@/var/snmp/snmptrapd.pid");
   166  #endif
   168  #ifndef NETSNMP_FEATURE_REMOVE_LOGGING_SYSLOG
   169 Index: include/net-snmp/library/system.h
   170 diff -Nau include/net-snmp/library/system.h.orig include/net-snmp/library/system.h
   171 --- include/net-snmp/library/system.h.orig	2011-07-02 00:35:46.000000000 +0200
   172 +++ include/net-snmp/library/system.h	2011-09-15 09:22:50.271350973 +0200
   173 @@ -155,7 +155,8 @@
   174  #endif
   175  #ifndef HAVE_SETENV
   176      NETSNMP_IMPORT
   177 -    int             setenv(const char *, const char *, int);
   178 +    int             __netsnmp_setenv(const char *, const char *, int);
   179 +#   define          setenv(a,b,c) __netsnmp_setenv(a,b,c)
   180  #endif
   182      NETSNMP_IMPORT
   183 Index: snmplib/system.c
   184 diff -Nau snmplib/system.c.orig snmplib/system.c
   185 --- snmplib/system.c.orig	2011-07-02 00:35:46.000000000 +0200
   186 +++ snmplib/system.c	2011-09-15 09:22:50.274625796 +0200
   187 @@ -1048,7 +1048,7 @@
   189  #ifndef HAVE_SETENV
   190  int
   191 -setenv(const char *name, const char *value, int overwrite)
   192 +__netsnmp_setenv(const char *name, const char *value, int overwrite)
   193  {
   194      char           *cp;
   195      int             ret;
   196 Index: include/net-snmp/system/freebsd8.h
   197 --- include/net-snmp/system/freebsd8.h.orig	2011-09-28 06:53:47.000000000 +0200
   198 +++ include/net-snmp/system/freebsd8.h	2011-12-11 11:33:36.000000000 +0100
   199 @@ -1,3 +1,6 @@
   200 +/* freebsd8 is a superset of freebsd7 */
   201 +#include "freebsd7.h"
   202 +#define freebsd7 freebsd7
   203  /* freebsd8 is a superset of freebsd4 */
   204  #include "freebsd7.h"
   205  #define freebsd7 freebsd7
   206 Index: include/net-snmp/system/freebsd9.h
   207 --- include/net-snmp/system/freebsd9.h.orig	2011-09-28 06:53:47.000000000 +0200
   208 +++ include/net-snmp/system/freebsd9.h	2011-12-11 11:33:36.000000000 +0100
   209 @@ -1,3 +1,6 @@
   210 +/* freebsd9 is a superset of freebsd8 */
   211 +#include "freebsd8.h"
   212 +#define freebsd8 freebsd8
   213  /* freebsd9 is a superset of freebsd4 */
   214  #include "freebsd8.h"
   215  #define freebsd9 freebsd9

mercurial