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