/*
* 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.
*/
#include <assert.h>
#include <auth_attr.h>
#include <auth_list.h>
#include <bsm/adt_event.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <pwd.h>
#include <secdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include "libnwam_impl.h"
#include <libnwam_priv.h>
#include <libnwam.h>
/*
* Communicate with and implement library backend (running in netcfgd) to
* retrieve or change NWAM configuration.
*/
/*
* Check if uid has proper auths. flags is used to check auths for
*/
static nwam_error_t
{
endpwent();
return (NWAM_PERMISSION_DENIED);
}
if (flags & NWAM_FLAG_ENTITY_ENABLE) {
} else if (flags & NWAM_FLAG_ENTITY_KNOWN_WLAN) {
/* Known WLAN activity - need WLAN auth */
} else {
/*
* First, check for WRITE, since it implies READ. If this
* auth is not present, and write is true, fail, otherwise
* check for READ.
*/
if (write) {
} else {
}
}
}
endpwent();
return (err);
}
static nwam_error_t
{
switch (cmd) {
/*
* For a read request, we want the full buffer to be
* available for the backend door to write to.
*/
break;
/*
* An update request may either specify an object list
* (which we pack into the buffer immediately after the
* backend door request) or may not specify an object
* (signifying a request to create the container of the
* object).
*/
datalen = 0;
break;
}
/* Data immediately follows the descriptor */
/* pack object list for update request, adjusting datalen */
&datalen)) != NWAM_SUCCESS)
return (err);
break;
/* A remove request has no associated object list. */
datalen = 0;
break;
default:
return (NWAM_INVALID_ARG);
}
else
else
return (NWAM_SUCCESS);
}
/*
* If the arg datalen is non-zero, unpack the object list associated with
* the backend door argument.
*/
static nwam_error_t
{
return (arg->nwbda_result);
if (arg->nwbda_datalen > 0) {
return (err);
} else {
}
/*
* If "dbname" and "name" are non-NULL, copy in the actual dbname
* and name values from the door arg since both may have been changed
* from case-insensitive to case-sensitive matches. They will be the
* same length as they only differ in case.
*/
return (NWAM_SUCCESS);
}
/* ARGSUSED */
void
{
/* LINTED: alignment */
/* Check arg size */
if (arg_size < sizeof (nwam_backend_door_arg_t)) {
(void) door_return((char *)req,
sizeof (nwam_backend_door_arg_t), NULL, 0);
}
if (door_ucred(&ucr) != 0) {
}
/* Check auths */
!= NWAM_SUCCESS) {
if (write) {
(char *)req->nwbda_object,
}
goto door_return;
}
break;
}
sizeof (nwam_backend_door_arg_t);
sizeof (nwam_backend_door_arg_t);
req->nwbda_datalen = 0;
else
} else {
req->nwbda_datalen = 0;
}
break;
if (req->nwbda_datalen == 0) {
} else {
if ((req->nwbda_result =
break;
}
req->nwbda_datalen = 0;
(char *)req->nwbda_object,
}
break;
req->nwbda_flags);
(char *)req->nwbda_object,
}
break;
default:
break;
}
}
void
nwam_backend_fini(void)
{
if (backend_door_fd != -1) {
(void) door_revoke(backend_door_fd);
backend_door_fd = -1;
}
(void) unlink(NWAM_BACKEND_DOOR_FILE);
}
nwam_backend_init(void)
{
int did;
/* Create the door directory if it doesn't already exist */
return (NWAM_ERROR_BACKEND_INIT);
} else {
return (NWAM_ERROR_BACKEND_INIT);
}
return (NWAM_ERROR_BACKEND_INIT);
/* Do a low-overhead "touch" on the file that will be the door node. */
if (did != -1)
return (NWAM_ERROR_BACKEND_INIT);
/* Create the door. */
if (backend_door_fd == -1)
return (NWAM_ERROR_BACKEND_INIT);
/* Attach the door to the file. */
(void) fdetach(NWAM_BACKEND_DOOR_FILE);
(void) door_revoke(backend_door_fd);
return (NWAM_ERROR_BACKEND_INIT);
}
return (NWAM_SUCCESS);
}
static nwam_error_t
{
/* LINTED: alignment */
return (err);
return (NWAM_ERROR_BIND);
if (cmd == NWAM_BACKEND_DOOR_CMD_READ_REQ) {
}
}
/*
* Read object specified by objname from backend dbname, retrieving an object
* list representation.
*
* If dbname is NULL, obj is a list of string arrays consisting of the list
* of backend dbnames.
*
* If objname is NULL, read all objects in the specified dbname and create
* an object list containing a string array which represents each object.
*
* Otherwise obj will point to a list of the properties for the object
* specified by objname in the backend dbname.
*/
/* ARGSUSED2 */
{
if (err != NWAM_SUCCESS)
return (err);
}
/*
* Read in all objects from backend dbname and update object corresponding
* to objname with properties recorded in proplist, writing the results to
* the backend dbname.
*/
{
if (err != NWAM_SUCCESS)
return (err);
}
/*
* Remove specified object from backend by reading in the list of objects,
* removing objname and writing the remainder.
*
* If objname is NULL, remove the backend dbname.
*/
{
if (err != NWAM_SUCCESS)
return (err);
}