SUMMARY: pidentd 3.0.19 On Solaris 10

From: Cooper, Scott <scooper_at_hp.com>
Date: Thu Dec 10 2009 - 04:52:58 EST
Hi all,

Many thanks to those who responded especially Jussi Sallinen who provided me
with a patched version of pidentd with code changes from Casper Dik that has
been used in a zones environment. This also works in my non zoned
environment.

So another hurdle jumped onto the next. Fortunately Jussi had done this bit as
I would have taken ages to sort it out.

==========================

*** ./configure.org     Tue Oct 18 11:25:24 2005
--- ./configure Tue Oct 23 11:59:46 2007
***************
*** 2464,2470 ****
        *-solaris2.6)
                host_os=sunos56
                ;;
!       *-solaris2.7|*-solaris2.8|*-solaris2.9|*-solaris2.10)
                case "$host" in
                        *7) host_os=sunos57
                            ;;
--- 2464,2470 ----
        *-solaris2.6)
                host_os=sunos56
                ;;
!       *-solaris2.7|*-solaris2.8|*-solaris2.9|*-solaris2.10*|*-solaris2.11)
                case "$host" in
                        *7) host_os=sunos57
                            ;;
***************
*** 2472,2480 ****
                            host_os=sunos58
                            CPPFLAGS="$CPPFLAGS -DHAVE_IPV6=1"
                            ;;
!                       *10)
                            host_os=sunos510
                            CPPFLAGS="$CPPFLAGS -DHAVE_IPV6=1"
                            ;;
                esac
                ISA="`isainfo -k`"
--- 2472,2484 ----
                            host_os=sunos58
                            CPPFLAGS="$CPPFLAGS -DHAVE_IPV6=1"
                            ;;
!                       *10|*10.1|*11)
                            host_os=sunos510
                            CPPFLAGS="$CPPFLAGS -DHAVE_IPV6=1"
+                           if [ -f /usr/include/inet/ip_stack.h ]
+                           then
+                               CPPFLAGS="$CPPFLAGS -DHAVE_IPINSTANCES=1"
+                           fi
                            ;;
                esac
                ISA="`isainfo -k`"
