FreeBSD/Linux Kernel Cross Reference
sys/sys/ucred.h
1 /*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
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. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ucred.h 8.4 (Berkeley) 1/9/95
34 * $FreeBSD: releng/5.2/sys/sys/ucred.h 122562 2003-11-12 15:07:18Z bde $
35 */
36
37 #ifndef _SYS_UCRED_H_
38 #define _SYS_UCRED_H_
39
40 /*
41 * Credentials.
42 *
43 * Please do not inspect cr_uid directly to determine superuserness.
44 * Only the suser() or suser_cred() function should be used for this.
45 */
46 #if defined(_KERNEL) || defined(_WANT_UCRED)
47 struct ucred {
48 u_int cr_ref; /* reference count */
49 #define cr_startcopy cr_uid
50 uid_t cr_uid; /* effective user id */
51 uid_t cr_ruid; /* real user id */
52 uid_t cr_svuid; /* saved user id */
53 short cr_ngroups; /* number of groups */
54 gid_t cr_groups[NGROUPS]; /* groups */
55 gid_t cr_rgid; /* real group id */
56 gid_t cr_svgid; /* saved user id */
57 struct uidinfo *cr_uidinfo; /* per euid resource consumption */
58 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
59 struct prison *cr_prison; /* jail(2) */
60 #define cr_endcopy cr_label
61 struct label *cr_label; /* MAC label */
62 struct mtx *cr_mtxp; /* protect refcount */
63 };
64 #define NOCRED ((struct ucred *)0) /* no credential available */
65 #define FSCRED ((struct ucred *)-1) /* filesystem credential */
66 #endif /* _KERNEL || _WANT_UCRED */
67
68 /*
69 * This is the external representation of struct ucred.
70 */
71 struct xucred {
72 u_int cr_version; /* structure layout version */
73 uid_t cr_uid; /* effective user id */
74 short cr_ngroups; /* number of groups */
75 gid_t cr_groups[NGROUPS]; /* groups */
76 void *_cr_unused1; /* compatibility with old ucred */
77 };
78 #define XUCRED_VERSION 0
79
80 /* This can be used for both ucred and xucred structures. */
81 #define cr_gid cr_groups[0]
82
83 #ifdef _KERNEL
84 struct thread;
85
86 void change_egid(struct ucred *newcred, gid_t egid);
87 void change_euid(struct ucred *newcred, struct uidinfo *euip);
88 void change_rgid(struct ucred *newcred, gid_t rgid);
89 void change_ruid(struct ucred *newcred, struct uidinfo *ruip);
90 void change_svgid(struct ucred *newcred, gid_t svgid);
91 void change_svuid(struct ucred *newcred, uid_t svuid);
92 void crcopy(struct ucred *dest, struct ucred *src);
93 struct ucred *crdup(struct ucred *cr);
94 #ifdef DIAGNOSTIC
95 void cred_free_thread(struct thread *td);
96 #endif
97 void cred_update_thread(struct thread *td);
98 void crfree(struct ucred *cr);
99 struct ucred *crget(void);
100 struct ucred *crhold(struct ucred *cr);
101 int crshared(struct ucred *cr);
102 void cru2x(struct ucred *cr, struct xucred *xcr);
103 int groupmember(gid_t gid, struct ucred *cred);
104 #endif /* _KERNEL */
105
106 #endif /* !_SYS_UCRED_H_ */
Cache object: ce2af5111f109fa228994a5fba5500af
|