From 2af3d29e01df631785afba36ec03a35ac23d04f2 Mon Sep 17 00:00:00 2001 From: ad Date: Mon, 17 Jul 2006 14:47:02 +0000 Subject: [PATCH] - Don't cast kauth_cred_t to (struct ucred *), just set pc_ucred = NULL. - Fill ucred::cr_ref. --- sys/kern/init_sysctl.c | 12 ++++-------- sys/kern/kern_auth.c | 11 +++++------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/sys/kern/init_sysctl.c b/sys/kern/init_sysctl.c index 879b7f935804..a5dc8981230d 100644 --- a/sys/kern/init_sysctl.c +++ b/sys/kern/init_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_sysctl.c,v 1.76 2006/07/16 20:21:42 elad Exp $ */ +/* $NetBSD: init_sysctl.c,v 1.77 2006/07/17 14:47:02 ad Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.76 2006/07/16 20:21:42 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.77 2006/07/17 14:47:02 ad Exp $"); #include "opt_sysv.h" #include "opt_multiprocessor.h" @@ -3074,15 +3074,11 @@ fill_eproc(struct proc *p, struct eproc *ep) { struct tty *tp; struct lwp *l; - struct pcred pc; - struct ucred uc; ep->e_paddr = p; ep->e_sess = p->p_session; - kauth_cred_topcred(p->p_cred, &pc); - kauth_cred_toucred(p->p_cred, &uc); - ep->e_pcred = pc; - ep->e_ucred = uc; + kauth_cred_topcred(p->p_cred, &ep->e_pcred); + kauth_cred_toucred(p->p_cred, &ep->e_ucred); if (p->p_stat == SIDL || P_ZOMBIE(p)) { ep->e_vm.vm_rssize = 0; ep->e_vm.vm_tsize = 0; diff --git a/sys/kern/kern_auth.c b/sys/kern/kern_auth.c index 85d75fcec7bb..b1f9d34b4b90 100644 --- a/sys/kern/kern_auth.c +++ b/sys/kern/kern_auth.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_auth.c,v 1.11 2006/07/17 14:37:20 ad Exp $ */ +/* $NetBSD: kern_auth.c,v 1.12 2006/07/17 14:47:02 ad Exp $ */ /*- * Copyright (c) 2005, 2006 Elad Efrat @@ -459,8 +459,7 @@ kauth_cred_uucmp(kauth_cred_t cred, const struct uucred *uuc) } /* - * Make a struct ucred out of a kauth_cred_t. - * XXX: For sysctl. + * Make a struct ucred out of a kauth_cred_t. For compatibility. */ void kauth_cred_toucred(kauth_cred_t cred, struct ucred *uc) @@ -468,6 +467,7 @@ kauth_cred_toucred(kauth_cred_t cred, struct ucred *uc) KASSERT(cred != NULL); KASSERT(uc != NULL); + uc->cr_ref = cred->cr_refcnt; uc->cr_uid = cred->cr_euid; uc->cr_gid = cred->cr_egid; uc->cr_ngroups = min(cred->cr_ngroups, @@ -477,8 +477,7 @@ kauth_cred_toucred(kauth_cred_t cred, struct ucred *uc) } /* - * Make a struct pcred out of a kauth_cred_t. - * XXX: For sysctl. + * Make a struct pcred out of a kauth_cred_t. For compatibility. */ void kauth_cred_topcred(kauth_cred_t cred, struct pcred *pc) @@ -486,7 +485,7 @@ kauth_cred_topcred(kauth_cred_t cred, struct pcred *pc) KASSERT(cred != NULL); KASSERT(pc != NULL); - pc->pc_ucred = (struct ucred *)cred; /* XXX this is just wrong */ + pc->pc_ucred = NULL; pc->p_ruid = cred->cr_uid; pc->p_svuid = cred->cr_svuid; pc->p_rgid = cred->cr_gid;