Remove FreeBSD blocks that did not compile anyway, and use l->l_cred

consistently.
This commit is contained in:
christos 2021-09-21 14:30:15 +00:00
parent a298a1ad72
commit 59d03a6b31
12 changed files with 36 additions and 90 deletions

View File

@ -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 <sys/cdefs.h>
__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;

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}

View File

@ -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 <sys/cdefs.h>
__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;
}