FreeBSD/contrib/openbsm/libauditd/auditd_lib.c
/*
 * Create the new audit file with appropriate permissions and ownership.
 * Call auditctl(2) for this file.
 * Try to clean up if something goes wrong.
 * *errorp is modified only on auditctl(2) failure.
 */
Create the new audit file with appropriate permissions and ownership.
Call auditctl(2) for this file.
Try to clean up if something goes wrong.
*errorp is modified only on auditctl(2) failure.
Create the new audit file with appropriate permissions and ownership . Call auditctl ( 2 ) for this file . Try to clean up if something goes wrong . * errorp is modified only on auditctl ( 2 ) failure .
static int
open_trail(char *fname, gid_t gid, int *errorp)
{
	int fd;
	fd = open(fname, O_RDONLY | O_CREAT, S_IRUSR);
	if (fd < 0)
		return (-1);
	if (fchown(fd, -1, gid) < 0 || fchmod(fd, S_IRUSR | S_IRGRP) < 0) {
		(void) close(fd);
		(void) unlink(fname);
		return (-1);
	}
	(void) close(fd);
	if (auditctl(fname) < 0) {
		*errorp = errno;
		(void) unlink(fname);
		return (-1);
	}
	(void) auditdist_link(fname);
	return (0);
}
static int open_trail ( char * fname , gid_t gid , int * errorp ) { int fd ; fd = open ( fname , O_RDONLY | O_CREAT , S_IRUSR ) ; if ( fd < 0 ) return ( -1 ) ; if ( fchown ( fd , -1 , gid ) < 0 || fchmod ( fd , S_IRUSR | S_IRGRP ) < 0 ) { ( void ) close ( fd ) ; ( void ) unlink ( fname ) ; return ( -1 ) ; } ( void ) close ( fd ) ; if ( auditctl ( fname ) < 0 ) { * errorp = errno ; ( void ) unlink ( fname ) ; return ( -1 ) ; } ( void ) auditdist_link ( fname ) ; return ( 0 ) ; }
Create the new audit file with appropriate permissions and ownership.
Create the new audit file with appropriate permissions and ownership .
/* XXXPJD: What should we do if the file already exists? */