1*45916cd2Sjpk /* 2*45916cd2Sjpk * CDDL HEADER START 3*45916cd2Sjpk * 4*45916cd2Sjpk * The contents of this file are subject to the terms of the 5*45916cd2Sjpk * Common Development and Distribution License (the "License"). 6*45916cd2Sjpk * You may not use this file except in compliance with the License. 7*45916cd2Sjpk * 8*45916cd2Sjpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*45916cd2Sjpk * or http://www.opensolaris.org/os/licensing. 10*45916cd2Sjpk * See the License for the specific language governing permissions 11*45916cd2Sjpk * and limitations under the License. 12*45916cd2Sjpk * 13*45916cd2Sjpk * When distributing Covered Code, include this CDDL HEADER in each 14*45916cd2Sjpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*45916cd2Sjpk * If applicable, add the following below this CDDL HEADER, with the 16*45916cd2Sjpk * fields enclosed by brackets "[]" replaced with your own identifying 17*45916cd2Sjpk * information: Portions Copyright [yyyy] [name of copyright owner] 18*45916cd2Sjpk * 19*45916cd2Sjpk * CDDL HEADER END 20*45916cd2Sjpk */ 21*45916cd2Sjpk /* 22*45916cd2Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*45916cd2Sjpk * Use is subject to license terms. 24*45916cd2Sjpk */ 25*45916cd2Sjpk 26*45916cd2Sjpk #ifndef _TSOL_LABEL_H 27*45916cd2Sjpk #define _TSOL_LABEL_H 28*45916cd2Sjpk 29*45916cd2Sjpk #pragma ident "%Z%%M% %I% %E% SMI" 30*45916cd2Sjpk 31*45916cd2Sjpk #include <sys/tsol/label.h> 32*45916cd2Sjpk #include <priv.h> 33*45916cd2Sjpk 34*45916cd2Sjpk #ifdef __cplusplus 35*45916cd2Sjpk extern "C" { 36*45916cd2Sjpk #endif 37*45916cd2Sjpk 38*45916cd2Sjpk /* Procedural Interface Structure Definitions */ 39*45916cd2Sjpk 40*45916cd2Sjpk struct label_info { /* structure returned by label_info */ 41*45916cd2Sjpk short ilabel_len; /* max Information Label length */ 42*45916cd2Sjpk short slabel_len; /* max Sensitivity Label length */ 43*45916cd2Sjpk short clabel_len; /* max CMW Label length */ 44*45916cd2Sjpk short clear_len; /* max Clearance Label length */ 45*45916cd2Sjpk short vers_len; /* version string length */ 46*45916cd2Sjpk short header_len; /* max len of banner page header */ 47*45916cd2Sjpk short protect_as_len; /* max len of banner page protect as */ 48*45916cd2Sjpk short caveats_len; /* max len of banner page caveats */ 49*45916cd2Sjpk short channels_len; /* max len of banner page channels */ 50*45916cd2Sjpk }; 51*45916cd2Sjpk 52*45916cd2Sjpk typedef struct label_set_identifier { /* valid label set identifier */ 53*45916cd2Sjpk int type; /* type of the set */ 54*45916cd2Sjpk char *name; /* name of the set if needed */ 55*45916cd2Sjpk } set_id; 56*45916cd2Sjpk 57*45916cd2Sjpk struct name_fields { /* names for label builder fields */ 58*45916cd2Sjpk char *class_name; /* Classifications field name */ 59*45916cd2Sjpk char *comps_name; /* Compartments field name */ 60*45916cd2Sjpk char *marks_name; /* Markings field name */ 61*45916cd2Sjpk }; 62*45916cd2Sjpk 63*45916cd2Sjpk /* Label Set Identifier Types */ 64*45916cd2Sjpk 65*45916cd2Sjpk /* 66*45916cd2Sjpk * The accreditation ranges as specified in the label encodings file. 67*45916cd2Sjpk * The name parameter is ignored. 68*45916cd2Sjpk * 69*45916cd2Sjpk * System Accreditation Range is all valid labels plus Admin High and Low. 70*45916cd2Sjpk * 71*45916cd2Sjpk * User Accreditation Range is valid user labels as defined in the 72*45916cd2Sjpk * ACCREDITATION RANGE: section of the label encodings file. 73*45916cd2Sjpk */ 74*45916cd2Sjpk 75*45916cd2Sjpk #define SYSTEM_ACCREDITATION_RANGE 1 76*45916cd2Sjpk #define USER_ACCREDITATION_RANGE 2 77*45916cd2Sjpk 78*45916cd2Sjpk 79*45916cd2Sjpk /* System Call Interface Definitions */ 80*45916cd2Sjpk 81*45916cd2Sjpk extern int getlabel(const char *, m_label_t *); 82*45916cd2Sjpk extern int fgetlabel(int, m_label_t *); 83*45916cd2Sjpk 84*45916cd2Sjpk extern int getplabel(m_label_t *); 85*45916cd2Sjpk extern int setflabel(const char *, m_label_t *); 86*45916cd2Sjpk extern char *getpathbylabel(const char *, char *, size_t, 87*45916cd2Sjpk const m_label_t *sl); 88*45916cd2Sjpk extern m_label_t *getzonelabelbyid(zoneid_t); 89*45916cd2Sjpk extern m_label_t *getzonelabelbyname(const char *); 90*45916cd2Sjpk extern zoneid_t getzoneidbylabel(const m_label_t *); 91*45916cd2Sjpk extern char *getzonenamebylabel(const m_label_t *); 92*45916cd2Sjpk extern char *getzonerootbyid(zoneid_t); 93*45916cd2Sjpk extern char *getzonerootbyname(const char *); 94*45916cd2Sjpk extern char *getzonerootbylabel(const m_label_t *); 95*45916cd2Sjpk extern m_label_t *getlabelbypath(const char *); 96*45916cd2Sjpk 97*45916cd2Sjpk 98*45916cd2Sjpk /* Flag word values */ 99*45916cd2Sjpk 100*45916cd2Sjpk #define ALL_ENTRIES 0x00000000 101*45916cd2Sjpk #define ACCESS_RELATED 0x00000001 102*45916cd2Sjpk #define ACCESS_MASK 0x0000FFFF 103*45916cd2Sjpk #define ACCESS_SHIFT 0 104*45916cd2Sjpk 105*45916cd2Sjpk #define LONG_WORDS 0x00010000 /* use long names */ 106*45916cd2Sjpk #define SHORT_WORDS 0x00020000 /* use short names if present */ 107*45916cd2Sjpk #define LONG_CLASSIFICATION 0x00040000 /* use long classification */ 108*45916cd2Sjpk #define SHORT_CLASSIFICATION 0x00080000 /* use short classification */ 109*45916cd2Sjpk #define NO_CLASSIFICATION 0x00100000 /* don't translate the class */ 110*45916cd2Sjpk #define VIEW_INTERNAL 0x00200000 /* don't promote/demote */ 111*45916cd2Sjpk #define VIEW_EXTERNAL 0x00400000 /* promote/demote label */ 112*45916cd2Sjpk 113*45916cd2Sjpk #define NEW_LABEL 0x00000001 /* create a full new label */ 114*45916cd2Sjpk #define NO_CORRECTION 0x00000002 /* don't correct label errors */ 115*45916cd2Sjpk /* implies NEW_LABEL */ 116*45916cd2Sjpk 117*45916cd2Sjpk #define CVT_DIM 0x01 /* display word dimmed */ 118*45916cd2Sjpk #define CVT_SET 0x02 /* display word currently set */ 119*45916cd2Sjpk 120*45916cd2Sjpk /* Procedure Interface Definitions available to user */ 121*45916cd2Sjpk 122*45916cd2Sjpk /* APIs shared with the kernel are in <sys/tsol/label.h */ 123*45916cd2Sjpk 124*45916cd2Sjpk extern m_label_t *blabel_alloc(void); 125*45916cd2Sjpk extern void blabel_free(m_label_t *); 126*45916cd2Sjpk extern size_t blabel_size(void); 127*45916cd2Sjpk extern char *bsltoh(const m_label_t *); 128*45916cd2Sjpk extern char *bcleartoh(const m_label_t *); 129*45916cd2Sjpk 130*45916cd2Sjpk extern char *bsltoh_r(const m_label_t *, char *); 131*45916cd2Sjpk extern char *bcleartoh_r(const m_label_t *, char *); 132*45916cd2Sjpk extern char *h_alloc(uint8_t); 133*45916cd2Sjpk extern void h_free(char *); 134*45916cd2Sjpk 135*45916cd2Sjpk extern int htobsl(const char *, m_label_t *); 136*45916cd2Sjpk extern int htobclear(const char *, m_label_t *); 137*45916cd2Sjpk 138*45916cd2Sjpk extern m_range_t *getuserrange(const char *); 139*45916cd2Sjpk extern m_range_t *getdevicerange(const char *); 140*45916cd2Sjpk 141*45916cd2Sjpk extern int set_effective_priv(priv_op_t, int, ...); 142*45916cd2Sjpk extern int set_inheritable_priv(priv_op_t, int, ...); 143*45916cd2Sjpk extern int set_permitted_priv(priv_op_t, int, ...); 144*45916cd2Sjpk extern int is_system_labeled(void); 145*45916cd2Sjpk 146*45916cd2Sjpk /* Procedures needed for multi-level printing */ 147*45916cd2Sjpk 148*45916cd2Sjpk extern int tsol_check_admin_auth(uid_t uid); 149*45916cd2Sjpk 150*45916cd2Sjpk /* APIs implemented via labeld */ 151*45916cd2Sjpk 152*45916cd2Sjpk extern int blinset(const m_label_t *, const set_id *); 153*45916cd2Sjpk extern int labelinfo(struct label_info *); 154*45916cd2Sjpk extern ssize_t labelvers(char **, size_t); 155*45916cd2Sjpk extern char *bltocolor(const m_label_t *); 156*45916cd2Sjpk extern char *bltocolor_r(const m_label_t *, size_t, char *); 157*45916cd2Sjpk 158*45916cd2Sjpk extern ssize_t bsltos(const m_label_t *, char **, size_t, int); 159*45916cd2Sjpk extern ssize_t bcleartos(const m_label_t *, char **, size_t, int); 160*45916cd2Sjpk 161*45916cd2Sjpk 162*45916cd2Sjpk extern char *sbsltos(const m_label_t *, size_t); 163*45916cd2Sjpk extern char *sbcleartos(const m_label_t *, size_t); 164*45916cd2Sjpk 165*45916cd2Sjpk 166*45916cd2Sjpk extern int stobsl(const char *, m_label_t *, int, int *); 167*45916cd2Sjpk extern int stobclear(const char *, m_label_t *, int, int *); 168*45916cd2Sjpk extern int bslvalid(const m_label_t *); 169*45916cd2Sjpk extern int bclearvalid(const m_label_t *); 170*45916cd2Sjpk 171*45916cd2Sjpk /* Manifest human readable label names */ 172*45916cd2Sjpk 173*45916cd2Sjpk #define ADMIN_LOW "ADMIN_LOW" 174*45916cd2Sjpk #define ADMIN_HIGH "ADMIN_HIGH" 175*45916cd2Sjpk 176*45916cd2Sjpk /* DIA label conversion and parsing */ 177*45916cd2Sjpk 178*45916cd2Sjpk /* Conversion types */ 179*45916cd2Sjpk 180*45916cd2Sjpk typedef enum _m_label_str { 181*45916cd2Sjpk M_LABEL = 1, /* process or user clearance */ 182*45916cd2Sjpk M_INTERNAL = 2, /* internal form for use in public databases */ 183*45916cd2Sjpk M_COLOR = 3, /* process label color */ 184*45916cd2Sjpk PRINTER_TOP_BOTTOM = 4, /* DIA banner page top/bottom */ 185*45916cd2Sjpk PRINTER_LABEL = 5, /* DIA banner page label */ 186*45916cd2Sjpk PRINTER_CAVEATS = 6, /* DIA banner page caveats */ 187*45916cd2Sjpk PRINTER_CHANNELS = 7 /* DIA banner page handling channels */ 188*45916cd2Sjpk } m_label_str_t; 189*45916cd2Sjpk 190*45916cd2Sjpk /* Flags for conversion, not all flags apply to all types */ 191*45916cd2Sjpk #define DEF_NAMES 0x1 192*45916cd2Sjpk #define SHORT_NAMES 0x3 /* short names are prefered where defined */ 193*45916cd2Sjpk #define LONG_NAMES 0x4 /* long names are prefered where defined */ 194*45916cd2Sjpk 195*45916cd2Sjpk extern int label_to_str(const m_label_t *, char **, const m_label_str_t, 196*45916cd2Sjpk uint_t); 197*45916cd2Sjpk 198*45916cd2Sjpk /* Parsing types */ 199*45916cd2Sjpk typedef enum _m_label_type { 200*45916cd2Sjpk MAC_LABEL = 1, /* process or object label */ 201*45916cd2Sjpk USER_CLEAR = 2 /* user's clearance (LUB) */ 202*45916cd2Sjpk } m_label_type_t; 203*45916cd2Sjpk 204*45916cd2Sjpk /* Flags for parsing */ 205*45916cd2Sjpk 206*45916cd2Sjpk #define L_DEFAULT 0x0 207*45916cd2Sjpk #define L_MODIFY_EXISTING 0x1 /* start parsing with existing label */ 208*45916cd2Sjpk #define L_NO_CORRECTION 0x2 /* must be correct by l_e rules */ 209*45916cd2Sjpk 210*45916cd2Sjpk /* EINVAL sub codes */ 211*45916cd2Sjpk 212*45916cd2Sjpk #define M_BAD_STRING -3 /* DIA L_BAD_LABEL */ 213*45916cd2Sjpk /* bad requested label type, bad previous label type */ 214*45916cd2Sjpk #define M_BAD_LABEL -2 /* DIA L_BAD_CLASSIFICATION, */ 215*45916cd2Sjpk 216*45916cd2Sjpk extern int str_to_label(const char *, m_label_t **, const m_label_type_t, 217*45916cd2Sjpk uint_t, int *); 218*45916cd2Sjpk 219*45916cd2Sjpk extern m_label_t *m_label_alloc(const m_label_type_t); 220*45916cd2Sjpk 221*45916cd2Sjpk extern int m_label_dup(m_label_t **, const m_label_t *); 222*45916cd2Sjpk 223*45916cd2Sjpk extern void m_label_free(m_label_t *); 224*45916cd2Sjpk 225*45916cd2Sjpk /* Contract Private interfaces with the label builder GUIs */ 226*45916cd2Sjpk 227*45916cd2Sjpk extern int bslcvtfull(const m_label_t *, const m_range_t *, int, 228*45916cd2Sjpk char **, char **[], char **[], char *[], int *, int *); 229*45916cd2Sjpk extern int bslcvt(const m_label_t *, int, char **, char *[]); 230*45916cd2Sjpk extern int bclearcvtfull(const m_label_t *, const m_range_t *, int, 231*45916cd2Sjpk char **, char **[], char **[], char *[], int *, int *); 232*45916cd2Sjpk extern int bclearcvt(const m_label_t *, int, char **, char *[]); 233*45916cd2Sjpk 234*45916cd2Sjpk extern int labelfields(struct name_fields *); 235*45916cd2Sjpk extern int userdefs(m_label_t *, m_label_t *); 236*45916cd2Sjpk extern int zonecopy(m_label_t *, char *, char *, char *, int); 237*45916cd2Sjpk 238*45916cd2Sjpk #ifdef __cplusplus 239*45916cd2Sjpk } 240*45916cd2Sjpk #endif 241*45916cd2Sjpk 242*45916cd2Sjpk #endif /* !_TSOL_LABEL_H */ 243