summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-29 11:31:09 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-29 11:31:09 +0000
commit82f44aed5ba3b5b4b55aec1b94427285cfd370cb (patch)
tree34d826c4dee0d7c0545eaff7391a987580e22917 /usr.sbin
parent97dea373f640f6bdac510c898a85823405436c49 (diff)
check callit() stuff like portmap5 does (ugh)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/portmap/portmap.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.sbin/portmap/portmap.c b/usr.sbin/portmap/portmap.c
index 92a88b5d669..6de6878da17 100644
--- a/usr.sbin/portmap/portmap.c
+++ b/usr.sbin/portmap/portmap.c
@@ -40,7 +40,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)portmap.c 5.4 (Berkeley) 4/19/91";*/
-static char rcsid[] = "$Id: portmap.c,v 1.8 1996/07/29 09:29:14 deraadt Exp $";
+static char rcsid[] = "$Id: portmap.c,v 1.9 1996/07/29 11:31:08 deraadt Exp $";
#endif /* not lint */
/*
@@ -575,6 +575,9 @@ callit(rqstp, xprt)
a.rmt_args.args = buf;
if (!svc_getargs(xprt, xdr_rmtcall_args, (caddr_t)&a))
return;
+ if (!check_callit(svc_getcaller(xprt), rqstp->rq_proc,
+ a.rmt_prog, a.rmt_proc))
+ return;
if ((pml = find_service(a.rmt_prog, a.rmt_vers,
(u_long)IPPROTO_UDP)) == NULL)
return;
@@ -625,3 +628,30 @@ reap()
;
errno = save_errno;
}
+
+#define NFSPROG ((u_long) 100003)
+#define MOUNTPROG ((u_long) 100005)
+#define YPXPROG ((u_long) 100069)
+#define YPPROG ((u_long) 100004)
+#define YPPROC_DOMAIN_NONACK ((u_long) 2)
+#define MOUNTPROC_MNT ((u_long) 1)
+
+int
+check_callit(addr, proc, prog, aproc)
+ struct sockaddr_in *addr;
+ u_long proc;
+ u_long prog;
+ u_long aproc;
+{
+ if (prog == PMAPPROG ||
+ prog == NFSPROG ||
+ prog == YPXPROG ||
+ (prog == MOUNTPROG && aproc == MOUNTPROC_MNT) ||
+ (prog == YPPROG && aproc != YPPROC_DOMAIN_NONACK)) {
+ syslog(LOG_WARNING,
+ "callit prog %d aproc %d (might be from %s)",
+ prog, aproc, inet_ntoa(*addr));
+ return (FALSE);
+ }
+ return (TRUE);
+}