ucred.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* $OpenBSD: ucred.h,v 1.11 2015/03/02 20:46:50 guenther Exp $ */
  2. /* $NetBSD: ucred.h,v 1.12 1995/06/01 22:44:50 jtc Exp $ */
  3. /*
  4. * Copyright (c) 1989, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * @(#)ucred.h 8.2 (Berkeley) 1/4/94
  32. */
  33. #ifndef _SYS_UCRED_H_
  34. #define _SYS_UCRED_H_
  35. #include <sys/syslimits.h>
  36. /*
  37. * Credentials.
  38. */
  39. struct ucred {
  40. u_int cr_ref; /* reference count */
  41. /* The following fields are all copied by crset() */
  42. #define cr_startcopy cr_uid
  43. uid_t cr_uid; /* effective user id */
  44. uid_t cr_ruid; /* Real user id. */
  45. uid_t cr_svuid; /* Saved effective user id. */
  46. gid_t cr_gid; /* effective group id */
  47. gid_t cr_rgid; /* Real group id. */
  48. gid_t cr_svgid; /* Saved effective group id. */
  49. short cr_ngroups; /* number of groups */
  50. gid_t cr_groups[NGROUPS_MAX]; /* groups */
  51. };
  52. #define NOCRED ((struct ucred *)-1) /* no credential available */
  53. #define FSCRED ((struct ucred *)-2) /* filesystem credential */
  54. /*
  55. * Userspace version, for use in syscalls arguments
  56. */
  57. struct xucred {
  58. uid_t cr_uid; /* user id */
  59. gid_t cr_gid; /* group id */
  60. short cr_ngroups; /* number of groups */
  61. gid_t cr_groups[NGROUPS_MAX]; /* groups */
  62. };
  63. #ifdef _KERNEL
  64. #define crhold(cr) (cr)->cr_ref++
  65. #define SUSER_NOACCT 0x1 /* don't mark accounting flags */
  66. int crfromxucred(struct ucred *, const struct xucred *);
  67. void crset(struct ucred *, const struct ucred *);
  68. struct ucred *crcopy(struct ucred *cr);
  69. struct ucred *crdup(struct ucred *cr);
  70. void crfree(struct ucred *cr);
  71. struct ucred *crget(void);
  72. int suser(struct proc *p, u_int flags);
  73. int suser_ucred(struct ucred *cred);
  74. #endif /* _KERNEL */
  75. #endif /* !_SYS_UCRED_H_ */