#ifndef MAIL_STORAGE_SERVICE_H
#define MAIL_STORAGE_SERVICE_H
#include "net.h"
struct master_service;
struct mail_user;
struct setting_parser_context;
struct setting_parser_info;
struct mail_storage_service_user;
enum mail_storage_service_flags {
/* Allow not dropping root privileges */
/* Lookup user from userdb */
/* Force mail_debug=yes */
/* Keep the current process permissions */
/* Don't chdir() to user's home */
/* Drop privileges only temporarily (keep running as setuid-root) */
/* Enable core dumps even when dropping privileges temporarily */
/* Don't initialize logging or change log prefixes */
/* Don't load plugins in _service_lookup() */
/* Don't close auth connections because of idling. */
/* When executing doveconf, tell it to use sysexits codes */
/* Don't create namespaces, only the user. */
};
struct mail_storage_service_input {
const char *module;
const char *service;
const char *username;
/* If set, use this string as the session ID */
const char *session_id;
/* If set, use this string as the session ID prefix, but also append
a unique session ID suffix to it. */
const char *session_id_prefix;
/* If non-zero, override timestamp when session was created and set
mail_user.session_restored=TRUE */
const char *const *userdb_fields;
/* Override specified global flags */
/* override MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP for this lookup */
/* Enable auth_debug=yes for this lookup */
/* Connection is secure (SSL or just trusted) */
/* Connection is secured using SSL specifically */
};
extern struct module *mail_storage_service_modules;
struct mail_storage_service_ctx *
const struct setting_parser_info *set_roots[],
struct auth_master_connection *
/* Set auth connection (instead of creating a new one automatically). */
struct auth_master_connection *conn);
const struct mail_storage_service_input *input,
const struct setting_parser_info **user_info_r,
const struct setting_parser_context **parser_r,
/* Read settings and initialize context to use them. Do nothing if service is
already initialized. This is mainly necessary when calling _get_auth_conn()
or _all_init(). */
const struct mail_storage_service_input *input)
ATTR_NULL(2);
/* Returns 1 if ok, 0 if user wasn't found, -1 if fatal error,
-2 if error is user-specific (e.g. invalid settings). */
const struct mail_storage_service_input *input,
struct mail_storage_service_user **user_r,
const char **error_r);
/* The next mail_storage_service_lookup() will save the userdb fields into the
given pointer, allocated from the given pool. */
/* Returns 0 if ok, -1 if fatal error, -2 if error is user-specific. */
struct mail_storage_service_user *user,
struct mail_user **mail_user_r,
const char **error_r);
/* Returns 0 if ok, -1 if fatal error, -2 if error is user-specific. */
struct mail_storage_service_user *user,
const char *session_id_postfix,
struct mail_user **mail_user_r,
const char **error_r);
struct mail_storage_service_user *user);
/* Combine lookup() and next() into one call. */
const struct mail_storage_service_input *input,
struct mail_storage_service_user **user_r,
struct mail_user **mail_user_r,
const char **error_r);
/* Initialize iterating through all users. */
/* Initialize iterating through all users with a user mask hint to the
userdb iteration lookup. This itself isn't yet guaranteed to filter out any
usernames. */
const char *user_mask_hint);
/* Iterate through all usernames. Returns 1 if username was returned, 0 if
there are no more users, -1 if error. */
const char **username_r);
/* Activate user context. Normally this is called automatically by the ioloop,
but e.g. during loops at deinit where all users are being destroyed, it's
useful to call this to set the correct user-specific log prefix. */
/* Deactivate user context. This only switches back to non-user-specific
log prefix. */
/* Return the settings pointed to by set_root parameter in _init().
The settings contain all the changes done by userdb lookups. */
const struct mail_storage_settings *
const struct mail_storage_service_input *
struct setting_parser_context *
struct mail_storage_service_ctx *
const struct var_expand_table *
struct mail_storage_service_input *input);
const char *mail_storage_service_fields_var_expand(const char *data,
const char *const *fields);
/* Return the settings pointed to by set_root parameter in _init() */
/* Updates settings for storage service user, forwards return value of settings_parse_keyvalue() */
const char *key,
const char *value,
const char **error_r);
#endif