Relax strict checking of log file.
Add a strict_check parameter to create_file_safely() and disable the strict file type checking when opening the log file. This allows the log file to be a device file, fifo, etc.
This commit is contained in:
parent
cb6f868739
commit
14523bb1f1
@ -70,7 +70,7 @@ static unsigned int logging_initialized = FALSE; /* boolean */
|
||||
*/
|
||||
int open_log_file (const char *log_file_name)
|
||||
{
|
||||
log_file_fd = create_file_safely (log_file_name, FALSE);
|
||||
log_file_fd = create_file_safely (log_file_name, FALSE, FALSE);
|
||||
return log_file_fd;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,8 @@ send_http_message (struct conn_s *connptr, int http_code,
|
||||
/*
|
||||
* Safely creates filename and returns the low-level file descriptor.
|
||||
*/
|
||||
int create_file_safely (const char *filename, unsigned int truncate_file)
|
||||
int create_file_safely (const char *filename, unsigned int truncate_file,
|
||||
unsigned int strict_check)
|
||||
{
|
||||
struct stat lstatinfo;
|
||||
int fildes;
|
||||
@ -112,6 +113,7 @@ int create_file_safely (const char *filename, unsigned int truncate_file)
|
||||
return fildes;
|
||||
}
|
||||
|
||||
if (strict_check) {
|
||||
/*
|
||||
* fstat() the opened file and check that the file mode bits,
|
||||
* inode, and device match.
|
||||
@ -142,6 +144,7 @@ int create_file_safely (const char *filename, unsigned int truncate_file)
|
||||
close (fildes);
|
||||
return -EMLINK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Just return the file descriptor if we _don't_ want the file
|
||||
@ -194,7 +197,7 @@ pidfile_create (const char *filename)
|
||||
/*
|
||||
* Create a new file
|
||||
*/
|
||||
if ((fildes = create_file_safely (filename, TRUE)) < 0)
|
||||
if ((fildes = create_file_safely (filename, TRUE, TRUE)) < 0)
|
||||
return fildes;
|
||||
|
||||
/*
|
||||
|
@ -32,6 +32,7 @@ extern int send_http_message (struct conn_s *connptr, int http_code,
|
||||
|
||||
extern int pidfile_create (const char *path);
|
||||
extern int create_file_safely (const char *filename,
|
||||
unsigned int truncate_file);
|
||||
unsigned int truncate_file,
|
||||
unsigned int strict_check);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user