/usr/src/lib/libbsm/common/adt.h

https://github.com/buffygb/illumos-gate · C Header · 130 lines · 57 code · 22 blank · 51 comment · 0 complexity · f0abbf92dcb9e7877faa568ab4c56b27 MD5 · raw file

  1. /*
  2. * CDDL HEADER START
  3. *
  4. * The contents of this file are subject to the terms of the
  5. * Common Development and Distribution License (the "License").
  6. * You may not use this file except in compliance with the License.
  7. *
  8. * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  9. * or http://www.opensolaris.org/os/licensing.
  10. * See the License for the specific language governing permissions
  11. * and limitations under the License.
  12. *
  13. * When distributing Covered Code, include this CDDL HEADER in each
  14. * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15. * If applicable, add the following below this CDDL HEADER, with the
  16. * fields enclosed by brackets "[]" replaced with your own identifying
  17. * information: Portions Copyright [yyyy] [name of copyright owner]
  18. *
  19. * CDDL HEADER END
  20. */
  21. /*
  22. * adt.h
  23. *
  24. * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
  25. * Use is subject to license terms.
  26. *
  27. * This is a contract private interface and is subject to change
  28. */
  29. #ifndef _ADT_H
  30. #define _ADT_H
  31. #include <bsm/audit.h>
  32. #include <bsm/libbsm.h>
  33. #include <bsm/audit_record.h>
  34. #include <bsm/audit_uevents.h>
  35. #include <door.h>
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #define ADT_STRING_MAX 511 /* max non-null characters */
  40. #define ADT_NO_ATTRIB (uid_t)-1 /* unattributed user */
  41. #define ADT_NO_CHANGE (uid_t)-2 /* no update for this parameter */
  42. #define ADT_NO_AUDIT (uid_t)-3 /* unaudited user */
  43. /*
  44. * terminal id types
  45. */
  46. #define ADT_IPv4 1
  47. #define ADT_IPv6 2
  48. /*
  49. * for adt_set_user(): ADT_NEW if creating a session for a newly
  50. * authenticated user -- login -- and ADT_UPDATE if an authenticated
  51. * user is changing uid/gid -- e.g., su. ADT_USER changes only the
  52. * ruid / euid / rgid / egid values and is appropriate for login-like
  53. * operations where PAM has already set the audit context in the cred.
  54. * ADT_SETTID is for the special case where it is necessary to store
  55. * the terminal id in the credential before forking to the login or
  56. * login-like process.
  57. */
  58. enum adt_user_context {ADT_NEW, ADT_UPDATE, ADT_USER, ADT_SETTID};
  59. typedef ulong_t adt_session_flags_t;
  60. typedef struct adt_session_data adt_session_data_t;
  61. typedef struct adt_export_data adt_export_data_t;
  62. typedef union adt_event_data adt_event_data_t;
  63. typedef struct adt_termid adt_termid_t;
  64. typedef struct translation adt_translation_t;
  65. /*
  66. * flag defs for the flags argument of adt_start_session()
  67. */
  68. #define ADT_BUFFER_RECORDS 0x2 /* server buffering */
  69. #define ADT_USE_PROC_DATA 0x1 /* copy audit char's from proc */
  70. /* | all of above = ADT_FLAGS_ALL */
  71. #define ADT_FLAGS_ALL ADT_BUFFER_RECORDS | \
  72. ADT_USE_PROC_DATA
  73. /*
  74. * Functions
  75. */
  76. extern int adt_start_session(adt_session_data_t **,
  77. const adt_export_data_t *,
  78. adt_session_flags_t);
  79. extern int adt_end_session(adt_session_data_t *);
  80. extern int adt_dup_session(const adt_session_data_t *,
  81. adt_session_data_t **);
  82. extern int adt_set_proc(const adt_session_data_t *);
  83. extern int adt_set_user(const adt_session_data_t *, uid_t, gid_t,
  84. uid_t, gid_t, const adt_termid_t *,
  85. enum adt_user_context);
  86. extern int adt_set_from_ucred(const adt_session_data_t *,
  87. const ucred_t *,
  88. enum adt_user_context);
  89. extern size_t adt_get_session_id(const adt_session_data_t *, char **);
  90. extern size_t adt_export_session_data(const adt_session_data_t *,
  91. adt_export_data_t **);
  92. extern adt_event_data_t
  93. *adt_alloc_event(const adt_session_data_t *, au_event_t);
  94. extern int adt_put_event(const adt_event_data_t *, int, int);
  95. extern void adt_free_event(adt_event_data_t *);
  96. extern int adt_load_termid(int, adt_termid_t **);
  97. extern int adt_load_hostname(const char *, adt_termid_t **);
  98. extern int adt_load_ttyname(const char *, adt_termid_t **);
  99. extern boolean_t adt_audit_enabled(void);
  100. extern boolean_t adt_audit_state(int);
  101. /*
  102. * Special typedefs for translations.
  103. */
  104. typedef int fd_t; /* file descriptor */
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* _ADT_H */