From 76183f345377df655cfb357a53d52aa045fa8073 Mon Sep 17 00:00:00 2001 From: Dima Dorfman Date: Wed, 27 Feb 2002 04:45:37 +0000 Subject: Introduce a version field to `struct xucred' in place of one of the spares (the size of the field was changed from u_short to u_int to reflect what it really ends up being). Accordingly, change users of xucred to set and check this field as appropriate. In the kernel, this is being done inside the new cru2x() routine which takes a `struct ucred' and fills out a `struct xucred' according to the former. This also has the pleasant sideaffect of removing some duplicate code. Reviewed by: rwatson --- sys/kern/kern_prot.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys/kern/kern_prot.c') diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 615709eb26c3..56f7895c8d4e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1759,6 +1759,22 @@ crdup(cr) return (newcr); } +/* + * Fill in a struct xucred based on a struct ucred. + */ +void +cru2x(cr, xcr) + struct ucred *cr; + struct xucred *xcr; +{ + + bzero(xcr, sizeof(*xcr)); + xcr->cr_version = XUCRED_VERSION; + xcr->cr_uid = cr->cr_uid; + xcr->cr_ngroups = cr->cr_ngroups; + bcopy(cr->cr_groups, xcr->cr_groups, sizeof(cr->cr_groups)); +} + /* * small routine to swap a thread's current ucred for the correct one * taken from the process. -- cgit v1.2.3