From 59d03a6b31db9020821d8c75dd3384b974ec1a1d Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 21 Sep 2021 14:30:15 +0000 Subject: [PATCH] Remove FreeBSD blocks that did not compile anyway, and use l->l_cred consistently. --- sys/altq/altq_afmap.c | 13 +++++-------- sys/altq/altq_blue.c | 9 ++------- sys/altq/altq_cbq.c | 13 +++++-------- sys/altq/altq_cdnr.c | 8 ++------ sys/altq/altq_conf.c | 16 ++++++---------- sys/altq/altq_fifoq.c | 9 ++------- sys/altq/altq_hfsc.c | 9 ++------- sys/altq/altq_jobs.c | 12 +++--------- sys/altq/altq_priq.c | 9 ++------- sys/altq/altq_red.c | 11 +++-------- sys/altq/altq_rio.c | 9 ++------- sys/altq/altq_wfq.c | 8 ++------ 12 files changed, 36 insertions(+), 90 deletions(-) diff --git a/sys/altq/altq_afmap.c b/sys/altq/altq_afmap.c index 0c40daf8353f..ae04bddbc3a2 100644 --- a/sys/altq/altq_afmap.c +++ b/sys/altq/altq_afmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_afmap.c,v 1.20 2014/03/20 20:51:54 christos Exp $ */ +/* $NetBSD: altq_afmap.c,v 1.21 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_afmap.c,v 1.12 2005/04/13 03:44:24 suz Exp $ */ /* @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.20 2014/03/20 20:51:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.21 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -357,12 +357,9 @@ afmioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case AFM_GETFMAP: break; default: -#if (__FreeBSD_version > 400000) - error = suser(p); -#else - error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, - KAUTH_REQ_NETWORK_ALTQ_AFMAP, NULL, NULL, NULL); -#endif + error = kauth_authorize_network(l->l_cred, + KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_AFMAP, NULL, + NULL, NULL); if (error) return (error); break; diff --git a/sys/altq/altq_blue.c b/sys/altq/altq_blue.c index 90eb06f3c937..1ca0ddf71f43 100644 --- a/sys/altq/altq_blue.c +++ b/sys/altq/altq_blue.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_blue.c,v 1.25 2019/12/26 04:53:11 msaitoh Exp $ */ +/* $NetBSD: altq_blue.c,v 1.26 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_blue.c,v 1.15 2005/04/13 03:44:24 suz Exp $ */ /* @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.25 2019/12/26 04:53:11 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_blue.c,v 1.26 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -163,15 +163,10 @@ blueioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case BLUE_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_BLUE, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index 6e5e6b2b1aab..6ac0c18fa5a4 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_cbq.c,v 1.37 2021/08/17 22:00:26 andvar Exp $ */ +/* $NetBSD: altq_cbq.c,v 1.38 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.37 2021/08/17 22:00:26 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.38 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -1011,12 +1011,9 @@ cbqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, /* currently only command that an ordinary user can call */ break; default: -#if (__FreeBSD_version > 400000) - error = suser(p); -#else - error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, - KAUTH_REQ_NETWORK_ALTQ_CBQ, NULL, NULL, NULL); -#endif + error = kauth_authorize_network(l->l_cred, + KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_CBQ, NULL, NULL, + NULL); if (error) return (error); break; diff --git a/sys/altq/altq_cdnr.c b/sys/altq/altq_cdnr.c index 45dcc489f67d..5dbe95127d36 100644 --- a/sys/altq/altq_cdnr.c +++ b/sys/altq/altq_cdnr.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_cdnr.c,v 1.21 2016/06/10 13:31:43 ozaki-r Exp $ */ +/* $NetBSD: altq_cdnr.c,v 1.22 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_cdnr.c,v 1.15 2005/04/13 03:44:24 suz Exp $ */ /* @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.21 2016/06/10 13:31:43 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.22 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -1189,13 +1189,9 @@ cdnrioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case CDNR_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_CDNR, NULL, NULL, NULL)) != 0) -#endif return (error); break; } diff --git a/sys/altq/altq_conf.c b/sys/altq/altq_conf.c index ed87d8555520..2f14f1f7ec38 100644 --- a/sys/altq/altq_conf.c +++ b/sys/altq/altq_conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_conf.c,v 1.21 2014/07/25 08:10:31 dholland Exp $ */ +/* $NetBSD: altq_conf.c,v 1.22 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_conf.c,v 1.24 2005/04/13 03:44:24 suz Exp $ */ /* @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_conf.c,v 1.21 2014/07/25 08:10:31 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_conf.c,v 1.22 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -224,15 +224,11 @@ altqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, struct lwp *l) case ALTQTBRGET: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) + if ((error = kauth_authorize_network( + l->l_cred, KAUTH_NETWORK_ALTQ, + KAUTH_REQ_NETWORK_ALTQ_CONF, NULL, NULL, + NULL)) != 0) return (error); -#else - if ((error = kauth_authorize_network(l->l_cred, - KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_CONF, - NULL, NULL, NULL)) != 0) - return (error); -#endif break; } diff --git a/sys/altq/altq_fifoq.c b/sys/altq/altq_fifoq.c index a8d6faee2de0..807d27611f28 100644 --- a/sys/altq/altq_fifoq.c +++ b/sys/altq/altq_fifoq.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_fifoq.c,v 1.17 2016/04/20 08:58:48 knakahara Exp $ */ +/* $NetBSD: altq_fifoq.c,v 1.18 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_fifoq.c,v 1.12 2003/07/10 12:07:48 kjc Exp $ */ /* @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.17 2016/04/20 08:58:48 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_fifoq.c,v 1.18 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -131,15 +131,10 @@ fifoqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case FIFOQ_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_FIFOQ, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index 19a491d54a66..c1feeada4b4f 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_hfsc.c,v 1.29 2021/08/30 08:40:31 riastradh Exp $ */ +/* $NetBSD: altq_hfsc.c,v 1.30 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_hfsc.c,v 1.26 2005/04/13 03:44:24 suz Exp $ */ /* @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.29 2021/08/30 08:40:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.30 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -1916,15 +1916,10 @@ hfscioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case HFSC_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_HFSC, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_jobs.c b/sys/altq/altq_jobs.c index 0ba00b719f6e..a71b60b12d7b 100644 --- a/sys/altq/altq_jobs.c +++ b/sys/altq/altq_jobs.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_jobs.c,v 1.11 2017/07/28 13:53:17 riastradh Exp $ */ +/* $NetBSD: altq_jobs.c,v 1.12 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_jobs.c,v 1.11 2005/04/13 03:44:25 suz Exp $ */ /* * Copyright (c) 2001, the Rector and Board of Visitors of the @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.11 2017/07/28 13:53:17 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.12 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -1858,7 +1858,6 @@ jobsioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, { struct jobs_if *jif; struct jobs_interface *ifacep; - struct proc *p = l->l_proc; int error = 0; /* check super-user privilege */ @@ -1866,15 +1865,10 @@ jobsioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case JOBS_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else - if ((error = kauth_authorize_network(p->p_cred, + if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_JOBS, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index faf0bb3eba47..b8505ba7a915 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_priq.c,v 1.27 2021/08/30 08:40:31 riastradh Exp $ */ +/* $NetBSD: altq_priq.c,v 1.28 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_priq.c,v 1.13 2005/04/13 03:44:25 suz Exp $ */ /* * Copyright (C) 2000-2003 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.27 2021/08/30 08:40:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.28 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -711,15 +711,10 @@ priqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case PRIQ_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_PRIQ, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_red.c b/sys/altq/altq_red.c index 3ac5c15f9d87..357b9c8b6bb6 100644 --- a/sys/altq/altq_red.c +++ b/sys/altq/altq_red.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_red.c,v 1.33 2021/09/03 21:54:59 andvar Exp $ */ +/* $NetBSD: altq_red.c,v 1.34 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_red.c,v 1.20 2005/04/13 03:44:25 suz Exp $ */ /* @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_red.c,v 1.33 2021/09/03 21:54:59 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_red.c,v 1.34 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -759,7 +759,6 @@ redioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, red_queue_t *rqp; struct red_interface *ifacep; struct ifnet *ifp; - struct proc *p = l->l_proc; int error = 0; /* check super-user privilege */ @@ -767,13 +766,9 @@ redioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case RED_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) -#else - if ((error = kauth_authorize_network(p->p_cred, + if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_RED, NULL, NULL, NULL)) != 0) -#endif return (error); break; } diff --git a/sys/altq/altq_rio.c b/sys/altq/altq_rio.c index 4a0d4a88dcce..5c05187a386d 100644 --- a/sys/altq/altq_rio.c +++ b/sys/altq/altq_rio.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_rio.c,v 1.24 2019/12/26 04:53:11 msaitoh Exp $ */ +/* $NetBSD: altq_rio.c,v 1.25 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_rio.c,v 1.19 2005/04/13 03:44:25 suz Exp $ */ /* @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.24 2019/12/26 04:53:11 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.25 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -500,15 +500,10 @@ rioioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case RIO_GETSTATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) - return (error); -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_RIO, NULL, NULL, NULL)) != 0) return (error); -#endif break; } diff --git a/sys/altq/altq_wfq.c b/sys/altq/altq_wfq.c index c86d0983a10b..d7a9a37c3c4f 100644 --- a/sys/altq/altq_wfq.c +++ b/sys/altq/altq_wfq.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_wfq.c,v 1.22 2017/07/28 13:58:47 riastradh Exp $ */ +/* $NetBSD: altq_wfq.c,v 1.23 2021/09/21 14:30:15 christos Exp $ */ /* $KAME: altq_wfq.c,v 1.14 2005/04/13 03:44:25 suz Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.22 2017/07/28 13:58:47 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.23 2021/09/21 14:30:15 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -679,13 +679,9 @@ wfqioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, case WFQ_GET_STATS: break; default: -#if (__FreeBSD_version > 400000) - if ((error = suser(p)) != 0) -#else if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_ALTQ, KAUTH_REQ_NETWORK_ALTQ_WFQ, NULL, NULL, NULL)) != 0) -#endif return (error); break; }