"Fossies" - the Fresh Open Source Software Archive

Member "msmtp-1.8.5/src/conf.h" (30 Aug 2018, 10559 Bytes) of package /linux/privat/msmtp-1.8.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "conf.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * conf.h
    3  *
    4  * This file is part of msmtp, an SMTP client.
    5  *
    6  * Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2014,
    7  * 2016, 2018
    8  * Martin Lambers <marlam@marlam.de>
    9  * Martin Stenberg <martin@gnutiken.se> (passwordeval support)
   10  * Scott Shumate <sshumate@austin.rr.com> (aliases support)
   11  *
   12  *   This program is free software; you can redistribute it and/or modify
   13  *   it under the terms of the GNU General Public License as published by
   14  *   the Free Software Foundation; either version 3 of the License, or
   15  *   (at your option) any later version.
   16  *
   17  *   This program is distributed in the hope that it will be useful,
   18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20  *   GNU General Public License for more details.
   21  *
   22  *   You should have received a copy of the GNU General Public License
   23  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   24  */
   25 
   26 #ifndef CONF_H
   27 #define CONF_H
   28 
   29 #include "list.h"
   30 
   31 /*
   32  * If a function with an 'errstr' argument returns a value != CONF_EOK,
   33  * '*errstr' either points to an allocates string containing an error
   34  * description or is NULL.
   35  * If such a function returns CONF_EOK, 'errstr' will not be changed.
   36  */
   37 #define CONF_EOK        0       /* no error */
   38 #define CONF_ECANTOPEN  1       /* Cannot open file */
   39 #define CONF_EIO        2       /* Input/output error */
   40 #define CONF_EPARSE     3       /* Parse error */
   41 #define CONF_ESYNTAX    4       /* Syntax error */
   42 #define CONF_EINSECURE  5       /* Insecure permissions */
   43 
   44 /*
   45  * An account
   46  */
   47 
   48 #define ACC_HOST                        (1LL << 0LL)
   49 #define ACC_PORT                        (1LL << 1LL)
   50 #define ACC_TIMEOUT                     (1LL << 2LL)
   51 #define ACC_PROTOCOL                    (1LL << 3LL)
   52 #define ACC_AUTO_FROM                   (1LL << 4LL)
   53 #define ACC_FROM                        (1LL << 5LL)
   54 #define ACC_DOMAIN                      (1LL << 6LL)
   55 #define ACC_MAILDOMAIN                  (1LL << 7LL)
   56 #define ACC_DSN_RETURN                  (1LL << 8LL)
   57 #define ACC_DSN_NOTIFY                  (1LL << 9LL)
   58 #define ACC_AUTH_MECH                   (1LL << 10LL)
   59 #define ACC_USERNAME                    (1LL << 11LL)
   60 #define ACC_PASSWORD                    (1LL << 12LL)
   61 #define ACC_PASSWORDEVAL                (1LL << 13LL)
   62 #define ACC_NTLMDOMAIN                  (1LL << 14LL)
   63 #define ACC_TLS                         (1LL << 15LL)
   64 #define ACC_TLS_NOSTARTTLS              (1LL << 16LL)
   65 #define ACC_TLS_KEY_FILE                (1LL << 17LL)
   66 #define ACC_TLS_CERT_FILE               (1LL << 18LL)
   67 #define ACC_TLS_TRUST_FILE              (1LL << 19LL)
   68 #define ACC_TLS_CRL_FILE                (1LL << 20LL)
   69 #define ACC_TLS_FINGERPRINT             (1LL << 21LL)
   70 #define ACC_TLS_NOCERTCHECK             (1LL << 22LL)
   71 #define ACC_TLS_MIN_DH_PRIME_BITS       (1LL << 23LL)
   72 #define ACC_TLS_PRIORITIES              (1LL << 24LL)
   73 #define ACC_LOGFILE                     (1LL << 25LL)
   74 #define ACC_SYSLOG                      (1LL << 26LL)
   75 #define ACC_ALIASES                     (1LL << 27LL)
   76 #define ACC_PROXY_HOST                  (1LL << 28LL)
   77 #define ACC_PROXY_PORT                  (1LL << 29LL)
   78 #define ACC_ADD_MISSING_FROM_HEADER     (1LL << 30LL)
   79 #define ACC_ADD_MISSING_DATE_HEADER     (1LL << 31LL)
   80 #define ACC_REMOVE_BCC_HEADERS          (1LL << 32LL)
   81 #define ACC_SOURCE_IP                   (1LL << 33LL)
   82 #define ACC_LOGFILE_TIME_FORMAT         (1LL << 34LL)
   83 
   84 typedef struct
   85 {
   86     /* identification */
   87     char *id;                   /* name of this account */
   88     char *conffile;             /* name of the configuration file of this
   89                                    account or NULL for command line */
   90     long long mask;             /* combination of the above ACC_* flags.
   91                                    Shows which settings were changed */
   92     /* SMTP server */
   93     char *host;                 /* hostname of SMTP server */
   94     int port;                   /* port number */
   95     int timeout;                /* network timeout in seconds */
   96     /* SMTP settings */
   97     int protocol;               /* which SMTP sub protocol? */
   98     char *domain;               /* argument to EHLO command */
   99     int auto_from;              /* automatic envelope-from addresses? */
  100     char *from;                 /* envelope from address */
  101     char *maildomain;           /* the domain part of generated envelope from
  102                                    addresses */
  103     char *dsn_return;           /* DSN return request */
  104     char *dsn_notify;           /* DSN notify request */
  105     /* Authentication */
  106     char *auth_mech;            /* authentication mechanism */
  107     char *username;             /* username for authentication */
  108     char *password;             /* password for authentication */
  109     char *passwordeval;         /* command for password evaluation */
  110     char *ntlmdomain;           /* domain for NTLM authentication */
  111     /* TLS / SSL */
  112     int tls;                    /* flag: use TLS? */
  113     char *tls_key_file;         /* file in PEM format */
  114     char *tls_cert_file;        /* file in PEM format */
  115     char *tls_trust_file;       /* file in PEM format */
  116     char *tls_crl_file;         /* file in PEM format */
  117     unsigned char *tls_sha256_fingerprint; /* certificate fingerprint */
  118     unsigned char *tls_sha1_fingerprint;   /* certificate fingerprint */
  119     unsigned char *tls_md5_fingerprint;    /* certificate fingerprint */
  120     int tls_nostarttls;         /* flag: start TLS immediatly
  121                                    (without STARTTLS command)? */
  122     int tls_nocertcheck;        /* flag: do not check certificate? */
  123     int tls_min_dh_prime_bits;  /* parameter; -1 for default */
  124     char *tls_priorities;       /* parameter; NULL for default */
  125     /* logging */
  126     char *logfile;              /* NULL or logfile */
  127     char *logfile_time_format;  /* NULL or format string for strftime() */
  128     char *syslog;               /* NULL or syslog facility */
  129     char *aliases;              /* NULL or aliases file */
  130     /* proxy */
  131     char *proxy_host;           /* NULL or proxy hostname */
  132     int proxy_port;             /* port number; 0 for default */
  133     /* header modifications */
  134     int add_missing_from_header;/* add From header if it is missing? */
  135     int add_missing_date_header;/* add Date header if it is missing? */
  136     int remove_bcc_headers;     /* remove the Bcc headers from the mail? */
  137     /* source ip binding */
  138     char *source_ip;            /* Source IP to bind the connection to */
  139 } account_t;
  140 
  141 
  142 /*
  143  * account_new()
  144  *
  145  * Create a new account_t. Built-in default values are filled in, except for
  146  * settings whose default values are not yet known. This currently only affects
  147  * the port.
  148  * Must be freed with account_free().
  149  * Both arguments may be NULL.
  150  */
  151 account_t *account_new(const char *conffile, const char *id);
  152 
  153 /*
  154  * account_copy()
  155  *
  156  * Create a new account which is a copy of 'acc'.
  157  * If 'acc' is NULL, NULL is returned.
  158  */
  159 account_t *account_copy(account_t *acc);
  160 
  161 /*
  162  * account_free()
  163  *
  164  * Free an account_t.
  165  */
  166 void account_free(void *a);
  167 
  168 /*
  169  * find_account()
  170  *
  171  * Find an account in a list of accounts by its id.
  172  * Returns the account or NULL.
  173  */
  174 account_t *find_account(list_t *acc_list, const char *id);
  175 
  176 /*
  177  * find_account_by_envelope_from()
  178  *
  179  * Find an account in a list of accounts by its envelope from address.
  180  * Returns the *first* account that matches or NULL.
  181  */
  182 account_t *find_account_by_envelope_from(list_t *acc_list, const char *from);
  183 
  184 /*
  185  * is_on(), is_off()
  186  *
  187  * Check whether the given string is "on" or "off"
  188  */
  189 int is_on(char *s);
  190 int is_off(char *s);
  191 
  192 /*
  193  * get_pos_int()
  194  *
  195  * Gets a positive integer. Returns -1 on error.
  196  */
  197 int get_pos_int(const char *arg);
  198 
  199 /*
  200  * get_fingerprint()
  201  *
  202  * Gets a fingerprint of the given length and returns it in an allocated array.
  203  * Returns NULL on error.
  204  */
  205 unsigned char *get_fingerprint(const char *arg, size_t len);
  206 
  207 /*
  208  * check_auth_arg()
  209  *
  210  * checks if the given string is a proper argument to the auth command.
  211  * If so, the string is converted to uppercase and 0 is returned. Otherwise, 1
  212  * is returned.
  213  * Note that you have to check whether the arg is "off" separately, because
  214  * that value results in NULL.
  215  */
  216 int check_auth_arg(char *arg);
  217 
  218 /*
  219  * check_dsn_notify_arg()
  220  *
  221  * checks if the given string is a proper argument to the dsn_notify command.
  222  * If so, the string is converted to uppercase and 0 is returned. Otherwise, 1
  223  * is returned.
  224  * Note that you have to check whether the arg is "off" separately, because that
  225  * value results in NULL.
  226  */
  227 int check_dsn_notify_arg(char *arg);
  228 
  229 /*
  230  * check_syslog_arg()
  231  *
  232  * checks if the given string is a proper argument to the syslog command.
  233  * If so, the string is converted to uppercase and 0 is returned. Otherwise, 1
  234  * is returned.
  235  * Note that you have to check whether the arg is "on" or "off" or ""
  236  * separately.
  237  */
  238 int check_syslog_arg(const char *arg);
  239 
  240 /*
  241  * get_default_syslog_facility()
  242  *
  243  * Returns a pointer to an allocated string containing the default syslog
  244  * facility.
  245  */
  246 char *get_default_syslog_facility(void);
  247 
  248 /*
  249  * override_account()
  250  *
  251  * Override 'acc1' with 'acc2': those settings of acc2 whose flag is set in
  252  * acc2->mask override the corresponding settings of acc1.
  253  * The flags from acc2->mask will also be set in acc1->mask.
  254  */
  255 void override_account(account_t *acc1, account_t *acc2);
  256 
  257 /*
  258  * check_account()
  259  *
  260  * Check an account_t. 'sendmail_mode' must indicate whether msmtp works
  261  * in sendmail mode, because some checks depend on this.
  262  * If this function returns CONF_ESYNTAX, *errstr will always point to an
  263  * error string.
  264  * Used error codes: CONF_ESYNTAX
  265  */
  266 int check_account(account_t *acc, int sendmail_mode, char **errstr);
  267 
  268 /*
  269  * get_password_eval()
  270  *
  271  * Evaluates command in 'arg' and stores result in 'buf' (which is allocated).
  272  * Returns CONF_EIO if command exectution failed, otherwise CONF_EOK. On error,
  273  * *errstr will contain an error string.
  274  */
  275 int get_password_eval(const char *arg, char **buf, char **errstr);
  276 
  277 /*
  278  * get_conf()
  279  *
  280  * Read 'conffile' and store all account data in 'acc_list'.
  281  * If 'securitycheck' is set, the file must not have more permissions than 0600,
  282  * must be a regular file and owned by the current user.
  283  * Used error codes: CONF_ECANTOPEN, CONF_EIO, CONF_EPARSE, CONF_ESYNTAX
  284  */
  285 int get_conf(const char *conffile, int securitycheck, list_t **acc_list,
  286         char **errstr);
  287 
  288 #endif