145916cd2Sjpk /* 245916cd2Sjpk * CDDL HEADER START 345916cd2Sjpk * 445916cd2Sjpk * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 745916cd2Sjpk * 845916cd2Sjpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 945916cd2Sjpk * or http://www.opensolaris.org/os/licensing. 1045916cd2Sjpk * See the License for the specific language governing permissions 1145916cd2Sjpk * and limitations under the License. 1245916cd2Sjpk * 1345916cd2Sjpk * When distributing Covered Code, include this CDDL HEADER in each 1445916cd2Sjpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1545916cd2Sjpk * If applicable, add the following below this CDDL HEADER, with the 1645916cd2Sjpk * fields enclosed by brackets "[]" replaced with your own identifying 1745916cd2Sjpk * information: Portions Copyright [yyyy] [name of copyright owner] 1845916cd2Sjpk * 1945916cd2Sjpk * CDDL HEADER END 2045916cd2Sjpk */ 2145916cd2Sjpk 2245916cd2Sjpk /* 23*7e3e5701SJan Parcel * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2445916cd2Sjpk * Use is subject to license terms. 2545916cd2Sjpk */ 2645916cd2Sjpk 2745916cd2Sjpk #ifndef _DEVALLOC_H 2845916cd2Sjpk #define _DEVALLOC_H 2945916cd2Sjpk 3045916cd2Sjpk #ifdef __cplusplus 3145916cd2Sjpk extern "C" { 3245916cd2Sjpk #endif 3345916cd2Sjpk 3445916cd2Sjpk #include <stdio.h> 3545916cd2Sjpk #include <fcntl.h> 3645916cd2Sjpk #include <sys/param.h> 3745916cd2Sjpk #include <secdb.h> 3845916cd2Sjpk 3945916cd2Sjpk /* 4045916cd2Sjpk * These are unsupported, SUNWprivate interfaces. 4145916cd2Sjpk */ 4245916cd2Sjpk 4345916cd2Sjpk #define DA_UID (uid_t)0 /* root */ 4445916cd2Sjpk #define DA_GID (gid_t)3 /* sys */ 4510ddde3aSaj #define ALLOC_MODE 0600 4610ddde3aSaj #define DEALLOC_MODE 0000 4710ddde3aSaj 4845916cd2Sjpk #define LOGINDEVPERM "/etc/logindevperm" 4945916cd2Sjpk #define DA_DB_LOCK "/etc/security/.da_db_lock" 5045916cd2Sjpk #define DA_DEV_LOCK "/etc/security/.da_dev_lock" 5145916cd2Sjpk #define DEVALLOC "/etc/security/device_allocate" 5245916cd2Sjpk #define DEVMAP "/etc/security/device_maps" 5345916cd2Sjpk #define DEFATTRS "/etc/security/tsol/devalloc_defaults" 5445916cd2Sjpk #define TMPALLOC "/etc/security/.device_allocate" 5545916cd2Sjpk #define TMPMAP "/etc/security/.device_maps" 5645916cd2Sjpk #define TMPATTRS "/etc/security/tsol/.devalloc_defaults" 5745916cd2Sjpk 5845916cd2Sjpk #define DA_DEFAULT_MIN "admin_low" 5945916cd2Sjpk #define DA_DEFAULT_MAX "admin_high" 6045916cd2Sjpk #define DA_DEFAULT_CLEAN "/bin/true" 6145916cd2Sjpk #define DA_DEFAULT_AUDIO_CLEAN "/etc/security/lib/audio_clean_wrapper" 6245916cd2Sjpk #define DA_DEFAULT_DISK_CLEAN "/etc/security/lib/disk_clean" 6345916cd2Sjpk #define DA_DEFAULT_TAPE_CLEAN "/etc/security/lib/st_clean" 6445916cd2Sjpk 6545916cd2Sjpk #define DA_ON_STR "DEVICE_ALLOCATION=ON\n" 6645916cd2Sjpk #define DA_OFF_STR "DEVICE_ALLOCATION=OFF\n" 6745916cd2Sjpk #define DA_IS_LABELED "system_labeled" 6845916cd2Sjpk #define DA_DBMODE 0644 6945916cd2Sjpk #define DA_COUNT 5 /* allocatable devices suppported */ 7045916cd2Sjpk /* audio, cd, floppy, rmdisk, tape */ 7145916cd2Sjpk #define DA_AUTHLEN MAX_CANON /* approx. sum of strlen of all */ 7245916cd2Sjpk /* device auths in auth_list.h */ 7345916cd2Sjpk #define DA_MAXNAME 80 74*7e3e5701SJan Parcel #define DA_MAX_DEVNO ((8 * sizeof (uint64_t)) - 1) 7545916cd2Sjpk #define DA_BUFSIZE 4096 7645916cd2Sjpk 7745916cd2Sjpk #define DA_RDWR O_RDWR|O_CREAT|O_NONBLOCK 7845916cd2Sjpk #define DA_RDONLY O_RDONLY|O_NONBLOCK 7945916cd2Sjpk 8045916cd2Sjpk #define DA_ANYUSER "*" 8145916cd2Sjpk #define DA_NOUSER "@" 8245916cd2Sjpk 8345916cd2Sjpk #define DA_SILENT 0x00000001 8445916cd2Sjpk #define DA_VERBOSE 0x00000002 8545916cd2Sjpk #define DA_ADD 0x00000004 8645916cd2Sjpk #define DA_REMOVE 0x00000008 8745916cd2Sjpk #define DA_UPDATE 0x00000010 8845916cd2Sjpk #define DA_ADD_ZONE 0x00000020 8945916cd2Sjpk #define DA_REMOVE_ZONE 0x00000040 9045916cd2Sjpk #define DA_FORCE 0x00000080 9145916cd2Sjpk #define DA_ALLOC_ONLY 0x00000100 9245916cd2Sjpk #define DA_MAPS_ONLY 0x00000200 9345916cd2Sjpk #define DA_ON 0x00000400 9445916cd2Sjpk #define DA_OFF 0x00000800 9545916cd2Sjpk #define DA_NO_OVERRIDE 0x00001000 9645916cd2Sjpk #define DA_DEFATTRS 0x00002000 97*7e3e5701SJan Parcel #define DA_EVENT 0x00004000 9845916cd2Sjpk 9945916cd2Sjpk #define DA_AUDIO 0x00001000 10045916cd2Sjpk #define DA_CD 0x00002000 10145916cd2Sjpk #define DA_FLOPPY 0x00004000 10245916cd2Sjpk #define DA_TAPE 0x00008000 10345916cd2Sjpk #define DA_RMDISK 0x00010000 10445916cd2Sjpk 10545916cd2Sjpk #define DA_AUDIO_NAME "audio" 10645916cd2Sjpk #define DA_SOUND_NAME "sound" 10745916cd2Sjpk #define DA_AUDIO_TYPE DA_AUDIO_NAME 10845916cd2Sjpk #define DA_AUDIO_DIR "/dev/sound/" 10945916cd2Sjpk 11045916cd2Sjpk #define DA_CD_NAME "cdrom" 11145916cd2Sjpk #define DA_CD_TYPE "sr" 11245916cd2Sjpk 11345916cd2Sjpk #define DA_DISK_DIR "/dev/dsk/" 11445916cd2Sjpk #define DA_DISK_DIRR "/dev/rdsk/" 11545916cd2Sjpk #define DA_DISKR_DIR "/dev/(r)dsk" 11645916cd2Sjpk 11745916cd2Sjpk #define DA_FLOPPY_NAME "floppy" 11845916cd2Sjpk #define DA_FLOPPY_TYPE "fd" 11945916cd2Sjpk 12045916cd2Sjpk #define DA_RMDISK_NAME "rmdisk" 12145916cd2Sjpk #define DA_RMDISK_TYPE DA_RMDISK_NAME 12245916cd2Sjpk 12345916cd2Sjpk #define DA_TAPE_NAME "tape" 12445916cd2Sjpk #define DA_TAPE_DIR "/dev/rmt/" 12545916cd2Sjpk #define DA_TAPE_TYPE "st" 12645916cd2Sjpk 12745916cd2Sjpk typedef struct _devinfo_t { 12845916cd2Sjpk char *devname; 12945916cd2Sjpk char *devtype; 13045916cd2Sjpk char *devauths; 13145916cd2Sjpk char *devexec; 13245916cd2Sjpk char *devopts; 13345916cd2Sjpk char *devlist; 13445916cd2Sjpk int instance; 13545916cd2Sjpk } devinfo_t; 13645916cd2Sjpk 13745916cd2Sjpk typedef struct _deventry_t { 13845916cd2Sjpk devinfo_t devinfo; 13945916cd2Sjpk struct _deventry_t *next; 14045916cd2Sjpk } deventry_t; 14145916cd2Sjpk 14245916cd2Sjpk typedef struct _devlist_t { 14345916cd2Sjpk deventry_t *audio; 14445916cd2Sjpk deventry_t *cd; 14545916cd2Sjpk deventry_t *floppy; 14645916cd2Sjpk deventry_t *tape; 14745916cd2Sjpk deventry_t *rmdisk; 14845916cd2Sjpk } devlist_t; 14945916cd2Sjpk 15045916cd2Sjpk typedef struct _da_optargs { 15145916cd2Sjpk int optflag; 15245916cd2Sjpk char *rootdir; 15345916cd2Sjpk char **devnames; 15445916cd2Sjpk devinfo_t *devinfo; 15545916cd2Sjpk } da_args; 15645916cd2Sjpk 15745916cd2Sjpk typedef struct _da_defs { 15845916cd2Sjpk char *devtype; 15945916cd2Sjpk kva_t *devopts; 16045916cd2Sjpk } da_defs_t; 16145916cd2Sjpk 16245916cd2Sjpk da_defs_t *getdadefent(void); 16345916cd2Sjpk da_defs_t *getdadeftype(char *); 16445916cd2Sjpk void freedadefent(da_defs_t *); 16545916cd2Sjpk void setdadefent(void); 16645916cd2Sjpk void enddadefent(void); 16745916cd2Sjpk int da_is_on(void); 16845916cd2Sjpk int da_check_logindevperm(char *); 16945916cd2Sjpk int da_open_devdb(char *, FILE **, FILE **, int); 17045916cd2Sjpk int da_update_device(da_args *); 17145916cd2Sjpk int da_update_defattrs(da_args *); 17245916cd2Sjpk int da_add_list(devlist_t *, char *, int, int); 17345916cd2Sjpk int da_remove_list(devlist_t *, char *, int, char *, int); 174*7e3e5701SJan Parcel int da_rm_list_entry(devlist_t *, char *, int, char *); 17545916cd2Sjpk void da_print_device(int, devlist_t *); 17645916cd2Sjpk 17745916cd2Sjpk 17845916cd2Sjpk #ifdef __cplusplus 17945916cd2Sjpk } 18045916cd2Sjpk #endif 18145916cd2Sjpk 18245916cd2Sjpk #endif /* _DEVALLOC_H */ 183