ipfw: Add icmpcodes support.
[dragonfly.git] / sys / sys / ucred.h
blobbaf350665febc2b9bfff225f0e0f0920811aaf06
1 /*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)ucred.h 8.4 (Berkeley) 1/9/95
30 * $FreeBSD: src/sys/sys/ucred.h,v 1.14.2.5 2002/03/09 05:20:25 dd Exp $
31 * $DragonFly: src/sys/sys/ucred.h,v 1.9 2007/01/08 21:32:57 corecode Exp $
34 #ifndef _SYS_UCRED_H_
35 #define _SYS_UCRED_H_
37 #ifndef _SYS_TYPES_H_
38 #include <sys/types.h>
39 #endif
40 #ifndef _SYS_PARAM_H_
41 #include <sys/param.h>
42 #endif
43 #ifndef _SYS_SPINLOCK_H_
44 #include <sys/spinlock.h>
45 #endif
47 struct prison;
50 * Credentials.
52 * Please do not inspect cr_uid directly to determine superuserness.
53 * Only the priv(9) functions should be used for this.
55 * NOTE: Creds are accessed a lot, and cr_ref is also adjusted a lot.
56 * This can ping-pong fields in its cache line that are otherwise
57 * read-only. To solve this problem we note that even in really
58 * busy systems, ucred isn't replicated a whole lot. So put
59 * the blasted cr_ref in its own cache line.
61 struct ucred {
62 struct {
63 long cr_ref; /* reference count */
64 } __cachealign;
65 uid_t cr_uid; /* effective user id */
66 short cr_ngroups; /* number of groups */
67 gid_t cr_groups[NGROUPS]; /* groups */
68 struct uidinfo *cr_uidinfo; /* per uid resource consumption */
69 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
70 struct prison *cr_prison; /* prison info */
71 uid_t cr_ruid; /* Real user id. */
72 uid_t cr_svuid; /* Saved effective user id. */
73 gid_t cr_rgid; /* Real group id. */
74 gid_t cr_svgid; /* Saved effective group id. */
75 } __cachealign;
77 #define cr_gid cr_groups[0]
78 #define NOCRED ((struct ucred *)0) /* no credential available */
79 #define FSCRED ((struct ucred *)-1) /* filesystem credential */
82 * This is the external representation of struct ucred, based upon the
83 * size of a 4.2-RELEASE struct ucred. There will probably never be
84 * any need to change the size of this or layout of its used fields.
86 struct xucred {
87 u_int cr_version; /* structure layout version */
88 uid_t cr_uid; /* effective user id */
89 short cr_ngroups; /* number of groups */
90 gid_t cr_groups[NGROUPS]; /* groups */
91 void *_cr_unused1; /* compatibility with old ucred */
93 #define XUCRED_VERSION 0
95 #ifdef _KERNEL
97 struct proc;
99 struct ucred *change_euid (uid_t euid);
100 struct ucred *change_ruid (uid_t ruid);
101 struct ucred *cratom (struct ucred **pcr);
102 struct ucred *cratom_proc (struct proc *p);
103 struct ucred *crcopy (struct ucred *cr);
104 struct ucred *crdup (struct ucred *cr);
105 void crfree (struct ucred *cr);
106 void crinit (struct ucred *cr);
107 struct ucred *crget (void);
108 struct ucred *crhold (struct ucred *cr);
109 void cru2x (struct ucred *cr, struct xucred *xcr);
110 int groupmember (gid_t gid, struct ucred *cred);
111 #endif /* _KERNEL */
113 #endif /* !_SYS_UCRED_H_ */