#include <config.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "sudoers.h"
#ifdef HAVE_BSM_AUDIT
# include "bsm_audit.h"
#endif
#ifdef HAVE_LINUX_AUDIT
# include "linux_audit.h"
#endif
#ifdef HAVE_SOLARIS_AUDIT
# include "solaris_audit.h"
#endif
int
audit_success(int argc, char *argv[])
{
int rc = 0;
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT)
if (!def_log_allowed)
debug_return_int(0);
if (argv != NULL) {
#ifdef HAVE_BSM_AUDIT
if (bsm_audit_success(argv) == -1)
rc = -1;
#endif
#ifdef HAVE_LINUX_AUDIT
if (linux_audit_command(argv, 1) == -1)
rc = -1;
#endif
#ifdef HAVE_SOLARIS_AUDIT
if (solaris_audit_success(argc, argv) == -1)
rc = -1;
#endif
}
debug_return_int(rc);
}
int
audit_failure(int argc, char *argv[], char const *const fmt, ...)
{
int rc = 0;
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT)
if (!def_log_denied)
debug_return_int(0);
#if defined(HAVE_BSM_AUDIT) || defined(HAVE_LINUX_AUDIT)
if (argv != NULL) {
va_list ap;
int oldlocale;
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
#ifdef HAVE_BSM_AUDIT
va_start(ap, fmt);
if (bsm_audit_failure(argv, _(fmt), ap) == -1)
rc = -1;
va_end(ap);
#endif
#ifdef HAVE_LINUX_AUDIT
va_start(ap, fmt);
if (linux_audit_command(argv, 0) == -1)
rc = -1;
va_end(ap);
#endif
#ifdef HAVE_SOLARIS_AUDIT
va_start(ap, fmt);
if (solaris_audit_failure(argc, argv, _(fmt), ap) == -1)
rc = -1;
va_end(ap);
#endif
sudoers_setlocale(oldlocale, NULL);
}
#endif
debug_return_int(rc);
}