MINOR: ssl: add a list of bind_conf in struct crtlist
In order to be able to add new certificate in a crt-list, we need the
list of bind_conf that uses this crt-list so we can create a ckch_inst
for each of them.
diff --git a/include/types/ssl_sock.h b/include/types/ssl_sock.h
index f4cecfb..add7454 100644
--- a/include/types/ssl_sock.h
+++ b/include/types/ssl_sock.h
@@ -138,8 +138,15 @@
struct list by_crtlist_entry; /* chained in crtlist_entry list of inst */
};
+/* list of bind conf used by struct crtlist */
+struct bind_conf_list {
+ struct bind_conf *bind_conf;
+ struct bind_conf_list *next;
+};
+
/* This structure is basically a crt-list or a directory */
struct crtlist {
+ struct bind_conf_list *bind_conf; /* list of bind_conf which use this crtlist */
struct eb_root entries;
struct list ord_entries; /* list to keep the line order of the crt-list file */
struct ebmb_node node; /* key is the filename or directory */
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index d2e5948..1207e9c 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -4456,6 +4456,7 @@
}
memcpy(dir->node.key, path, strlen(path) + 1);
dir->entries = EB_ROOT_UNIQUE; /* it's a directory, files are unique */
+ dir->bind_conf = NULL;
LIST_INIT(&dir->ord_entries);
n = scandir(path, &de_list, 0, alphasort);
@@ -4719,6 +4720,7 @@
}
memcpy(newlist->node.key, file, strlen(file) + 1);
newlist->entries = EB_ROOT;
+ newlist->bind_conf = NULL;
LIST_INIT(&newlist->ord_entries);
while (fgets(thisline, sizeof(thisline), f) != NULL) {
@@ -4896,9 +4898,20 @@
struct ebmb_node *eb;
struct crtlist_entry *entry;
struct list instances; /* temporary list head */
+ struct bind_conf_list *bind_conf_node = NULL;
int cfgerr = 0;
LIST_INIT(&instances);
+
+ bind_conf_node = malloc(sizeof(*bind_conf_node));
+ if (!bind_conf_node) {
+ memprintf(err, "%sCan't alloc memory!\n", err && *err ? *err : "");
+ cfgerr |= ERR_FATAL | ERR_ALERT;
+ goto error;
+ }
+ bind_conf_node->next = NULL;
+ bind_conf_node->bind_conf = bind_conf;
+
/* look for an existing crtlist or create one */
eb = ebst_lookup(&crtlists_tree, file);
if (eb) {
@@ -4935,6 +4948,10 @@
/* add the instances to the actual instance list in the crtlist_entry */
LIST_SPLICE(&entry->ckch_inst, &instances);
+ /* add the bind_conf to the list */
+ bind_conf_node->next = crtlist->bind_conf;
+ crtlist->bind_conf = bind_conf_node;
+
return cfgerr;
error:
{
@@ -4952,6 +4969,7 @@
LIST_DEL(&inst->by_crtlist_entry);
free(inst);
}
+ free(bind_conf_node);
}
return cfgerr;
}