2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +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:
David Lawrence
2001-04-26 02:38:08 +00:00
parent 2b5f436aeb
commit 5bc6f56bc1

View File

@@ -15,12 +15,13 @@
* 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 <isc/offset.h>
#include <isc/result.h>
#include <isc/stdio.h>
#include <isc/string.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,
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);
}