xref: /titanic_41/usr/src/head/exec_attr.h (revision 6dfee4834394825da35b977ca71cdc965bc7b6a4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_EXEC_ATTR_H
28 #define	_EXEC_ATTR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 #include <sys/types.h>
38 #include <secdb.h>
39 
40 
41 #define	EXECATTR_FILENAME		"/etc/security/exec_attr"
42 #define	EXECATTR_DB_NAME		"exec_attr.org_dir"
43 #define	EXECATTR_DB_NCOL		7	/* total columns */
44 #define	EXECATTR_DB_NKEYCOL		3	/* total searchable columns */
45 #define	EXECATTR_DB_TBLT		"exec_attr_tbl"
46 #define	EXECATTR_NAME_DEFAULT_KW	"nobody"
47 
48 #define	EXECATTR_COL0_KW		"name"
49 #define	EXECATTR_COL1_KW		"policy"
50 #define	EXECATTR_COL2_KW		"type"
51 #define	EXECATTR_COL3_KW		"res1"
52 #define	EXECATTR_COL4_KW		"res2"
53 #define	EXECATTR_COL5_KW		"id"
54 #define	EXECATTR_COL6_KW		"attr"
55 
56 /*
57  * indices of searchable columns
58  */
59 #define	EXECATTR_KEYCOL0		0	/* name */
60 #define	EXECATTR_KEYCOL1		1	/* policy */
61 #define	EXECATTR_KEYCOL2		5	/* id */
62 
63 
64 /*
65  * Some macros used internally by the nsswitch code
66  */
67 
68 #define	GET_ONE		0	/* get only one exec_attr from list */
69 #define	GET_ALL		1	/* get all matching exec_attrs in list */
70 
71 
72 /*
73  * Key words used in the exec_attr database
74  */
75 #define	EXECATTR_EUID_KW	"euid"
76 #define	EXECATTR_EGID_KW	"egid"
77 #define	EXECATTR_UID_KW		"uid"
78 #define	EXECATTR_GID_KW		"gid"
79 #define	EXECATTR_LPRIV_KW	"limitprivs"
80 #define	EXECATTR_IPRIV_KW	"privs"
81 
82 /*
83  * Nsswitch representation of execution attributes.
84  */
85 typedef struct execstr_s {
86 	char   *name;		/* profile name */
87 	char   *policy;		/* suser/rbac/tsol */
88 	char   *type;		/* cmd/act */
89 	char   *res1;		/* reserved for future use */
90 	char   *res2;		/* reserved for future use */
91 	char   *id;		/* unique ID */
92 	char   *attr;		/* string of key-value pair attributes */
93 	struct execstr_s *next;	/* pointer to next entry */
94 } execstr_t;
95 
96 typedef struct execattr_s {
97 	char   *name;		/* profile name */
98 	char   *policy;		/* suser/rbac/tsol */
99 	char   *type;		/* cmd/act */
100 	char   *res1;		/* reserved for future use */
101 	char   *res2;		/* reserved for future use */
102 	char   *id;		/* unique ID */
103 	kva_t  *attr;		/* array of key-value pair attributes */
104 	struct execattr_s *next;	/* pointer to next entry */
105 } execattr_t;
106 
107 typedef struct __private_execattr {
108 	const char *name;
109 	const char *type;
110 	const char *id;
111 	const char *policy;
112 	int search_flag;
113 	execstr_t *head_exec;
114 	execstr_t *prev_exec;
115 } _priv_execattr;		/* Un-supported. For Sun internal use only */
116 
117 
118 #ifdef    __STDC__
119 extern execattr_t *getexecattr(void);
120 extern execattr_t *getexecuser(const char *, const char *, const char *, int);
121 extern execattr_t *getexecprof(const char *, const char *, const char *, int);
122 extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \
123 	const char *);
124 extern void free_execattr(execattr_t *);
125 extern void setexecattr(void);
126 extern void endexecattr(void);
127 
128 #else				/* not __STDC__ */
129 
130 extern execattr_t *getexecattr();
131 extern execattr_t *getexecuser();
132 extern execattr_t *getexecprof();
133 extern execattr_t *match_execattr();
134 extern void setexecattr();
135 extern void endexecattr();
136 extern void free_execattr();
137 #endif
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif	/* _EXEC_ATTR_H */
144