mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Merge branch '189-fix-tsig-dump-keyfile-name-generation-issues' into 'master'
Resolve "Fix TSIG dump keyfile name generation issues" Closes #189 See merge request isc-projects/bind9!164
This commit is contained in:
@@ -13,8 +13,10 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef HAVE_LMDB
|
#ifdef HAVE_LMDB
|
||||||
#include <lmdb.h>
|
#include <lmdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <isc/file.h>
|
#include <isc/file.h>
|
||||||
@@ -350,28 +352,28 @@ destroy(dns_view_t *view) {
|
|||||||
|
|
||||||
if (view->dynamickeys != NULL) {
|
if (view->dynamickeys != NULL) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
char template[20];
|
char template[PATH_MAX];
|
||||||
char keyfile[20];
|
char keyfile[PATH_MAX];
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
int n;
|
|
||||||
|
|
||||||
n = snprintf(keyfile, sizeof(keyfile), "%s.tsigkeys",
|
result = isc_file_mktemplate(NULL, template, sizeof(template));
|
||||||
view->name);
|
if (result == ISC_R_SUCCESS) {
|
||||||
if (n > 0 && (size_t)n < sizeof(keyfile)) {
|
(void)isc_file_openuniqueprivate(template, &fp);
|
||||||
result = isc_file_mktemplate(keyfile, template,
|
|
||||||
sizeof(template));
|
|
||||||
if (result == ISC_R_SUCCESS)
|
|
||||||
(void)isc_file_openuniqueprivate(template, &fp);
|
|
||||||
}
|
}
|
||||||
if (fp == NULL)
|
if (fp == NULL) {
|
||||||
dns_tsigkeyring_detach(&view->dynamickeys);
|
dns_tsigkeyring_detach(&view->dynamickeys);
|
||||||
else {
|
} else {
|
||||||
result = dns_tsigkeyring_dumpanddetach(
|
result = dns_tsigkeyring_dumpanddetach
|
||||||
&view->dynamickeys, fp);
|
(&view->dynamickeys, fp);
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
if (fclose(fp) == 0)
|
if (fclose(fp) == 0) {
|
||||||
result = isc_file_rename(template,
|
result = isc_file_sanitize
|
||||||
keyfile);
|
(NULL, view->name, "tsigkeys",
|
||||||
|
keyfile, sizeof(keyfile));
|
||||||
|
if (result == ISC_R_SUCCESS)
|
||||||
|
result = isc_file_rename
|
||||||
|
(template, keyfile);
|
||||||
|
}
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
(void)remove(template);
|
(void)remove(template);
|
||||||
} else {
|
} else {
|
||||||
@@ -905,15 +907,15 @@ dns_view_getdynamickeyring(dns_view_t *view, dns_tsig_keyring_t **ringp) {
|
|||||||
void
|
void
|
||||||
dns_view_restorekeyring(dns_view_t *view) {
|
dns_view_restorekeyring(dns_view_t *view) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char keyfile[20];
|
char keyfile[PATH_MAX];
|
||||||
int n;
|
isc_result_t result;
|
||||||
|
|
||||||
REQUIRE(DNS_VIEW_VALID(view));
|
REQUIRE(DNS_VIEW_VALID(view));
|
||||||
|
|
||||||
if (view->dynamickeys != NULL) {
|
if (view->dynamickeys != NULL) {
|
||||||
n = snprintf(keyfile, sizeof(keyfile), "%s.tsigkeys",
|
result = isc_file_sanitize(NULL, view->name, "tsigkeys",
|
||||||
view->name);
|
keyfile, sizeof(keyfile));
|
||||||
if (n > 0 && (size_t)n < sizeof(keyfile)) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
fp = fopen(keyfile, "r");
|
fp = fopen(keyfile, "r");
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
dns_keyring_restore(view->dynamickeys, fp);
|
dns_keyring_restore(view->dynamickeys, fp);
|
||||||
|
@@ -24,6 +24,10 @@
|
|||||||
*** Network.
|
*** Network.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX _MAX_PATH
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ISC_PLATFORM_HAVEIPV6
|
#define ISC_PLATFORM_HAVEIPV6
|
||||||
#if _MSC_VER > 1200
|
#if _MSC_VER > 1200
|
||||||
#define ISC_PLATFORM_HAVEIN6PKTINFO
|
#define ISC_PLATFORM_HAVEIN6PKTINFO
|
||||||
|
Reference in New Issue
Block a user