mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
Test that log files can be opened when they are configured, since
isc_log_open() can't effectively report failures when called in isc_log_doit().
This commit is contained in:
@@ -15,12 +15,13 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: logconf.c,v 1.28 2001/03/04 21:21:22 bwelling Exp $ */
|
/* $Id: logconf.c,v 1.29 2001/04/26 02:38:08 tale Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <isc/offset.h>
|
#include <isc/offset.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
|
#include <isc/stdio.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
#include <isc/syslog.h>
|
#include <isc/syslog.h>
|
||||||
|
|
||||||
@@ -209,6 +210,31 @@ channel_fromconf(cfg_obj_t *channel, isc_logconfig_t *lctx) {
|
|||||||
|
|
||||||
result = isc_log_createchannel(lctx, channelname,
|
result = isc_log_createchannel(lctx, channelname,
|
||||||
type, level, &dest, flags);
|
type, level, &dest, flags);
|
||||||
|
|
||||||
|
if (result == ISC_R_SUCCESS && type == ISC_LOG_TOFILE) {
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that the file can be opened, since isc_log_open()
|
||||||
|
* can't effectively report failures when called in
|
||||||
|
* isc_log_doit().
|
||||||
|
*/
|
||||||
|
result = isc_stdio_open(dest.file.name, "a", &fp);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
isc_log_write(ns_g_lctx, DNS_LOGCATEGORY_CONFIG,
|
||||||
|
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||||
|
"logging channel '%s' file '%s': %s",
|
||||||
|
channelname, dest.file.name,
|
||||||
|
isc_result_totext(result));
|
||||||
|
else
|
||||||
|
(void)isc_stdio_close(fp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow named to continue by returning success.
|
||||||
|
*/
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user