tsol_sgettpent.c revision 4b484e007f44a62fb92d63bf345660cb76111d26
/*
* 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 2007 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 "tnrhtp" (remote host template) file.
* Each entry in this file has two fields, separated by a colon. The first
* field is the template name. The second is a list of "key=value" attributes,
* separated by semicolons.
*
* In order to help preserve sanity, we do not allow more than one unescaped
* colon in a line, nor any unescaped '=' or ';' characters in the template
* name. Such things are indicative of typing errors, not intentional
* configuration.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <strings.h>
#include <libtsnet.h>
#include <nss.h>
#include <secdb.h>
#include <errno.h>
static int
{
char *cp;
return (LTSNET_NO_DOI);
errno = 0;
if (errno != 0)
return (LTSNET_SYSERR);
if (*cp != '\0')
return (LTSNET_ILL_DOI);
return (0);
}
static int
{
int err = 0;
return (LTSNET_NO_RANGE);
return (LTSNET_NO_LOWERBOUND);
return (LTSNET_NO_UPPERBOUND);
return (LTSNET_ILL_LOWERBOUND);
return (LTSNET_ILL_UPPERBOUND);
return (LTSNET_ILL_RANGE);
return (0);
}
static int
{
return (LTSNET_ILL_LABEL);
}
return (LTSNET_SET_TOO_BIG);
return (0);
}
static int
{
int err = 0;
return (LTSNET_NO_HOSTTYPE);
else
return (LTSNET_ILL_HOSTTYPE);
/*
* parse fields by host type -
* add on to the following if statement for each new host type.
*/
tpentp->tp_mask_unl = 0;
/*
* doi
*/
return (err);
/*
* default label
*/
return (LTSNET_NO_LABEL);
&err) == 0)
return (LTSNET_ILL_LABEL);
/*
* check label range
*/
/*
* This is the old format. Use ADMIN_LOW to SL of the
* default label as the gw_sl_range.
*/
} else {
val2);
if (err != 0)
return (err);
}
/*
* also label set, if present. (optional)
*/
if (err != 0)
return (err);
}
} else {
tpentp->tp_mask_cipso = 0;
/*
* doi
*/
return (err);
/*
* label range
*/
if (err != 0)
return (err);
/*
* also label set, if present. (optional)
*/
if (err != 0)
return (err);
}
/* CIPSO entries don't support default labels */
return (LTSNET_BAD_TYPE);
}
return (0);
}
{
int err = 0;
char *errstr;
/*
* 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_EMPTY;
*errstrp = " ";
goto err_ret;
}
if (*template == '\0') {
*errp = LTSNET_NO_NAME;
goto err_ret;
}
*attrs == '\n') {
*errp = LTSNET_NO_ATTRS;
goto err_ret;
}
*errp = LTSNET_SYSERR;
return (NULL);
}
*errp = LTSNET_ILL_NAME;
goto err_ret;
}
if (*errp == 0) {
#ifdef DEBUG
attrs);
#endif /* DEBUG */
return (tpentp);
}
#ifdef DEBUG
#endif /* DEBUG */
return (NULL);
}
void
{
}