17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*01ef659dSJoep Vesseur * Common Development and Distribution License (the "License"). 6*01ef659dSJoep Vesseur * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*01ef659dSJoep Vesseur * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _EXEC_ATTR_H 277c478bd9Sstevel@tonic-gate #define _EXEC_ATTR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <secdb.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #define EXECATTR_FILENAME "/etc/security/exec_attr" 397c478bd9Sstevel@tonic-gate #define EXECATTR_DB_NAME "exec_attr.org_dir" 407c478bd9Sstevel@tonic-gate #define EXECATTR_DB_NCOL 7 /* total columns */ 417c478bd9Sstevel@tonic-gate #define EXECATTR_DB_NKEYCOL 3 /* total searchable columns */ 427c478bd9Sstevel@tonic-gate #define EXECATTR_DB_TBLT "exec_attr_tbl" 437c478bd9Sstevel@tonic-gate #define EXECATTR_NAME_DEFAULT_KW "nobody" 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define EXECATTR_COL0_KW "name" 467c478bd9Sstevel@tonic-gate #define EXECATTR_COL1_KW "policy" 477c478bd9Sstevel@tonic-gate #define EXECATTR_COL2_KW "type" 487c478bd9Sstevel@tonic-gate #define EXECATTR_COL3_KW "res1" 497c478bd9Sstevel@tonic-gate #define EXECATTR_COL4_KW "res2" 507c478bd9Sstevel@tonic-gate #define EXECATTR_COL5_KW "id" 517c478bd9Sstevel@tonic-gate #define EXECATTR_COL6_KW "attr" 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * indices of searchable columns 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #define EXECATTR_KEYCOL0 0 /* name */ 577c478bd9Sstevel@tonic-gate #define EXECATTR_KEYCOL1 1 /* policy */ 587c478bd9Sstevel@tonic-gate #define EXECATTR_KEYCOL2 5 /* id */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Some macros used internally by the nsswitch code 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate 65*01ef659dSJoep Vesseur /* 66*01ef659dSJoep Vesseur * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0 67*01ef659dSJoep Vesseur * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield 68*01ef659dSJoep Vesseur * 1 and can be logically ORed with GET_ALL if one wants to get 69*01ef659dSJoep Vesseur * all matching profiles from all policies, not just the ones from 70*01ef659dSJoep Vesseur * the currently active policy 71*01ef659dSJoep Vesseur * 72*01ef659dSJoep Vesseur * Testing for these values should be done using the IS_* macros 73*01ef659dSJoep Vesseur * defined below. 74*01ef659dSJoep Vesseur */ 75*01ef659dSJoep Vesseur #define GET_ONE 0 76*01ef659dSJoep Vesseur #define GET_ALL 1 77*01ef659dSJoep Vesseur #define __SEARCH_ALL_POLS 2 787c478bd9Sstevel@tonic-gate 79*01ef659dSJoep Vesseur /* get only one exec_attr from list */ 80*01ef659dSJoep Vesseur #define IS_GET_ONE(f) (((f) & GET_ALL) == 0) 81*01ef659dSJoep Vesseur /* get all matching exec_attrs in list */ 82*01ef659dSJoep Vesseur #define IS_GET_ALL(f) (((f) & GET_ALL) == 1) 83*01ef659dSJoep Vesseur /* search all existing policies */ 84*01ef659dSJoep Vesseur #define IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS) 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * Key words used in the exec_attr database 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate #define EXECATTR_EUID_KW "euid" 907c478bd9Sstevel@tonic-gate #define EXECATTR_EGID_KW "egid" 917c478bd9Sstevel@tonic-gate #define EXECATTR_UID_KW "uid" 927c478bd9Sstevel@tonic-gate #define EXECATTR_GID_KW "gid" 937c478bd9Sstevel@tonic-gate #define EXECATTR_LPRIV_KW "limitprivs" 947c478bd9Sstevel@tonic-gate #define EXECATTR_IPRIV_KW "privs" 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Nsswitch representation of execution attributes. 987c478bd9Sstevel@tonic-gate */ 997c478bd9Sstevel@tonic-gate typedef struct execstr_s { 1007c478bd9Sstevel@tonic-gate char *name; /* profile name */ 1017c478bd9Sstevel@tonic-gate char *policy; /* suser/rbac/tsol */ 1027c478bd9Sstevel@tonic-gate char *type; /* cmd/act */ 1037c478bd9Sstevel@tonic-gate char *res1; /* reserved for future use */ 1047c478bd9Sstevel@tonic-gate char *res2; /* reserved for future use */ 1057c478bd9Sstevel@tonic-gate char *id; /* unique ID */ 1067c478bd9Sstevel@tonic-gate char *attr; /* string of key-value pair attributes */ 1077c478bd9Sstevel@tonic-gate struct execstr_s *next; /* pointer to next entry */ 1087c478bd9Sstevel@tonic-gate } execstr_t; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate typedef struct execattr_s { 1117c478bd9Sstevel@tonic-gate char *name; /* profile name */ 1127c478bd9Sstevel@tonic-gate char *policy; /* suser/rbac/tsol */ 1137c478bd9Sstevel@tonic-gate char *type; /* cmd/act */ 1147c478bd9Sstevel@tonic-gate char *res1; /* reserved for future use */ 1157c478bd9Sstevel@tonic-gate char *res2; /* reserved for future use */ 1167c478bd9Sstevel@tonic-gate char *id; /* unique ID */ 1177c478bd9Sstevel@tonic-gate kva_t *attr; /* array of key-value pair attributes */ 1187c478bd9Sstevel@tonic-gate struct execattr_s *next; /* pointer to next entry */ 1197c478bd9Sstevel@tonic-gate } execattr_t; 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate typedef struct __private_execattr { 1227c478bd9Sstevel@tonic-gate const char *name; 1237c478bd9Sstevel@tonic-gate const char *type; 1247c478bd9Sstevel@tonic-gate const char *id; 1257c478bd9Sstevel@tonic-gate const char *policy; 1267c478bd9Sstevel@tonic-gate int search_flag; 1277c478bd9Sstevel@tonic-gate execstr_t *head_exec; 1287c478bd9Sstevel@tonic-gate execstr_t *prev_exec; 1297c478bd9Sstevel@tonic-gate } _priv_execattr; /* Un-supported. For Sun internal use only */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1337c478bd9Sstevel@tonic-gate extern execattr_t *getexecattr(void); 1347c478bd9Sstevel@tonic-gate extern execattr_t *getexecuser(const char *, const char *, const char *, int); 1357c478bd9Sstevel@tonic-gate extern execattr_t *getexecprof(const char *, const char *, const char *, int); 1367c478bd9Sstevel@tonic-gate extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \ 1377c478bd9Sstevel@tonic-gate const char *); 1387c478bd9Sstevel@tonic-gate extern void free_execattr(execattr_t *); 1397c478bd9Sstevel@tonic-gate extern void setexecattr(void); 1407c478bd9Sstevel@tonic-gate extern void endexecattr(void); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #else /* not __STDC__ */ 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate extern execattr_t *getexecattr(); 1457c478bd9Sstevel@tonic-gate extern execattr_t *getexecuser(); 1467c478bd9Sstevel@tonic-gate extern execattr_t *getexecprof(); 1477c478bd9Sstevel@tonic-gate extern execattr_t *match_execattr(); 1487c478bd9Sstevel@tonic-gate extern void setexecattr(); 1497c478bd9Sstevel@tonic-gate extern void endexecattr(); 1507c478bd9Sstevel@tonic-gate extern void free_execattr(); 1517c478bd9Sstevel@tonic-gate #endif 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate #endif 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #endif /* _EXEC_ATTR_H */ 158