From 162c0b2eff6f5645f8303d9d34c91036fe18638e Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Fri, 31 Aug 2001 12:31:09 +0000 Subject: Synch with NetBSD and OpenBSD. Allow non-superuser to open, listen to, and send safe commands on the routing socket. Superuser priviledge is required for all commands but RTM_GET. Lose `setuid root' bit of route(8). Reviewed by: wollman, dd --- sys/net/rtsock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index e8e85eb71bdf..ede7ad698d45 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -123,7 +123,7 @@ rts_attach(struct socket *so, int proto, struct proc *p) */ s = splnet(); so->so_pcb = (caddr_t)rp; - error = raw_usrreqs.pru_attach(so, proto, p); + error = raw_attach(so, proto); rp = sotorawcb(so); if (error) { splx(s); @@ -326,6 +326,14 @@ route_output(m, so) else senderr(ENOBUFS); } + + /* + * Verify that the caller has the appropriate privilege; RTM_GET + * is the only operation the non-superuser is allowed. + */ + if (rtm->rtm_type != RTM_GET && suser_xxx(so->so_cred, NULL, 0) != 0) + senderr(EPERM); + switch (rtm->rtm_type) { case RTM_ADD: -- cgit v1.3