From: William Lallemand Date: Wed, 25 Mar 2020 14:10:49 +0000 (+0100) Subject: MINOR: ssl: add a list of bind_conf in struct crtlist X-Git-Tag: v2.2-dev6~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79d31ec0d400693c21c1bfba838ac23bf8a300e4;p=thirdparty%2Fhaproxy.git 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 f4cecfb7f6..add74544d1 100644 --- a/include/types/ssl_sock.h +++ b/include/types/ssl_sock.h @@ -138,8 +138,15 @@ struct ckch_inst { 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 d2e59482b8..1207e9c710 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -4456,6 +4456,7 @@ static int crtlist_load_cert_dir(char *path, struct bind_conf *bind_conf, struct } 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 @@ static int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct pr } 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 @@ int ssl_sock_load_cert_list_file(char *file, int dir, struct bind_conf *bind_con 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 @@ int ssl_sock_load_cert_list_file(char *file, int dir, struct bind_conf *bind_con /* 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 @@ error: LIST_DEL(&inst->by_crtlist_entry); free(inst); } + free(bind_conf_node); } return cfgerr; }