Source-Changes-HG archive

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

[src/trunk]: src/sys don't opencode kauth_cred_get()



details:   https://anonhg.NetBSD.org/src/rev/a0ff5fbab5b5
branches:  trunk
changeset: 1023673:a0ff5fbab5b5
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Sep 21 14:59:14 2021 +0000

description:
don't opencode kauth_cred_get()

diffstat:

 sys/net/if_gre.c               |   6 +++---
 sys/net80211/ieee80211_ioctl.c |  18 ++++++++++--------
 sys/netatalk/at_control.c      |   6 +++---
 sys/netatalk/ddp_usrreq.c      |   7 ++++---
 sys/netbt/hci_ioctl.c          |  14 +++++++-------
 sys/netcan/can.c               |  12 ++++++------
 sys/netinet/in.c               |  10 ++++++----
 sys/netinet6/in6.c             |   6 +++---
 sys/netinet6/ip6_output.c      |  27 ++++++++++++++++-----------
 sys/netinet6/raw_ip6.c         |   6 +++---
 10 files changed, 61 insertions(+), 51 deletions(-)

diffs (truncated from 434 to 300 lines):

diff -r 64545b09de1c -r a0ff5fbab5b5 sys/net/if_gre.c
--- a/sys/net/if_gre.c  Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/net/if_gre.c  Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gre.c,v 1.180 2021/02/14 19:33:29 roy Exp $ */
+/*     $NetBSD: if_gre.c,v 1.181 2021/09/21 14:59:14 christos Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.180 2021/02/14 19:33:29 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.181 2021/09/21 14:59:14 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_atalk.h"
@@ -1195,7 +1195,7 @@
        case GRESADDRS:
        case GRESSOCK:
        case GREDSOCK:
-               if (kauth_authorize_network(curlwp->l_cred,
+               if (kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL) != 0)
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/net80211/ieee80211_ioctl.c
--- a/sys/net80211/ieee80211_ioctl.c    Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/net80211/ieee80211_ioctl.c    Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_ioctl.c,v 1.68 2021/07/24 21:31:38 andvar Exp $      */
+/*     $NetBSD: ieee80211_ioctl.c,v 1.69 2021/09/21 15:00:34 christos Exp $    */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.68 2021/07/24 21:31:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.69 2021/09/21 15:00:34 christos Exp $");
 #endif
 
 /*
@@ -367,7 +367,7 @@
        case WI_RID_DEFLT_CRYPT_KEYS:
                keys = (struct wi_ltv_keys *)wreq;
                /* do not show keys to non-root user */
-               error = kauth_authorize_network(curlwp->l_cred,
+               error = kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, ifp,
                    NULL, NULL);
@@ -904,7 +904,8 @@
        ik.ik_flags = wk->wk_flags & (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV);
        if (wk->wk_keyix == ic->ic_def_txkey)
                ik.ik_flags |= IEEE80211_KEY_DEFAULT;
