Subject: Re: CVS commit: src/lib/libkvm
To: Elad Efrat <elad@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: source-changes
Date: 02/06/2007 21:32:53
On Tue, Feb 06, 2007 at 09:21:51PM +0000, Elad Efrat wrote:

> Module Name:	src
> Committed By:	elad
> Date:		Tue Feb  6 21:21:51 UTC 2007
> 
> Modified Files:
> 	src/lib/libkvm: kvm_proc.c
> 
> Log Message:
> PR/35506: Chuck Silvers: ps doesn't work on crash dumps, libkvm doesn't
> know about kauth
> 
> Implemented _kvm_convertcred() to handle copying kauth_cred_t to userspace
> and converting it to the appropriate 'struct eproc' members ('pcred' and
> 'ucred' respectively).
> 
> Okay mlelstv@.

Thanks for fixing this. Redefining kauth_cred_t in userland isn't the right
way to go about it though. Please change it so that kauth_cred_t is defined
in a non-installed header file under sys/sys.

Cheers,
Andrew

@@ -150,6 +150,26 @@
                (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 {
+       struct simplelock 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 */
+};