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