xref: /onnv-gate/usr/src/uts/common/sys/cred.h (revision 1676:37f4a3e2bd99)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1676Sjpk  * Common Development and Distribution License (the "License").
6*1676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1676Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
310Sstevel@tonic-gate  * under license from the Regents of the University of California.
320Sstevel@tonic-gate  */
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifndef _SYS_CRED_H
350Sstevel@tonic-gate #define	_SYS_CRED_H
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <sys/types.h>
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #ifdef	__cplusplus
420Sstevel@tonic-gate extern "C" {
430Sstevel@tonic-gate #endif
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * The credential is an opaque kernel private data structure defined in
470Sstevel@tonic-gate  * <sys/cred_impl.h>.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate 
500Sstevel@tonic-gate typedef struct cred cred_t;
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #ifdef _KERNEL
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #define	CRED()		curthread->t_cred
550Sstevel@tonic-gate 
560Sstevel@tonic-gate struct proc;				/* cred.h is included in proc.h */
570Sstevel@tonic-gate struct prcred;
580Sstevel@tonic-gate 
590Sstevel@tonic-gate struct auditinfo_addr;			/* cred.h is included in audit.h */
600Sstevel@tonic-gate 
610Sstevel@tonic-gate extern int ngroups_max;
620Sstevel@tonic-gate /*
630Sstevel@tonic-gate  * kcred is used when you need all privileges.
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate extern struct cred *kcred;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate extern void cred_init(void);
680Sstevel@tonic-gate extern void crhold(cred_t *);
690Sstevel@tonic-gate extern void crfree(cred_t *);
700Sstevel@tonic-gate extern cred_t *cralloc(void);		/* all but ref uninitialized */
710Sstevel@tonic-gate extern cred_t *crget(void);		/* initialized */
720Sstevel@tonic-gate extern cred_t *crcopy(cred_t *);
730Sstevel@tonic-gate extern void crcopy_to(cred_t *, cred_t *);
740Sstevel@tonic-gate extern cred_t *crdup(cred_t *);
750Sstevel@tonic-gate extern void crdup_to(cred_t *, cred_t *);
760Sstevel@tonic-gate extern cred_t *crgetcred(void);
770Sstevel@tonic-gate extern void crset(struct proc *, cred_t *);
780Sstevel@tonic-gate extern int groupmember(gid_t, const cred_t *);
790Sstevel@tonic-gate extern int supgroupmember(gid_t, const cred_t *);
800Sstevel@tonic-gate extern int hasprocperm(const cred_t *, const cred_t *);
810Sstevel@tonic-gate extern int prochasprocperm(struct proc *, struct proc *, const cred_t *);
820Sstevel@tonic-gate extern int crcmp(const cred_t *, const cred_t *);
83*1676Sjpk extern cred_t *zone_kcred(void);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate extern uid_t crgetuid(const cred_t *);
860Sstevel@tonic-gate extern uid_t crgetruid(const cred_t *);
870Sstevel@tonic-gate extern uid_t crgetsuid(const cred_t *);
880Sstevel@tonic-gate extern gid_t crgetgid(const cred_t *);
890Sstevel@tonic-gate extern gid_t crgetrgid(const cred_t *);
900Sstevel@tonic-gate extern gid_t crgetsgid(const cred_t *);
910Sstevel@tonic-gate extern zoneid_t crgetzoneid(const cred_t *);
920Sstevel@tonic-gate extern projid_t crgetprojid(const cred_t *);
930Sstevel@tonic-gate 
94*1676Sjpk 
950Sstevel@tonic-gate extern const struct auditinfo_addr *crgetauinfo(const cred_t *);
960Sstevel@tonic-gate extern struct auditinfo_addr *crgetauinfo_modifiable(cred_t *);
970Sstevel@tonic-gate 
980Sstevel@tonic-gate extern uint_t crgetref(const cred_t *);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate extern const gid_t *crgetgroups(const cred_t *);
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate extern int crgetngroups(const cred_t *);
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * Sets real, effective and/or saved uid/gid;
1060Sstevel@tonic-gate  * -1 argument accepted as "no change".
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate extern int crsetresuid(cred_t *, uid_t, uid_t, uid_t);
1090Sstevel@tonic-gate extern int crsetresgid(cred_t *, gid_t, gid_t, gid_t);
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /*
1120Sstevel@tonic-gate  * Sets real, effective and saved uids/gids all to the same
1130Sstevel@tonic-gate  * values.  Both values must be non-negative and <= MAXUID
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate extern int crsetugid(cred_t *, uid_t, gid_t);
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate extern int crsetgroups(cred_t *, int, gid_t *);
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /*
1200Sstevel@tonic-gate  * Private interface for setting zone association of credential.
1210Sstevel@tonic-gate  */
1220Sstevel@tonic-gate struct zone;
1230Sstevel@tonic-gate extern void crsetzone(cred_t *, struct zone *);
124*1676Sjpk extern struct zone *crgetzone(const cred_t *);
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate /*
1270Sstevel@tonic-gate  * Private interface for setting project id in credential.
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate extern void crsetprojid(cred_t *, projid_t);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate /*
1320Sstevel@tonic-gate  * Private interface for nfs.
1330Sstevel@tonic-gate  */
1340Sstevel@tonic-gate extern cred_t *crnetadjust(cred_t *);
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate /*
1370Sstevel@tonic-gate  * Private interface for procfs.
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate extern void cred2prcred(const cred_t *, struct prcred *);
1400Sstevel@tonic-gate 
141*1676Sjpk /*
142*1676Sjpk  * Private interfaces for Rampart Trusted Solaris.
143*1676Sjpk  */
144*1676Sjpk struct ts_label_s;
145*1676Sjpk extern struct ts_label_s *crgetlabel(const cred_t *);
146*1676Sjpk extern boolean_t crisremote(const cred_t *);
147*1676Sjpk 
1480Sstevel@tonic-gate #endif	/* _KERNEL */
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate #ifdef	__cplusplus
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate #endif
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate #endif	/* _SYS_CRED_H */
155