-       if (kauth_authorize_network(curlwp->l_cred, KAUTH_NETWORK_INTERFACE,
+       if (kauth_authorize_network(kauth_cred_get(),
+           KAUTH_NETWORK_INTERFACE,
            KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, ic->ic_ifp, NULL, NULL) == 0) {
                /* NB: only root can read key data */
                ik.ik_keyrsc = wk->wk_keyrsc;
@@ -1357,7 +1358,7 @@
                        return EINVAL;
                len = (u_int) ic->ic_nw_keys[kid].wk_keylen;
                /* NB: only root can read WEP keys */
-               if (kauth_authorize_network(curlwp->l_cred,
+               if (kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, ifp, NULL,
                    NULL) == 0) {
@@ -2582,7 +2583,7 @@
                                (struct ieee80211req *) data);
                break;
        case SIOCS80211:
-               if ((error = kauth_authorize_network(curlwp->l_cred,
+               if ((error = kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL)) != 0)
@@ -2722,7 +2723,8 @@
                        if (nwkey->i_key[i].i_keydat == NULL)
                                continue;
                        /* do not show any keys to non-root user */
-                       if ((error = kauth_authorize_network(curlwp->l_cred,
+                       if ((error = kauth_authorize_network(
+                           kauth_cred_get(),
                            KAUTH_NETWORK_INTERFACE,
                            KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, ifp,
                            (void *)cmd, NULL)) != 0)
@@ -2836,7 +2838,7 @@
                error = ieee80211_cfgget(ic, cmd, data);
                break;
        case SIOCSIFGENERIC:
-               error = kauth_authorize_network(curlwp->l_cred,
+               error = kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL);
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netatalk/at_control.c
--- a/sys/netatalk/at_control.c Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netatalk/at_control.c Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: at_control.c,v 1.41 2021/08/02 12:56:25 andvar Exp $    */
+/*     $NetBSD: at_control.c,v 1.42 2021/09/21 15:01:59 christos Exp $  */
 
 /*
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.41 2021/08/02 12:56:25 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.42 2021/09/21 15:01:59 christos Exp $");
 
 #include "opt_atalk.h"
 
@@ -127,7 +127,7 @@
                 * If we are not superuser, then we don't get to do these
                 * ops.
                 */
-               if (kauth_authorize_network(curlwp->l_cred,
+               if (kauth_authorize_network(kauth_cred_get(),
                    KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL) != 0)
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netatalk/ddp_usrreq.c
--- a/sys/netatalk/ddp_usrreq.c Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netatalk/ddp_usrreq.c Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddp_usrreq.c,v 1.74 2019/11/29 17:40:16 maxv Exp $      */
+/*     $NetBSD: ddp_usrreq.c,v 1.75 2021/09/21 15:01:59 christos Exp $  */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.74 2019/11/29 17:40:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.75 2021/09/21 15:01:59 christos Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_atalk.h"
@@ -120,7 +120,8 @@
                                return (EINVAL);
 
                        if (sat->sat_port < ATPORT_RESERVED &&
-                           (error = kauth_authorize_network(curlwp->l_cred,
+                           (error = kauth_authorize_network(
+                           kauth_cred_get(),
                            KAUTH_NETWORK_BIND, KAUTH_REQ_NETWORK_BIND_PRIVPORT,
                            ddpcb->ddp_socket, sat, NULL)) != 0)
                                return (error);
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netbt/hci_ioctl.c
--- a/sys/netbt/hci_ioctl.c     Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netbt/hci_ioctl.c     Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hci_ioctl.c,v 1.14 2019/02/03 03:19:28 mrg Exp $       */
+/*     $NetBSD: hci_ioctl.c,v 1.15 2021/09/21 15:03:08 christos Exp $  */
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.14 2019/02/03 03:19:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.15 2021/09/21 15:03:08 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/domain.h>
@@ -227,7 +227,7 @@
                break;
 
        case SIOCSBTFLAGS:      /* set unit flags (privileged) */
-               err = kauth_authorize_device(curlwp->l_cred,
+               err = kauth_authorize_device(kauth_cred_get(),
                    KAUTH_DEVICE_BLUETOOTH_SETPRIV, unit, KAUTH_ARG(cmd),
                    btr, NULL);
                if (err)
@@ -255,7 +255,7 @@
                break;
 
        case SIOCSBTPOLICY:     /* set unit link policy (privileged) */
-               err = kauth_authorize_device(curlwp->l_cred,
+               err = kauth_authorize_device(kauth_cred_get(),
                    KAUTH_DEVICE_BLUETOOTH_SETPRIV, unit, KAUTH_ARG(cmd),
                    btr, NULL);
                if (err)
@@ -267,7 +267,7 @@
                break;
 
        case SIOCSBTPTYPE:      /* set unit packet types (privileged) */
-               err = kauth_authorize_device(curlwp->l_cred,
+               err = kauth_authorize_device(kauth_cred_get(),
                    KAUTH_DEVICE_BLUETOOTH_SETPRIV, unit, KAUTH_ARG(cmd),
                    btr, NULL);
                if (err)
@@ -283,7 +283,7 @@
                break;
 
        case SIOCZBTSTATS:      /* get & reset unit statistics */
-               err = kauth_authorize_device(curlwp->l_cred,
+               err = kauth_authorize_device(kauth_cred_get(),
                    KAUTH_DEVICE_BLUETOOTH_SETPRIV, unit, KAUTH_ARG(cmd),
                    btr, NULL);
                if (err)
@@ -299,7 +299,7 @@
                 * sent to USB bluetooth controllers that are not an
                 * integer number of frame sizes, the USB bus locks up.
                 */
-               err = kauth_authorize_device(curlwp->l_cred,
+               err = kauth_authorize_device(kauth_cred_get(),
                    KAUTH_DEVICE_BLUETOOTH_SETPRIV, unit, KAUTH_ARG(cmd),
                    btr, NULL);
                if (err)
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netcan/can.c
--- a/sys/netcan/can.c  Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netcan/can.c  Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: can.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $  */
+/*     $NetBSD: can.c,v 1.10 2021/09/21 15:04:27 christos Exp $        */
 
 /*-
  * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.10 2021/09/21 15:04:27 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -132,10 +132,10 @@
        if (ifp->if_dlt != DLT_CAN_SOCKETCAN || csc == NULL)
                return EOPNOTSUPP;
 
-       error = kauth_authorize_network(curlwp->l_cred,
-                   KAUTH_NETWORK_INTERFACE,
-                   KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp,
-                   (void *)SIOCSDRVSPEC, NULL);
+       error = kauth_authorize_network(kauth_cred_get(),
+           KAUTH_NETWORK_INTERFACE,
+           KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp,
+           (void *)SIOCSDRVSPEC, NULL);
        if (error != 0)
                return error;
 
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netinet/in.c
--- a/sys/netinet/in.c  Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netinet/in.c  Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.241 2020/09/29 19:33:36 roy Exp $     */
+/*     $NetBSD: in.c,v 1.242 2021/09/21 15:05:41 christos Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.241 2020/09/29 19:33:36 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.242 2021/09/21 15:05:41 christos Exp $");
 
 #include "arp.h"
 
@@ -521,7 +521,8 @@
                        goto out;
                }
 
-               if (kauth_authorize_network(curlwp->l_cred, KAUTH_NETWORK_INTERFACE,
+               if (kauth_authorize_network(kauth_cred_get(),
+                   KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL) != 0) {
                        error = EPERM;
@@ -565,7 +566,8 @@
                break;
 
        case SIOCSIFBRDADDR:
-               if (kauth_authorize_network(curlwp->l_cred, KAUTH_NETWORK_INTERFACE,
+               if (kauth_authorize_network(kauth_cred_get(),
+                   KAUTH_NETWORK_INTERFACE,
                    KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd,
                    NULL) != 0) {
                        error = EPERM;
diff -r 64545b09de1c -r a0ff5fbab5b5 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Tue Sep 21 14:57:26 2021 +0000
+++ b/sys/netinet6/in6.c        Tue Sep 21 14:59:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.282 2020/09/29 19:33:36 roy Exp $    */
+/*     $NetBSD: in6.c,v 1.283 2021/09/21 15:06:21 christos Exp $       */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -62,7 +62,7 @@



Home | Main Index | Thread Index | Old Index