FreeBSD/contrib/openbsm/bin/auditd/auditd.c
/*
 * Close the previous audit trail file.
 */
Close the previous audit trail file.
Close the previous audit trail file .
static int
close_lastfile(char *TS)
{
	char *ptr;
	char *oldname;
	if (lastfile == NULL)
		lastfile = get_curfile();
	if (lastfile != NULL) {
		oldname = strdup(lastfile);
		if (oldname == NULL)
			return (-1);
		if ((ptr = strstr(lastfile, NOT_TERMINATED)) != NULL) {
			memcpy(ptr, TS, POSTFIX_LEN);
			if (auditd_rename(oldname, lastfile) != 0)
				auditd_log_err(
				    "Could not rename %s to %s: %m", oldname,
				    lastfile);
			else {
				(void) unlink(AUDIT_CURRENT_LINK);
				auditd_log_notice("renamed %s to %s",
				    oldname, lastfile);
				audit_warn_closefile(lastfile);
			}
		} else
			auditd_log_err("Could not rename %s to %s", oldname,
			    lastfile);
		free(lastfile);
		free(oldname);
		lastfile = NULL;
	}
	return (0);
}
static int close_lastfile ( char * TS ) { char * ptr ; char * oldname ; if ( lastfile == NULL ) lastfile = get_curfile ( ) ; if ( lastfile != NULL ) { oldname = strdup ( lastfile ) ; if ( oldname == NULL ) return ( -1 ) ; if ( ( ptr = strstr ( lastfile , NOT_TERMINATED ) ) != NULL ) { memcpy ( ptr , TS , POSTFIX_LEN ) ; if ( auditd_rename ( oldname , lastfile ) != 0 ) auditd_log_err ( " " , oldname , lastfile ) ; else { ( void ) unlink ( AUDIT_CURRENT_LINK ) ; auditd_log_notice ( " " , oldname , lastfile ) ; audit_warn_closefile ( lastfile ) ; } } else auditd_log_err ( " " , oldname , lastfile ) ; free ( lastfile ) ; free ( oldname ) ; lastfile = NULL ; } return ( 0 ) ; }
Close the previous audit trail file.
Close the previous audit trail file .
/* If lastfile is NULL try to get it from the 'current' link.  */ /* Rename the last file -- append timestamp. */ /*
				 * Remove the 'current' symlink since the link
				 * is now invalid.
				 */