~ubuntu-branches/ubuntu/trusty/opendkim/trusty

« back to all changes in this revision

Viewing changes to opendkim/opendkim.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2012-06-08 14:38:25 UTC
  • mfrom: (1.2.14) (3.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20120608143825-ehz9xxdvii6podhh
Tags: 2.6.0-1
* New upstream release (now DFSG free so tarball repacking no longer
  required)
  - Rename libopendkim6 to libopendkim7 to match new soname
    - Update package and dependencies in debian/control
    - Rename .install and .doc files
  - Drop --enable-xtags from configure in debian/rules since it is now on by
    default
  - Update debian/copyright
  - Remove dversionmangle from debian/watch
  - Update README.Debian to reflect documentation no longer being stripped
* Correct copyright/license information in libar/ar-strl.h based on feedback
  from upstream (correction already implemented upstream for the next
  relese)
* Set --sysconfdir=/etc in configure so that generated man pages refer to
  the correct configuration file locations

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
 
204
204
struct dkimf_config
205
205
{
 
206
#ifdef USE_LDAP
 
207
        _Bool           conf_softstart;         /* do LDAP soft starts */
 
208
#endif /* USE_LDAP */
206
209
        _Bool           conf_weaksyntax;        /* do weaker syntax checking */
207
210
        _Bool           conf_noadsp;            /* suppress ADSP */
 
211
        _Bool           conf_logresults;        /* log all results */
208
212
        _Bool           conf_allsigs;           /* report on all signatures */
209
213
        _Bool           conf_dnsconnect;        /* request TCP mode from DNS */
210
214
        _Bool           conf_capture;           /* capture unknown errors */
214
218
        _Bool           conf_blen;              /* use "l=" when signing */
215
219
        _Bool           conf_ztags;             /* use "z=" when signing */
216
220
        _Bool           conf_alwaysaddar;       /* always add Auth-Results:? */
217
 
#ifdef _FFR_XTAGS
218
221
        _Bool           conf_reqreports;        /* request reports */
219
 
#endif /* _FFR_XTAGS */
220
222
        _Bool           conf_sendreports;       /* signature failure reports */
221
223
        _Bool           conf_sendadspreports;   /* ADSP failure reports */
222
224
        _Bool           conf_adspnxdomain;      /* reject on ADSP NXDOMAIN? */
245
247
#ifdef USE_LDAP
246
248
        _Bool           conf_ldap_usetls;       /* LDAP TLS */
247
249
#endif /* USE_LDAP */
248
 
#ifdef _FFR_STATS
249
 
        _Bool           conf_anonstats;         /* anonymize stats? */
250
 
#endif /* _FFR_STATS */
251
250
#ifdef _FFR_VBR
252
251
        _Bool           conf_vbr_purge;         /* purge X-VBR-* fields */
253
252
        _Bool           conf_vbr_trustedonly;   /* trusted certifiers only */
351
350
        char *          conf_redirect;          /* redirect failures to */
352
351
#endif /* _FFR_REDIRECT */
353
352
#ifdef USE_LDAP
 
353
        char *          conf_ldap_timeout;      /* LDAP timeout */
 
354
        char *          conf_ldap_kaidle;       /* LDAP keepalive idle */
 
355
        char *          conf_ldap_kaprobes;     /* LDAP keepalive probes */
 
356
        char *          conf_ldap_kainterval;   /* LDAP keepalive interval */
354
357
        char *          conf_ldap_binduser;     /* LDAP bind user */
355
358
        char *          conf_ldap_bindpw;       /* LDAP bind password */
356
359
        char *          conf_ldap_authmech;     /* LDAP auth mechanism */
453
456
        DKIMF_DB        conf_replowtimedb;      /* reputed low timers DB */
454
457
        DKIMF_REP       conf_rep;               /* reputation subsystem */
455
458
        char *          conf_repcache;          /* reputation cache DB */
 
459
        char *          conf_repdups;           /* reputation duplicates DB */
456
460
        char *          conf_repspamcheck;      /* reputation spam RE string */
457
461
        regex_t         conf_repspamre;         /* reputation spam RE */
458
462
#endif /* _FFR_REPUTATION */
1435
1439
}
1436
1440
# endif /* _FFR_RBL */
1437
1441
 
1438
 
# ifdef _FFR_XTAGS
1439
1442
/*
1440
1443
**  DKIMF_XS_XTAG -- add an extension tag
1441
1444
**
1505
1508
                return 1;
1506
1509
        }
1507
1510
}
1508
 
# endif /* _FFR_XTAGS */
1509
1511
 
1510
1512
/*
1511
1513
**  DKIMF_XS_PARSEFIELD -- parse an address field into its components
2106
2108
}
2107
2109
 
2108
2110
/*
 
2111
**  DKIMF_XS_GETENVFROM -- request envelope sender
 
2112
**
 
2113
**  Parameters:
 
2114
**      l -- Lua state
 
2115
**
 
2116
**  Return value:
 
2117
**      Number of stack items pushed.
 
2118
*/
 
2119
 
 
2120
int
 
2121
dkimf_xs_getenvfrom(lua_State *l)
 
2122
{
 
2123
        int idx;
 
2124
        const char *hdrname;
 
2125
        SMFICTX *ctx;
 
2126
        struct connctx *cc;
 
2127
        struct msgctx *dfc;
 
2128
        struct dkimf_config *conf;
 
2129
        Header hdr;
 
2130
 
 
2131
        assert(l != NULL);
 
2132
 
 
2133
        if (lua_gettop(l) != 1)
 
2134
        {
 
2135
                lua_pushstring(l,
 
2136
                               "odkim.get_envfrom(): incorrect argument count");
 
2137
                lua_error(l);
 
2138
        }
 
2139
        else if (!lua_islightuserdata(l, 1))
 
2140
        {
 
2141
                lua_pushstring(l,
 
2142
                               "odkim.get_envfrom(): incorrect argument type");
 
2143
                lua_error(l);
 
2144
        }
 
2145
 
 
2146
        ctx = (SMFICTX *) lua_touserdata(l, 1);
 
2147
 
 
2148
        if (ctx != NULL)
 
2149
        {
 
2150
                cc = (struct connctx *) dkimf_getpriv(ctx);
 
2151
                dfc = cc->cctx_msg;
 
2152
        }
 
2153
 
 
2154
        lua_pop(l, 1);
 
2155
 
 
2156
        if (ctx == NULL)
 
2157
                lua_pushstring(l, "dkimf_xs_getenvfrom");
 
2158
        else
 
2159
                lua_pushstring(l, dfc->mctx_envfrom);
 
2160
        return 1;
 
2161
}
 
2162
 
 
2163
/*
2109
2164
**  DKIMF_XS_GETHEADER -- request a header value
2110
2165
**
2111
2166
**  Parameters:
5576
5631
        new->conf_adspaction = SMFIS_CONTINUE;
5577
5632
#ifdef _FFR_STATS
5578
5633
        new->conf_reporthost = myhostname;
5579
 
        new->conf_anonstats = TRUE;
5580
5634
#endif /* _FFR_STATS */
5581
5635
#ifdef _FFR_RATE_LIMIT
5582
5636
        new->conf_flowdatattl = DEFFLOWDATATTL;
5879
5933
                  char *err, size_t errlen)
