mail-storage-service.h revision 95d9395d15540b3a96f75c7f9fd73e6d8ad5e897
2ronwalf#ifndef MAIL_STORAGE_SERVICE_H
2ronwalf#define MAIL_STORAGE_SERVICE_H
2ronwalf
2ronwalf#include "network.h"
2ronwalf
2ronwalfstruct master_service;
2ronwalfstruct mail_user;
2ronwalf
2ronwalfenum mail_storage_service_flags {
2ronwalf /* Fail if we don't drop root privileges */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT = 0x01,
2ronwalf /* Lookup user from userdb */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP = 0x02,
2ronwalf /* Force mail_debug=yes */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_DEBUG = 0x04,
2ronwalf /* Keep the current process permissions */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS = 0x08,
2ronwalf /* Don't chdir() to user's home */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR = 0x10,
2ronwalf /* Drop privileges only temporarily (keep running as setuid-root) */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP = 0x20,
2ronwalf /* Enable core dumps even when dropping privileges temporarily */
2ronwalf MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS = 0x40,
2ronwalf /* Don't initialize logging or change log prefixes */
2ronwalf MAIL_STORAGE_SERVICE_NO_LOG_INIT = 0x80
2ronwalf};
2ronwalf
2ronwalfstruct mail_storage_service_input {
2ronwalf const char *module;
2ronwalf const char *service;
2ronwalf const char *username;
2ronwalf struct ip_addr local_ip, remote_ip;
2ronwalf
2ronwalf const char *const *userdb_fields;
2ronwalf};
2ronwalf
2ronwalfstruct setting_parser_info;
2ronwalfstruct mail_storage_service_user;
2ronwalf
2ronwalfstruct mail_storage_service_ctx *
2ronwalfmail_storage_service_init(struct master_service *service,
2ronwalf const struct setting_parser_info *set_roots[],
2ronwalf enum mail_storage_service_flags flags);
2ronwalfstruct auth_master_connection *
2ronwalfmail_storage_service_get_auth_conn(struct mail_storage_service_ctx *ctx);
7daenzeroramaint mail_storage_service_read_settings(struct mail_storage_service_ctx *ctx,
2ronwalf const struct mail_storage_service_input *input,
2ronwalf pool_t pool,
2ronwalf const struct setting_parser_info **user_info_r,
2ronwalf const char **error_r);
2ronwalf/* Read settings and initialize context to use them. Do nothing if service is
2ronwalf already initialized. This is mainly necessary when calling _get_auth_conn()
7daenzerorama or _all_init(). */
2ronwalfvoid mail_storage_service_init_settings(struct mail_storage_service_ctx *ctx,
2ronwalf const struct mail_storage_service_input *input);
2ronwalf/* Returns 1 if ok, 0 if user wasn't found, -1 if error. */
2ronwalfint mail_storage_service_lookup(struct mail_storage_service_ctx *ctx,
2ronwalf const struct mail_storage_service_input *input,
2ronwalf struct mail_storage_service_user **user_r,
7daenzerorama const char **error_r);
2ronwalfint mail_storage_service_next(struct mail_storage_service_ctx *ctx,
2ronwalf struct mail_storage_service_user *user,
2ronwalf struct mail_user **mail_user_r,
2ronwalf const char **error_r);
2ronwalf/* Combine lookup() and next() into one call. */
2ronwalfint mail_storage_service_lookup_next(struct mail_storage_service_ctx *ctx,
2ronwalf const struct mail_storage_service_input *input,
2ronwalf struct mail_storage_service_user **user_r,
2ronwalf struct mail_user **mail_user_r,
2ronwalf const char **error_r);
2ronwalfvoid mail_storage_service_user_free(struct mail_storage_service_user **user);
2ronwalf/* Initialize iterating through all users. Return the number of users. */
2ronwalfunsigned int
2ronwalfmail_storage_service_all_init(struct mail_storage_service_ctx *ctx);
2ronwalf/* Iterate through all usernames. Returns 1 if username was returned, 0 if
2ronwalf there are no more users, -1 if error. */
2ronwalfint mail_storage_service_all_next(struct mail_storage_service_ctx *ctx,
2ronwalf const char **username_r);
2ronwalfvoid mail_storage_service_deinit(struct mail_storage_service_ctx **ctx);
2ronwalf
2ronwalf/* Return the settings pointed to by set_root parameter in _init().
2ronwalf The settings contain all the changes done by userdb lookups. */
2ronwalfvoid **mail_storage_service_user_get_set(struct mail_storage_service_user *user);
2ronwalfconst struct mail_storage_service_input *
2ronwalfmail_storage_service_user_get_input(struct mail_storage_service_user *user);
2ronwalfstruct setting_parser_context *
2ronwalfmail_storage_service_user_get_settings_parser(struct mail_storage_service_user *user);
2ronwalf
2ronwalf/* Return the settings pointed to by set_root parameter in _init() */
2ronwalfvoid *mail_storage_service_get_settings(struct master_service *service);
2ronwalf
2ronwalf#endif
2ronwalf