s3-eventlog: Make sure the eventlog directory exists.
authorAndreas Schneider <asn@samba.org>
Thu, 13 Dec 2012 16:50:55 +0000 (17:50 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 21 Dec 2012 12:55:59 +0000 (13:55 +0100)
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source3/lib/eventlog/eventlog.c

index 67583b8..0cc0240 100644 (file)
@@ -340,6 +340,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only )
        ELOG_TDB *tdb_node = NULL;
        char *eventlogdir;
        TALLOC_CTX *ctx = talloc_tos();
+       bool ok;
 
        /* check for invalid options */
 
@@ -372,8 +373,10 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only )
        /* make sure that the eventlog dir exists */
 
        eventlogdir = state_path( "eventlog" );
-       if ( !directory_exist( eventlogdir ) )
-               mkdir( eventlogdir, 0755 );
+       ok = directory_create_or_exist(eventlogdir, geteuid(), 0755);
+       if (!ok) {
+               return NULL;
+       }
 
        /* get the path on disk */