xref: /titanic_52/usr/src/head/exec_attr.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
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
501ef659dSJoep Vesseur  * Common Development and Distribution License (the "License").
601ef659dSJoep 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*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23*ba3594baSGarrett D'Amore  *
2401ef659dSJoep Vesseur  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_EXEC_ATTR_H
297c478bd9Sstevel@tonic-gate #define	_EXEC_ATTR_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <secdb.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #define	EXECATTR_FILENAME		"/etc/security/exec_attr"
417c478bd9Sstevel@tonic-gate #define	EXECATTR_DB_NAME		"exec_attr.org_dir"
427c478bd9Sstevel@tonic-gate #define	EXECATTR_DB_NCOL		7	/* total columns */
437c478bd9Sstevel@tonic-gate #define	EXECATTR_DB_NKEYCOL		3	/* total searchable columns */
447c478bd9Sstevel@tonic-gate #define	EXECATTR_DB_TBLT		"exec_attr_tbl"
457c478bd9Sstevel@tonic-gate #define	EXECATTR_NAME_DEFAULT_KW	"nobody"
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	EXECATTR_COL0_KW		"name"
487c478bd9Sstevel@tonic-gate #define	EXECATTR_COL1_KW		"policy"
497c478bd9Sstevel@tonic-gate #define	EXECATTR_COL2_KW		"type"
507c478bd9Sstevel@tonic-gate #define	EXECATTR_COL3_KW		"res1"
517c478bd9Sstevel@tonic-gate #define	EXECATTR_COL4_KW		"res2"
527c478bd9Sstevel@tonic-gate #define	EXECATTR_COL5_KW		"id"
537c478bd9Sstevel@tonic-gate #define	EXECATTR_COL6_KW		"attr"
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * indices of searchable columns
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate #define	EXECATTR_KEYCOL0		0	/* name */
597c478bd9Sstevel@tonic-gate #define	EXECATTR_KEYCOL1		1	/* policy */
607c478bd9Sstevel@tonic-gate #define	EXECATTR_KEYCOL2		5	/* id */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * Some macros used internally by the nsswitch code
657c478bd9Sstevel@tonic-gate  */
667c478bd9Sstevel@tonic-gate 
6701ef659dSJoep Vesseur /*
6801ef659dSJoep Vesseur  * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0
6901ef659dSJoep Vesseur  * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield
7001ef659dSJoep Vesseur  * 1 and can be logically ORed with GET_ALL if one wants to get
7101ef659dSJoep Vesseur  * all matching profiles from all policies, not just the ones from
7201ef659dSJoep Vesseur  * the currently active policy
7301ef659dSJoep Vesseur  *
7401ef659dSJoep Vesseur  * Testing for these values should be done using the IS_* macros
7501ef659dSJoep Vesseur  * defined below.
7601ef659dSJoep Vesseur  */
7701ef659dSJoep Vesseur #define	GET_ONE			0
7801ef659dSJoep Vesseur #define	GET_ALL			1
7901ef659dSJoep Vesseur #define	__SEARCH_ALL_POLS	2
807c478bd9Sstevel@tonic-gate 
8101ef659dSJoep Vesseur /* get only one exec_attr from list */
8201ef659dSJoep Vesseur #define	IS_GET_ONE(f) (((f) & GET_ALL) == 0)
8301ef659dSJoep Vesseur /* get all matching exec_attrs in list */
8401ef659dSJoep Vesseur #define	IS_GET_ALL(f) (((f) & GET_ALL) == 1)
8501ef659dSJoep Vesseur /* search all existing policies */
8601ef659dSJoep Vesseur #define	IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS)
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * Key words used in the exec_attr database
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate #define	EXECATTR_EUID_KW	"euid"
927c478bd9Sstevel@tonic-gate #define	EXECATTR_EGID_KW	"egid"
937c478bd9Sstevel@tonic-gate #define	EXECATTR_UID_KW		"uid"
947c478bd9Sstevel@tonic-gate #define	EXECATTR_GID_KW		"gid"
957c478bd9Sstevel@tonic-gate #define	EXECATTR_LPRIV_KW	"limitprivs"
967c478bd9Sstevel@tonic-gate #define	EXECATTR_IPRIV_KW	"privs"
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * Nsswitch representation of execution attributes.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate typedef struct execstr_s {
1027c478bd9Sstevel@tonic-gate 	char   *name;		/* profile name */
1037c478bd9Sstevel@tonic-gate 	char   *policy;		/* suser/rbac/tsol */
1047c478bd9Sstevel@tonic-gate 	char   *type;		/* cmd/act */
1057c478bd9Sstevel@tonic-gate 	char   *res1;		/* reserved for future use */
1067c478bd9Sstevel@tonic-gate 	char   *res2;		/* reserved for future use */
1077c478bd9Sstevel@tonic-gate 	char   *id;		/* unique ID */
1087c478bd9Sstevel@tonic-gate 	char   *attr;		/* string of key-value pair attributes */
1097c478bd9Sstevel@tonic-gate 	struct execstr_s *next;	/* pointer to next entry */
1107c478bd9Sstevel@tonic-gate } execstr_t;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate typedef struct execattr_s {
1137c478bd9Sstevel@tonic-gate 	char   *name;		/* profile name */
1147c478bd9Sstevel@tonic-gate 	char   *policy;		/* suser/rbac/tsol */
1157c478bd9Sstevel@tonic-gate 	char   *type;		/* cmd/act */
1167c478bd9Sstevel@tonic-gate 	char   *res1;		/* reserved for future use */
1177c478bd9Sstevel@tonic-gate 	char   *res2;		/* reserved for future use */
1187c478bd9Sstevel@tonic-gate 	char   *id;		/* unique ID */
1197c478bd9Sstevel@tonic-gate 	kva_t  *attr;		/* array of key-value pair attributes */
1207c478bd9Sstevel@tonic-gate 	struct execattr_s *next;	/* pointer to next entry */
1217c478bd9Sstevel@tonic-gate } execattr_t;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate typedef struct __private_execattr {
1247c478bd9Sstevel@tonic-gate 	const char *name;
1257c478bd9Sstevel@tonic-gate 	const char *type;
1267c478bd9Sstevel@tonic-gate 	const char *id;
1277c478bd9Sstevel@tonic-gate 	const char *policy;
1287c478bd9Sstevel@tonic-gate 	int search_flag;
1297c478bd9Sstevel@tonic-gate 	execstr_t *head_exec;
1307c478bd9Sstevel@tonic-gate 	execstr_t *prev_exec;
1317c478bd9Sstevel@tonic-gate } _priv_execattr;		/* Un-supported. For Sun internal use only */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate extern execattr_t *getexecattr(void);
1357c478bd9Sstevel@tonic-gate extern execattr_t *getexecuser(const char *, const char *, const char *, int);
1367c478bd9Sstevel@tonic-gate extern execattr_t *getexecprof(const char *, const char *, const char *, int);
1377c478bd9Sstevel@tonic-gate extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \
1387c478bd9Sstevel@tonic-gate 	const char *);
1397c478bd9Sstevel@tonic-gate extern void free_execattr(execattr_t *);
1407c478bd9Sstevel@tonic-gate extern void setexecattr(void);
1417c478bd9Sstevel@tonic-gate extern void endexecattr(void);
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1447c478bd9Sstevel@tonic-gate }
1457c478bd9Sstevel@tonic-gate #endif
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #endif	/* _EXEC_ATTR_H */
148