X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=onak-conf.h;h=3e02b7a0226769bacc240e47db3972a7e42d7aca;hp=34dcff2edd89c45aa3c63a4bb01bf23b2e3599a1;hb=adc800dbc424a1e246dd4a82a0c2e88eeda25531;hpb=8e0907be1d73011075a99a0c029c56664e12843e diff --git a/onak-conf.h b/onak-conf.h index 34dcff2..3e02b7a 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -14,14 +14,35 @@ * more details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * this program. If not, see . */ #ifndef __ONAK_CONF_H_ #define __ONAK_CONF_H_ -#include "keydb.h" +#include +#include + +#include "ll.h" + +/** + * @brief Backend database configuration. + * + */ +struct onak_db_config { + /** Name, as used to refer to individual backend instances */ + char *name; + /** Backend type [e.g. db4, pg, fs, file] */ + char *type; + /** Location information; directory for file backed, DB name for DBs */ + char *location; + /** Database backend hostname, if appropriate */ + char *hostname; + /** Database backend username, if appropriate */ + char *username; + /** Database backend password, if appropriate */ + char *password; +}; /** * @brief Runtime configuration for onak. @@ -48,25 +69,14 @@ struct onak_config { /** Set if we're using keyd as the backend. */ bool use_keyd; + /** The path to the directory the keyd socket lives in. */ + char *sock_dir; - /* - * Options for any database backend that needs a directory, be it the - * file, fs or db4 options. - */ - /** The path to the directory containing the database files. */ - char *db_dir; - - /* - * Options for the Postgres backend. - */ - /** The host that Postgres is running on. */ - char *pg_dbhost; - /** The database name. */ - char *pg_dbname; - /** The user we should connect as. */ - char *pg_dbuser; - /** The password for the user. */ - char *pg_dbpass; + /** List of backend configurations */ + struct ll *backends; + + /* The default backend to use */ + struct onak_db_config *backend; /* * Options for the dynamic backend. @@ -77,10 +87,20 @@ struct onak_config { char *backends_dir; /** Pointer to the initialisation function for our loaded DB backend */ - struct onak_dbctx *(*dbinit)(bool); + struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool); - /** Should we verify signature hashes match? */ - bool check_sighash; + /** What policies should we use for cleaning keys? */ + uint64_t clean_policies; + + /* + * Options used by the email handling script. + * None of the C code uses this information, but we should be able + * to parse it. + */ + /** Location of the onak binary, so the mail script can find it. */ + char *bin_dir; + /** Where incoming mail gets queue, one file per mail. */ + char *mail_dir; }; /** @@ -97,9 +117,23 @@ extern struct onak_config config; */ void readconfig(const char *configfile); +/** + * @brief write the onak config. + * @param configfile the config file to write to. + * + * Write out the config file. If config file is NULL write it to STDOUT. + */ +void writeconfig(const char *configfile); + /** * @brief clean up the config when we're shutting down. */ void cleanupconfig(void); + +/** + * @brief Find a specified backend configuration by name. + */ +struct onak_db_config *find_db_backend_config(struct ll *backends, char *name); + #endif /* __ONAK_CONF_H_ */