audit.c revision c75e1b9d842405d0cf0bd85bd21d4b32f8103e16
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Common Development and Distribution License (the "License").
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * You may not use this file except in compliance with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * or http://www.opensolaris.org/os/licensing.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * See the License for the specific language governing permissions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * and limitations under the License.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5dbfd19ad5fcc2b779f40f80fa05c1bd28fd0b4eTheo Schlossnagle * If applicable, add the following below this CDDL HEADER, with the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * CDDL HEADER END
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#pragma ident "%Z%%M% %I% %E% SMI"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <dlfcn.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <stdio.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include "_debug.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include "msg.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include "libld.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDbg_audit_version(Lm_list *lml, const char *lib, ulong_t version)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Dbg_util_nl(lml, DBG_NL_STD);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_VERSION), lib, (int)version);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDbg_audit_lib(Lm_list *lml, const char *lib)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Dbg_util_nl(lml, DBG_NL_STD);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_INIT), lib);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDbg_audit_interface(Lm_list *lml, const char *lib, const char *interface)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Dbg_util_nl(lml, DBG_NL_STD);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_INTERFACE), lib, interface);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
89b9271284be1a4e3e3053d7bc12f9bbf8145b06Robert MustacchiDbg_audit_object(Lm_list *lml, const char *lib, const char *obj)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Dbg_util_nl(lml, DBG_NL_STD);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_OBJECT), lib, obj);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDbg_audit_symval(Lm_list *lml, const char *lib, const char *func,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe const char *sym, Addr pval, Addr nval)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe char mesg[100];
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTDETAIL())
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (pval == nval)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mesg[0] = '\0';
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe else
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (void) sprintf(mesg, MSG_INTL(MSG_AUD_SYMNEW), EC_XWORD(nval));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_SYM), lib, func, Dbg_demangle_name(sym),
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe EC_XWORD(pval), mesg);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowevoid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDbg_audit_skip(Lm_list *lml, const char *name, const char *lmid)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe dbg_print(lml, MSG_INTL(MSG_AUD_SKIP), name, lmid);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe