Print this page
4142 truss should expand connect() arguments


  65 #include <sys/iapriocntl.h>
  66 #include <sys/rtpriocntl.h>
  67 #include <sys/fsspriocntl.h>
  68 #include <sys/fxpriocntl.h>
  69 #include <netdb.h>
  70 #include <nss_dbdefs.h>
  71 #include <sys/socketvar.h>
  72 #include <netinet/in.h>
  73 #include <netinet/tcp.h>
  74 #include <netinet/udp.h>
  75 #include <netinet/sctp.h>
  76 #include <net/route.h>
  77 #include <sys/utrap.h>
  78 #include <sys/lgrp_user.h>
  79 #include <sys/door.h>
  80 #include <sys/tsol/tndb.h>
  81 #include <sys/rctl.h>
  82 #include <sys/rctl_impl.h>
  83 #include <sys/fork.h>
  84 #include <sys/task.h>


  85 #include "ramdata.h"
  86 #include "print.h"
  87 #include "proto.h"
  88 #include "systable.h"
  89 
  90 void grow(private_t *, int nbyte);
  91 
  92 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
  93 
  94 
  95 /*ARGSUSED*/
  96 void
  97 prt_nov(private_t *pri, int raw, long val)      /* print nothing */
  98 {
  99 }
 100 
 101 /*ARGSUSED*/
 102 void
 103 prt_dec(private_t *pri, int raw, long val)      /* print as decimal */
 104 {


1769 
1770 
1771 /*
1772  * Print so_socket() 5th argument.
1773  */
1774 /*ARGSUSED*/
1775 void
1776 prt_skv(private_t *pri, int raw, long val)
1777 {
1778         switch (val) {
1779         case SOV_STREAM:        outstring(pri, "SOV_STREAM");   break;
1780         case SOV_DEFAULT:       outstring(pri, "SOV_DEFAULT");  break;
1781         case SOV_SOCKSTREAM:    outstring(pri, "SOV_SOCKSTREAM");       break;
1782         case SOV_SOCKBSD:       outstring(pri, "SOV_SOCKBSD");  break;
1783         case SOV_XPG4_2:        outstring(pri, "SOV_XPG4_2");   break;
1784         default:                prt_dec(pri, 0, val);           break;
1785         }
1786 }
1787 
1788 /*


























































































1789  * Print accept4() flags argument.
1790  */
1791 void
1792 prt_acf(private_t *pri, int raw, long val)
1793 {
1794         int first = 1;
1795         if (raw || !val ||
1796             (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1797                 prt_dex(pri, 0, val);
1798                 return;
1799         }
1800 
1801         if (val & SOCK_CLOEXEC) {
1802                 outstring(pri, "|SOCK_CLOEXEC" + first);
1803                 first = 0;
1804         }
1805         if (val & SOCK_NDELAY) {
1806                 outstring(pri, "|SOCK_NDELAY" + first);
1807                 first = 0;
1808         }


2798         prt_acl,        /* ACL -- print acl() code */
2799         prt_aio,        /* AIO -- print kaio() code */
2800         prt_aud,        /* AUD -- print auditsys() code */
2801         prt_uns,        /* DEC -- print value in unsigned decimal */
2802         prt_clc,        /* CLC -- print cladm command argument */
2803         prt_clf,        /* CLF -- print cladm flag argument */
2804         prt_cor,        /* COR -- print corectl() subcode */
2805         prt_cco,        /* CCO -- print corectl() options */
2806         prt_ccc,        /* CCC -- print corectl() content */
2807         prt_rcc,        /* RCC -- print corectl() returned content */
2808         prt_cpc,        /* CPC -- print cpc() subcode */
2809         prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2810         prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2811         prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2812         prt_pst,        /* PST -- print processor set id */
2813         prt_mif,        /* MIF -- print meminfo() arguments */
2814         prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2815         prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2816         prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2817         prt_skv,        /* SKV -- print socket version arg */

2818         prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2819         prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2820         prt_utt,        /* UTT -- print utrap type */
2821         prt_uth,        /* UTH -- print utrap handler */
2822         prt_acc,        /* ACC -- print access() flags */
2823         prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2824         prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2825         prt_prs,        /* PRS -- print privilege set */
2826         prt_pro,        /* PRO -- print privilege set operation */
2827         prt_prn,        /* PRN -- print privilege set name */
2828         prt_pfl,        /* PFL -- print privilege/process flag name */
2829         prt_laf,        /* LAF -- print lgrp_affinity arguments */
2830         prt_key,        /* KEY -- print key_t 0 as IPC_PRIVATE */
2831         prt_zga,        /* ZGA -- print zone_getattr attribute types */
2832         prt_atc,        /* ATC -- print AT_FDCWD or file descriptor */
2833         prt_lio,        /* LIO -- print LIO_XX flags */
2834         prt_dfl,        /* DFL -- print door_create() flags */
2835         prt_dpm,        /* DPM -- print DOOR_PARAM_XX flags */
2836         prt_tnd,        /* TND -- print trusted network data base opcode */
2837         prt_rsc,        /* RSC -- print rctlsys() subcodes */


  65 #include <sys/iapriocntl.h>
  66 #include <sys/rtpriocntl.h>
  67 #include <sys/fsspriocntl.h>
  68 #include <sys/fxpriocntl.h>
  69 #include <netdb.h>
  70 #include <nss_dbdefs.h>
  71 #include <sys/socketvar.h>
  72 #include <netinet/in.h>
  73 #include <netinet/tcp.h>
  74 #include <netinet/udp.h>
  75 #include <netinet/sctp.h>
  76 #include <net/route.h>
  77 #include <sys/utrap.h>
  78 #include <sys/lgrp_user.h>
  79 #include <sys/door.h>
  80 #include <sys/tsol/tndb.h>
  81 #include <sys/rctl.h>
  82 #include <sys/rctl_impl.h>
  83 #include <sys/fork.h>
  84 #include <sys/task.h>
  85 #include <sys/socket.h>
  86 #include <arpa/inet.h>
  87 #include "ramdata.h"
  88 #include "print.h"
  89 #include "proto.h"
  90 #include "systable.h"
  91 
  92 void grow(private_t *, int nbyte);
  93 
  94 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
  95 
  96 
  97 /*ARGSUSED*/
  98 void
  99 prt_nov(private_t *pri, int raw, long val)      /* print nothing */
 100 {
 101 }
 102 
 103 /*ARGSUSED*/
 104 void
 105 prt_dec(private_t *pri, int raw, long val)      /* print as decimal */
 106 {


1771 
1772 
1773 /*
1774  * Print so_socket() 5th argument.
1775  */
1776 /*ARGSUSED*/
1777 void
1778 prt_skv(private_t *pri, int raw, long val)
1779 {
1780         switch (val) {
1781         case SOV_STREAM:        outstring(pri, "SOV_STREAM");   break;
1782         case SOV_DEFAULT:       outstring(pri, "SOV_DEFAULT");  break;
1783         case SOV_SOCKSTREAM:    outstring(pri, "SOV_SOCKSTREAM");       break;
1784         case SOV_SOCKBSD:       outstring(pri, "SOV_SOCKBSD");  break;
1785         case SOV_XPG4_2:        outstring(pri, "SOV_XPG4_2");   break;
1786         default:                prt_dec(pri, 0, val);           break;
1787         }
1788 }
1789 
1790 /*
1791  * Print connect() 2nd and 3rd arguments.
1792  */
1793 /*ARGSUSED*/
1794 void
1795 prt_sad(private_t *pri, int raw, long addr, long len)
1796 {
1797         /*
1798          * A buffer large enough for PATH_MAX size AF_UNIX address, which is
1799          * also large enough to store a sockaddr_in or a sockaddr_in6.
1800          */
1801         struct sockaddr_storage buf;
1802 
1803         struct sockaddr *sa = (struct sockaddr *)&buf;
1804         struct sockaddr_in *sin = (struct sockaddr_in *)&buf;
1805         struct sockaddr_un *soun = (struct sockaddr_un *)&buf;
1806         struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&buf;
1807         char addrbuf[INET6_ADDRSTRLEN];
1808         char scope[16] = "";
1809         long rlen = len;
1810 
1811         GROW(20);
1812         if (data_model == PR_MODEL_ILP32) {
1813                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1814                     "0x%.8X", (int)addr);
1815         } else {
1816                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1817                     "0x%.8lX", addr);
1818         }
1819 
1820         if (raw != 0)
1821                 return;
1822 
1823         if (rlen >= sizeof (buf))    /* protect against ridiculous length */
1824                 rlen = sizeof (buf) - 1;
1825         if (Pread(Proc, (void*)&buf, rlen, addr) != rlen)
1826                 return;
1827 
1828         GROW(175);
1829 
1830         switch (sa->sa_family) {
1831         case AF_INET6:
1832                 if (ntohl(sin6->sin6_scope_id) != 0) {
1833                     sprintf(scope, "%%%u", ntohl(sin6->sin6_scope_id));
1834                 }
1835                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1836                     " AF_INET6 to = [%s]%s:%u",
1837                     inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
1838                     sizeof (addrbuf)),
1839                     scope, ntohs(sin6->sin6_port));
1840                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1841                     " source id = 0x%x"
1842                     " flow class = 0x%02x flow label = 0x%05x",
1843                     ntohl(sin6->__sin6_src_id),
1844                     ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
1845                     ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
1846                 break;
1847         case AF_INET:
1848                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1849                     " AF_INET to = %s:%u",
1850                     inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
1851                     sizeof (addrbuf)),
1852                     ntohs(sin->sin_port));
1853                 break;
1854         case AF_UNIX:
1855                 rlen -= sizeof (soun->sun_family);
1856                 if (rlen >= 0) {
1857                         /* Null terminate */
1858                         soun->sun_path[rlen] = NULL;
1859                         pri->sys_leng += sprintf(
1860                             pri->sys_string + pri->sys_leng,
1861                             " AF_UNIX to = %s", soun->sun_path);
1862                 }
1863                 break;
1864         }
1865 
1866         /*
1867          * print the third argument len
1868          */
1869         if (data_model == PR_MODEL_ILP32) {
1870                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1871                     ", %d", (int)len);
1872         } else {
1873                 pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1874                     ", %ld", len);
1875         }
1876 
1877 }
1878 
1879 
1880 /*
1881  * Print accept4() flags argument.
1882  */
1883 void
1884 prt_acf(private_t *pri, int raw, long val)
1885 {
1886         int first = 1;
1887         if (raw || !val ||
1888             (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1889                 prt_dex(pri, 0, val);
1890                 return;
1891         }
1892 
1893         if (val & SOCK_CLOEXEC) {
1894                 outstring(pri, "|SOCK_CLOEXEC" + first);
1895                 first = 0;
1896         }
1897         if (val & SOCK_NDELAY) {
1898                 outstring(pri, "|SOCK_NDELAY" + first);
1899                 first = 0;
1900         }


2890         prt_acl,        /* ACL -- print acl() code */
2891         prt_aio,        /* AIO -- print kaio() code */
2892         prt_aud,        /* AUD -- print auditsys() code */
2893         prt_uns,        /* DEC -- print value in unsigned decimal */
2894         prt_clc,        /* CLC -- print cladm command argument */
2895         prt_clf,        /* CLF -- print cladm flag argument */
2896         prt_cor,        /* COR -- print corectl() subcode */
2897         prt_cco,        /* CCO -- print corectl() options */
2898         prt_ccc,        /* CCC -- print corectl() content */
2899         prt_rcc,        /* RCC -- print corectl() returned content */
2900         prt_cpc,        /* CPC -- print cpc() subcode */
2901         prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2902         prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2903         prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2904         prt_pst,        /* PST -- print processor set id */
2905         prt_mif,        /* MIF -- print meminfo() arguments */
2906         prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2907         prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2908         prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2909         prt_skv,        /* SKV -- print socket version arg */
2910         prt_sad,        /* SAD -- print connect 2nd and 3rd arguments */
2911         prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2912         prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2913         prt_utt,        /* UTT -- print utrap type */
2914         prt_uth,        /* UTH -- print utrap handler */
2915         prt_acc,        /* ACC -- print access() flags */
2916         prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2917         prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2918         prt_prs,        /* PRS -- print privilege set */
2919         prt_pro,        /* PRO -- print privilege set operation */
2920         prt_prn,        /* PRN -- print privilege set name */
2921         prt_pfl,        /* PFL -- print privilege/process flag name */
2922         prt_laf,        /* LAF -- print lgrp_affinity arguments */
2923         prt_key,        /* KEY -- print key_t 0 as IPC_PRIVATE */
2924         prt_zga,        /* ZGA -- print zone_getattr attribute types */
2925         prt_atc,        /* ATC -- print AT_FDCWD or file descriptor */
2926         prt_lio,        /* LIO -- print LIO_XX flags */
2927         prt_dfl,        /* DFL -- print door_create() flags */
2928         prt_dpm,        /* DPM -- print DOOR_PARAM_XX flags */
2929         prt_tnd,        /* TND -- print trusted network data base opcode */
2930         prt_rsc,        /* RSC -- print rctlsys() subcodes */