Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/rpcbind - Enable WARMSTART



details:   https://anonhg.NetBSD.org/src/rev/9aabd9378307
branches:  trunk
changeset: 953347:9aabd9378307
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 07 00:23:06 2021 +0000

description:
- Enable WARMSTART
- Pass fd to libwrap
- Add blocklist
>From Greg A. Woods

- Tidy up debugging

diffstat:

 usr.sbin/rpcbind/Makefile       |    9 +-
 usr.sbin/rpcbind/pmap_svc.c     |   12 +-
 usr.sbin/rpcbind/rpcb_svc_com.c |  136 +++++++++++++++++++--------------------
 usr.sbin/rpcbind/rpcbind.c      |    8 +-
 usr.sbin/rpcbind/security.c     |    4 +-
 5 files changed, 83 insertions(+), 86 deletions(-)

diffs (truncated from 476 to 300 lines):

diff -r 01b6f62e1658 -r 9aabd9378307 usr.sbin/rpcbind/Makefile
--- a/usr.sbin/rpcbind/Makefile Sat Mar 06 23:09:17 2021 +0000
+++ b/usr.sbin/rpcbind/Makefile Sun Mar 07 00:23:06 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.16 2019/10/13 07:28:20 mrg Exp $
+#      $NetBSD: Makefile,v 1.17 2021/03/07 00:23:06 christos Exp $
 
 .include <bsd.own.mk>
 
@@ -12,7 +12,7 @@
 LIBCDIR=        ${NETBSDSRCDIR}/lib/libc
 LIBCRPCDIR=     ${LIBCDIR}/rpc
 
-CPPFLAGS+=     -I${LIBCRPCDIR} -DPORTMAP -DLIBWRAP
+CPPFLAGS+=     -I${LIBCRPCDIR} -DPORTMAP -DLIBWRAP -DWARMSTART
 
 .if (${USE_INET6} != "no")
 CPPFLAGS+=     -DINET6
@@ -24,10 +24,11 @@
 
 # Uncomment these to get any useful output from 'rpcbind -d'
 # CPPFLAGS+=   -DRPCBIND_DEBUG
+# CPPFLAGS+=   -DDEBUG_RMTCALL
 # CPPFLAGS+=   -DSVC_RUN_DEBUG
 
-LDADD+= -lwrap -lutil
-DPADD+= ${LIBWRAP} ${LIBUTIL}
+LDADD+= -lwrap -lblocklist -lutil
+DPADD+= ${LIBWRAP} ${LIBBLOCKLIST} ${LIBUTIL}
 
 COPTS.rpcb_svc_4.c+=   ${GCC_NO_CAST_FUNCTION_TYPE}
 COPTS.pmap_svc.c+=     ${GCC_NO_CAST_FUNCTION_TYPE}
