xref: /titanic_51/usr/src/lib/libbsm/common/devalloc.h (revision a6d42e7d71324c5193c3b94d57d96ba2925d52e1)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DEVALLOC_H
28 #define	_DEVALLOC_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdio.h>
37 #include <fcntl.h>
38 #include <sys/param.h>
39 #include <secdb.h>
40 
41 /*
42  * These are unsupported, SUNWprivate interfaces.
43  */
44 
45 #define	DA_UID			(uid_t)0	/* root */
46 #define	DA_GID			(gid_t)3	/* sys */
47 #define	ALLOC_MODE		0600
48 #define	DEALLOC_MODE    	0000
49 
50 #define	LOGINDEVPERM		"/etc/logindevperm"
51 #define	DA_DB_LOCK		"/etc/security/.da_db_lock"
52 #define	DA_DEV_LOCK		"/etc/security/.da_dev_lock"
53 #define	DEVALLOC		"/etc/security/device_allocate"
54 #define	DEVMAP			"/etc/security/device_maps"
55 #define	DEFATTRS		"/etc/security/tsol/devalloc_defaults"
56 #define	TMPALLOC		"/etc/security/.device_allocate"
57 #define	TMPMAP			"/etc/security/.device_maps"
58 #define	TMPATTRS		"/etc/security/tsol/.devalloc_defaults"
59 
60 #define	DA_DEFAULT_MIN		"admin_low"
61 #define	DA_DEFAULT_MAX		"admin_high"
62 #define	DA_DEFAULT_CLEAN	"/bin/true"
63 #define	DA_DEFAULT_AUDIO_CLEAN	"/etc/security/lib/audio_clean_wrapper"
64 #define	DA_DEFAULT_DISK_CLEAN	"/etc/security/lib/disk_clean"
65 #define	DA_DEFAULT_TAPE_CLEAN	"/etc/security/lib/st_clean"
66 
67 #define	DA_ON_STR		"DEVICE_ALLOCATION=ON\n"
68 #define	DA_OFF_STR		"DEVICE_ALLOCATION=OFF\n"
69 #define	DA_IS_LABELED		"system_labeled"
70 #define	DA_DBMODE		0644
71 #define	DA_COUNT		5	/* allocatable devices suppported */
72 					/* audio, cd, floppy, rmdisk, tape */
73 #define	DA_AUTHLEN		MAX_CANON   /* approx. sum of strlen of all */
74 					    /* device auths in auth_list.h */
75 #define	DA_MAXNAME		80
76 #define	DA_BUFSIZE		4096
77 
78 #define	DA_RDWR			O_RDWR|O_CREAT|O_NONBLOCK
79 #define	DA_RDONLY		O_RDONLY|O_NONBLOCK
80 
81 #define	DA_ANYUSER		"*"
82 #define	DA_NOUSER		"@"
83 
84 #define	DA_SILENT		0x00000001
85 #define	DA_VERBOSE		0x00000002
86 #define	DA_ADD			0x00000004
87 #define	DA_REMOVE		0x00000008
88 #define	DA_UPDATE		0x00000010
89 #define	DA_ADD_ZONE		0x00000020
90 #define	DA_REMOVE_ZONE		0x00000040
91 #define	DA_FORCE		0x00000080
92 #define	DA_ALLOC_ONLY		0x00000100
93 #define	DA_MAPS_ONLY		0x00000200
94 #define	DA_ON			0x00000400
95 #define	DA_OFF			0x00000800
96 #define	DA_NO_OVERRIDE		0x00001000
97 #define	DA_DEFATTRS		0x00002000
98 
99 #define	DA_AUDIO		0x00001000
100 #define	DA_CD			0x00002000
101 #define	DA_FLOPPY		0x00004000
102 #define	DA_TAPE			0x00008000
103 #define	DA_RMDISK		0x00010000
104 
105 #define	DA_AUDIO_NAME		"audio"
106 #define	DA_SOUND_NAME		"sound"
107 #define	DA_AUDIO_TYPE		DA_AUDIO_NAME
108 #define	DA_AUDIO_DIR		"/dev/sound/"
109 
110 #define	DA_CD_NAME		"cdrom"
111 #define	DA_CD_TYPE		"sr"
112 
113 #define	DA_DISK_DIR		"/dev/dsk/"
114 #define	DA_DISK_DIRR		"/dev/rdsk/"
115 #define	DA_DISKR_DIR		"/dev/(r)dsk"
116 
117 #define	DA_FLOPPY_NAME		"floppy"
118 #define	DA_FLOPPY_TYPE		"fd"
119 
120 #define	DA_RMDISK_NAME		"rmdisk"
121 #define	DA_RMDISK_TYPE		DA_RMDISK_NAME
122 
123 #define	DA_TAPE_NAME		"tape"
124 #define	DA_TAPE_DIR		"/dev/rmt/"
125 #define	DA_TAPE_TYPE		"st"
126 
127 typedef struct _devinfo_t {
128 	char	*devname;
129 	char	*devtype;
130 	char	*devauths;
131 	char	*devexec;
132 	char	*devopts;
133 	char	*devlist;
134 	int	instance;
135 } devinfo_t;
136 
137 typedef struct _deventry_t {
138 	devinfo_t		devinfo;
139 	struct _deventry_t	*next;
140 } deventry_t;
141 
142 typedef struct _devlist_t {
143 	deventry_t	*audio;
144 	deventry_t	*cd;
145 	deventry_t	*floppy;
146 	deventry_t	*tape;
147 	deventry_t	*rmdisk;
148 } devlist_t;
149 
150 typedef struct _da_optargs {
151 	int		optflag;
152 	char		*rootdir;
153 	char		**devnames;
154 	devinfo_t	*devinfo;
155 } da_args;
156 
157 typedef struct _da_defs {
158 	char		*devtype;
159 	kva_t		*devopts;
160 } da_defs_t;
161 
162 da_defs_t *getdadefent(void);
163 da_defs_t *getdadeftype(char *);
164 void freedadefent(da_defs_t *);
165 void setdadefent(void);
166 void enddadefent(void);
167 int da_is_on(void);
168 int da_check_logindevperm(char *);
169 int da_open_devdb(char *, FILE **, FILE **, int);
170 int da_update_device(da_args *);
171 int da_update_defattrs(da_args *);
172 int da_add_list(devlist_t *, char *, int, int);
173 int da_remove_list(devlist_t *, char *, int, char *, int);
174 void da_print_device(int, devlist_t *);
175 
176 
177 #ifdef	__cplusplus
178 }
179 #endif
180 
181 #endif	/* _DEVALLOC_H */
182