mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
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.
This commit is contained in:
parent
638f6ad033
commit
79d31ec0d4
@ -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 */
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user