diff -r 01b6f62e1658 -r 9aabd9378307 usr.sbin/rpcbind/pmap_svc.c
--- a/usr.sbin/rpcbind/pmap_svc.c       Sat Mar 06 23:09:17 2021 +0000
+++ b/usr.sbin/rpcbind/pmap_svc.c       Sun Mar 07 00:23:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_svc.c,v 1.9 2017/08/16 08:44:40 christos Exp $    */
+/*     $NetBSD: pmap_svc.c,v 1.10 2021/03/07 00:23:06 christos Exp $   */
 /*     $FreeBSD: head/usr.sbin/rpcbind/pmap_svc.c 258564 2013-11-25 16:44:02Z hrs $ */
 
 /*-
@@ -173,6 +173,11 @@
        struct sockcred *sc;
        char uidbuf[32];
 
+       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
+               svcerr_decode(xprt);
+               return (FALSE);
+       }
+
 #ifdef RPCBIND_DEBUG
        if (debugging)
                fprintf(stderr, "%s request for (%lu, %lu) : ",
@@ -180,11 +185,6 @@
                    reg.pm_prog, reg.pm_vers);
 #endif
 
-       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
-               svcerr_decode(xprt);
-               return (FALSE);
-       }
-
        if (!check_access(xprt, op, &reg, PMAPVERS)) {
                svcerr_weakauth(xprt);
                return FALSE;
diff -r 01b6f62e1658 -r 9aabd9378307 usr.sbin/rpcbind/rpcb_svc_com.c
--- a/usr.sbin/rpcbind/rpcb_svc_com.c   Sat Mar 06 23:09:17 2021 +0000
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c   Sun Mar 07 00:23:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcb_svc_com.c,v 1.23 2020/06/17 00:16:22 kamil Exp $  */
+/*     $NetBSD: rpcb_svc_com.c,v 1.24 2021/03/07 00:23:06 christos Exp $       */
 /*     $FreeBSD: head/usr.sbin/rpcbind/rpcb_svc_com.c 301770 2016-06-09 22:25:00Z pfg $ */
 
 /*-
@@ -140,9 +140,9 @@
 
 #ifdef RPCBIND_DEBUG
        if (debugging)
-               fprintf(stderr, "RPCB_SET request for (%lu, %lu, %s, %s) : ",
-                   (unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
-                   regp->r_netid, regp->r_addr);
+               fprintf(stderr, "%s: RPCB_SET request for (%lu, %lu, %s, %s): ",
+                   __func__, (unsigned long)regp->r_prog,
+                   (unsigned long)regp->r_vers, regp->r_netid, regp->r_addr);
 #endif
        ans = map_set(regp, getowner(transp, owner, sizeof owner));
 #ifdef RPCBIND_DEBUG
@@ -228,9 +228,9 @@
 
 #ifdef RPCBIND_DEBUG
        if (debugging)
-               fprintf(stderr, "RPCB_UNSET request for (%lu, %lu, %s) : ",
-                   (unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
-                   regp->r_netid);
+               fprintf(stderr, "%s: RPCB_UNSET request for (%lu, %lu, %s): ",
+                   __func__, (unsigned long)regp->r_prog,
+                   (unsigned long)regp->r_vers, regp->r_netid);
 #endif
        ans = map_unset(regp, getowner(transp, owner, sizeof owner));
 #ifdef RPCBIND_DEBUG
@@ -350,7 +350,7 @@
        }
 #ifdef RPCBIND_DEBUG
        if (debugging)
-               fprintf(stderr, "getaddr: %s\n", uaddr);
+               fprintf(stderr, "%s: %s\n", __func__, uaddr);
 #endif
        /* XXX: should have used some defined constant here */
        rpcbs_getaddr(rpcbversnum - 2, regp->r_prog, regp->r_vers,
@@ -508,9 +508,8 @@
 
        if ((fd = __rpc_nconf2fd(nconf)) == -1) {
                if (debugging)
-                       fprintf(stderr,
-       "create_rmtcall_fd: couldn't open \"%s\" (errno %d)\n",
-                       nconf->nc_device, errno);
+                       fprintf(stderr, "%s: couldn't open \"%s\" (%s)\n",
+                           __func__, nconf->nc_device, strerror(errno));
                return (-1);
        }
        xprt = svc_tli_create(fd, 0, NULL, 0, 0);
@@ -655,8 +654,7 @@
 #endif /* notyet */
                if (buf_alloc == NULL) {
                        if (debugging)
-                               fprintf(stderr,
-                                       "rpcbproc_callit_com:  No Memory!\n");
+                               fprintf(stderr, "%s: No Memory!\n", __func__);
                        if (reply_type == RPCBPROC_INDIRECT)
                                svcerr_systemerr(transp);
                        return;
@@ -671,8 +669,7 @@
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_decode(transp);
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  svc_getargs failed\n");
+                       fprintf(stderr, "%s: svc_getargs failed\n", __func__);
                goto error;
        }
 
@@ -685,15 +682,16 @@
 #ifdef RPCBIND_DEBUG
        if (debugging) {
                uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), caller);
-               fprintf(stderr, "%s %s req for (%lu, %lu, %lu, %s) from %s : ",
-                       versnum == PMAPVERS ? "pmap_rmtcall" :
-                       versnum == RPCBVERS ? "rpcb_rmtcall" :
-                       versnum == RPCBVERS4 ? "rpcb_indirect" :
-                       rpcbind_unknown,
-                       reply_type == RPCBPROC_INDIRECT ? "indirect" : "callit",
-                       (unsigned long)a.rmt_prog, (unsigned long)a.rmt_vers,
-                       (unsigned long)a.rmt_proc, transp->xp_netid,
-                       uaddr ? uaddr : rpcbind_unknown);
+               fprintf(stderr,
+                   "%s: %s %s req for (%lu, %lu, %lu, %s) from %s: ",
+                   __func__, versnum == PMAPVERS ? "pmap_rmtcall" :
+                   versnum == RPCBVERS ? "rpcb_rmtcall" :
+                   versnum == RPCBVERS4 ? "rpcb_indirect" :
+                   rpcbind_unknown,
+                   reply_type == RPCBPROC_INDIRECT ? "indirect" : "callit",
+                   (unsigned long)a.rmt_prog, (unsigned long)a.rmt_vers,
+                   (unsigned long)a.rmt_proc, transp->xp_netid,
+                   uaddr ? uaddr : rpcbind_unknown);
                if (uaddr)
                        free(uaddr);
        }
