/*
* 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 "tsol_tndb_parser.c 7.24 01/09/05 SMI; TSOL 2.x"
*
* These functions parse entries in the "tnzonecfg" (zone configuration) file.
* Each entry in this file has five fields, separated by a colon. These fields
* are:
*
* zone name : label : flags : zone-specific MLPs : global MLPs
*
* The fourth and fifth fields contain subfields consisting of MLP entries
* separated by semicolons. The MLP entries are of the form:
*
* port[-port]/protocol
*
* In order to help preserve sanity, we do not allow more than four unescaped
* colons in a line, nor any unescaped ';' characters in the non-MLP fields.
* Such things are indicative of typing errors, not intentional configuration.
*/
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <strings.h>
#include <libtsnet.h>
#include <nss.h>
#include <errno.h>
#include <secdb.h>
/*
* Parse an MLP specification in port1-port2/proto or port/proto form.
*/
static int
{
char *fieldp;
int i;
return (-1);
errno = 0;
zone_mlp[i].mlp_port_upper = 0;
return (-1);
if (*cp == '-') {
return (-1);
}
if (*cp != '/')
return (-1);
else
return (-1);
}
return (0);
}
static boolean_t
{
int mmax;
int mc;
mmax = 0;
while (!TSOL_MLP_END(mlp)) {
mmax++;
mlp++;
}
mmax++;
}
mmax += 8;
*errp = LTSNET_SYSERR;
return (B_FALSE);
}
}
*errp = LTSNET_ILL_MLP;
return (B_FALSE);
}
}
*errp = LTSNET_SYSERR;
return (B_FALSE);
}
}
return (B_TRUE);
}
{
int err;
char *errstr;
const char *nextf;
char *cp;
/*
* The user can specify NULL pointers for these. Make sure that we
* don't have to deal with checking for NULL everywhere by just
* pointing to our own variables if the user gives NULL.
*/
/* The default, unless we find a more specific error locus. */
*errp = LTSNET_SYSERR;
return (NULL);
}
/* First, parse off the zone name. */
*errp = LTSNET_EMPTY;
else if (*instr == ':')
*errp = LTSNET_NO_NAME;
else
*errp = LTSNET_ILL_NAME;
goto err_ret;
}
if (*instr != ':') {
*errp = LTSNET_ILL_NAME;
else
*errp = LTSNET_ILL_ENTRY;
goto err_ret;
}
instr++;
/* Field two: parse off the label. */
if (*nextf != ':') {
*errp = LTSNET_ILL_ENTRY;
goto err_ret;
}
if (fieldbuf[0] == '\0') {
*errp = LTSNET_NO_LABEL;
goto err_ret;
}
!= 0) {
*errp = LTSNET_ILL_LABEL;
goto err_ret;
}
/* The kernel will apply the system doi to the zone label later */
/* Field three: get match flag */
errno = 0;
*errp = LTSNET_ILL_FLAG;
goto err_ret;
}
if (*cp != ':') {
goto err_ret;
}
/* Field four: get zone-specific MLP list. */
if (*nextf != ':') {
*errp = LTSNET_ILL_ENTRY;
goto err_ret;
}
goto err_ret;
}
/* Field five: get global MLP list. */
*errp = LTSNET_ILL_ENTRY;
goto err_ret;
}
goto err_ret;
}
return (zc);
return (NULL);
}
void
{
}
}