Date: Fri, 23 Jul 2004 01:53:48 GMT From: Wayne Salamon <wsalamon@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 57959 for review Message-ID: <200407230153.i6N1rmGS023383@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=57959 Change 57959 by wsalamon@wsalamon_epi on 2004/07/23 01:52:58 Clean up includes mostly, fix some compilation errors. Create Makefile to build libbsm.a. Affected files ... .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/Makefile#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_audit.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_class.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_control.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_event.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_flags.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_io.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_mask.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_notify.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_token.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_user.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/lib_wrappers.c#2 edit .. //depot/projects/trustedbsd/audit3/contrib/bsm/lib/libbsm.h#2 edit .. //depot/projects/trustedbsd/audit3/sys/bsm/audit.h#3 edit Differences ... ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/Makefile#2 (text+ko) ==== @@ -1,12 +1,9 @@ -## Probably only works with GNU make - -ifndef CFLAGS CFLAGS = -g -Wall -pipe -fno-common -endif GCC=gcc -LIBCFLAGS = $(CFLAGS) -I. -dynamic -LIB_NAME=libbsm.dylib +AR=ar +LIBCFLAGS = $(CFLAGS) -I/usr/include -I. +LIB_NAME=libbsm.a LIBCURVERS=1.0 LIBCOMPATVERS=1.0 @@ -25,9 +22,13 @@ $(GCC) $(LIBCFLAGS) -c bsm_mask.c $(GCC) $(LIBCFLAGS) -c bsm_token.c $(GCC) $(LIBCFLAGS) -c bsm_user.c - $(GCC) $(LIBCFLAGS) -c bsm_notify.c $(GCC) $(LIBCFLAGS) -c lib_wrappers.c - $(GCC) -dynamiclib $(CFLAGS) -install_name /usr/lib/$(LIB_NAME) -compatibility_version $(LIBCOMPATVERS) -current_version $(LIBCURVERS) *.o -o $(LIB_NAME) +## +## bsm_notify is not compiled for now; needs ported to FreeBSD if we decide +## to use it. +## +## $(GCC) $(LIBCFLAGS) -c bsm_notify.c + $(AR) -r $(LIB_NAME) *.o install: $(LIB_NAME) install -d /usr/lib ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_audit.c#2 (text+ko) ==== @@ -26,13 +26,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/types.h> -#include <sys/queue.h> #include <pthread.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#include <sys/queue.h> +#include <sys/syscall.h> +#include <sys/types.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* array of used descriptors */ static au_record_t* open_desc_table[MAX_AUDIT_RECORDS]; @@ -213,7 +215,7 @@ } /* Call the kernel interface to audit */ - retval = audit(rec->data, rec->len); + retval = syscall(SYS_audit, rec->data, rec->len); } /* CLEANUP */ ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_class.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ #include <stdio.h> #include <stdlib.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* * Parse the contents of the audit_class file to return ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_control.c#2 (text+ko) ==== @@ -30,8 +30,9 @@ #include <pthread.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* * Parse the contents of the audit_control file to return ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_event.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ #include <stdio.h> #include <stdlib.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* * Parse the contents of the audit_event file to return ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_flags.c#2 (text+ko) ==== @@ -29,7 +29,7 @@ #include <stdio.h> #include <string.h> -#include <libbsm.h> +#include <bsm/libbsm.h> char *delim = ","; ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_io.c#2 (text+ko) ==== @@ -40,7 +40,7 @@ #include <pwd.h> #include <grp.h> -#include <libbsm.h> +#include <bsm/libbsm.h> #define READ_TOKEN_BYTES(buf, len, dest, size, bytesread, err) \ do {\ ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_mask.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ #include <pthread.h> #include <stdlib.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* MT-Safe */ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_notify.c#2 (text+ko) ==== @@ -35,7 +35,7 @@ #include <stdint.h> /* uint32_t */ #include <syslog.h> /* syslog() */ #include <stdarg.h> /* syslog() */ -#include "libbsm.h" +#include <bsm/libbsm.h> /* if 1, assumes a kernel that sends the right notification */ #define AUDIT_NOTIFICATION_ENABLED 1 ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_token.c#2 (text+ko) ==== @@ -29,10 +29,12 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <sys/socketvar.h> +#include <sys/syscall.h> +#include <sys/time.h> #include <sys/types.h> -#include <sys/socketvar.h> -#include <libbsm.h> +#include <bsm/libbsm.h> #define GET_TOKEN_AREA(t, dptr, length) \ do {\ @@ -838,14 +840,12 @@ * address type/length 4 bytes * remote Internet address 4 bytes/16 bytes (IPv4/IPv6 address) */ -token_t *au_to_socket_ex_32(u_int16_t lp, u_int16_t rp, - struct sockaddr *la, struct sockaddr *ra) +token_t *au_to_socket_ex_32(struct socket *so) { return NULL; } -token_t *au_to_socket_ex_128(u_int16_t lp, u_int16_t rp, - struct sockaddr *la, struct sockaddr *ra) +token_t *au_to_socket_ex_128(struct socket *so) { return NULL; } @@ -1052,7 +1052,7 @@ auditinfo_t auinfo; - if(getaudit(&auinfo) != 0) { + if(syscall(SYS_getaudit, &auinfo) != 0) { return NULL; } ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/bsm_user.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ #include <stdio.h> #include <stdlib.h> -#include <libbsm.h> +#include <bsm/libbsm.h> /* * Parse the contents of the audit_user file into au_user_ent structures ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/lib_wrappers.c#2 (text+ko) ==== @@ -29,14 +29,15 @@ /* * XXX lib_wrappers.c is a provisional name */ -#include <sys/types.h> /* [f]stat(), sysctl(), gete[ug]id(), getpid() */ +#include <errno.h> +#include <stdarg.h> /* syslog() */ +#include <string.h> +#include <syslog.h> /* syslog() */ +#include <unistd.h> /* STDIN_FILENO, gete[ug]id(), getpid() */ +#include <bsm/libbsm.h> #include <sys/stat.h> /* [f]stat() */ #include <sys/sysctl.h> /* sysctl() */ -#include <unistd.h> /* STDIN_FILENO, gete[ug]id(), getpid() */ -#include <syslog.h> /* syslog() */ -#include <stdarg.h> /* syslog() */ -#include <errno.h> -#include "libbsm.h" +#include <sys/types.h> /* [f]stat(), sysctl(), gete[ug]id(), getpid() */ /* * XXX Write up in a separate white paper. @@ -319,36 +320,3 @@ /* END OF au_write() WRAPPERS */ - -void -audit_token_to_au32( - audit_token_t atoken, - uid_t *auidp, - uid_t *euidp, - gid_t *egidp, - uid_t *ruidp, - gid_t *rgidp, - pid_t *pidp, - au_asid_t *asidp, - au_tid_t *tidp) -{ - if (auidp != NULL) - *auidp = (uid_t)atoken.val[0]; - if (euidp != NULL) - *euidp = (uid_t)atoken.val[1]; - if (egidp != NULL) - *egidp = (gid_t)atoken.val[2]; - if (ruidp != NULL) - *ruidp = (uid_t)atoken.val[3]; - if (rgidp != NULL) - *rgidp = (gid_t)atoken.val[4]; - if (pidp != NULL) - *pidp = (pid_t)atoken.val[5]; - if (asidp != NULL) - *asidp = (au_asid_t)atoken.val[6]; - if (tidp != NULL) { - audit_set_terminal_host(&tidp->machine); - tidp->port = (dev_t)atoken.val[7]; - } -} - ==== //depot/projects/trustedbsd/audit3/contrib/bsm/lib/libbsm.h#2 (text+ko) ==== @@ -45,7 +45,6 @@ #include <bsm/audit.h> #include <bsm/audit_record.h> -#include <mach/mach.h> /* audit_token_t */ #define AU_PRS_SUCCESS 1 #define AU_PRS_FAILURE 2 @@ -838,12 +837,6 @@ void au_print_tok(FILE *outfp, tokenstr_t *tok, char *del, char raw, char sfrm); __END_DECLS -/* - * Apple-internal "wrapping" and utility definitions and prototypes. - */ - -#include <sys/appleapiopts.h> - #ifdef __APPLE_API_PRIVATE #define __BSM_INTERNAL_NOTIFY_KEY "com.apple.audit.change" #endif @@ -1144,55 +1137,6 @@ /* END au_write() WRAPPERS */ - -/* - * audit_token_to_au32() - * - * @summary - Extract information from an audit_token_t, used to identify - * Mach tasks and senders of Mach messages as subjects to the audit system. - * audit_tokent_to_au32() is the only method that should be used to parse - * an audit_token_t, since its internal representation may change over - * time. A pointer parameter may be NULL if that information is not - * needed. - * - * @param atoken - the audit token containing the desired information - * - * @param auidp - Pointer to a uid_t; on return will be set to the task or - * sender's audit user ID - * - * @param euidp - Pointer to a uid_t; on return will be set to the task or - * sender's effective user ID - * - * @param egidp - Pointer to a gid_t; on return will be set to the task or - * sender's effective group ID - * - * @param ruidp - Pointer to a uid_t; on return will be set to the task or - * sender's real user ID - * - * @param rgidp - Pointer to a gid_t; on return will be set to the task or - * sender's real group ID - * - * @param pidp - Pointer to a pid_t; on return will be set to the task or - * sender's process ID - * - * @param asidp - Pointer to an au_asid_t; on return will be set to the - * task or sender's audit session ID - * - * @param tidp - Pointer to an au_tid_t; on return will be set to the task - * or sender's terminal ID - */ -void audit_token_to_au32( - audit_token_t atoken, - uid_t *auidp, - uid_t *euidp, - gid_t *egidp, - uid_t *ruidp, - gid_t *rgidp, - pid_t *pidp, - au_asid_t *asidp, - au_tid_t *tidp); - - __END_DECLS ==== //depot/projects/trustedbsd/audit3/sys/bsm/audit.h#3 (text+ko) ==== @@ -24,9 +24,9 @@ #ifndef _BSM_AUDIT_H #define _BSM_AUDIT_H +#include <sys/param.h> #include <sys/queue.h> #include <sys/ucred.h> -#include <sys/param.h> #include <sys/ipc.h> #include <sys/socket.h> #include <sys/cdefs.h>home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407230153.i6N1rmGS023383>
