diff -Naur lsof_4.84_src.orig/Configure lsof_4.84_src/Configure --- lsof_4.84_src.orig/Configure 2010-07-29 17:59:32.000000000 +0200 +++ lsof_4.84_src/Configure 2011-09-03 01:16:26.176810333 +0200 @@ -2740,6 +2740,13 @@ LSOF_CFGF="$LSOF_CFGF -DHASIPv6" fi # } + # Test for rpc/rpc.h + + if ! test -r ${LSOF_INCLUDE}/rpc/rpc.h # { + then + LSOF_CFGF="$LSOF_CFGF -DHASNOTRPC" + fi # } + # Test for SELinux support. LSOF_TMP1=0 diff -Naur lsof_4.84_src.orig/dialects/linux/dlsof.h lsof_4.84_src/dialects/linux/dlsof.h --- lsof_4.84_src.orig/dialects/linux/dlsof.h 2010-01-18 20:03:19.000000000 +0100 +++ lsof_4.84_src/dialects/linux/dlsof.h 2011-09-03 01:16:39.810639887 +0200 @@ -56,8 +56,10 @@ #include # endif /* defined(GLIBCV) || defined(__UCLIBC__) */ +# if !defined(HASNOTRPC) #include #include +# endif /* !defined(HASNOTRPC) */ #if defined(HASSELINUX) #include diff -Naur lsof_4.84_src.orig/lsof.h lsof_4.84_src/lsof.h --- lsof_4.84_src.orig/lsof.h 2010-07-29 17:59:37.000000000 +0200 +++ lsof_4.84_src/lsof.h 2011-09-03 01:31:53.746214120 +0200 @@ -609,7 +609,9 @@ extern int Foffset; extern int Fovhd; extern int Fport; +#if !defined(HASNOTRPC) extern int FportMap; +#endif /* !defined(HASNOTRPC) */ extern int Fpgid; extern int Fppid; extern int Fsize; diff -Naur lsof_4.84_src.orig/main.c lsof_4.84_src/main.c --- lsof_4.84_src.orig/main.c 2010-07-29 17:59:40.000000000 +0200 +++ lsof_4.84_src/main.c 2011-09-03 01:29:56.887675052 +0200 @@ -154,7 +154,7 @@ * Create option mask. */ (void) snpf(options, sizeof(options), - "?a%sbc:D:d:%sf:F:g:hi:%s%slL:%sMnNo:Op:Pr:%ss:S:tT:u:UvVwx:%s%s%s", + "?a%sbc:D:d:%sf:F:g:hi:%s%slL:%s%snNo:Op:Pr:%ss:S:tT:u:UvVwx:%s%s%s", #if defined(HAS_AFS) && defined(HASAOPT) "A:", @@ -186,6 +186,12 @@ "", #endif /* defined(HASMOPT) || defined(HASMNTSUP) */ +#if !defined(HASNOTRPC) + "M", +#else /* defined(HASNOTRPC) */ + "", +#endif /* defined(HASNOTRPC) */ + #if defined(HASPPID) "R", #else /* !defined(HASPPID) */ @@ -643,9 +649,11 @@ break; #endif /* defined(HASMOPT) || defined(HASMNTSUP) */ +#if !defined(HASNOTRPC) case 'M': FportMap = (GOp == '+') ? 1 : 0; break; +#endif /* !defined(HASNOTRPC) */ case 'n': Fhost = (GOp == '-') ? 0 : 1; break; diff -Naur lsof_4.84_src.orig/print.c lsof_4.84_src/print.c --- lsof_4.84_src.orig/print.c 2010-07-29 17:59:42.000000000 +0200 +++ lsof_4.84_src/print.c 2011-09-03 01:36:30.355756023 +0200 @@ -67,8 +67,11 @@ struct porttab *next; }; - +#if defined(HASNOTRPC) +static struct porttab **Pth[2] = { NULL, NULL }; +#else /* !defined(HASNOTRPC) */ static struct porttab **Pth[4] = { NULL, NULL, NULL, NULL }; +#endif /* !defined(HASNOTRPC) */ /* port hash buckets: * Pth[0] for TCP service names * Pth[1] for UDP service names @@ -78,12 +81,14 @@ #define HASHPORT(p) (((((int)(p)) * 31415) >> 3) & (PORTHASHBUCKETS - 1)) +#if !defined(HASNOTRPC) _PROTOTYPE(static void fill_portmap,(void)); +_PROTOTYPE(static void update_portmap,(struct porttab *pt, char *pn)); +#endif /* !defined(HASNOTRPC) */ _PROTOTYPE(static void fill_porttab,(void)); _PROTOTYPE(static char *lkup_port,(int p, int pr, int src)); _PROTOTYPE(static char *lkup_svcnam,(int h, int p, int pr, int ss)); _PROTOTYPE(static int printinaddr,(void)); -_PROTOTYPE(static void update_portmap,(struct porttab *pt, char *pn)); /* @@ -104,6 +109,7 @@ } +#if !defined(HASNOTRPC) /* * fill_portmap() -- fill the RPC portmap program name table via a conversation * with the portmapper @@ -267,6 +273,7 @@ } clnt_destroy(c); } +#endif /* !defined(HASNOTRPC) */ /* @@ -468,8 +475,12 @@ * If the hash buckets haven't been allocated, do so. */ if (!Pth[0]) { +#if defined(HASNOTRPC) + for (h = 0; h < 2; h++) { +#else /* !defined(HASNOTRPC) */ nh = FportMap ? 4 : 2; for (h = 0; h < nh; h++) { +#endif /* !defined(HASNOTRPC) */ if (!(Pth[h] = (struct porttab **)calloc(PORTHASHBUCKETS, sizeof(struct porttab *)))) { @@ -483,6 +494,7 @@ } } } +#if !defined(HASNOTRPC) /* * If we're looking up program names for portmapped ports, make sure the * portmap table has been loaded. @@ -491,11 +503,13 @@ (void) fill_portmap(); pm++; } +#endif /* !defined(HASNOTRPC) */ /* * Hash the port and see if its name has been cached. Look for a local * port first in the portmap, if portmap searching is enabled. */ h = HASHPORT(p); +#if !defined(HASNOTRPC) if (!src && FportMap) { for (pt = Pth[pr+2][h]; pt; pt = pt->next) { if (pt->port != p) @@ -511,6 +525,7 @@ return(pt->name); } } +#endif /* !defined(HASNOTRPC) */ for (pt = Pth[pr][h]; pt; pt = pt->next) { if (pt->port == p) return(pt->name); @@ -1154,7 +1169,11 @@ * Process the port number. */ if (Lf->li[i].p > 0) { - if (Fport || FportMap) { + if (Fport +#if !defined(HASNOTRPC) + || FportMap +#endif /* !defined(HASNOTRPC) */ + ) { /* * If converting port numbers to service names, or looking @@ -1167,9 +1186,10 @@ * loopback address 127.0.0.1. (Test 2 may not always work * -- e.g., on hosts with multiple interfaces.) */ +#if !defined(HASNOTRPC) if ((src = i) && FportMap) { -#if defined(HASIPv6) +# if defined(HASIPv6) if (Lf->li[0].af == AF_INET6) { if (IN6_IS_ADDR_LOOPBACK(&Lf->li[i].ia.a6) || IN6_ARE_ADDR_EQUAL(&Lf->li[0].ia.a6, @@ -1177,7 +1197,7 @@ ) src = 0; } else -#endif /* defined(HASIPv6) */ +# endif /* defined(HASIPv6) */ if (Lf->li[0].af == AF_INET) { if (Lf->li[i].ia.a4.s_addr == htonl(INADDR_LOOPBACK) @@ -1186,6 +1206,7 @@ src = 0; } } +#endif /* !defined(HASNOTRPC) */ if (strcasecmp(Lf->iproto, "TCP") == 0) port = lkup_port(Lf->li[i].p, 0, src); else if (strcasecmp(Lf->iproto, "UDP") == 0) @@ -2748,6 +2769,7 @@ } +#if !defined(HASNOTRPC) /* * update_portmap() - update a portmap entry with its port number or service * name @@ -2780,3 +2802,4 @@ pt->nl = nl; pt->ss = 1; } +#endif /* !defined(HASNOTRPC) */ diff -Naur lsof_4.84_src.orig/store.c lsof_4.84_src/store.c --- lsof_4.84_src.orig/store.c 2010-07-29 17:59:44.000000000 +0200 +++ lsof_4.84_src/store.c 2011-09-03 01:31:19.746639172 +0200 @@ -156,11 +156,13 @@ int Fovhd = 0; /* -O option status */ int Fport = 1; /* -P option status */ -#if defined(HASPMAPENABLED) +#if !defined(HASNOTRPC) +# if defined(HASPMAPENABLED) int FportMap = 1; /* +|-M option status */ -#else /* !defined(HASPMAPENABLED) */ +# else /* !defined(HASPMAPENABLED) */ int FportMap = 0; /* +|-M option status */ -#endif /* defined(HASPMAPENABLED) */ +# endif /* defined(HASPMAPENABLED) */ +#endif /* !defined(HASNOTRPC) */ int Fpgid = 0; /* -g option status */ int Fppid = 0; /* -R option status */ diff -Naur lsof_4.84_src.orig/usage.c lsof_4.84_src/usage.c --- lsof_4.84_src.orig/usage.c 2010-07-29 17:59:45.000000000 +0200 +++ lsof_4.84_src/usage.c 2011-09-03 01:42:41.110120956 +0200 @@ -453,8 +453,12 @@ ); #endif /* defined(HASMOPT) || defined(HASMNTSUP) */ +#if !defined(HASNOTRPC) + (void) fprintf(stderr, " [+|-M]"); +#endif /* !defined(HASNOTRPC) */ + (void) fprintf(stderr, - " [+|-M] [-o [o]] [-p s]\n[+|-r [t]]%s [-S [t]] [-T [t]]", + " [-o [o]] [-p s]\n[+|-r [t]]%s [-S [t]] [-T [t]]", #if defined(HASTCPUDPSTATE) " [-s [p:s]]" @@ -690,16 +694,19 @@ # endif /* defined(HASMNTSUP) */ #endif /* defined(HASMOPT) || defined(HASMNTSUP) */ +#if !defined(HASNOTRPC) (void) snpf(buf, sizeof(buf), "+|-M portMap registration (%s)", - -#if defined(HASPMAPENABLED) +# if defined(HASPMAPENABLED) "+" -#else /* !defined(HASPMAPENABLED) */ +# else /* !defined(HASPMAPENABLED) */ "-" -#endif /* defined(HASPMAPENABLED) */ - +# endif /* defined(HASPMAPENABLED) */ ); +#else /* defined(HASNOTRPC) */ + buf[0] = '\0'; +#endif /* defined(HASNOTRPC) */ (void) fprintf(stderr, " %-36.36s", buf); + (void) snpf(buf, sizeof(buf), "-o o o 0t offset digits (%d)", OFFDECDIG); (void) fprintf(stderr, " %s\n", buf);