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 5*10020SJoep.Vesseur@Sun.COM * Common Development and Distribution License (the "License"). 6*10020SJoep.Vesseur@Sun.COM * 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 /* 22*10020SJoep.Vesseur@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _EXEC_ATTR_H 270Sstevel@tonic-gate #define _EXEC_ATTR_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <sys/types.h> 350Sstevel@tonic-gate #include <secdb.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate 380Sstevel@tonic-gate #define EXECATTR_FILENAME "/etc/security/exec_attr" 390Sstevel@tonic-gate #define EXECATTR_DB_NAME "exec_attr.org_dir" 400Sstevel@tonic-gate #define EXECATTR_DB_NCOL 7 /* total columns */ 410Sstevel@tonic-gate #define EXECATTR_DB_NKEYCOL 3 /* total searchable columns */ 420Sstevel@tonic-gate #define EXECATTR_DB_TBLT "exec_attr_tbl" 430Sstevel@tonic-gate #define EXECATTR_NAME_DEFAULT_KW "nobody" 440Sstevel@tonic-gate 450Sstevel@tonic-gate #define EXECATTR_COL0_KW "name" 460Sstevel@tonic-gate #define EXECATTR_COL1_KW "policy" 470Sstevel@tonic-gate #define EXECATTR_COL2_KW "type" 480Sstevel@tonic-gate #define EXECATTR_COL3_KW "res1" 490Sstevel@tonic-gate #define EXECATTR_COL4_KW "res2" 500Sstevel@tonic-gate #define EXECATTR_COL5_KW "id" 510Sstevel@tonic-gate #define EXECATTR_COL6_KW "attr" 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* 540Sstevel@tonic-gate * indices of searchable columns 550Sstevel@tonic-gate */ 560Sstevel@tonic-gate #define EXECATTR_KEYCOL0 0 /* name */ 570Sstevel@tonic-gate #define EXECATTR_KEYCOL1 1 /* policy */ 580Sstevel@tonic-gate #define EXECATTR_KEYCOL2 5 /* id */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * Some macros used internally by the nsswitch code 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate 65*10020SJoep.Vesseur@Sun.COM /* 66*10020SJoep.Vesseur@Sun.COM * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0 67*10020SJoep.Vesseur@Sun.COM * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield 68*10020SJoep.Vesseur@Sun.COM * 1 and can be logically ORed with GET_ALL if one wants to get 69*10020SJoep.Vesseur@Sun.COM * all matching profiles from all policies, not just the ones from 70*10020SJoep.Vesseur@Sun.COM * the currently active policy 71*10020SJoep.Vesseur@Sun.COM * 72*10020SJoep.Vesseur@Sun.COM * Testing for these values should be done using the IS_* macros 73*10020SJoep.Vesseur@Sun.COM * defined below. 74*10020SJoep.Vesseur@Sun.COM */ 75*10020SJoep.Vesseur@Sun.COM #define GET_ONE 0 76*10020SJoep.Vesseur@Sun.COM #define GET_ALL 1 77*10020SJoep.Vesseur@Sun.COM #define __SEARCH_ALL_POLS 2 780Sstevel@tonic-gate 79*10020SJoep.Vesseur@Sun.COM /* get only one exec_attr from list */ 80*10020SJoep.Vesseur@Sun.COM #define IS_GET_ONE(f) (((f) & GET_ALL) == 0) 81*10020SJoep.Vesseur@Sun.COM /* get all matching exec_attrs in list */ 82*10020SJoep.Vesseur@Sun.COM #define IS_GET_ALL(f) (((f) & GET_ALL) == 1) 83*10020SJoep.Vesseur@Sun.COM /* search all existing policies */ 84*10020SJoep.Vesseur@Sun.COM #define IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS) 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 870Sstevel@tonic-gate * Key words used in the exec_attr database 880Sstevel@tonic-gate */ 890Sstevel@tonic-gate #define EXECATTR_EUID_KW "euid" 900Sstevel@tonic-gate #define EXECATTR_EGID_KW "egid" 910Sstevel@tonic-gate #define EXECATTR_UID_KW "uid" 920Sstevel@tonic-gate #define EXECATTR_GID_KW "gid" 930Sstevel@tonic-gate #define EXECATTR_LPRIV_KW "limitprivs" 940Sstevel@tonic-gate #define EXECATTR_IPRIV_KW "privs" 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * Nsswitch representation of execution attributes. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate typedef struct execstr_s { 1000Sstevel@tonic-gate char *name; /* profile name */ 1010Sstevel@tonic-gate char *policy; /* suser/rbac/tsol */ 1020Sstevel@tonic-gate char *type; /* cmd/act */ 1030Sstevel@tonic-gate char *res1; /* reserved for future use */ 1040Sstevel@tonic-gate char *res2; /* reserved for future use */ 1050Sstevel@tonic-gate char *id; /* unique ID */ 1060Sstevel@tonic-gate char *attr; /* string of key-value pair attributes */ 1070Sstevel@tonic-gate struct execstr_s *next; /* pointer to next entry */ 1080Sstevel@tonic-gate } execstr_t; 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate typedef struct execattr_s { 1110Sstevel@tonic-gate char *name; /* profile name */ 1120Sstevel@tonic-gate char *policy; /* suser/rbac/tsol */ 1130Sstevel@tonic-gate char *type; /* cmd/act */ 1140Sstevel@tonic-gate char *res1; /* reserved for future use */ 1150Sstevel@tonic-gate char *res2; /* reserved for future use */ 1160Sstevel@tonic-gate char *id; /* unique ID */ 1170Sstevel@tonic-gate kva_t *attr; /* array of key-value pair attributes */ 1180Sstevel@tonic-gate struct execattr_s *next; /* pointer to next entry */ 1190Sstevel@tonic-gate } execattr_t; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate typedef struct __private_execattr { 1220Sstevel@tonic-gate const char *name; 1230Sstevel@tonic-gate const char *type; 1240Sstevel@tonic-gate const char *id; 1250Sstevel@tonic-gate const char *policy; 1260Sstevel@tonic-gate int search_flag; 1270Sstevel@tonic-gate execstr_t *head_exec; 1280Sstevel@tonic-gate execstr_t *prev_exec; 1290Sstevel@tonic-gate } _priv_execattr; /* Un-supported. For Sun internal use only */ 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #ifdef __STDC__ 1330Sstevel@tonic-gate extern execattr_t *getexecattr(void); 1340Sstevel@tonic-gate extern execattr_t *getexecuser(const char *, const char *, const char *, int); 1350Sstevel@tonic-gate extern execattr_t *getexecprof(const char *, const char *, const char *, int); 1360Sstevel@tonic-gate extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \ 1370Sstevel@tonic-gate const char *); 1380Sstevel@tonic-gate extern void free_execattr(execattr_t *); 1390Sstevel@tonic-gate extern void setexecattr(void); 1400Sstevel@tonic-gate extern void endexecattr(void); 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate #else /* not __STDC__ */ 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate extern execattr_t *getexecattr(); 1450Sstevel@tonic-gate extern execattr_t *getexecuser(); 1460Sstevel@tonic-gate extern execattr_t *getexecprof(); 1470Sstevel@tonic-gate extern execattr_t *match_execattr(); 1480Sstevel@tonic-gate extern void setexecattr(); 1490Sstevel@tonic-gate extern void endexecattr(); 1500Sstevel@tonic-gate extern void free_execattr(); 1510Sstevel@tonic-gate #endif 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate #ifdef __cplusplus 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate #endif 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #endif /* _EXEC_ATTR_H */ 158