]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added hostname, postmaster_address and recipient_delimiter settings...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 20 Sep 2017 19:49:34 +0000 (21:49 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Wed, 4 Oct 2017 22:07:46 +0000 (01:07 +0300)
Copied from lda_settings.

src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h

index 8e2754b19762804201d92b50a51b57cad88d9fa3..9c82b167282e2aeaabd1dedf9f3dd24df6adaa95 100644 (file)
@@ -5,6 +5,7 @@
 #include "hash-format.h"
 #include "var-expand.h"
 #include "unichar.h"
+#include "hostpid.h"
 #include "settings-parser.h"
 #include "mail-index.h"
 #include "mail-user.h"
@@ -60,6 +61,10 @@ static const struct setting_define mail_storage_setting_defines[] = {
        DEF(SET_ENUM, lock_method),
        DEF(SET_STR, pop3_uidl_format),
 
+       DEF(SET_STR_VARS, postmaster_address),
+       DEF(SET_STR, hostname),
+       DEF(SET_STR, recipient_delimiter),
+
        DEF(SET_STR, ssl_client_ca_dir),
        DEF(SET_STR, ssl_client_ca_file),
        DEF(SET_STR, ssl_crypto_device),
@@ -103,6 +108,10 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .lock_method = "fcntl:flock:dotlock",
        .pop3_uidl_format = "%08Xu%08Xv",
 
+       .postmaster_address = "postmaster@%d",
+       .hostname = "",
+       .recipient_delimiter = "+",
+
        .ssl_client_ca_dir = "",
        .ssl_client_ca_file = "",
        .ssl_crypto_device = ""
@@ -463,6 +472,22 @@ static bool mail_storage_settings_check(void *_set, pool_t pool ATTR_UNUSED,
 
        // FIXME: check set->mail_server_admin syntax (RFC 5464, Section 6.2.2)
 
+#ifndef CONFIG_BINARY
+       if (*set->hostname == '\0')
+               set->hostname = p_strdup(pool, my_hostdomain());
+       if (set->postmaster_address[0] == SETTING_STRVAR_UNEXPANDED[0] &&
+           set->postmaster_address[1] == '\0') {
+               /* check for valid looking fqdn in hostname */
+               if (strchr(set->hostname, '.') == NULL) {
+                       *error_r = "postmaster_address setting not given";
+                       return FALSE;
+               }
+               set->postmaster_address =
+                       p_strconcat(pool, SETTING_STRVAR_UNEXPANDED,
+                                   "postmaster@", set->hostname, NULL);
+       }
+#endif
+
        return TRUE;
 }
 
index 288ad69572f0f2c44b3be1e7d0717ea3f0b1609c..fa005f1b314787871435f388c37014ebd46dde23 100644 (file)
@@ -46,6 +46,10 @@ struct mail_storage_settings {
        const char *lock_method;
        const char *pop3_uidl_format;
 
+       const char *postmaster_address;
+       const char *hostname;
+       const char *recipient_delimiter;
+
        const char *ssl_client_ca_dir;
        const char *ssl_client_ca_file;
        const char *ssl_crypto_device;