5880
5934
{
5881
5935
        int maxsign;
 
5936
        int dbflags = 0;
5882
5937
        char *str;
5883
5938
        char confstr[BUFRSZ + 1];
5884
5939
        char basedir[MAXPATHLEN + 1];
5891
5946
 
5892
5947
        if (data != NULL)
5893
5948
        {
 
5949
#ifdef USE_LDAP
 
5950
                (void) config_get(data, "LDAPSoftStart",
 
5951
                                  &conf->conf_softstart,
 
5952
                                  sizeof conf->conf_softstart);
 
5953
#endif /* USE_LDAP */
 
5954
 
5894
5955
                (void) config_get(data, "AddAllSignatureResults",
5895
5956
                                  &conf->conf_allsigs,
5896
5957
                                  sizeof conf->conf_allsigs);
5974
6035
                                  &conf->conf_enablecores,
5975
6036
                                  sizeof conf->conf_enablecores);
5976
6037
 
5977
 
#ifdef _FFR_XTAGS
5978
6038
                (void) config_get(data, "RequestReports",
5979
6039
                                  &conf->conf_reqreports,
5980
6040
                                  sizeof conf->conf_reqreports);
5981
 
#endif /* _FFR_XTAGS */
5982
6041
 
5983
6042
                (void) config_get(data, "RequireSafeKeys",
5984
6043
                                  &conf->conf_safekeys,
6197
6256
                                          sizeof conf->conf_logwhy);
6198
6257
                }
6199
6258
 
 
6259
                (void) config_get(data, "LogResults", &conf->conf_logresults,
 
6260
                                  sizeof conf->conf_logresults);
 
6261
 
6200
6262
                (void) config_get(data, "MultipleSignatures",
6201
6263
                                  &conf->conf_multisig,
6202
6264
                                  sizeof conf->conf_multisig);
6263
6325
                else
6264
6326
                        dkimf_db_set_ldap_param(DKIMF_LDAP_PARAM_USETLS, "n");
6265
6327
 
 
6328
                (void) config_get(data, "LDAPTimeout",
 
6329
                                  &conf->conf_ldap_timeout,
 
6330
                                  sizeof conf->conf_ldap_timeout);
 
6331
 
 
6332
                dkimf_db_set_ldap_param(DKIMF_LDAP_PARAM_TIMEOUT,
 
6333
                                        conf->conf_ldap_timeout);
 
6334
 
 
6335
                (void) config_get(data, "LDAPKeepaliveIdle",
 
6336
                                  &conf->conf_ldap_kaidle,
 
6337
                                  sizeof conf->conf_ldap_kaidle);
 
