kill tsol ("Trusted Solaris") aka TX ("Trusted Extensions")
[unleashed.git] / usr / src / lib / libbsm / common / devalloc.h
blob0110e4b4da31cf65e93cca2eaf385f2c3ef23b5c
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
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _DEVALLOC_H
28 #define _DEVALLOC_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include <stdio.h>
35 #include <fcntl.h>
36 #include <sys/param.h>
37 #include <secdb.h>
40 * These are unsupported, SUNWprivate interfaces.
43 #define DA_UID (uid_t)0 /* root */
44 #define DA_GID (gid_t)3 /* sys */
45 #define ALLOC_MODE 0600
46 #define DEALLOC_MODE 0000
48 #define LOGINDEVPERM "/etc/logindevperm"
49 #define DA_DB_LOCK "/etc/security/.da_db_lock"
50 #define DA_DEV_LOCK "/etc/security/.da_dev_lock"
51 #define DEVALLOC "/etc/security/device_allocate"
52 #define DEVMAP "/etc/security/device_maps"
53 #define TMPALLOC "/etc/security/.device_allocate"
54 #define TMPMAP "/etc/security/.device_maps"
56 #define DA_DEFAULT_CLEAN "/bin/true"
57 #define DA_DEFAULT_AUDIO_CLEAN "/etc/security/lib/audio_clean_wrapper"
58 #define DA_DEFAULT_DISK_CLEAN "/etc/security/lib/disk_clean"
59 #define DA_DEFAULT_TAPE_CLEAN "/etc/security/lib/st_clean"
61 #define DA_ON_STR "DEVICE_ALLOCATION=ON\n"
62 #define DA_OFF_STR "DEVICE_ALLOCATION=OFF\n"
63 #define DA_DBMODE 0644
64 #define DA_COUNT 5 /* allocatable devices suppported */
65 /* audio, cd, floppy, rmdisk, tape */
66 #define DA_AUTHLEN MAX_CANON /* approx. sum of strlen of all */
67 /* device auths in auth_list.h */
68 #define DA_MAXNAME 80
69 #define DA_MAX_DEVNO ((8 * sizeof (uint64_t)) - 1)
70 #define DA_BUFSIZE 4096
72 #define DA_RDWR O_RDWR|O_CREAT|O_NONBLOCK
73 #define DA_RDONLY O_RDONLY|O_NONBLOCK
75 #define DA_ANYUSER "*"
76 #define DA_NOUSER "@"
78 #define DA_SILENT 0x00000001
79 #define DA_VERBOSE 0x00000002
80 #define DA_ADD 0x00000004
81 #define DA_REMOVE 0x00000008
82 #define DA_UPDATE 0x00000010
83 #define DA_ADD_ZONE 0x00000020
84 #define DA_REMOVE_ZONE 0x00000040
85 #define DA_FORCE 0x00000080
86 #define DA_ALLOC_ONLY 0x00000100
87 #define DA_MAPS_ONLY 0x00000200
88 #define DA_ON 0x00000400
89 #define DA_OFF 0x00000800
90 #define DA_NO_OVERRIDE 0x00001000
91 #define DA_DEFATTRS 0x00002000
92 #define DA_EVENT 0x00004000
94 #define DA_AUDIO 0x00001000
95 #define DA_CD 0x00002000
96 #define DA_FLOPPY 0x00004000
97 #define DA_TAPE 0x00008000
98 #define DA_RMDISK 0x00010000
100 #define DA_AUDIO_NAME "audio"
101 #define DA_SOUND_NAME "sound"
102 #define DA_AUDIO_TYPE DA_AUDIO_NAME
103 #define DA_AUDIO_DIR "/dev/sound/"
105 #define DA_CD_NAME "cdrom"
106 #define DA_CD_TYPE "sr"
108 #define DA_DISK_DIR "/dev/dsk/"
109 #define DA_DISK_DIRR "/dev/rdsk/"
110 #define DA_DISKR_DIR "/dev/(r)dsk"
112 #define DA_FLOPPY_NAME "floppy"
113 #define DA_FLOPPY_TYPE "fd"
115 #define DA_RMDISK_NAME "rmdisk"
116 #define DA_RMDISK_TYPE DA_RMDISK_NAME
118 #define DA_TAPE_NAME "tape"
119 #define DA_TAPE_DIR "/dev/rmt/"
120 #define DA_TAPE_TYPE "st"
122 typedef struct _devinfo_t {
123 char *devname;
124 char *devtype;
125 char *devauths;
126 char *devexec;
127 char *devopts;
128 char *devlist;
129 int instance;
130 } devinfo_t;
132 typedef struct _deventry_t {
133 devinfo_t devinfo;
134 struct _deventry_t *next;
135 } deventry_t;
137 typedef struct _devlist_t {
138 deventry_t *audio;
139 deventry_t *cd;
140 deventry_t *floppy;
141 deventry_t *tape;
142 deventry_t *rmdisk;
143 } devlist_t;
145 typedef struct _da_optargs {
146 int optflag;
147 char *rootdir;
148 char **devnames;
149 devinfo_t *devinfo;
150 } da_args;
152 int da_is_on(void);
153 int da_check_logindevperm(char *);
154 int da_open_devdb(char *, FILE **, FILE **, int);
155 int da_update_device(da_args *);
156 int da_add_list(devlist_t *, char *, int, int);
157 int da_remove_list(devlist_t *, char *, int, char *, int);
158 int da_rm_list_entry(devlist_t *, char *, int, char *);
159 void da_print_device(int, devlist_t *);
162 #ifdef __cplusplus
164 #endif
166 #endif /* _DEVALLOC_H */