@@ -232,11 +232,11 @@ void exfile_enable_triggers(exfile_t *ef, CONF_SECTION *conf, char const *trigge
232232 * Try to open the file. It it doesn't exist, try to
233233 * create it's parent directories.
234234 */
235- static int exfile_open_mkdir (exfile_t * ef , char const * filename , mode_t permissions )
235+ static int exfile_open_mkdir (exfile_t * ef , char const * filename , mode_t permissions , int flags )
236236{
237237 int fd ;
238238
239- fd = open (filename , O_RDWR | O_CREAT , permissions );
239+ fd = open (filename , O_RDWR | O_CREAT | flags , permissions );
240240 if (fd < 0 ) {
241241 mode_t dirperm ;
242242 char * p , * dir ;
@@ -271,7 +271,7 @@ static int exfile_open_mkdir(exfile_t *ef, char const *filename, mode_t permissi
271271 }
272272 talloc_free (dir );
273273
274- fd = open (filename , O_RDWR | O_CREAT , permissions );
274+ fd = open (filename , O_RDWR | O_CREAT | flags , permissions );
275275 if (fd < 0 ) {
276276 fr_strerror_printf ("Failed to open file %s: %s" , filename , fr_syserror (errno ));
277277 return -1 ;
@@ -286,7 +286,7 @@ static int exfile_open_mkdir(exfile_t *ef, char const *filename, mode_t permissi
286286 * to influence whether and which __coverity*__() functions are called. We therefore create a
287287 * separate function for the locking case which we *can* model.
288288 */
289- static int exfile_open_lock (exfile_t * ef , char const * filename , mode_t permissions , off_t * offset )
289+ static int exfile_open_lock (exfile_t * ef , char const * filename , mode_t permissions , int flags , off_t * offset )
290290{
291291 int i , tries , unused = -1 , found = -1 , oldest = -1 ;
292292 bool do_cleanup = false;
@@ -399,7 +399,7 @@ static int exfile_open_lock(exfile_t *ef, char const *filename, mode_t permissio
399399 ef -> entries [i ].fd = -1 ;
400400
401401reopen :
402- ef -> entries [i ].fd = exfile_open_mkdir (ef , filename , permissions );
402+ ef -> entries [i ].fd = exfile_open_mkdir (ef , filename , permissions , flags );
403403 if (ef -> entries [i ].fd < 0 ) goto error ;
404404
405405 exfile_trigger (ef , & ef -> entries [i ], EXFILE_TRIGGER_OPEN );
@@ -432,7 +432,7 @@ static int exfile_open_lock(exfile_t *ef, char const *filename, mode_t permissio
432432 }
433433
434434 close (ef -> entries [i ].fd );
435- ef -> entries [i ].fd = open (filename , O_RDWR | O_CREAT , permissions );
435+ ef -> entries [i ].fd = open (filename , O_RDWR | O_CREAT | flags , permissions );
436436 if (ef -> entries [i ].fd < 0 ) {
437437 fr_strerror_printf ("Failed to open file %s: %s" , filename , fr_syserror (errno ));
438438 goto error ;
@@ -518,17 +518,18 @@ static int exfile_open_lock(exfile_t *ef, char const *filename, mode_t permissio
518518 * @param ef The logfile context returned from exfile_init().
519519 * @param filename the file to open.
520520 * @param permissions to use.
521+ * @param flags flags to pass to open.
521522 * @param offset Optional pointer to store offset in when seeking the end of file.
522523 * @return
523524 * - FD used to write to the file.
524525 * - -1 on failure.
525526 */
526- int exfile_open (exfile_t * ef , char const * filename , mode_t permissions , off_t * offset )
527+ int exfile_open (exfile_t * ef , char const * filename , mode_t permissions , int flags , off_t * offset )
527528{
528529 if (!ef || !filename ) return -1 ;
529530
530531 if (!ef -> locking ) {
531- int found = exfile_open_mkdir (ef , filename , permissions );
532+ int found = exfile_open_mkdir (ef , filename , permissions , flags );
532533 off_t real_offset ;
533534
534535 if (found < 0 ) return -1 ;
@@ -537,7 +538,7 @@ int exfile_open(exfile_t *ef, char const *filename, mode_t permissions, off_t *o
537538 return found ;
538539 }
539540
540- return exfile_open_lock (ef , filename , permissions , offset );
541+ return exfile_open_lock (ef , filename , permissions , flags , offset );
541542}
542543
543544/*
0 commit comments