@@ -749,15 +747,14 @@
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_systemerr(transp);
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  rpcbind_get_conf failed\n");
+                       fprintf(stderr, "%s: rpcbind_get_conf failed\n",
+                           __func__);
                goto error;
        }
        localsa = local_sa(((struct sockaddr *)caller->buf)->sa_family);
        if (localsa == NULL) {
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com: no local address\n");
+                       fprintf(stderr, "%s: no local address\n", __func__);
                goto error;
        }
        tbuf.len = tbuf.maxlen = localsa->sa_len;
@@ -768,7 +765,7 @@
                        nconf->nc_netid);
 #ifdef RPCBIND_DEBUG
        if (debugging)
-               fprintf(stderr, "merged uaddr %s\n", m_uaddr);
+               fprintf(stderr, "%s: merged uaddr %s\n", __func__, m_uaddr);
 #endif
        if ((fd = find_rmtcallfd_by_netid(nconf->nc_netid)) == -1) {
                if (reply_type == RPCBPROC_INDIRECT)
@@ -788,22 +785,20 @@
                 * beat on it any more.
                 */
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  duplicate request\n");
+                       fprintf(stderr, "%s: duplicate request\n", __func__);
                goto error;
        case -1:
                /*  forward_register failed.  Perhaps no memory. */
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  forward_register failed\n");
+                       fprintf(stderr, "%s: forward_register failed\n",
+                           __func__);
                goto error;
        }
 
 #ifdef DEBUG_RMTCALL
        if (debugging)
-               fprintf(stderr,
-                       "rpcbproc_callit_com:  original XID %x, new XID %x\n",
-                               *xidp, call_msg.rm_xid);
+               fprintf(stderr, "%s: original XID %x, new XID %x\n", __func__,
+                   *xidp, call_msg.rm_xid);
 #endif
        call_msg.rm_direction = CALL;
        call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
@@ -829,16 +824,14 @@
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_systemerr(transp);
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  xdr_callhdr failed\n");
+                       fprintf(stderr, "%s: xdr_callhdr failed\n", __func__);
                goto error;
        }
        if (!xdr_u_int32_t(&outxdr, &(a.rmt_proc))) {
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_systemerr(transp);
                if (debugging)
-                       fprintf(stderr,
-                       "rpcbproc_callit_com:  xdr_u_long failed\n");
+                       fprintf(stderr, "%s: xdr_u_long failed\n", __func__);
                goto error;
        }
 
@@ -856,8 +849,8 @@
        } else {
                /* we do not support any other authentication scheme */
                if (debugging)
-                       fprintf(stderr,
-"rpcbproc_callit_com:  oa_flavor != AUTH_NONE and oa_flavor != AUTH_SYS\n");
+                       fprintf(stderr, "%s: oa_flavor != AUTH_NONE and"
+                           " oa_flavor != AUTH_SYS\n", __func__);
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_weakauth(transp); /* XXX too strong.. */
                goto error;
@@ -867,7 +860,8 @@
                        svcerr_systemerr(transp);
                if (debugging)
                        fprintf(stderr,
-               "rpcbproc_callit_com:  authwhatever_create returned NULL\n");
+                           "%s: authwhatever_create returned NULL\n",
+                           __func__);
                goto error;
        }
        if (!AUTH_MARSHALL(auth, &outxdr)) {
@@ -876,7 +870,7 @@
                AUTH_DESTROY(auth);
                if (debugging)
                        fprintf(stderr,
-               "rpcbproc_callit_com:  AUTH_MARSHALL failed\n");
+                           "%s: AUTH_MARSHALL failed\n", __func__);
                goto error;
        }
        AUTH_DESTROY(auth);
@@ -884,8 +878,8 @@
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_systemerr(transp);
                if (debugging)
-                       fprintf(stderr,
-               "rpcbproc_callit_com:  xdr_opaque_parms failed\n");
+                       fprintf(stderr, "%s: xdr_opaque_parms failed\n",
+                           __func__);
                goto error;
        }
        outlen = (int) XDR_GETPOS(&outxdr);
@@ -904,8 +898,8 @@
        if (sendto(fd, outbufp, outlen, 0, (struct sockaddr *)na->buf, na->len)
            != outlen) {
                if (debugging)
-                       fprintf(stderr,
-       "rpcbproc_callit_com:  sendto failed:  errno %d\n", errno);
+                       fprintf(stderr, "%s: sendto failed (%s)\n", __func__,
+                           strerror(errno));
                if (reply_type == RPCBPROC_INDIRECT)
                        svcerr_systemerr(transp);
                goto error;
@@ -1116,7 +1110,7 @@
        int poll_ret, check_ret;
        int n, *m;
 #ifdef SVC_RUN_DEBUG
-       int i;
+       size_t i;



Home | Main Index | Thread Index | Old Index