Revert the kauth_impl.h change. Elad is going to maintain this. Asked by core@

This commit is contained in:
christos 2007-02-24 20:41:33 +00:00
parent b0f9a8a9aa
commit 2a84b2c2c1
3 changed files with 53 additions and 72 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kvm_proc.c,v 1.67 2007/02/18 15:22:44 dsl Exp $ */
/* $NetBSD: kvm_proc.c,v 1.68 2007/02/24 20:41:34 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
#if 0
static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93";
#else
__RCSID("$NetBSD: kvm_proc.c,v 1.67 2007/02/18 15:22:44 dsl Exp $");
__RCSID("$NetBSD: kvm_proc.c,v 1.68 2007/02/24 20:41:34 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -85,8 +85,6 @@ __RCSID("$NetBSD: kvm_proc.c,v 1.67 2007/02/18 15:22:44 dsl Exp $");
* most other applications are interested only in open/close/read/nlist).
*/
#define _KAUTH_PRIVATE
#include <sys/param.h>
#include <sys/user.h>
#include <sys/lwp.h>
@ -96,7 +94,8 @@ __RCSID("$NetBSD: kvm_proc.c,v 1.67 2007/02/18 15:22:44 dsl Exp $");
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/resourcevar.h>
#include <sys/kauth_impl.h>
#include <sys/mutex.h>
#include <sys/specificdata.h>
#include <errno.h>
#include <stdlib.h>
@ -154,6 +153,28 @@ struct miniproc {
(p)->p_vmspace = (void *)(long)(kp)->p_vmspace; \
} while (/*CONSTCOND*/0);
/*
* NetBSD uses kauth(9) to manage credentials, which are stored in kauth_cred_t,
* a kernel-only opaque type. This is an embedded version which is *INTERNAL* to
* kvm(3) so dumps can be read properly.
*
* Whenever NetBSD starts exporting credentials to userland consistently (using
* 'struct uucred', or something) this will have to be updated again.
*/
struct kvm_kauth_cred {
kmutex_t cr_lock; /* lock on cr_refcnt */
u_int cr_refcnt; /* reference count */
uid_t cr_uid; /* user id */
uid_t cr_euid; /* effective user id */
uid_t cr_svuid; /* saved effective user id */
gid_t cr_gid; /* group id */
gid_t cr_egid; /* effective group id */
gid_t cr_svgid; /* saved effective group id */
u_int cr_ngroups; /* number of groups */
gid_t cr_groups[NGROUPS]; /* group memberships */
specificdata_reference cr_sd; /* specific data */
};
#define KREAD(kd, addr, obj) \
(kvm_read(kd, addr, (obj), sizeof(*obj)) != sizeof(*obj))
@ -288,7 +309,7 @@ _kvm_uread(kd, p, va, cnt)
static int
_kvm_convertcred(kvm_t *kd, u_long cred, struct eproc *eproc)
{
struct kauth_cred kauthcred;
struct kvm_kauth_cred kauthcred;
struct ki_pcred *pc = &eproc->e_pcred;
struct ki_ucred *uc = &eproc->e_ucred;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_auth.c,v 1.45 2007/02/18 15:20:34 dsl Exp $ */
/* $NetBSD: kern_auth.c,v 1.46 2007/02/24 20:41:33 christos Exp $ */
/*-
* Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
@ -28,20 +28,20 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.45 2007/02/18 15:20:34 dsl Exp $");
#define _KAUTH_PRIVATE
__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.46 2007/02/24 20:41:33 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/proc.h>
#include <sys/ucred.h>
#include <sys/pool.h>
#include <sys/kauth.h>
#include <sys/kauth_impl.h>
#include <sys/kmem.h>
#include <sys/rwlock.h>
#include <sys/sysctl.h> /* for pi_[p]cread */
#include <sys/mutex.h>
#include <sys/specificdata.h>
/*
* Secmodel-specific credentials.
@ -51,6 +51,27 @@ struct kauth_key {
specificdata_key_t ks_key; /* key */
};
/*
* Credentials.
*
* A subset of this structure is used in kvm(3) (src/lib/libkvm/kvm_proc.c)
* and should be synchronized with this structure when the update is
* relevant.
*/
struct kauth_cred {
kmutex_t cr_lock; /* lock on cr_refcnt */
u_int cr_refcnt; /* reference count */
uid_t cr_uid; /* user id */
uid_t cr_euid; /* effective user id */
uid_t cr_svuid; /* saved effective user id */
gid_t cr_gid; /* group id */
gid_t cr_egid; /* effective group id */
gid_t cr_svgid; /* saved effective group id */
u_int cr_ngroups; /* number of groups */
gid_t cr_groups[NGROUPS]; /* group memberships */
specificdata_reference cr_sd; /* specific data */
};
/*
* Listener.
*/

View File

@ -1,61 +0,0 @@
/* $NetBSD: kauth_impl.h,v 1.2 2007/02/09 21:55:37 ad Exp $ */
/*-
* Copyright (c) 2005, 2006 Elad Efrat <elad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Implementation private definitions used by kauth, and kernel memory
* grovellers.
*/
#ifndef _SYS_KAUTH_IMPL_H_
#define _SYS_KAUTH_IMPL_H_ 1
#include <sys/types.h>
#include <sys/mutex.h>
#include <sys/specificdata.h>
#ifdef _KAUTH_PRIVATE
/*
* Credentials.
*/
struct kauth_cred {
kmutex_t cr_lock; /* lock on cr_refcnt */
u_int cr_refcnt; /* reference count */
uid_t cr_uid; /* user id */
uid_t cr_euid; /* effective user id */
uid_t cr_svuid; /* saved effective user id */
gid_t cr_gid; /* group id */
gid_t cr_egid; /* effective group id */
gid_t cr_svgid; /* saved effective group id */
u_int cr_ngroups; /* number of groups */
gid_t cr_groups[NGROUPS]; /* group memberships */
specificdata_reference cr_sd; /* specific data */
};
#endif /* _KAUTH_PRIVATE */
#endif /* _SYS_KAUTH_IMPL_H_ */