add a crcmp() function.

This commit is contained in:
christos 2003-05-16 13:55:18 +00:00
parent 34e4755a7d
commit ade6fba604
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_prot.c,v 1.78 2003/03/27 17:47:45 jdolecek Exp $ */ /* $NetBSD: kern_prot.c,v 1.79 2003/05/16 13:55:18 christos Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
@ -45,7 +45,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.78 2003/03/27 17:47:45 jdolecek Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.79 2003/05/16 13:55:18 christos Exp $");
#include "opt_compat_43.h" #include "opt_compat_43.h"
@ -638,6 +638,18 @@ crfree(struct ucred *cr)
FREE((caddr_t)cr, M_CRED); FREE((caddr_t)cr, M_CRED);
} }
/*
* Compare cred structures and return 0 if they match
*/
int
crcmp(const struct ucred *cr1, const struct uucred *cr2)
{
return cr1->cr_uid != cr2->cr_uid ||
cr1->cr_gid != cr2->cr_gid ||
cr1->cr_ngroups != (uint32_t)cr2->cr_ngroups ||
memcmp(cr1->cr_groups, cr2->cr_groups, cr1->cr_ngroups);
}
/* /*
* Copy cred structure to a new one and free the old one. * Copy cred structure to a new one and free the old one.
*/ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ucred.h,v 1.16 2003/03/05 18:39:17 dsl Exp $ */ /* $NetBSD: ucred.h,v 1.17 2003/05/16 13:55:54 christos Exp $ */
/* /*
* Copyright (c) 1989, 1993 * Copyright (c) 1989, 1993
@ -85,6 +85,7 @@ void crfree(struct ucred *);
struct ucred *crget(void); struct ucred *crget(void);
int suser(const struct ucred *, u_short *); int suser(const struct ucred *, u_short *);
void crcvt(struct ucred *, const struct uucred *); void crcvt(struct ucred *, const struct uucred *);
int crcmp(const struct ucred *, const struct uucred *);
#endif /* _KERNEL */ #endif /* _KERNEL */
#endif /* !_SYS_UCRED_H_ */ #endif /* !_SYS_UCRED_H_ */