Add filename and linenum arguments to the crt-store / ckch_conf parsing.
It allows to use them in the parsing function so we could emits error.
const char *name;
ssize_t offset;
enum parse_type_t type;
- int (*func)(void *value, char *buf, struct ckch_data *d, int cli, char **err);
+ int (*func)(void *value, char *buf, struct ckch_data *d, int cli, const char *filename, int linenum, char **err);
};
extern struct ckch_conf_kws ckch_conf_kws[];
/* ckch_store functions */
struct ckch_store *ckch_store_new_load_files_path(char *path, char **err);
-struct ckch_store *ckch_store_new_load_files_conf(char *name, struct ckch_conf *conf, char **err);
+struct ckch_store *ckch_store_new_load_files_conf(char *name, struct ckch_conf *conf, const char *filename, int linenum, char **err);
struct ckch_store *ckchs_lookup(char *path);
struct ckch_store *ckchs_dup(const struct ckch_store *src);
struct ckch_store *ckch_store_new(const char *filename);
void ckch_store_free(struct ckch_store *store);
void ckch_store_replace(struct ckch_store *old_ckchs, struct ckch_store *new_ckchs);
-int ckch_store_load_files(struct ckch_conf *f, struct ckch_store *c, int cli, char **err);
+int ckch_store_load_files(struct ckch_conf *f, struct ckch_store *c, int cli, const char *file, int linenum, char **err);
/* ckch_conf functions */
* The following macro allow to declare a wrapper on function that actually load files
*
*/
-#define DECLARE_CKCH_CONF_LOAD(name, base, callback) \
-static inline int ckch_conf_load_##name(void *value, char *buf, struct ckch_data *d, int cli, char **err) \
-{ \
- char path[PATH_MAX]; \
- int err_code = 0; \
- if (cli) \
- return 0; \
- err_code |= path_base(value, (base), path, err); \
- if (err_code & ERR_CODE) \
- goto out; \
- err_code |= (callback)(path, buf, d, err); \
-out: \
- return err_code; \
+#define DECLARE_CKCH_CONF_LOAD(name, base, callback) \
+static inline int ckch_conf_load_##name(void *value, char *buf, struct ckch_data *d, int cli, const char *filename, int linenum, char **err) \
+{ \
+ char path[PATH_MAX]; \
+ int err_code = 0; \
+ if (cli) \
+ return 0; \
+ err_code |= path_base(value, (base), path, err); \
+ if (err_code & ERR_CODE) \
+ goto out; \
+ err_code |= (callback)(path, buf, d, err); \
+out: \
+ return err_code; \
};
#endif /* USE_OPENSSL */
int ssl_ocsp_update_insert(struct certificate_ocsp *ocsp);
-int ocsp_update_init(void *value, char *buf, struct ckch_data *d, int cli, char **err);
+int ocsp_update_init(void *value, char *buf, struct ckch_data *d, int cli, const char *filename, int linenum, char **err);
#endif /* (defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB && !defined OPENSSL_NO_OCSP) */
* This function allocate a ckch_store and populate it with certificates using
* the ckch_conf structure.
*/
-struct ckch_store *ckch_store_new_load_files_conf(char *name, struct ckch_conf *conf, char **err)
+struct ckch_store *ckch_store_new_load_files_conf(char *name, struct ckch_conf *conf, const char *file, int linenum, char **err)
{
struct ckch_store *ckchs;
int cfgerr = ERR_NONE;
}
/* load files using the ckch_conf */
- cfgerr = ckch_store_load_files(conf, ckchs, 0, err);
+ cfgerr = ckch_store_load_files(conf, ckchs, 0, file, linenum, err);
if (cfgerr & ERR_FATAL)
goto end;
/* crt-store does not try to find files, but use the stored filename */
-int ckch_store_load_files(struct ckch_conf *f, struct ckch_store *c, int cli, char **err)
+int ckch_store_load_files(struct ckch_conf *f, struct ckch_store *c, int cli, const char *file, int linenum, char **err)
{
int i;
int err_code = 0;
if (!v)
goto next;
- rc = ckch_conf_kws[i].func(v, NULL, d, cli, err);
+ rc = ckch_conf_kws[i].func(v, NULL, d, cli, file, linenum, err);
if (rc) {
err_code |= ERR_ALERT | ERR_FATAL;
memprintf(err, "%s '%s' cannot be read or parsed.", err && *err ? *err : "", v);
case PARSE_TYPE_ONOFF:
{
int v = *(int *)src;
- rc = ckch_conf_kws[i].func(&v, NULL, d, cli, err);
+ rc = ckch_conf_kws[i].func(&v, NULL, d, cli, file, linenum, err);
if (rc) {
err_code |= ERR_ALERT | ERR_FATAL;
memprintf(err, "%s '%d' cannot be read or parsed.", err && *err ? *err : "", v);
if (!c)
goto alloc_error;
- err_code |= ckch_store_load_files(&f, c, 0, err);
+ err_code |= ckch_store_load_files(&f, c, 0, file, linenum, err);
if (err_code & ERR_FATAL)
goto out;
}
}
- ckchs = ckch_store_new_load_files_conf(crt_path, cc, err);
+ ckchs = ckch_store_new_load_files_conf(crt_path, cc, file, linenum, err);
if (ckchs == NULL) {
cfgerr |= ERR_ALERT | ERR_FATAL;
goto error;
store->conf = cc;
/* fresh new, run more init (for example init ocsp-update tasks) */
- cfgerr |= ckch_store_load_files(&cc, store, 1, &err);
+ cfgerr |= ckch_store_load_files(&cc, store, 1, "CLI", 1, &err);
if (cfgerr & ERR_FATAL)
goto error;