/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <libdllink.h>
#include <libscf.h>
#include <pwd.h>
#include <auth_attr.h>
#include <nss_dbdefs.h>
#include <secdb.h>
#include <priv.h>
#include <zone.h>
#include "aconf.h"
#include "utils.h"
#include "res.h"
#define NELEM(x) (sizeof (x)) / (sizeof (x[0]))
typedef struct props {
char *propname;
int proptype;
} props_t;
static int aconf_get_bool(const char *, const char *, uint8_t *);
static int aconf_get_string(const char *, const char *, char *, size_t);
static props_t *aconf_prop(const char *, int);
static int aconf_fmri2type(const char *);
void
{
void *buf;
char *tracked;
char *untracked;
ac_type_name(type));
if (errno == ENOTACTIVE)
else
ac_type_name(type));
}
}
/*
* SMF start method: configure extended accounting from properties stored in
* the repository. Any errors encountered while retrieving properties from
* the repository, such as missing properties or properties of the wrong type,
* are fatal as they indicate severe damage to the service (all required
* properties are delivered in the service manifest and should thus always be
* present). No attempts will be made to repair such damage; the service will
* be forced into maintenance state by returning SMF_EXIT_ERR_CONFIG. For all
* other errors we we try to configure as much as possible and return
* SMF_EXIT_ERR_FATAL.
*/
int
{
void *buf;
int type;
int state;
uint8_t b;
return (SMF_EXIT_ERR_FATAL);
}
/*
* the service instance should therefore never be 'enabled' in
* non-global zones. This is enforced by acctadm(1M), but there is
* nothing that prevents someone from calling svcadm enable directly,
* so we handle that case here by disabling the instance.
*/
getzoneid() != GLOBAL_ZONEID) {
(void) smf_disable_instance(fmri, 0);
return (SMF_EXIT_OK);
}
return (SMF_EXIT_ERR_FATAL);
}
sizeof (tracked)) == -1) {
goto out;
}
sizeof (untracked)) == -1) {
goto out;
}
sizeof (file)) == -1) {
goto out;
}
goto out;
}
goto out;
}
ac_type_name(type));
}
} else {
ac_type_name(type));
}
}
ac_type_name(type));
}
/*
* Start logging.
*/
NULL);
(void) dladm_start_usagelog(dld_handle,
NULL);
}
out:
return (ret);
}
void
{
int i;
for (i = 0; i < NELEM(print_order); i++) {
if (types & print_order[i]) {
}
}
}
static void
{
switch (type) {
case AC_TASK:
gettext(" Task accounting: %s\n"),
gettext(" Task accounting file: %s\n"),
gettext(" Tracked task resources: %s\n"),
gettext(" Untracked task resources: %s\n"),
break;
case AC_PROC:
gettext(" Process accounting: %s\n"),
gettext(" Process accounting file: %s\n"),
gettext(" Tracked process resources: %s\n"),
gettext("Untracked process resources: %s\n"),
break;
case AC_FLOW:
gettext(" Flow accounting: %s\n"),
gettext(" Flow accounting file: %s\n"),
gettext(" Tracked flow resources: %s\n"),
gettext(" Untracked flow resources: %s\n"),
break;
case AC_NET:
gettext(" Net accounting: %s\n"),
gettext(" Net accounting file: %s\n"),
gettext(" Tracked net resources: %s\n"),
gettext(" Untracked net resources: %s\n"),
break;
}
}
/*
* Modified properties are put on the 'props' linked list by aconf_set_string()
* and aconf_set_bool(). Walk the list of modified properties and write them
* to the repository. The list is deleted on exit.
*/
int
aconf_save(void)
{
props_t *p;
props_t *q;
int tx_result;
return (0);
goto out;
do {
goto out;
goto out;
}
} while (tx_result == 0);
out:
p = props;
while (p != NULL) {
scf_value_destroy(p->value);
scf_entry_destroy(p->entry);
q = p->next;
free(p);
p = q;
}
}
aconf_have_smf_auths(void)
{
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_TRUE);
}
const char *
{
switch (type) {
case AC_PROC:
return (FMRI_PROC_ACCT);
case AC_TASK:
return (FMRI_TASK_ACCT);
case AC_FLOW:
return (FMRI_FLOW_ACCT);
case AC_NET:
return (FMRI_NET_ACCT);
default:
}
/* NOTREACHED */
return (NULL);
}
static int
{
return (AC_PROC);
return (AC_TASK);
return (AC_FLOW);
return (AC_NET);
else
return (-1);
}
int
{
SCF_DECODE_FMRI_EXACT) == -1) {
return (-1);
}
return (0);
}
void
aconf_scf_fini(void)
{
(void) scf_handle_unbind(handle);
}
static int
{
int ret = 0;
return (-1);
return (-1);
}
ret = -1;
return (ret);
}
static int
{
int ret = 0;
return (-1);
return (-1);
}
ret = -1;
return (ret);
}
int
{
props_t *p;
return (-1);
return (-1);
return (0);
}
int
{
props_t *p;
return (-1);
return (0);
}
static props_t *
{
props_t *p;
free(p);
return (NULL);
}
free(p);
return (NULL);
}
scf_entry_destroy(p->entry);
free(p);
return (NULL);
}
props = p;
}
return (p);
}