FreeBSD/contrib/openbsm/libauditd/auditd_lib.c
/*
 * Get the host from audit_control(5) and set it in the audit kernel
 * information.  Return:
 *	ADE_NOERR	on success.
 *	ADE_PARSE	error parsing audit_control(5).
 *	ADE_AUDITON	error getting/setting auditon(2) value.
 *	ADE_GETADDR	error getting address info for host.
 *	ADE_ADDRFAM	un-supported address family.
 */
Get the host from audit_control(5) and set it in the audit kernel
information.  Return:
ADE_NOERR       on success.
Get the host from audit_control ( 5 ) and set it in the audit kernel information . Return : ADE_NOERR on success .
int
auditd_set_host(void)
{
	struct sockaddr_in6 *sin6;
	struct sockaddr_in *sin;
	struct addrinfo *res;
	struct auditinfo_addr aia;
	int error, ret = ADE_NOERR;
	if (getachost(auditd_host, sizeof(auditd_host)) != 0) {
		ret = ADE_PARSE;
		bzero(&aia, sizeof(aia));
		aia.ai_termid.at_type = AU_IPv4;
		error = audit_set_kaudit(&aia, sizeof(aia));
		if (error < 0 && errno != ENOSYS)
			ret = ADE_AUDITON;
		return (ret);
	}
	auditd_hostlen = strlen(auditd_host);
	error = getaddrinfo(auditd_host, NULL, NULL, &res);
	if (error)
		return (ADE_GETADDR);
	switch (res->ai_family) {
	case PF_INET6:
		sin6 = (struct sockaddr_in6 *) res->ai_addr;
		bcopy(&sin6->sin6_addr.s6_addr,
		    &aia.ai_termid.at_addr[0], sizeof(struct in6_addr));
		aia.ai_termid.at_type = AU_IPv6;
		break;
	case PF_INET:
		sin = (struct sockaddr_in *) res->ai_addr;
		bcopy(&sin->sin_addr.s_addr,
		    &aia.ai_termid.at_addr[0], sizeof(struct in_addr));
		aia.ai_termid.at_type = AU_IPv4;
		break;
	default:
		errno = EAFNOSUPPORT;
		return (ADE_ADDRFAM);
	}
	if (audit_set_kaudit(&aia, sizeof(aia)) < 0)
		ret = ADE_AUDITON;
	return (ret);
}
int auditd_set_host ( void ) { struct sockaddr_in6 * sin6 ; struct sockaddr_in * sin ; struct addrinfo * res ; struct auditinfo_addr aia ; int error , ret = ADE_NOERR ; if ( getachost ( auditd_host , sizeof ( auditd_host ) ) != 0 ) { ret = ADE_PARSE ; bzero ( & aia , sizeof ( aia ) ) ; aia . ai_termid . at_type = AU_IPv4 ; error = audit_set_kaudit ( & aia , sizeof ( aia ) ) ; if ( error < 0 && errno != ENOSYS ) ret = ADE_AUDITON ; return ( ret ) ; } auditd_hostlen = strlen ( auditd_host ) ; error = getaddrinfo ( auditd_host , NULL , NULL , & res ) ; if ( error ) return ( ADE_GETADDR ) ; switch ( res -> ai_family ) { case PF_INET6 : sin6 = ( struct sockaddr_in6 * ) res -> ai_addr ; bcopy ( & sin6 -> sin6_addr . s6_addr , & aia . ai_termid . at_addr [ 0 ] , sizeof ( struct in6_addr ) ) ; aia . ai_termid . at_type = AU_IPv6 ; break ; case PF_INET : sin = ( struct sockaddr_in * ) res -> ai_addr ; bcopy ( & sin -> sin_addr . s_addr , & aia . ai_termid . at_addr [ 0 ] , sizeof ( struct in_addr ) ) ; aia . ai_termid . at_type = AU_IPv4 ; break ; default : errno = EAFNOSUPPORT ; return ( ADE_ADDRFAM ) ; } if ( audit_set_kaudit ( & aia , sizeof ( aia ) ) < 0 ) ret = ADE_AUDITON ; return ( ret ) ; }
Get the host from audit_control(5) and set it in the audit kernel
 information.
Get the host from audit_control ( 5 ) and set it in the audit kernel information .
/*
		 * To maintain reverse compatability with older audit_control
		 * files, simply drop a warning if the host parameter has not
		 * been set.  However, we will explicitly disable the
		 * generation of extended audit header by passing in a zeroed
		 * termid structure.
		 */ /* Un-supported address family in host parameter. */