tnchkdb.c revision 96b5b3ca87222b74a6d5ea4acab6642410bac158
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* tnchkdb.c - Trusted network database checking utility
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <locale.h>
#include <malloc.h>
#include <string.h>
#include <libtsnet.h>
#include <nss_dbdefs.h>
static void usage(void);
static void check_tnrhtp(const char *);
static void check_tnrhdb(const char *);
static void check_tnzonecfg(const char *);
static boolean_t tnrhtp_bad;
static int exitval;
struct tsol_name_list {
struct tsol_name_list *next;
int linenum;
};
struct tsol_addr_list {
struct tsol_addr_list *next;
int linenum;
int prefix_len;
};
static struct tsol_name_list *tp_list_head;
static struct tsol_addr_list *rh_list_head;
static struct tsol_name_list *zc_list_head;
typedef struct mlp_info_list_s {
struct mlp_info_list_s *next;
int linenum;
static mlp_info_list_t *global_mlps;
static void
{
int err;
struct tsol_name_list *entry;
gettext("tnchkdb: allocating name list: %s\n"),
exit(1);
}
}
static struct tsol_name_list *
{
struct tsol_name_list *entry;
break;
return (entry);
}
static void
int linenum)
{
int err;
struct tsol_addr_list *entry;
gettext("tnchkdb: allocating addr list: %s\n"),
exit(2);
}
}
static struct tsol_addr_list *
{
struct tsol_addr_list *entry;
break;
return (entry);
}
static void
{
}
static struct tsol_name_list *
find_template(const char *name)
{
}
static void
{
}
static struct tsol_addr_list *
{
}
static void
{
}
static struct tsol_name_list *
{
}
int
{
const char *tnrhdb_file = TNRHDB_PATH;
const char *tnrhtp_file = TNRHTP_PATH;
const char *tnzonecfg_file = TNZONECFG_PATH;
int chr;
/* set the locale for only the messages system (all else is clean) */
#ifndef TEXT_DOMAIN /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
switch (chr) {
case 'h':
break;
case 't':
break;
case 'z':
break;
default:
usage();
}
}
return (exitval);
}
static void
usage(void)
{
"usage: tnchkdb [-h path] [-t path] [-z path]\n"));
exit(2);
}
static void
{
}
static void
const char *name)
{
int lclass;
"%1$s type %2$d is invalid for cipso labels: "
template);
exitval = 1;
}
if (lclass & 0xff00) {
"%1$s classification %2$x is invalid for cipso labels: "
template);
exitval = 1;
}
#ifdef _BIG_ENDIAN
if (c8 & 0x0000ffff) {
#else
if (c8 & 0xffff0000) {
#endif
"compartments 241-256 must be zero for cipso labels: "
exitval = 1;
}
}
static void
check_tnrhtp(const char *file)
{
int err;
char *errstr;
int linenum = 0;
struct tsol_name_list *tnl;
char buf[NSS_BUFLEN_TSOL_TP];
uint32_t initial_doi = 0;
exitval = 2;
tnrhtp_bad = B_TRUE;
return;
}
linenum++;
if (line[0] == '#')
continue;
*cp = '\0';
sizeof (buf));
if (err == LTSNET_EMPTY)
continue;
exitval = 1;
/*
* Flag is set *only* for parsing errors, which result
* in omitting the entry from tsol_name_list.
*/
tnrhtp_bad = B_TRUE;
continue;
}
case UNLABELED:
/*
* check doi
*/
if (initial_doi == 0)
if (tpentp->tp_cipso_doi_unl == 0)
/*
* check max_sl dominates min_sl
*/
gettext("tnchkdb: max_sl does not "
"dominate min_sl: line %1$d entry %2$s\n"),
exitval = 1;
}
if (bisinvalid(l1))
break;
TP_SET);
}
break;
case SUN_CIPSO:
/*
* check max_sl dominates min_sl
*/
gettext("tnchkdb: max_sl does not "
"dominate min_sl: line %1$d entry %2$s\n"),
exitval = 1;
}
if (bisinvalid(l1))
break;
TP_SET);
}
/*
* check doi
*/
if (initial_doi == 0)
if (tpentp->tp_cipso_doi_cipso == 0)
break;
default:
"type %1$d: line %2$d entry %3$s\n"),
exitval = 1;
} /* switch */
/*
* check if a duplicated entry
*/
"entry: %1$s at lines %2$d and %3$d\n"),
exitval = 1;
} else {
}
}
if (multiple_doi_found == B_TRUE) {
gettext("tnchkdb: Warning: tnrhtp entries do not all "
"contain the same DOI value\n"));
}
if (doi_zero_found == B_TRUE) {
gettext("tnchkdb: Warning: DOI=0 found in some "
"tnrhtp entries\n"));
}
}
static void
check_tnrhdb(const char *file)
{
int err;
char *errstr;
int linenum;
struct tsol_addr_list *tal;
char buf[NSS_BUFLEN_TSOL_RH];
exitval = 2;
return;
}
/*
* check that all templates used in tnrhdb file are defined by tnrhtp
*/
linenum = 0;
linenum++;
if (line[0] == '#')
continue;
*cp = '\0';
sizeof (buf));
if (err == LTSNET_EMPTY)
continue;
exitval = 1;
continue;
}
&addr);
} else {
}
gettext("tnchkdb: duplicate entry: lines %1$d and "
exitval = 1;
} else {
}
gettext("tnchkdb: unknown template name: %1$s at "
exitval = 1;
}
}
}
static void
int linenum)
{
if (mlpptr->mlp_port_upper == 0)
/* First, validate against self for duplicates */
break;
}
"of %1$s MLP protocol %2$d port %3$d-%4$d with "
"%5$d-%6$d: zone %7$s line %8$d\n"),
exitval = 1;
}
if (isglobal) {
/* Next, validate against list for duplicates */
continue;
break;
}
"overlap of global MLP protocol %1$d port "
"%2$d-%3$d with zone %4$s %5$d-%6$d: zone "
"%7$s lines %8$d and %9$d\n"),
exitval = 1;
}
/* Now throw into list */
exit(2);
}
global_mlps = mil;
}
}
}
static void
check_tnzonecfg(const char *file)
{
int err;
char *errstr;
int linenum;
struct tsol_name_list *tnl;
exitval = 2;
return;
}
linenum = 0;
*cp = '\0';
linenum++;
if (err == LTSNET_EMPTY)
continue;
exitval = 1;
continue;
}
"label");
saw_global = B_TRUE;
gettext("tnchkdb: duplicate zones: %1$s at lines "
linenum);
exitval = 1;
} else {
}
}
if (!saw_global) {
"entry for global zone in %s\n"), file);
exitval = 1;
}
}