*** ./src/server.c.org  Fri Mar 22 22:42:33 2002
--- ./src/server.c      Tue Jun 30 14:12:12 2009
***************
*** 63,70 ****
  {
      static int one = 1;
      int nofile;
!     struct sockaddr_in sin;


      /*
      ** Increase the number of available file descriptors
--- 63,73 ----
  {
      static int one = 1;
      int nofile;
!     struct sockaddr_gen sin;

+ #ifdef HAVE_IPV6
+     SGFAM(sin) = AF_INET6;
+ #endif

      /*
      ** Increase the number of available file descriptors
***************
*** 77,83 ****

      if (listen_sock < 0)
      {
!       listen_sock = socket(AF_INET, SOCK_STREAM, 0);
        if (listen_sock < 0)
        {
            syslog(LOG_ERR, "socket(AF_INET, SOCK_STREAM) failed: %m");
--- 80,86 ----

      if (listen_sock < 0)
      {
!       listen_sock = socket(SGFAM(sin), SOCK_STREAM, 0);
        if (listen_sock < 0)
        {
            syslog(LOG_ERR, "socket(AF_INET, SOCK_STREAM) failed: %m");
***************
*** 87,98 ****
        (void) setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
                   (void *) &one, sizeof(one));

        memset(&sin, 0, sizeof(sin));
!       sin.sin_family = AF_INET;
        sin.sin_addr.s_addr = htonl(listen_addr);
        sin.sin_port = htons(listen_port);

!       if (bind(listen_sock, (struct sockaddr *) &sin, sizeof(sin)) < 0)
        {
            syslog(LOG_ERR, "bind(port=%d) failed: %m",
                   listen_port);
--- 90,111 ----
        (void) setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
                   (void *) &one, sizeof(one));

+ #ifdef SO_ALLZONES
+       (void) setsockopt(listen_sock, SOL_SOCKET, SO_ALLZONES,
+                  (void *) &one, sizeof(one));
+ #endif
+
        memset(&sin, 0, sizeof(sin));
! #ifdef HAVE_IPV6
!       SGFAM(sin) = AF_INET6;
!       SGPORT(sin) = htons(listen_port);
! #else
!       SGFAM(sin) = AF_INET;
        sin.sin_addr.s_addr = htonl(listen_addr);
        sin.sin_port = htons(listen_port);
+ #endif

!       if (bind(listen_sock, (struct sockaddr *) &sin, SGSOCKSIZE(sin)) < 0)
        {
            syslog(LOG_ERR, "bind(port=%d) failed: %m",
                   listen_port);
*** ./src/pdes.c.org    Sun May 21 21:07:05 2000
--- ./src/pdes.c        Tue Jun 30 14:22:30 2009
***************
*** 127,136 ****
      time(&bt);
      r.fields.date = htonl(bt);

!     r.fields.ip_local    = kp->local.sin_addr.s_addr;
!     r.fields.ip_remote   = kp->remote.sin_addr.s_addr;
!     r.fields.port_local  = kp->local.sin_port;
!     r.fields.port_remote = kp->remote.sin_port;

      r.fields.checksum = 0;
      for (i = 1; i < 6; i++)
--- 127,136 ----
      time(&bt);
      r.fields.date = htonl(bt);

!     r.fields.ip_local    = SGADDRP(kp->local);
!     r.fields.ip_remote   = SGADDRP(kp->remote);
!     r.fields.port_local  = SGPORT(kp->local);
!     r.fields.port_remote = SGPORT(kp->remote);

      r.fields.checksum = 0;
      for (i = 1; i < 6; i++)
*** ./src/k_sunos510.c.org      Tue Oct 18 11:22:04 2005
--- ./src/k_sunos510.c  Tue Jun 30 14:14:39 2009
***************
*** 1,7 ****
  /*
  ** k_sunos510.c - SunOS 5.10 kernel access functions
  **
! ** Copyright (c) 1995-2003 Casper Dik <Casper.Dik@Holland.Sun.COM>
  ** Copyright (c) 1997      Peter Eriksson <pen@lysator.liu.se>
  **
  ** This program is free software; you can redistribute it and/or
--- 1,7 ----
  /*
  ** k_sunos510.c - SunOS 5.10 kernel access functions
  **
! ** Copyright (c) 1995-2009 Casper Dik <Casper.Dik@Sun.COM>
  ** Copyright (c) 1997      Peter Eriksson <pen@lysator.liu.se>
  **
  ** This program is free software; you can redistribute it and/or
***************
*** 41,46 ****
--- 41,52 ----
  #define mutex_destroy kernel_mutex_destroy
  #define sema_init     kernel_sema_init
  #define sema_destroy  kernel_sema_destroy
+ #define printf                kernel_printf
+ #define vprintf               kernel_vprintf
+ #define sprintf               kernel_sprintf
+ #define snprintf      kernel_snprintf
+ #define vsprintf      kernel_vsprintf
+ #define vsnprintf     kernel_vsnprintf

  #include <syslog.h>

***************
*** 64,69 ****
--- 70,91 ----
  #include <netinet/ip6.h>
  #include <net/if.h>

+ #if HAVE_IPINSTANCES
+ #include <sys/zone.h>
+
+ /*
+  * IP instances make things much more complicated; there are no
+  * multiple IP stacks but still only one identd; we really ought to
+  * have some in-kernel implementation which tells us about the process
+  * at our end of a TCP/IP connection, but that may turn out to be
+  * problematic.
+  * For now, we limit ourselves to one IP stack, the initial one found.
+  * The number of configured IP stacks can vary dynamically and we would
need
+  * to rescan the stacks each and every time we resolve a query.
+  */
+
+ #endif
+
  uint_t   ipcl_conn_fanout_size;

  #if   !defined(IN6_V4_MAPPED_TO_INADDR)
***************
*** 154,161 ****
  ka_open(void **misc)
  {
      struct kainfo *kp;

-
      kp = s_malloc(sizeof(*kp));

      /*
--- 176,185 ----
  ka_open(void **misc)
  {
      struct kainfo *kp;
+ #if HAVE_IPINSTANCES
+     uintptr_t kptr;
+ #endif

      kp = s_malloc(sizeof(*kp));

      /*
***************
*** 169,177 ****
--- 193,206 ----
      }


+ #if HAVE_IPINSTANCES
+     kp->nl[0].n_name = "zone0";
+     kp->nl[1].n_name = NULL;
+ #else
      kp->nl[0].n_name = "ipcl_conn_fanout";
      kp->nl[1].n_name = "ipcl_conn_fanout_size";
      kp->nl[2].n_name = NULL;
+ #endif

      /*
      ** Extract offsets to the needed variables in the kernel
***************
*** 184,190 ****
--- 213,242 ----
        return -1;
      }

+ #if HAVE_IPINSTANCES
      /*
+      * Find zone0->zone_netstack->netstack_u.nu_s.ip_stack pointer
+      * and read hash_table and hash_size variables.
+      */
+     if (!getbuf(kp->kd, kp->nl[0].n_value + offsetof(zone_t,
zone_netstack),
+       (char *) &kptr, sizeof(kptr), kp->nl[0].n_name)) {
+ err:
+           kvm_close(kp->kd);
+           s_free(kp);
+           syslog(LOG_ERR, "getbuf: can't get needed symbols");
+           return -1;
+     }
+     if (!getbuf(kp->kd, kptr + offsetof(netstack_t, netstack_u.nu_s.nu_ip),
+       (char *) &kptr, sizeof(kptr), "netstack_t"))
+           goto err;
+     if (!getbuf(kp->kd, kptr + offsetof(ip_stack_t, ips_ipcl_conn_fanout),
+       (char *) &kp->hash_table, sizeof(kp->hash_table),
"ipcl_conn_fanout"))
+           goto err;
+     if (!getbuf(kp->kd, kptr + offsetof(ip_stack_t,
ips_ipcl_conn_fanout_size),
+       (char *) &kp->hash_size, sizeof(kp->hash_size),
"ipcl_conn_fanout_size"))
+           goto err;
+ #else
+     /*
       * Read the two kernel values we need but won't change
       */
      if (!getbuf(kp->kd, kp->nl[N_HASH_SIZE].n_value, (char *)
&kp->hash_size,
***************
*** 196,201 ****
--- 248,254 ----
            syslog(LOG_ERR, "getbuf: can't get needed symbols");
            return -1;
      }
+ #endif

      *misc = (void *) kp;
      return 0;

=============================
Regards
Scott


=========================
Scott Cooper
ITO IE Technical Consultant
Defence & Security
HP Enterprise Services
email: scooper@hp.com
EDS Defence Ltd,
Registered Office: Cain Road, Bracknell, Berkshire, RG12 1HN.
Registered in England No: 936751
This email contains information which is confidential and may be privileged.
Unless you are the intended addressee (or authorised to receive for the
addressee) you may not use, forward, copy or disclose to anyone this email or
any information contained in this email. If you have received this email in
error, please advise the sender by reply email immediately and delete this
email.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Thu Dec 10 04:52:05 2009

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:15 EST