main.c revision 074e084f68dd0b08686612bec695a0cfe249da6d
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include <priv.h>
#include <libscf.h>
#include <zone.h>
#include "utils.h"
#include "aconf.h"
#include "res.h"
static const char USAGE[] = "\
Usage:\n\
acctadm [ {process | task | flow} ]\n\
acctadm -s\n\
acctadm -r [ {process | task | flow} ]\n\
acctadm -x|-E|-D {process | task | flow}\n\
acctadm -f filename {process | task | flow}\n\
acctadm -e resources -d resources {process | task | flow}\n";
static const char OPTS[] = "rsxf:e:d:ED";
static void
usage()
{
}
static void
{
/*
* Add our privileges and remove unneeded 'basic' privileges from the
* permitted set.
*/
/*
* Clear the Inheritable and Limit sets.
*/
/*
* Turn off the sys_acct and file_dac_write privileges until needed.
*/
}
int
{
int c; /* options character */
int type = 0; /* type of accounting */
int modified = 0; /* have we modified any properties? */
int Eflg = 0;
int Dflg = 0;
int rflg = 0;
int sflg = 0;
int xflg = 0;
int optcnt = 0;
int state;
const char *fmri; /* FMRI for this instance */
setup_privs();
(void) textdomain(TEXT_DOMAIN);
(void) setprogname(argv[0]);
switch (c) {
case 'd':
break;
case 'e':
break;
case 'D':
Dflg = 1;
optcnt++;
break;
case 'E':
Eflg = 1;
optcnt++;
break;
case 'f':
optcnt++;
break;
case 'r':
rflg = 1;
optcnt++;
break;
case 's':
sflg = 1;
optcnt++;
break;
case 'x':
xflg = 1;
optcnt++;
break;
case '?':
default:
usage();
}
}
/*
* Permanently give up euid 0, egid 0 and privileges we
* don't need for the specified options.
*/
}
xflg))
usage();
} else {
}
}
}
else {
typestr);
usage();
}
} else
/*
* check for invalid options
*/
if (optcnt > 1)
usage();
usage();
!typestr) {
usage();
}
if (rflg) {
return (E_SUCCESS);
}
/*
* If no arguments have been passed then just print out the current
* state and exit.
*/
return (E_SUCCESS);
}
/*
* smf(5) start method. The FMRI to operate on is retrieved from the
* SMF_FMRI environment variable that the restarter provides.
*/
if (sflg) {
return (aconf_setup(fmri));
return (E_ERROR);
}
/*
* Since the sys_acct the privilege allows use of acctctl() regardless
* of the accounting type, we check the smf(5) authorizations granted
* to the user to determine whether the user is allowed to change the
* configuration for this particular accounting type.
*/
if (!aconf_have_smf_auths())
if (xflg) {
/*
* Turn off the specified accounting and close its file
*/
ac_type_name(type));
ac_type_name(type));
modified++;
}
/*
*/
}
if (disabled)
if (enabled)
}
modified++;
}
if (file) {
/*
* Open new accounting file
*/
ac_type_name(type));
modified++;
}
if (Dflg) {
/*
* Disable accounting
*/
ac_type_name(type));
modified++;
}
if (Eflg) {
/*
* Enable accounting
*/
ac_type_name(type));
modified++;
}
if (modified) {
char *smf_state;
if (aconf_save() == -1)
/*
* Enable or disable the instance depending on the effective
* configuration. If the effective configuration results in
* extended accounting being 'on', the instance is enabled so
* the configuration is applied at the next boot.
*/
fmri);
} else {
fmri);
}
}
return (E_SUCCESS);
}