ilbd_support.c revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9
/*
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <stropts.h>
#include <errno.h>
#include <auth_attr.h>
#include <auth_list.h>
#include <secdb.h>
#include <libilb.h>
#include "libilb_impl.h"
#include "ilbd.h"
/*
* logs error messages, either to stderr or syslog, depending on
* the -d option
*/
/* Socket to issue ioctl() to the kernel */
static int ksock = -1;
void
ilbd_enable_debug(void)
{
}
is_debugging_on(void)
{
return (ilbd_debugging);
}
/*
* All routines log to syslog, unless the daemon is running in
* the foreground, in which case the logging goes to stderr.
* The following logging functions are available:
*
*
* logdebug(): A printf-like function for outputting debug messages
* (messages at LOG_DEBUG) that are only of use to developers.
*
* logerr(): A printf-like function for outputting error messages
* (messages at LOG_ERR) from the daemon.
*
* logperror*(): A set of functions used to output error messages
* (messages at LOG_ERR); these automatically append strerror(errno)
* and a newline to the message passed to them.
*
* NOTE: since the logging functions write to syslog, the messages passed
* to them are not eligible for localization. Thus, gettext() must
* *not* be used.
*
*/
/* PRINTFLIKE2 */
void
{
if (ilbd_debugging == B_TRUE) {
} else {
}
}
/* PRINTFLIKE1 */
void
{
if (ilbd_debugging == B_TRUE)
else
}
{
logdebug("user %s is not authorized for"
return (ILB_STATUS_CFGAUTH);
}
return (ILB_STATUS_OK);
}
{
logdebug("user %s is not authorized for"
return (ILB_STATUS_CFGAUTH);
}
return (ILB_STATUS_OK);
}
/*
* input param. "err" should be one of the errnos defined in
* this list is NOT complete.
*/
ilb_map_errno2ilbstat(int err)
{
switch (err) {
case 0:
break;
case EINVAL:
break;
case ENOENT:
break;
case ENOMEM:
break;
case EINPROGRESS:
break;
case EEXIST:
break;
}
return (rc);
}
static int
i_get_kcmd_sz(void *cmdp)
{
int sz;
case ILB_DESTROY_RULE:
case ILB_ENABLE_RULE:
case ILB_DISABLE_RULE:
sz = sizeof (ilb_name_cmd_t);
break;
case ILB_CREATE_RULE:
case ILB_LIST_RULE:
sz = sizeof (ilb_rule_cmd_t);
break;
case ILB_NUM_RULES:
sz = sizeof (ilb_num_rules_cmd_t);
break;
case ILB_NUM_SERVERS:
sz = sizeof (ilb_num_servers_cmd_t);
break;
case ILB_ADD_SERVERS: {
break;
}
case ILB_RULE_NAMES: {
break;
}
case ILB_DEL_SERVERS:
case ILB_ENABLE_SERVERS:
case ILB_DISABLE_SERVERS: {
break;
}
default: sz = -1;
break;
}
return (sz);
}
/*
* parameter 'sz' is optional (indicated by == 0); if it's not set
* we try to derive it from cmdp->cmd
*/
{
int i_rc;
if (ksock == -1) {
if (ksock == -1) {
logperror("do_ioctl: AF_INET socket call"
" failed");
return (ILB_STATUS_INTERNAL);
}
}
if (sz == 0) {
if (sz == -1) {
logdebug("do_ioctl: unknown command");
return (ILB_STATUS_INVAL_CMD);
}
}
if (i_rc == -1) {
logdebug("do_ioctl: SIOCILB ioctl (%d) failed: %s",
return (ilb_map_errno2ilbstat(errno));
}
return (ILB_STATUS_OK);
}
/*
* Create an OK reply to a client request. It is assumed that the passed
* in buffer is large enough to hold the reply.
*/
void
{
*rbufsz = sizeof (ilb_comm_t);
}
/*
* Create an error reply to a client request. It is assumed that the passed
* in buffer is large enough to hold the reply.
*/
void
{
}