]> the.earth.li Git - onak.git/blob - onak-conf.h
Fix compilation with later versions of Nettle
[onak.git] / onak-conf.h
1 /**
2  * @file onak-conf.h
3  * @brief Routines related to runtime config.
4  *
5  * Copyright 2002 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __ONAK_CONF_H_
21 #define __ONAK_CONF_H_
22
23 #include <stdbool.h>
24 #include <stdint.h>
25
26 #include "keyarray.h"
27 #include "ll.h"
28
29 /**
30  * @brief Backend database configuration.
31  *
32  */
33 struct onak_db_config {
34         /** Name, as used to refer to individual backend instances */
35         char *name;
36         /** Backend type [e.g. db4, pg, fs, file] */
37         char *type;
38         /** Location information; directory for file backed, DB name for DBs */
39         char *location;
40         /** Database backend hostname, if appropriate */
41         char *hostname;
42         /** Database backend username, if appropriate */
43         char *username;
44         /** Database backend password, if appropriate */
45         char *password;
46 };
47
48 /**
49  * @brief Runtime configuration for onak.
50  *
51  * This structure holds various runtime configuration options for onak. It
52  * will eventually be populated from the config file.
53  */
54 struct onak_config {
55         /*
56          * Generic options.
57          */
58         /** The maximum number of keys a query should return. */
59         int maxkeys;
60         /** Our email address that servers sync with. */
61         char *thissite;
62         /** The email address of the server admin. */
63         char *adminemail;
64         /** The mta to invoke to send sync mails. */
65         char *mta;
66         /** List of email address for sites we sync with via email */
67         struct ll *syncsites;
68         /** A linked list of sites we sync with. */
69         char *logfile;
70
71         /** Set if we're using keyd as the backend. */
72         bool use_keyd;
73         /** The path to the directory the keyd socket lives in. */
74         char *sock_dir;
75
76         /** List of backend configurations */
77         struct ll *backends;
78
79         /* The default backend to use */
80         struct onak_db_config *backend;
81
82         /*
83          * Options for the dynamic backend.
84          */
85         /** Name of the DB backend we're using */
86         char *db_backend;
87         /** Directory where backend .so files can be found */
88         char *backends_dir;
89
90         /** Pointer to the initialisation function for our loaded DB backend */
91         struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool);
92
93         /** Blacklist of fingerprints to reject */
94         struct keyarray blacklist;
95
96         /** What policies should we use for cleaning keys? */
97         uint64_t clean_policies;
98
99         /*
100          * Options used by the email handling script.
101          * None of the C code uses this information, but we should be able
102          * to parse it.
103          */
104         /** Location of the onak binary, so the mail script can find it. */
105         char *bin_dir;
106         /** Where incoming mail gets queue, one file per mail. */
107         char *mail_dir;
108 };
109
110 /**
111  * @brief The variable containing our runtime config.
112  */
113 extern struct onak_config config;
114
115 /**
116  * @brief read the onak config.
117  * @param configfile the config file to read.
118  *
119  * Read in our config file. If config file is NULL read in the compile
120  * time default.
121  */
122 void readconfig(const char *configfile);
123
124 /**
125  * @brief write the onak config.
126  * @param configfile the config file to write to.
127  *
128  * Write out the config file. If config file is NULL write it to STDOUT.
129  */
130 void writeconfig(const char *configfile);
131
132 /**
133  * @brief clean up the config when we're shutting down.
134  */
135 void cleanupconfig(void);
136
137
138 /**
139  * @brief Find a specified backend configuration by name.
140  */
141 struct onak_db_config *find_db_backend_config(struct ll *backends, char *name);
142
143 #endif /* __ONAK_CONF_H_ */