/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* From "misc.c 5.15 00/05/31 SMI; TSOL 2.x"
*/
/*
* Miscellaneous user interfaces to trusted label functions.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <libintl.h>
#include <libtsnet.h>
/*
* Parse off an entry from a line. Entry is stored in 'outbuf'. Returned
* value is a pointer to the first unprocessed input character from 'instr'.
*/
const char *
const char *delimit)
{
char chr;
/*
* User may specify outlen as 0 to skip over a field without storing
* it anywhere. Otherwise, we need at least one byte for the
* terminating NUL plus one byte to store another byte from instr.
*/
if (!escape_state) {
if (chr == '\\') {
continue;
}
break;
break;
}
if (outlen > 0) {
outlen--;
}
}
if (outlen != 1)
instr--;
if (escape_state)
instr--;
if (outlen > 0)
*outbuf = '\0';
return (instr);
}
char *
{
return (strdup(unknown_str));
return (strdup(unknown_str));
return (sl_str);
}
static const char *rtsa_keywords[] = {
#define SAK_MINSL 0
"min_sl",
"max_sl",
"doi",
"cipso",
"sl",
};
const char *
{
slen = 0;
*line = '\0';
continue;
if (!(i & mask))
continue;
if (slen != 0)
switch (i & mask) {
case RTSA_MINSL:
if ((mask & RTSA_MAXSL) &&
sl_str =
"sl=%s", sl_str);
mask ^= RTSA_MAXSL;
break;
}
sl_str);
break;
case RTSA_MAXSL:
sl_str);
break;
case RTSA_DOI:
break;
case RTSA_CIPSO:
break;
}
}
return (line);
}
{
int key;
const char **keyword;
int err;
while (*options != '\0') {
if (attrbuf[0] == '\0') {
*errp = LTSNET_ILL_ENTRY;
goto out_err;
}
break;
*errp = LTSNET_ILL_KEY;
goto out_err;
}
goto out_err;
}
if (*valptr == '=') {
valptr++;
valptr, ",=");
if (*nxtopt == '=') {
goto out_err;
}
}
if (*nxtopt == ',')
nxtopt++;
switch (key) {
case SAK_MINSL:
if (mask & RTSA_MINSL) {
*errp = LTSNET_DUP_KEY;
goto out_err;
}
L_NO_CORRECTION, NULL) != 0) {
goto out_err;
}
mask |= RTSA_MINSL;
break;
case SAK_MAXSL:
if (mask & RTSA_MAXSL) {
*errp = LTSNET_DUP_KEY;
goto out_err;
}
L_NO_CORRECTION, NULL) != 0) {
goto out_err;
}
mask |= RTSA_MAXSL;
break;
case SAK_SL:
*errp = LTSNET_DUP_KEY;
goto out_err;
}
L_NO_CORRECTION, NULL) != 0) {
*errp = LTSNET_ILL_LABEL;
goto out_err;
}
break;
case SAK_DOI:
*errp = LTSNET_DUP_KEY;
goto out_err;
}
errno = 0;
*errp = LTSNET_ILL_DOI;
goto out_err;
}
break;
case SAK_CIPSO:
if (mask & RTSA_CIPSO) {
*errp = LTSNET_DUP_KEY;
goto out_err;
}
mask |= RTSA_CIPSO;
break;
}
}
/* Defaults to CIPSO if not specified */
mask |= RTSA_CIPSO;
/* If RTSA_CIPSO is specified, RTSA_DOI must be specified */
*errp = LTSNET_NO_DOI;
goto out_err;
}
/* SL range must be specified */
*errp = LTSNET_NO_RANGE;
goto out_err;
}
if (!(mask & RTSA_MINSL)) {
goto out_err;
}
if (!(mask & RTSA_MAXSL)) {
goto out_err;
}
/* SL range must have upper bound dominating lower bound */
*errp = LTSNET_ILL_RANGE;
goto out_err;
}
if (mask & RTSA_MINSL)
if (mask & RTSA_MAXSL)
return (B_TRUE);
return (B_FALSE);
}
/* Keep in sync with libtsnet.h */
static const char *tsol_errlist[] = {
"No error",
"System error",
"Empty string or end of list",
"Entry is malformed",
"Missing name",
"Missing attributes",
"Illegal name",
"Illegal keyword delimiter",
"Unknown keyword",
"Duplicate keyword",
"Illegal value delimiter",
"Missing host type",
"Illegal host type",
"Missing label",
"Illegal label",
"Missing label range",
"Illegal label range",
"No lower bound in range",
"Illegal lower bound in range",
"No upper bound in range",
"Illegal upper bound in range",
"Missing DOI",
"Illegal DOI",
"Too many entries in set",
"Illegal flag",
"Illegal MLP specification",
"Unacceptable keyword for type"
};
const char *
{
if (libtserr == LTSNET_SYSERR)
return (gettext("Unknown error"));
}