6338
 
 
6339
                dkimf_db_set_ldap_param(DKIMF_LDAP_PARAM_KA_IDLE,
 
6340
                                        conf->conf_ldap_kaidle);
 
6341
 
 
6342
                (void) config_get(data, "LDAPKeepaliveProbes",
 
6343
                                  &conf->conf_ldap_kaprobes,
 
6344
                                  sizeof conf->conf_ldap_kaprobes);
 
6345
 
 
6346
                dkimf_db_set_ldap_param(DKIMF_LDAP_PARAM_KA_PROBES,
 
6347
                                        conf->conf_ldap_kaprobes);
 
6348
 
 
6349
                (void) config_get(data, "LDAPKeepaliveInterval",
 
6350
                                  &conf->conf_ldap_kainterval,
 
6351
                                  sizeof conf->conf_ldap_kainterval);
 
6352
 
 
6353
                dkimf_db_set_ldap_param(DKIMF_LDAP_PARAM_KA_INTERVAL,
 
6354
                                        conf->conf_ldap_kainterval);
 
6355
 
6266
6356
                (void) config_get(data, "LDAPAuthMechanism",
6267
6357
                                  &conf->conf_ldap_authmech,
6268
6358
                                  sizeof conf->conf_ldap_authmech);
6686
6776
#endif /* USE_LUA */
6687
6777
        }
6688
6778
 
 
6779
#ifdef USE_LDAP
 
6780
        if (conf->conf_softstart)
 
6781
                dbflags |= DKIMF_DB_FLAG_SOFTSTART;
 
6782
#endif /* USE_LDAP */
 
6783
 
6689
6784
        if (basedir[0] != '\0')
6690
6785
        {
6691
6786
                if (chdir(basedir) != 0)
6711
6806
                char *dberr = NULL;
6712
6807
 
6713
6808
                status = dkimf_db_open(&conf->conf_peerdb, str,
6714
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6809
                                       (dbflags | 
 
6810
                                        DKIMF_DB_FLAG_ICASE |
6715
6811
                                        DKIMF_DB_FLAG_READONLY),
6716
6812
                                       NULL, &dberr);
6717
6813
                if (status != 0)
6729
6825
 
6730
6826
                status = dkimf_db_open(&conf->conf_testdnsdb,
6731
6827
                                       conf->conf_testdnsdata,
6732
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6828
                                       (dbflags | 
 
6829
                                        DKIMF_DB_FLAG_ICASE |
6733
6830
                                        DKIMF_DB_FLAG_READONLY),
6734
6831
                                       NULL, &dberr);
6735
6832
                if (status != 0)
6756
6853
                char *dberr = NULL;
6757
6854
 
6758
6855
                status = dkimf_db_open(&conf->conf_internal, str,
6759
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6856
                                       (dbflags | 
 
6857
                                        DKIMF_DB_FLAG_ICASE |
6760
6858
                                        DKIMF_DB_FLAG_READONLY),
6761
6859
                                       NULL, &dberr);
6762
6860
                if (status != 0)
6772
6870
                char *dberr = NULL;
6773
6871
 
6774
6872
                status = dkimf_db_open(&conf->conf_internal, DEFINTERNAL,
6775
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6873
                                       (dbflags | 
 
6874
                                        DKIMF_DB_FLAG_ICASE |
6776
6875
                                        DKIMF_DB_FLAG_READONLY),
6777
6876
                                       NULL, &dberr);
6778
6877
                if (status != 0)
6791
6890
        }
6792
6891
        else if (data != NULL)
6793
6892
        {
6794
 
                (void) config_get(data, "ExternalIgnoreList", &str, sizeof str);
 
6893
                (void) config_get(data, "ExternalIgnoreList", &str,
 
6894
                                  sizeof str);
6795
6895
        }
6796
6896
        if (str != NULL && !testmode)
