uadmin.c revision 753a6d457b330b1b29b2d3eefcd0831116ce950d
/*
* 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.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <signal.h>
#include <unistd.h>
#ifdef __i386
#include <libscf_priv.h>
#endif /* __i386 */
#include <bsm/adt_event.h>
static const char *Usage = "Usage: %s cmd fcn [mdep]\n";
static int closeout_audit(int, int);
static int turnoff_auditd(void);
static void wait_for_auqueue();
static int change_audit_file(void);
int
{
enum adt_uadmin_fcn fcn_id;
#ifdef __i386
uint8_t boot_config = 0;
#endif /* __i386 */
return (1);
}
(void) sigfillset(&set);
"allowed for this cmd value\n", argv[0]);
return (1);
} else {
}
}
/* set up audit session and event */
argv[0]);
}
switch (cmd) {
case A_SHUTDOWN:
break;
case A_REBOOT:
break;
case A_DUMP:
break;
case A_REMOUNT:
break;
case A_FREEZE:
break;
case A_FTRACE:
break;
case A_CONFIG:
break;
case A_SWAPCTL:
break;
default:
event_id = 0;
}
if ((event_id != 0) &&
argv[0]);
}
switch (fcn) {
case AD_HALT:
break;
case AD_POWEROFF:
break;
case AD_BOOT:
break;
case AD_IBOOT:
break;
case AD_SBOOT:
break;
case AD_SIBOOT:
break;
case AD_NOSYNC:
break;
case AD_FASTREBOOT:
#ifdef __i386
#else /* __i386 */
#endif /* __i386 */
break;
case AD_FASTREBOOT_DRYRUN:
break;
default:
fcn_id = 0;
}
switch (fcn) {
case AD_SUSPEND_TO_DISK:
break;
case AD_CHECK_SUSPEND_TO_DISK:
break;
case AD_FORCE:
break;
case AD_SUSPEND_TO_RAM:
break;
case AD_CHECK_SUSPEND_TO_RAM:
break;
case AD_REUSEINIT:
break;
case AD_REUSABLE:
break;
case AD_REUSEFINI:
break;
}
switch (fcn) {
case AD_FTRACE_START:
break;
case AD_FTRACE_STOP:
break;
}
#ifdef __i386
switch (fcn) {
case AD_UPDATE_BOOT_CONFIG:
break;
}
#endif /* __i386 */
}
if (geteuid() == 0) {
switch (cmd) {
case A_SHUTDOWN:
break;
case A_REBOOT:
break;
case A_DUMP:
break;
case A_REMOUNT:
/* no parameters */
break;
case A_FREEZE:
break;
case A_FTRACE:
break;
case A_CONFIG:
break;
case A_SWAPCTL:
break;
}
"%s: can't put audit event\n", argv[0]);
}
/*
* allow audit record to be processed in the kernel
* audit queue
*/
}
argv[0]);
}
(void) adt_free_event(event);
perror("uadmin");
return (1);
}
/* If returning from a suspend, audit thaw */
(fcn == AD_REUSABLE) ||
(fcn == AD_SUSPEND_TO_DISK) ||
(fcn == AD_SUSPEND_TO_RAM))) {
"event\n", argv[0]);
}
"event\n", argv[0]);
}
(void) adt_free_event(event);
}
(void) adt_end_session(ah);
return (0);
}
static int
{
if (!adt_audit_state(AUC_AUDITING)) {
/* auditd not running, just return */
return (0);
}
switch (cmd) {
case A_SHUTDOWN:
switch (fcn) {
case AD_FASTREBOOT_DRYRUN:
/* No system discontinuity, don't turn off auditd */
return (0);
default:
break; /* For all the other shutdown functions */
}
/* FALLTHROUGH */
case A_REBOOT:
case A_DUMP:
/* system shutting down, turn off auditd */
return (turnoff_auditd());
case A_REMOUNT:
case A_SWAPCTL:
case A_FTRACE:
case A_CONFIG:
/* No system discontinuity, don't turn off auditd */
return (0);
case A_FREEZE:
switch (fcn) {
case AD_CHECK_SUSPEND_TO_DISK: /* AD_CHECK */
case AD_CHECK_SUSPEND_TO_RAM:
case AD_REUSEINIT:
case AD_REUSEFINI:
/* No system discontinuity, don't turn off auditd */
return (0);
case AD_REUSABLE:
case AD_SUSPEND_TO_DISK: /* AD_COMPRESS */
case AD_SUSPEND_TO_RAM:
case AD_FORCE:
/* suspend the system, change audit files */
return (change_audit_file());
default:
return (0); /* not an audit error */
}
default:
return (0); /* not an audit error */
}
}
static int
turnoff_auditd(void)
{
int rc;
int retries = RETRY_COUNT;
_exit(-1);
} else if (rc == -1) {
return (-1);
}
/*
* wait for auditd to finish its work. auditd will change the
* auditstart from AUC_AUDITING (auditd up and running) to
* AUC_NOAUDIT. Other states are errors, so we're done as well.
*/
do {
int auditstate;
rc = -1;
sizeof (auditstate)) == 0) &&
(auditstate == AUC_AUDITING)) {
retries--;
(void) sleep(1);
} else {
rc = 0;
}
return (rc);
}
static int
change_audit_file(void)
{
_exit(-1);
} else if (pid == -1) {
return (-1);
} else {
int retries = RETRY_COUNT;
/*
* Wait for audit(1M) -n process to complete
*
*/
do {
return (0);
} else if (rc == -1) {
return (-1);
} else {
(void) sleep(1);
retries--;
}
} while (retries != 0);
}
return (-1);
}
static void
{
int retries = 10;
break;
}
(void) sleep(1);
}
}