The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/ucred.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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  * 4. 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.
   16  *
   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.
   28  *
   29  *      @(#)ucred.h     8.4 (Berkeley) 1/9/95
   30  * $FreeBSD: src/sys/sys/ucred.h,v 1.49.2.3 2005/07/02 20:14:18 delphij Exp $
   31  */
   32 
   33 #ifndef _SYS_UCRED_H_
   34 #define _SYS_UCRED_H_
   35 
   36 /*
   37  * Credentials.
   38  *
   39  * Please do not inspect cr_uid directly to determine superuserness.
   40  * Only the suser() or suser_cred() function should be used for this.
   41  */
   42 #if defined(_KERNEL) || defined(_WANT_UCRED)
   43 struct ucred {
   44         u_int   cr_ref;                 /* reference count */
   45 #define cr_startcopy cr_uid
   46         uid_t   cr_uid;                 /* effective user id */
   47         uid_t   cr_ruid;                /* real user id */
   48         uid_t   cr_svuid;               /* saved user id */
   49         short   cr_ngroups;             /* number of groups */
   50         gid_t   cr_groups[NGROUPS];     /* groups */
   51         gid_t   cr_rgid;                /* real group id */
   52         gid_t   cr_svgid;               /* saved group id */
   53         struct uidinfo  *cr_uidinfo;    /* per euid resource consumption */
   54         struct uidinfo  *cr_ruidinfo;   /* per ruid resource consumption */
   55         struct prison   *cr_prison;     /* jail(2) */
   56 #define cr_endcopy      cr_label
   57         struct label    *cr_label;      /* MAC label */
   58         struct mtx      *cr_mtxp;       /* protect refcount */
   59 };
   60 #define NOCRED  ((struct ucred *)0)     /* no credential available */
   61 #define FSCRED  ((struct ucred *)-1)    /* filesystem credential */
   62 #endif /* _KERNEL || _WANT_UCRED */
   63 
   64 /*
   65  * This is the external representation of struct ucred.
   66  */
   67 struct xucred {
   68         u_int   cr_version;             /* structure layout version */
   69         uid_t   cr_uid;                 /* effective user id */
   70         short   cr_ngroups;             /* number of groups */
   71         gid_t   cr_groups[NGROUPS];     /* groups */
   72         void    *_cr_unused1;           /* compatibility with old ucred */
   73 };
   74 #define XUCRED_VERSION  0
   75 
   76 /* This can be used for both ucred and xucred structures. */
   77 #define cr_gid cr_groups[0]
   78 
   79 #ifdef _KERNEL
   80 struct thread;
   81 
   82 void    change_egid(struct ucred *newcred, gid_t egid);
   83 void    change_euid(struct ucred *newcred, struct uidinfo *euip);
   84 void    change_rgid(struct ucred *newcred, gid_t rgid);
   85 void    change_ruid(struct ucred *newcred, struct uidinfo *ruip);
   86 void    change_svgid(struct ucred *newcred, gid_t svgid);
   87 void    change_svuid(struct ucred *newcred, uid_t svuid);
   88 void    crcopy(struct ucred *dest, struct ucred *src);
   89 struct ucred    *crdup(struct ucred *cr);
   90 void    cred_update_thread(struct thread *td);
   91 void    crfree(struct ucred *cr);
   92 struct ucred    *crget(void);
   93 struct ucred    *crhold(struct ucred *cr);
   94 int     crshared(struct ucred *cr);
   95 void    cru2x(struct ucred *cr, struct xucred *xcr);
   96 int     groupmember(gid_t gid, struct ucred *cred);
   97 #endif /* _KERNEL */
   98 
   99 #endif /* !_SYS_UCRED_H_ */

Cache object: 9b7e13c59299fba07d21493d613f9387


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.