6797
6897
        {
6799
6899
                char *dberr = NULL;
6800
6900
 
6801
6901
                status = dkimf_db_open(&conf->conf_exignore, str,
6802
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6902
                                       (dbflags | 
 
6903
                                        DKIMF_DB_FLAG_ICASE |
6803
6904
                                        DKIMF_DB_FLAG_READONLY),
6804
6905
                                       NULL, &dberr);
6805
6906
                if (status != 0)
6826
6927
                char *dberr = NULL;
6827
6928
 
6828
6929
                status = dkimf_db_open(&conf->conf_exemptdb, str,
6829
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6930
                                       (dbflags | 
 
6931
                                        DKIMF_DB_FLAG_ICASE |
6830
6932
                                        DKIMF_DB_FLAG_READONLY),
6831
6933
                                       NULL, &dberr);
6832
6934
                if (status != 0)
6847
6949
                char *dberr = NULL;
6848
6950
 
6849
6951
                status = dkimf_db_open(&conf->conf_bldb, str,
6850
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6952
                                       (dbflags | 
 
6953
                                        DKIMF_DB_FLAG_ICASE |
6851
6954
                                        DKIMF_DB_FLAG_READONLY),
6852
6955
                                       NULL, &dberr);
6853
6956
                if (status != 0)
6867
6970
                char *dberr = NULL;
6868
6971
 
6869
6972
                status = dkimf_db_open(&conf->conf_signhdrsdb, str,
6870
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6973
                                       (dbflags | 
 
6974
                                        DKIMF_DB_FLAG_ICASE |
6871
6975
                                        DKIMF_DB_FLAG_READONLY),
6872
6976
                                       NULL, &dberr);
6873
6977
                if (status != 0)
6887
6991
                char *dberr = NULL;
6888
6992
 
6889
6993
                status = dkimf_db_open(&conf->conf_remardb, str,
6890
 
                                       (DKIMF_DB_FLAG_ICASE |
 
6994
                                       (dbflags | 
 
6995
                                        DKIMF_DB_FLAG_ICASE |
6891
6996
                                        DKIMF_DB_FLAG_READONLY),
6892
6997
                                       NULL, &dberr);
6893
6998
                if (status != 0)
6911
7016
                char *dberr = NULL;
6912
7017
 
6913
7018
                status = dkimf_db_open(&conf->conf_nodiscardto, str,
6914
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7019
                                       (dbflags | 
 
7020
                                        DKIMF_DB_FLAG_ICASE |
6915
7021
                                        DKIMF_DB_FLAG_READONLY),
6916
7022
                                       NULL, &dberr);
6917
7023
                if (status != 0)
6947
7053
                char *dberr = NULL;
6948
7054
 
6949
7055
                status = dkimf_db_open(&conf->conf_atpsdb, str,
6950
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7056
                                       (dbflags | 
 
7057
                                        DKIMF_DB_FLAG_ICASE |
6951
7058
                                        DKIMF_DB_FLAG_READONLY),
6952
7059
                                       NULL, &dberr);
6953
7060
                if (status != 0)
6968
7075
                char *dberr = NULL;
6969
7076
 
6970
7077
                status = dkimf_db_open(&conf->conf_dontsigntodb, str,
6971
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7078
                                       (dbflags | 
 
7079
                                        DKIMF_DB_FLAG_ICASE |
6972
7080
                                        DKIMF_DB_FLAG_READONLY),
6973
7081
                                       NULL, &dberr);
6974
7082
                if (status != 0)
6988
7096
                char *dberr = NULL;
6989
7097
 
6990
7098
                status = dkimf_db_open(&conf->conf_mbsdb, str,
6991
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7099
                                       (dbflags |
 
7100
                                        DKIMF_DB_FLAG_ICASE |
6992
7101
                                        DKIMF_DB_FLAG_READONLY),
6993
7102
                                       NULL, &dberr);
6994
7103
                if (status != 0)
7014
7123
                char *dberr = NULL;
7015
7124
 
7016
7125
                status = dkimf_db_open(&conf->conf_omithdrdb, str,
7017
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7126
                                       (dbflags |
 
7127
                                        DKIMF_DB_FLAG_ICASE |
7018
7128
                                        DKIMF_DB_FLAG_READONLY),
7019
7129
                                       NULL, &dberr);
7020
7130
                if (status != 0)
7036
7146
                char *dberr = NULL;
7037
7147
 
7038
7148
                status = dkimf_db_open(&conf->conf_mtasdb, str,
7039
 
                                       DKIMF_DB_FLAG_READONLY, NULL, &dberr);
 
7149
                                       (dbflags | DKIMF_DB_FLAG_READONLY),
 
7150
                                       NULL, &dberr);
7040
7151
                if (status != 0)
7041
7152
                {
7042
7153
                        snprintf(err, errlen, "%s: dkimf_db_open(): %s",
7059
7170
                char *dberr = NULL;
7060
7171
 
7061
7172
                status = dkimf_db_open(&conf->conf_alwayshdrsdb, str,
7062
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7173
                                       (dbflags |
 
7174
                                        DKIMF_DB_FLAG_ICASE |
7063
7175
                                        DKIMF_DB_FLAG_READONLY),
7064
7176
                                       NULL, &dberr);
7065
7177
                if (status != 0)
7080
7192
                char *dberr = NULL;
7081
7193
 
7082
7194
                status = dkimf_db_open(&conf->conf_oversigndb, str,
7083
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7195
                                       (dbflags |
 
7196
                                        DKIMF_DB_FLAG_ICASE |
7084
7197
                                        DKIMF_DB_FLAG_READONLY),
7085
7198
                                       NULL, &dberr);
7086
7199
                if (status != 0)
7101
7214
                char *dberr = NULL;
7102
7215
 
7103
7216
                status = dkimf_db_open(&conf->conf_senderhdrsdb, str,
7104
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7217
                                       (dbflags |
 
7218
                                        DKIMF_DB_FLAG_ICASE |
7105
7219
                                        DKIMF_DB_FLAG_READONLY),
7106
7220
                                       NULL, &dberr);
7107
7221
                if (status != 0)
7144
7258
                int status;
7145
7259
 
7146
7260
                status = dkimf_db_open(&conf->conf_vbr_trusteddb, str,
7147
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7261
                                       (dbflags |
 
7262
                                        DKIMF_DB_FLAG_ICASE |
7148
7263
                                        DKIMF_DB_FLAG_READONLY),
7149
7264
                                       NULL, &dberr);
7150
7265
                if (status != 0)
7183
7298
 
7184
7299
                        status = dkimf_db_open(&conf->conf_signtabledb,
7185
7300
                                               conf->conf_signtable,
7186
 
                                               (DKIMF_DB_FLAG_ICASE |
 
7301
                                               (dbflags |
 
7302
                                                DKIMF_DB_FLAG_ICASE |
7187
7303
                                                DKIMF_DB_FLAG_ASCIIONLY |
7188
7304
                                                DKIMF_DB_FLAG_READONLY),
7189
7305
                                               NULL, &dberr);
7214
7330
 
7215
7331
                        status = dkimf_db_open(&conf->conf_keytabledb,
7216
7332
                                               conf->conf_keytable,
7217
 
                                               DKIMF_DB_FLAG_READONLY, NULL,
 
7333
                                               (dbflags |
 
7334
                                                DKIMF_DB_FLAG_READONLY), NULL,
7218
7335
                                               &dberr);
7219
7336
                        if (status != 0)
7220
7337
                        {
7249
7366
                char *dberr = NULL;
7250
7367
 
7251
7368
                status = dkimf_db_open(&conf->conf_localadsp_db, str,
7252
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7369
                                       (dbflags | DKIMF_DB_FLAG_ICASE |
7253
7370
                                        DKIMF_DB_FLAG_READONLY),
7254
7371
                                       NULL, &dberr);
7255
7372
                if (status != 0)
7272
7389
                char *dberr = NULL;
7273
7390
 
7274
7391
                status = dkimf_db_open(&conf->conf_thirdpartydb, str,
7275
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7392
                                       (dbflags | DKIMF_DB_FLAG_ICASE |
7276
7393
                                        DKIMF_DB_FLAG_READONLY),
7277
7394
                                       NULL, &dberr);
7278
7395
                if (status != 0)
7299
7416
                char *dberr = NULL;
7300
7417
 
7301
7418
                status = dkimf_db_open(&conf->conf_resigndb, str,
7302
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7419
                                       (dbflags | DKIMF_DB_FLAG_ICASE |
7303
7420
                                        DKIMF_DB_FLAG_READONLY),
7304
7421
                                       NULL, &dberr);
7305
7422
                if (status != 0)
7323
7440
                char *dberr = NULL;
7324
7441
 
7325
7442
                status = dkimf_db_open(&conf->conf_ratelimitdb, str,
7326
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7443
                                       (dbflags | DKIMF_DB_FLAG_ICASE |
7327
7444
                                        DKIMF_DB_FLAG_READONLY),
7328
7445
                                       NULL, &dberr);
7329
7446
                if (status != 0)
7353
7470
                char *dberr = NULL;
7354
7471
 
7355
7472
                status = dkimf_db_open(&conf->conf_flowdatadb, str,
7356
 
                                       (DKIMF_DB_FLAG_ICASE |
 
7473
                                       (dbflags | DKIMF_DB_FLAG_ICASE |
7357
7474
                                        DKIMF_DB_FLAG_MAKELOCK),
7358
7475
                                       NULL, &dberr);
7359
7476
                if (status != 0)
7389
7506
                char *dberr = NULL;
7390
7507
 
7391
7508
                status = dkimf_db_open(&conf->conf_domainsdb, str,
7392
 
                                       (DKIMF_DB_FLAG_READONLY |
 
7509
                                       (dbflags | DKIMF_DB_FLAG_READONLY |
7393
7510
                                        DKIMF_DB_FLAG_ICASE),
7394
7511
                                       NULL, &dberr);
7395
7512
                if (status != 0)
7412
7529
                char *dberr = NULL;
7413
7530
 
7414
7531
                status = dkimf_db_open(&conf->conf_macrosdb, str,
7415
 
                                       (DKIMF_DB_FLAG_READONLY |
 
7532
                                       (dbflags | DKIMF_DB_FLAG_READONLY |
7416
7533
                                        DKIMF_DB_FLAG_VALLIST |
7417
7534
                                        DKIMF_DB_FLAG_MATCHBOTH), NULL,
7418
7535
                                       &dberr);
7610
7727
                char *dberr = NULL;
7611
7728
 
7612
7729
                status = dkimf_db_open(&conf->conf_rephdrsdb, str,
7613
 
                                       (DKIMF_DB_FLAG_READONLY |
 
7730
                                       (dbflags | DKIMF_DB_FLAG_READONLY |
7614
7731
                                        DKIMF_DB_FLAG_ICASE), NULL,
7615
7732
                                       &dberr);
7616
7733
                if (status != 0)
7671
7788
                                  &conf->conf_repcachettl,
7672
7789
                                  sizeof conf->conf_repcachettl);
7673
7790
 
 
7791
                (void) config_get(data, "ReputationDuplicates",
 
7792
                                  &conf->conf_repdups,
 
7793
                                  sizeof conf->conf_repdups);
 
7794
 
7674
7795
                (void) config_get(data, "ReputationRatios",
7675
7796
                                  &conf->conf_repratios,
7676
7797
                                  sizeof conf->conf_repratios);
7725
7846
 
7726
7847
                status = dkimf_db_open(&conf->conf_replowtimedb,
7727
7848
                                       conf->conf_replowtime,
7728
 
                                       DKIMF_DB_FLAG_READONLY, NULL, &dberr);
 
7849
                                       (dbflags | DKIMF_DB_FLAG_READONLY),
 
7850
                                       NULL, &dberr);
7729
7851
                if (status != 0)
7730
7852
                {
7731
7853
                        snprintf(err, errlen, "%s: dkimf_db_open(): %s",
7743
7865
                {
7744
7866
                        status = dkimf_db_open(&conf->conf_replimitsdb,
7745
7867
                                               conf->conf_replimits,
7746
 
                                               DKIMF_DB_FLAG_READONLY, NULL,
 
7868
                                               (dbflags |
 
7869
                                                DKIMF_DB_FLAG_READONLY), NULL,
7747
7870
                                               &dberr);
7748
7871
                        if (status != 0)
7749
7872
                        {
7758
7881
                {
7759
7882
                        status = dkimf_db_open(&conf->conf_replimitmodsdb,
7760
7883
                                               conf->conf_replimitmods,
7761
 
                                               DKIMF_DB_FLAG_READONLY, NULL,
 
7884
                                               (dbflags |
 
7885
                                                DKIMF_DB_FLAG_READONLY), NULL,
7762
7886
                                               &dberr);
7763
7887
                        if (status != 0)
7764
7888
                        {
7771
7895
 
7772
7896
                status = dkimf_db_open(&conf->conf_repratiosdb,
7773
7897
                                       conf->conf_repratios,
7774
 
                                       DKIMF_DB_FLAG_READONLY, NULL, &dberr);
 
7898
                                       (dbflags | DKIMF_DB_FLAG_READONLY),
 
7899
                                       NULL, &dberr);
7775
7900
                if (status != 0)
7776
7901
                {
7777
7902
                        snprintf(err, errlen, "%s: dkimf_db_open(): %s",
7783
7908
                                   conf->conf_repminimum,
7784
7909
                                   conf->conf_repcachettl,
7785
7910
                                   conf->conf_repcache,
 
7911
                                   conf->conf_repdups,
7786
7912
                                   conf->conf_replimitsdb,
7787
7913
                                   conf->conf_replimitmodsdb,
7788
7914
                                   conf->conf_repratiosdb,
8043
8169
 
8044
8170
        (void) dkim_options(lib, DKIM_OP_GETOPT, DKIM_OPTS_FLAGS,
8045
8171
                            &opts, sizeof opts);
8046
 
        opts |= DKIM_LIBFLAGS_ACCEPTV05;
 
8172
        opts |= (DKIM_LIBFLAGS_ACCEPTV05 | DKIM_LIBFLAGS_DROPSIGNER);
8047
8173
        if (conf->conf_weaksyntax)
8048
8174
                opts |= DKIM_LIBFLAGS_BADSIGHANDLES;
8049
8175
#ifdef QUERY_CACHE
10352
10478
                                if (err != NULL)
10353
10479
                                {
10354
10480
                                        snprintf(comment, sizeof comment,
10355
 
                                                 " (%s)", err);
 
10481
                                                 " reason=\"%s\"", err);
10356
10482
                                }
10357
10483
                        }
10358
10484
                        else if (sigerror != DKIM_SIGERROR_UNKNOWN &&
10795
10921
 
10796
10922
        if (envfrom[0] != NULL)
10797
10923
        {
 
10924
                size_t len;
 
10925
                unsigned char *p;
 
10926
                unsigned char *q;
 
10927
 
10798
10928
                strlcpy(dfc->mctx_envfrom, envfrom[0],
10799
10929
                        sizeof dfc->mctx_envfrom);
 
10930
 
 
10931
                len = strlen(dfc->mctx_envfrom);
 
10932
                p = dfc->mctx_envfrom;
 
10933
                q = dfc->mctx_envfrom + len - 1;
 
10934
 
 
10935
                while (len >= 2 && *p == '<' && *q == '>')
 
10936
                {
 
10937
                        p++;
 
10938
                        q--;
 
10939
                        len -= 2;
 
10940
                }
 
10941
 
 
10942
                if (p != dfc->mctx_envfrom)
 
10943
                {
 
10944
                        *(q + 1) = '\0';
 
10945
                        memmove(dfc->mctx_envfrom, p, len + 1);
 
10946
                }
10800
10947
        }
10801
10948
 
10802
10949
        /*
11190
11337
 
11191
11338
        dfc->mctx_hqtail = newhdr;
11192
11339
 
11193
 
#ifdef _FFR_SELECT_CANONICALIZATION
11194
 
        if (strcasecmp(headerf, XSELECTCANONHDR) == 0)
11195
 
        {
11196
 
                int c;
11197
 
                char *slash;
11198
 
 
11199
 
                slash = strchr(headerv, '/');
11200
 
                if (slash != NULL)
11201
 
                {
11202
 
                        *slash = '\0';
11203
 
 
11204
 
                        c = dkimf_configlookup(headerv, dkimf_canon);
11205
 
                        if (c != -1)
11206
 
                                dfc->mctx_hdrcanon = (dkim_canon_t) c;
11207
 
                        c = dkimf_configlookup(slash + 1, dkimf_canon);
11208
 
                        if (c != -1)
11209
 
                                dfc->mctx_bodycanon = (dkim_canon_t) c;
11210
 
 
11211
 
                        *slash = '/';
11212
 
                }
11213
 
                else
11214
 
                {
11215
 
                        c = dkimf_configlookup(headerv, dkimf_canon);
11216
 
                        if (c != -1)
11217
 
                                dfc->mctx_hdrcanon = (dkim_canon_t) c;
11218
 
                }
11219
 
 
11220
 
                /* XXX -- eat this header? */
11221
 
        }
11222
 
#endif /* _FFR_SELECT_CANONICALIZATION */
11223
 
 
11224
11340
        return SMFIS_CONTINUE;
11225
11341
}
11226
11342
 
11592
11708
        if (conf->conf_mtasdb != NULL)
11593
11709
        {
11594
11710
                char *mtaname;
 
11711
                char *host;
11595
11712
 
11596
11713
                mtaname = dkimf_getsymval(ctx, "{daemon_name}");
 
11714
                host = dkimf_getsymval(ctx, "j");
11597
11715
 
11598
11716
                if (mtaname != NULL)
11599
11717
                {
11605
11723
 
11606
11724
                if (!originok && !status && conf->conf_logwhy)
11607
11725
                {
11608
 
                        syslog(LOG_INFO, "%s: no MTA name match",
11609
 
                               dfc->mctx_jobid);
 
11726
                        syslog(LOG_INFO,
 
11727
                               "%s: no MTA name match (host=%s, MTA=%s)",
 
11728
                               dfc->mctx_jobid, host,
 
11729
                               mtaname == NULL ? "?" : mtaname);
11610
11730
                }
11611
11731
        }
11612
11732
 
12144
12264
                                                       status);
12145
12265
                        }
12146
12266
 
12147
 
#ifdef _FFR_XTAGS
12148
12267
                        if (conf->conf_reqreports)
12149
12268
                        {
12150
12269
                                status = dkim_add_xtag(sr->srq_dkim,
12159
12278
                                               DKIM_REPORTTAG);
12160
12279
                                }
12161
12280
                        }
12162
 
#endif /* _FFR_XTAGS */
12163
12281
 
12164
12282
#ifdef _FFR_ATPS
12165
12283
                        if (atps)
13203
13321
                status = dkim_eom(dfc->mctx_dkimv, &testkey);
13204
13322
                lastdkim = dfc->mctx_dkimv;
13205
13323
 
 
13324
                if (conf->conf_logresults && conf->conf_dolog)
 
13325
                {
 
13326
                        int c;
 
13327
                        int nsigs;
 
13328
                        DKIM_SIGINFO **sigs;
 
13329
 
 
13330
                        if (dfc->mctx_tmpstr == NULL)
 
13331
                        {
 
13332
                                dfc->mctx_tmpstr = dkimf_dstring_new(BUFRSZ,
 
13333
                                                                     0);
 
13334
 
 
13335
                                if (dfc->mctx_tmpstr == NULL)
 
13336
                                {
 
13337
                                        syslog(LOG_WARNING,
 
13338
                                               "%s: dkimf_dstring_new() failed",
 
13339
                                               dfc->mctx_jobid);
 
13340
 
 
13341
                                        return SMFIS_TEMPFAIL;
 
13342
                                }
 
13343
                        }
 
13344
                        else
 
13345
                        {
 
13346
                                dkimf_dstring_blank(dfc->mctx_tmpstr);
 
13347
                        }
 
13348
 
 
13349
                        status = dkim_getsiglist(dfc->mctx_dkimv,
 
13350
                                                 &sigs, &nsigs);
 
13351
 
 
13352
                        if (status == DKIM_STAT_OK)
 
13353
                        {
 
13354
                                DKIM_SIGERROR err;
 
13355
                                size_t len;
 
13356
                                const char *domain;
 
13357
                                const char *selector;
 
13358
                                const char *errstr;
 
13359
                                char substr[BUFRSZ];
 
13360
 
 
13361
                                for (c = 0; c < nsigs; c++)
 
13362
                                {
 
13363
                                        domain = dkim_sig_getdomain(sigs[c]);
 
13364
                                        selector = dkim_sig_getdomain(sigs[c]);
 
13365
                                        err = dkim_sig_geterror(sigs[c]);
 
13366
                                        errstr = dkim_sig_geterrorstr(err);
 
13367
 
 
13368
                                        memset(substr, '\0', sizeof substr);
 
13369
                                        len = sizeof substr;
 
13370
 
 
13371
                                        status = dkim_get_sigsubstring(dfc->mctx_dkimv,
 
13372
                                                                       sigs[c],
 
13373
                                                                       substr,
 
13374
                                                                       &len);
 
13375
 
 
13376
                                        if (status == DKIM_STAT_OK &&
 
13377
                                            domain != NULL &&
 
13378
                                            selector != NULL &&
 
13379
                                            errstr != NULL)
 
13380
                                        {
 
13381
                                                if (dkimf_dstring_len(dfc->mctx_tmpstr) > 0)
 
13382
                                                {
 
13383
                                                        dkimf_dstring_catn(dfc->mctx_tmpstr,
 
13384
                                                                           "; ",
 
13385
                                                                           2);
 
13386
                                                }
 
13387
 
 
13388
                                                dkimf_dstring_printf(dfc->mctx_tmpstr,
 
13389
                                                                     "signature=%s domain=%s selector=%s result=\"%s\"",
 
13390
                                                                     substr,
 
13391
                                                                     domain,
 
13392
                                                                     selector,
 
13393
                                                                     errstr);
 
13394
                                        }
 
13395
                                }
 
13396
 
 
13397
                                if (dkimf_dstring_len(dfc->mctx_tmpstr) > 0)
 
13398
                                {
 
13399
                                        syslog(LOG_INFO, "%s: %s",
 
13400
                                               dfc->mctx_jobid,
 
13401
                                               dkimf_dstring_get(dfc->mctx_tmpstr));
 
13402
                                }
 
13403
                        }
 
13404
                }
 
13405
 
13206
13406
                switch (status)
13207
13407
                {
13208
13408
                  case DKIM_STAT_OK:
14197
14397
                                {
14198
14398
                                        strlcat((char *) header, DELIMITER,
14199
14399
                                                        sizeof header);
14200
 
                                        strlcat((char *) header, "(",
 
14400
                                        strlcat((char *) header, "reason=\"",
14201
14401
                                                sizeof header);
14202
14402
                                        strlcat((char *) header, comment,
14203
14403
                                                sizeof header);
14204
 
                                        strlcat((char *) header, ")",
 
14404
                                        strlcat((char *) header, "\"",
14205
14405
                                                sizeof header);
14206
14406
                                }
14207
14407
 
14277
14477
                                        err = dkim_geterror(dfc->mctx_dkimv);
14278
14478
                                        if (err != NULL)
14279
14479
                                        {
14280
 
                                                strlcat((char *) header, " (",
 
14480
                                                strlcat((char *) header,
 
14481
                                                        " reason=\"",
14281
14482
                                                        sizeof header);
14282
14483
                                                strlcat((char *) header, err,
14283
14484
                                                        sizeof header);
14284
 
                                                strlcat((char *) header, ")",
 
14485
                                                strlcat((char *) header, "\"",
14285
14486
                                                        sizeof header);
14286
14487
                                        }
14287
14488
                                }
14339
14540
                                        err = dkim_geterror(dfc->mctx_dkimv);
14340
14541
                                        if (err != NULL)
14341
14542
                                        {
14342
 
                                                strlcat((char *) header, " (",
 
14543
                                                strlcat((char *) header,
 
14544
                                                        " reason=\"",
14343
14545
                                                        sizeof header);
14344
14546
                                                strlcat((char *) header, err,
14345
14547
                                                        sizeof header);
14346
 
                                                strlcat((char *) header, ")",
 
14548
                                                strlcat((char *) header, "\"",
14347
14549
                                                        sizeof header);
14348
14550
                                        }
14349
14551
                                }
15871
16073
#ifdef _FFR_REPUTATION
15872
16074
                                        "\trepute:server[:reporter]\n"
15873
16075
#endif /* _FFR_REPUTATION */
 
16076
#ifdef _FFR_SOCKETDB
 
16077
                                        "\tsocket:{ port@host | path}\n"
 
16078
#endif /* _FFR_SOCKETDB */
 
16079
#ifdef USE_MDB
 
16080
                                        "\tmdb:path\n"
 
16081
#endif /* USE_MDB */
 
16082
#ifdef USE_ERLANG
 
16083
                                        "\terlang:node@host[,...]:cookie:module:function\n"
 
16084
#endif /* USE_ERLANG */
15874
16085
                                        "> ");
15875
16086
                }
15876
16087