@ -29,6 +29,7 @@
# include "conf.h" /* ConfNode, etc. */
# include "conf.h" /* ConfNode, etc. */
# include "output.h" /* DEFAULT_LOG_* */
# include "output.h" /* DEFAULT_LOG_* */
# include "util-byte.h"
# include "util-byte.h"
# include "util-path.h"
# include "util-logopenfile.h"
# include "util-logopenfile.h"
# include "util-logopenfile-tile.h"
# include "util-logopenfile-tile.h"
@ -243,41 +244,6 @@ static char *SCLogFilenameFromPattern(const char *pattern)
return filename ;
return filename ;
}
}
/** \brief recursively create missing log directories
* \ param path path to log file
* \ retval 0 on success
* \ retval - 1 on error
*/
static int SCLogCreateDirectoryTree ( const char * filepath )
{
char pathbuf [ PATH_MAX ] ;
char * p ;
size_t len = strlen ( filepath ) ;
if ( len > PATH_MAX - 1 ) {
return - 1 ;
}
strlcpy ( pathbuf , filepath , len ) ;
for ( p = pathbuf + 1 ; * p ; p + + ) {
if ( * p = = ' / ' ) {
/* Truncate, while creating directory */
* p = ' \0 ' ;
if ( SCMkDir ( pathbuf , S_IRWXU | S_IRGRP | S_IXGRP ) ! = 0 ) {
if ( errno ! = EEXIST ) {
return - 1 ;
}
}
* p = ' / ' ;
}
}
return 0 ;
}
static void SCLogFileClose ( LogFileCtx * log_ctx )
static void SCLogFileClose ( LogFileCtx * log_ctx )
{
{
if ( log_ctx - > fp )
if ( log_ctx - > fp )
@ -301,7 +267,7 @@ SCLogOpenFileFp(const char *path, const char *append_setting, uint32_t mode)
return NULL ;
return NULL ;
}
}
int rc = SC Log CreateDirectoryTree( filename ) ;
int rc = SC CreateDirectoryTree( filename ) ;
if ( rc < 0 ) {
if ( rc < 0 ) {
SCFree ( filename ) ;
SCFree ( filename ) ;
return NULL ;
return NULL ;