8939 btxld coverity cleanups
[unleashed.git] / include / exec_attr.h
blobf131a2f1d5833845c56bf0eaa199ddf7d0366eda
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #ifndef _EXEC_ATTR_H
29 #define _EXEC_ATTR_H
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 #include <sys/types.h>
37 #include <secdb.h>
40 #define EXECATTR_FILENAME "/etc/security/exec_attr"
41 #define EXECATTR_DB_NAME "exec_attr.org_dir"
42 #define EXECATTR_DB_NCOL 7 /* total columns */
43 #define EXECATTR_DB_NKEYCOL 3 /* total searchable columns */
44 #define EXECATTR_DB_TBLT "exec_attr_tbl"
45 #define EXECATTR_NAME_DEFAULT_KW "nobody"
47 #define EXECATTR_COL0_KW "name"
48 #define EXECATTR_COL1_KW "policy"
49 #define EXECATTR_COL2_KW "type"
50 #define EXECATTR_COL3_KW "res1"
51 #define EXECATTR_COL4_KW "res2"
52 #define EXECATTR_COL5_KW "id"
53 #define EXECATTR_COL6_KW "attr"
56 * indices of searchable columns
58 #define EXECATTR_KEYCOL0 0 /* name */
59 #define EXECATTR_KEYCOL1 1 /* policy */
60 #define EXECATTR_KEYCOL2 5 /* id */
64 * Some macros used internally by the nsswitch code
68 * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0
69 * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield
70 * 1 and can be logically ORed with GET_ALL if one wants to get
71 * all matching profiles from all policies, not just the ones from
72 * the currently active policy
74 * Testing for these values should be done using the IS_* macros
75 * defined below.
77 #define GET_ONE 0
78 #define GET_ALL 1
79 #define __SEARCH_ALL_POLS 2
81 /* get only one exec_attr from list */
82 #define IS_GET_ONE(f) (((f) & GET_ALL) == 0)
83 /* get all matching exec_attrs in list */
84 #define IS_GET_ALL(f) (((f) & GET_ALL) == 1)
85 /* search all existing policies */
86 #define IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS)
89 * Key words used in the exec_attr database
91 #define EXECATTR_EUID_KW "euid"
92 #define EXECATTR_EGID_KW "egid"
93 #define EXECATTR_UID_KW "uid"
94 #define EXECATTR_GID_KW "gid"
95 #define EXECATTR_LPRIV_KW "limitprivs"
96 #define EXECATTR_IPRIV_KW "privs"
99 * Nsswitch representation of execution attributes.
101 typedef struct execstr_s {
102 char *name; /* profile name */
103 char *policy; /* suser/rbac */
104 char *type; /* cmd/act */
105 char *res1; /* reserved for future use */
106 char *res2; /* reserved for future use */
107 char *id; /* unique ID */
108 char *attr; /* string of key-value pair attributes */
109 struct execstr_s *next; /* pointer to next entry */
110 } execstr_t;
112 typedef struct execattr_s {
113 char *name; /* profile name */
114 char *policy; /* suser/rbac */
115 char *type; /* cmd/act */
116 char *res1; /* reserved for future use */
117 char *res2; /* reserved for future use */
118 char *id; /* unique ID */
119 kva_t *attr; /* array of key-value pair attributes */
120 struct execattr_s *next; /* pointer to next entry */
121 } execattr_t;
123 typedef struct __private_execattr {
124 const char *name;
125 const char *type;
126 const char *id;
127 const char *policy;
128 int search_flag;
129 execstr_t *head_exec;
130 execstr_t *prev_exec;
131 } _priv_execattr; /* Un-supported. For Sun internal use only */
134 extern execattr_t *getexecattr(void);
135 extern execattr_t *getexecuser(const char *, const char *, const char *, int);
136 extern execattr_t *getexecprof(const char *, const char *, const char *, int);
137 extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \
138 const char *);
139 extern void free_execattr(execattr_t *);
140 extern void setexecattr(void);
141 extern void endexecattr(void);
143 #ifdef __cplusplus
145 #endif
147 #endif /* _EXEC_ATTR_H */