10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52478Sgww * Common Development and Distribution License (the "License"). 62478Sgww * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 220Sstevel@tonic-gate * adt.h 230Sstevel@tonic-gate * 24*11870SMarek.Pospisil@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 260Sstevel@tonic-gate * 270Sstevel@tonic-gate * This is a contract private interface and is subject to change 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _ADT_H 310Sstevel@tonic-gate #define _ADT_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <bsm/audit.h> 340Sstevel@tonic-gate #include <bsm/libbsm.h> 350Sstevel@tonic-gate #include <bsm/audit_record.h> 360Sstevel@tonic-gate #include <bsm/audit_uevents.h> 370Sstevel@tonic-gate #include <door.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define ADT_STRING_MAX 511 /* max non-null characters */ 440Sstevel@tonic-gate #define ADT_NO_ATTRIB (uid_t)-1 /* unattributed user */ 450Sstevel@tonic-gate #define ADT_NO_CHANGE (uid_t)-2 /* no update for this parameter */ 460Sstevel@tonic-gate #define ADT_NO_AUDIT (uid_t)-3 /* unaudited user */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * terminal id types 500Sstevel@tonic-gate */ 5110645Sgww@eng.sun.com #define ADT_IPv4 1 5210645Sgww@eng.sun.com #define ADT_IPv6 2 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * for adt_set_user(): ADT_NEW if creating a session for a newly 560Sstevel@tonic-gate * authenticated user -- login -- and ADT_UPDATE if an authenticated 570Sstevel@tonic-gate * user is changing uid/gid -- e.g., su. ADT_USER changes only the 580Sstevel@tonic-gate * ruid / euid / rgid / egid values and is appropriate for login-like 590Sstevel@tonic-gate * operations where PAM has already set the audit context in the cred. 600Sstevel@tonic-gate * ADT_SETTID is for the special case where it is necessary to store 610Sstevel@tonic-gate * the terminal id in the credential before forking to the login or 620Sstevel@tonic-gate * login-like process. 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate enum adt_user_context {ADT_NEW, ADT_UPDATE, ADT_USER, ADT_SETTID}; 650Sstevel@tonic-gate 660Sstevel@tonic-gate typedef ulong_t adt_session_flags_t; 670Sstevel@tonic-gate typedef struct adt_session_data adt_session_data_t; 680Sstevel@tonic-gate typedef struct adt_export_data adt_export_data_t; 690Sstevel@tonic-gate typedef union adt_event_data adt_event_data_t; 700Sstevel@tonic-gate typedef struct adt_termid adt_termid_t; 717496Sgww@eng.sun.com typedef struct translation adt_translation_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * flag defs for the flags argument of adt_start_session() 750Sstevel@tonic-gate */ 760Sstevel@tonic-gate 772478Sgww #define ADT_BUFFER_RECORDS 0x2 /* server buffering */ 780Sstevel@tonic-gate #define ADT_USE_PROC_DATA 0x1 /* copy audit char's from proc */ 790Sstevel@tonic-gate /* | all of above = ADT_FLAGS_ALL */ 800Sstevel@tonic-gate #define ADT_FLAGS_ALL ADT_BUFFER_RECORDS | \ 810Sstevel@tonic-gate ADT_USE_PROC_DATA 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * Functions 850Sstevel@tonic-gate */ 860Sstevel@tonic-gate 870Sstevel@tonic-gate extern int adt_start_session(adt_session_data_t **, 880Sstevel@tonic-gate const adt_export_data_t *, 890Sstevel@tonic-gate adt_session_flags_t); 900Sstevel@tonic-gate extern int adt_end_session(adt_session_data_t *); 910Sstevel@tonic-gate extern int adt_dup_session(const adt_session_data_t *, 920Sstevel@tonic-gate adt_session_data_t **); 930Sstevel@tonic-gate 940Sstevel@tonic-gate extern int adt_set_proc(const adt_session_data_t *); 950Sstevel@tonic-gate extern int adt_set_user(const adt_session_data_t *, uid_t, gid_t, 960Sstevel@tonic-gate uid_t, gid_t, const adt_termid_t *, 970Sstevel@tonic-gate enum adt_user_context); 980Sstevel@tonic-gate extern int adt_set_from_ucred(const adt_session_data_t *, 990Sstevel@tonic-gate const ucred_t *, 1000Sstevel@tonic-gate enum adt_user_context); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate extern size_t adt_get_session_id(const adt_session_data_t *, char **); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate extern size_t adt_export_session_data(const adt_session_data_t *, 1050Sstevel@tonic-gate adt_export_data_t **); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate extern adt_event_data_t 1080Sstevel@tonic-gate *adt_alloc_event(const adt_session_data_t *, au_event_t); 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate extern int adt_put_event(const adt_event_data_t *, int, int); 1110Sstevel@tonic-gate extern void adt_free_event(adt_event_data_t *); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate extern int adt_load_termid(int, adt_termid_t **); 1140Sstevel@tonic-gate extern int adt_load_hostname(const char *, adt_termid_t **); 1150Sstevel@tonic-gate extern int adt_load_ttyname(const char *, adt_termid_t **); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate extern boolean_t adt_audit_enabled(void); 1186680Sgww extern boolean_t adt_audit_state(int); 1190Sstevel@tonic-gate 1205622Ssabdar /* 1215622Ssabdar * Special typedefs for translations. 1225622Ssabdar */ 1235622Ssabdar 1245622Ssabdar typedef int fd_t; /* file descriptor */ 1255622Ssabdar 1260Sstevel@tonic-gate #ifdef __cplusplus 1270Sstevel@tonic-gate } 1280Sstevel@tonic-gate #endif 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate #endif /* _ADT_H */ 131