]> git.ipfire.org Git - people/ms/dma.git/blobdiff - conf.c
local: use space instead of tab in "From " separator
[people/ms/dma.git] / conf.c
diff --git a/conf.c b/conf.c
index b676f9ce9209dc9e48eca57364a2e09fa7fc7667..3e3c7d3d8bd2af783d196ee850451bcb2f5f09df 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -56,8 +56,6 @@ trim_line(char *line)
        size_t linelen;
        char *p;
 
-       p = line;
-
        if ((p = strchr(line, '\n')))
                *p = (char)0;
 
@@ -66,7 +64,7 @@ trim_line(char *line)
        if (line[0] == '.') {
                if ((linelen + 2) > 1000) {
                        syslog(LOG_CRIT, "Cannot escape leading dot.  Buffer overflow");
-                       exit(1);
+                       exit(EX_DATAERR);
                }
                memmove((line + 1), line, (linelen + 1));
                line[0] = '.';
@@ -84,59 +82,6 @@ chomp(char *str)
                str[len - 1] = 0;
 }
 
-/*
- * Read the virtual user table
- */
-void
-parse_virtuser(const char *path)
-{
-       char line[2048];
-       FILE *v;
-       char *data;
-       struct virtuser *vu;
-       int lineno = 0;
-
-       v = fopen(path, "r");
-       if (v == NULL) {
-               errlog(1, "can not open virtuser file `%s'", path);
-               /* NOTREACHED */
-       }
-
-       while (!feof(v)) {
-               if (fgets(line, sizeof(line), v) == NULL)
-                       break;
-               lineno++;
-
-               chomp(line);
-
-               /* We hit a comment */
-               if (*line == '#')
-                       continue;
-               /* Ignore empty lines */
-               if (*line == 0)
-                       continue;
-
-               vu = calloc(1, sizeof(*vu));
-               if (vu == NULL)
-                       errlog(1, NULL);
-
-               data = strdup(line);
-               vu->login = strsep(&data, DP);
-               vu->address = data;
-
-               if (vu->login == NULL ||
-                   vu->address == NULL) {
-                       errlogx(1, "syntax error in virtuser file %s:%d",
-                               path, lineno);
-                       /* NOTREACHED */
-               }
-
-               SLIST_INSERT_HEAD(&virtusers, vu, next);
-       }
-
-       fclose(v);
-}
-
 /*
  * Read the SMTP authentication config file
  *
@@ -156,7 +101,7 @@ parse_authfile(const char *path)
 
        a = fopen(path, "r");
        if (a == NULL) {
-               errlog(1, "can not open auth file `%s'", path);
+               errlog(EX_NOINPUT, "can not open auth file `%s'", path);
                /* NOTREACHED */
        }
 
@@ -176,7 +121,7 @@ parse_authfile(const char *path)
 
                au = calloc(1, sizeof(*au));
                if (au == NULL)
-                       errlog(1, NULL);
+                       errlog(EX_OSERR, NULL);
 
                data = strdup(line);
                au->login = strsep(&data, "|");
@@ -186,8 +131,7 @@ parse_authfile(const char *path)
                if (au->login == NULL ||
                    au->host == NULL ||
                    au->password == NULL) {
-                       errlogx(1, "syntax error in authfile %s:%d",
-                               path, lineno);
+                       errlogx(EX_CONFIG, "syntax error in authfile %s:%d", path, lineno);
                        /* NOTREACHED */
                }
 
@@ -215,7 +159,7 @@ parse_conf(const char *config_path)
                /* Don't treat a non-existing config file as error */
                if (errno == ENOENT)
                        return;
-               errlog(1, "can not open config `%s'", config_path);
+               errlog(EX_NOINPUT, "can not open config `%s'", config_path);
                /* NOTREACHED */
        }
 
@@ -250,20 +194,32 @@ parse_conf(const char *config_path)
                        config.aliases = data;
                else if (strcmp(word, "SPOOLDIR") == 0 && data != NULL)
                        config.spooldir = data;
-               else if (strcmp(word, "VIRTPATH") == 0 && data != NULL)
-                       config.virtualpath = data;
                else if (strcmp(word, "AUTHPATH") == 0 && data != NULL)
                        config.authpath= data;
                else if (strcmp(word, "CERTFILE") == 0 && data != NULL)
                        config.certfile = data;
                else if (strcmp(word, "MAILNAME") == 0 && data != NULL)
                        config.mailname = data;
-               else if (strcmp(word, "MAILNAMEFILE") == 0 && data != NULL)
-                       config.mailnamefile = data;
-               else if (strcmp(word, "VIRTUAL") == 0 && data == NULL)
-                       config.features |= VIRTUAL;
-               else if (strcmp(word, "STARTTLS") == 0 && data == NULL)
+               else if (strcmp(word, "MASQUERADE") == 0 && data != NULL) {
+                       char *user = NULL, *host = NULL;
+                       if (strrchr(data, '@')) {
+                               host = strrchr(data, '@');
+                               *host = 0;
+                               host++;
+                               user = data;
+                       } else {
+                               host = data;
+                       }
+                       if (host && *host == 0)
+                               host = NULL;
+                        if (user && *user == 0)
+                                user = NULL;
+                       config.masquerade_host = host;
+                       config.masquerade_user = user;
+               } else if (strcmp(word, "STARTTLS") == 0 && data == NULL)
                        config.features |= STARTTLS;
+               else if (strcmp(word, "OPPORTUNISTIC_TLS") == 0 && data == NULL)
+                       config.features |= TLS_OPP;
                else if (strcmp(word, "SECURETRANSFER") == 0 && data == NULL)
                        config.features |= SECURETRANS;
                else if (strcmp(word, "DEFER") == 0 && data == NULL)
@@ -272,11 +228,18 @@ parse_conf(const char *config_path)
                        config.features |= INSECURE;
                else if (strcmp(word, "FULLBOUNCE") == 0 && data == NULL)
                        config.features |= FULLBOUNCE;
+               else if (strcmp(word, "NULLCLIENT") == 0 && data == NULL)
+                       config.features |= NULLCLIENT;
                else {
-                       errlogx(1, "syntax error in %s:%d", config_path, lineno);
+                       errlogx(EX_CONFIG, "syntax error in %s:%d", config_path, lineno);
                        /* NOTREACHED */
                }
        }
 
+       if ((config.features & NULLCLIENT) && config.smarthost == NULL) {
+               errlogx(EX_CONFIG, "%s: NULLCLIENT requires SMARTHOST", config_path);
+               /* NOTREACHED */
+       }
+
        fclose(conf);
 }