secobj.c revision a399b7655a1d835aa8606c2b29e4e777baac8635
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <libinetutil.h>
#include <libdllink.h>
#include <libdladm_impl.h>
static dladm_status_t i_dladm_set_secobj_db(const char *,
static dladm_status_t i_dladm_get_secobj_db(const char *,
static dladm_status_t i_dladm_unset_secobj_db(const char *);
static dladm_status_t i_dladm_walk_secobj_db(void *,
boolean_t (*)(void *, const char *));
typedef struct secobj_class_info {
const char *sc_name;
static secobj_class_info_t secobj_class_table[] = {
{"wep", DLD_SECOBJ_CLASS_WEP},
{"wpa", DLD_SECOBJ_CLASS_WPA}
};
#define NSECOBJCLASS \
(sizeof (secobj_class_table) / sizeof (secobj_class_info_t))
static boolean_t
{
}
{
int i;
for (i = 0; i < NSECOBJCLASS; i++) {
sp = &secobj_class_table[i];
*class = i;
return (DLADM_STATUS_OK);
}
}
return (DLADM_STATUS_BADARG);
}
const char *
{
const char *s;
if (!dladm_check_secobjclass(class))
s = "";
else
return (buf);
}
static boolean_t
{
if (!dladm_check_secobjclass(class))
return (B_FALSE);
return (B_TRUE);
}
static boolean_t
{
int i;
for (i = 0; i < NSECOBJCLASS; i++) {
sp = &secobj_class_table[i];
*class = i;
return (B_TRUE);
}
}
return (B_FALSE);
}
{
int fd;
return (DLADM_STATUS_BADARG);
if ((flags & DLADM_OPT_TEMP) == 0)
goto persist;
return (DLADM_STATUS_BADARG);
if ((flags & DLADM_OPT_CREATE) != 0)
return (dladm_errno2status(errno));
sizeof (secobj_set)) < 0) {
}
if (status != DLADM_STATUS_OK)
return (status);
if ((flags & DLADM_OPT_PERSIST) != 0) {
}
return (status);
}
{
int fd;
return (DLADM_STATUS_BADARG);
if ((flags & DLADM_OPT_PERSIST) != 0) {
}
return (dladm_errno2status(errno));
sizeof (secobj_get)) < 0)
return (DLADM_STATUS_TOOSMALL);
return (DLADM_STATUS_FAILED);
return (status);
}
{
int fd;
flags == 0)
return (DLADM_STATUS_BADARG);
if ((flags & DLADM_OPT_TEMP) == 0)
goto persist;
return (dladm_errno2status(errno));
sizeof (secobj_unset)) < 0)
if (status != DLADM_STATUS_OK)
return (status);
if ((flags & DLADM_OPT_PERSIST) != 0)
return (status);
}
#define SECOBJ_BUFSZ 65536
{
int fd = -1;
if ((flags & DLADM_OPT_PERSIST) != 0)
if (secobj_getp == NULL)
return (DLADM_STATUS_NOMEM);
goto done;
}
SECOBJ_BUFSZ) < 0) {
goto done;
}
while (secobj_getp->sg_count > 0) {
goto done;
secobj_getp->sg_count--;
objp++;
}
done:
return (status);
}
/*
* Data structures used for implementing persistent secure objects
*/
typedef struct secobj_info {
const char *si_name;
typedef struct secobj_name {
char *sn_name;
struct secobj_name *sn_next;
typedef struct secobj_db_state secobj_db_state_t;
secobj_info_t *, dladm_status_t *);
struct secobj_db_state {
};
/*
* Update or generate a secobj entry using the info in ssp->ss_info.
*/
/* ARGSUSED */
static boolean_t
{
char tmpbuf[MAXLINELEN];
char classbuf[DLADM_STRSIZE];
int i;
}
return (B_FALSE);
}
return (B_FALSE);
}
/* ARGSUSED */
static boolean_t
{
return (B_FALSE);
}
return (B_FALSE);
}
/* ARGSUSED */
static boolean_t
{
/*
* Delete line.
*/
buf[0] = '\0';
return (B_FALSE);
}
/* ARGSUSED */
static boolean_t
{
return (B_TRUE);
return (B_TRUE);
}
return (B_TRUE);
}
/* ARGSUSED */
static boolean_t
{
return (B_TRUE);
}
static int
{
return (EINVAL);
}
static boolean_t
{
/*
* Skip leading spaces, blank lines, and comments.
*/
for (i = 0; i < len; i++) {
break;
}
return (B_TRUE);
/*
* Skip objects we're not interested in.
*/
return (B_TRUE);
} else {
/*
* If an object is not specified, find the object name
* and assign it to sinfo.si_name.
*/
goto fail;
}
goto fail;
/*
* Find the class name.
*/
goto fail;
if (*statusp != DLADM_STATUS_OK)
goto fail;
/*
* Find the object value.
*/
goto fail;
goto fail;
fail:
/*
* Delete corrupted line.
*/
buf[0] = '\0';
return (B_TRUE);
}
static dladm_status_t
{
char buf[MAXLINELEN];
/*
* This loop processes each line of the configuration file.
* buf can potentially be modified by process_secobj_line().
* If this is a write operation and buf is not truncated, buf will
* be written to disk. process_secobj_line() will no longer be
* called after it returns B_FALSE; at which point the remainder
* of the file will continue to be read and, if necessary, written
* to disk as well.
*/
if (cont)
break;
}
}
return (status);
/*
* If the specified object is not found above, we add the
* object to the configuration file.
*/
}
return (status);
}
static dladm_status_t
{
}
static dladm_status_t
{
}
static dladm_status_t
i_dladm_unset_secobj_db(const char *obj_name)
{
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
if (cont)
}
return (status);
}
dladm_init_secobj(void)
{
}