FreeBSD/contrib/openbsm/bin/auditfilterd/auditfilterd_conf.c
/*
 * Given a filled out auditfilter_module, use dlopen() and dlsym() to attach
 * the module.  If we fail, leave fields in the state we found them.
 *
 * XXXRW: Need a better way to report errors.
 */
Given a filled out auditfilter_module, use dlopen() and dlsym() to attach
the module.  If we fail, leave fields in the state we found them.

Need a better way to report errors.
Given a filled out auditfilter_module use dlopen () and dlsym () to attach the module . If we fail leave fields in the state we found them . Need a better way to report errors .
static int
auditfilter_module_attach(struct auditfilter_module *am)
{
	am->am_dlhandle = dlopen(am->am_modulename, RTLD_NOW);
	if (am->am_dlhandle == NULL) {
		warnx("auditfilter_module_attach: %s: %s", am->am_modulename,
		    dlerror());
		return (-1);
	}
	am->am_attach = dlsym(am->am_dlhandle, AUDIT_FILTER_ATTACH_STRING);
	am->am_reinit = dlsym(am->am_dlhandle, AUDIT_FILTER_REINIT_STRING);
	am->am_record = dlsym(am->am_dlhandle, AUDIT_FILTER_RECORD_STRING);
	am->am_rawrecord = dlsym(am->am_dlhandle,
	    AUDIT_FILTER_RAWRECORD_STRING);
	am->am_detach = dlsym(am->am_dlhandle, AUDIT_FILTER_DETACH_STRING);
	if (am->am_attach != NULL) {
		if (am->am_attach(am, am->am_argc, am->am_argv)
		    != AUDIT_FILTER_SUCCESS) {
			warnx("auditfilter_module_attach: %s: failed",
			    am->am_modulename);
			dlclose(am->am_dlhandle);
			am->am_dlhandle = NULL;
			am->am_cookie = NULL;
			am->am_attach = NULL;
			am->am_reinit = NULL;
			am->am_record = NULL;
			am->am_rawrecord = NULL;
			am->am_detach = NULL;
			return (-1);
		}
	}
	return (0);
}
static int auditfilter_module_attach ( struct auditfilter_module * am ) { am -> am_dlhandle = dlopen ( am -> am_modulename , RTLD_NOW ) ; if ( am -> am_dlhandle == NULL ) { warnx ( " " , am -> am_modulename , dlerror ( ) ) ; return ( -1 ) ; } am -> am_attach = dlsym ( am -> am_dlhandle , AUDIT_FILTER_ATTACH_STRING ) ; am -> am_reinit = dlsym ( am -> am_dlhandle , AUDIT_FILTER_REINIT_STRING ) ; am -> am_record = dlsym ( am -> am_dlhandle , AUDIT_FILTER_RECORD_STRING ) ; am -> am_rawrecord = dlsym ( am -> am_dlhandle , AUDIT_FILTER_RAWRECORD_STRING ) ; am -> am_detach = dlsym ( am -> am_dlhandle , AUDIT_FILTER_DETACH_STRING ) ; if ( am -> am_attach != NULL ) { if ( am -> am_attach ( am , am -> am_argc , am -> am_argv ) != AUDIT_FILTER_SUCCESS ) { warnx ( " " , am -> am_modulename ) ; dlclose ( am -> am_dlhandle ) ; am -> am_dlhandle = NULL ; am -> am_cookie = NULL ; am -> am_attach = NULL ; am -> am_reinit = NULL ; am -> am_record = NULL ; am -> am_rawrecord = NULL ; am -> am_detach = NULL ; return ( -1 ) ; } } return ( 0 ) ; }
Given a filled out auditfilter_module, use dlopen() and dlsym() to attach
 the module.
Given a filled out auditfilter_module use dlopen () and dlsym () to attach the module .
/*
	 * Not implementing these is not considered a failure condition,
	 * although we might want to consider warning if obvious stuff is
	 * not implemented, such as am_record.
	 */