ACL: "seen" condition
[exim.git] / src / src / dbstuff.h
index a18b288e680f8442ed70c3e665ca0505c4d86784..94db7f7fda92693f557bf685d2e795fd7e79389a 100644 (file)
@@ -2,7 +2,8 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2017 */
+/* Copyright (c) University of Cambridge 1995 - 2018 */
+/* Copyright (c) The Exim Maintainers 2020 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* This header file contains macro definitions so that a variety of DBM
@@ -74,7 +75,7 @@ free() must not die when passed NULL */
         key.dptr != NULL)
 
 /* EXIM_DBDELETE_CURSOR - terminate scanning operation. */
-#define EXIM_DBDELETE_CURSOR(cursor) free(cursor)
+#define EXIM_DBDELETE_CURSOR(cursor) store_free(cursor)
 
 /* EXIM_DBCLOSE */
 #define EXIM_DBCLOSE__(db)        tdb_close(db)
@@ -435,9 +436,8 @@ before been able to pass successfully. */
 #define EXIM_DBSCAN(db, key, data, first, cursor)      \
        ((db)->seq(db, &key, &data, (first? R_FIRST : R_NEXT)) == 0)
 
-/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). Make it
-refer to cursor, to keep picky compilers happy. */
-#define EXIM_DBDELETE_CURSOR(cursor) { cursor = cursor; }
+/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). */
+#define EXIM_DBDELETE_CURSOR(cursor) { }
 
 /* EXIM_DBCLOSE */
 #define EXIM_DBCLOSE__(db)        (db)->close(db)
@@ -523,9 +523,8 @@ typedef struct {
     (((db)->lkey.dptr != NULL)? (free((db)->lkey.dptr),1) : 1),\
     db->lkey = key, key.dptr != NULL)
 
-/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). Make it
-refer to cursor, to keep picky compilers happy. */
-#define EXIM_DBDELETE_CURSOR(cursor) { cursor = cursor; }
+/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). */
+#define EXIM_DBDELETE_CURSOR(cursor) { }
 
 /* EXIM_DBCLOSE */
 #define EXIM_DBCLOSE__(db) \
@@ -601,9 +600,8 @@ interface */
 #define EXIM_DBSCAN(db, key, data, first, cursor)      \
        (key = (first? dbm_firstkey(db) : dbm_nextkey(db)), key.dptr != NULL)
 
-/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). Make it
-refer to cursor, to keep picky compilers happy. */
-#define EXIM_DBDELETE_CURSOR(cursor) { cursor = cursor; }
+/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). */
+#define EXIM_DBDELETE_CURSOR(cursor) { }
 
 /* EXIM_DBCLOSE */
 #define EXIM_DBCLOSE__(db) dbm_close(db)
@@ -636,18 +634,22 @@ after reading data. */
 #  define EXIM_DBOPEN(name, dirname, flags, mode, dbpp) \
   do { \
   DEBUG(D_hints_lookup) \
-    debug_printf("EXIM_DBOPEN: file <%s> dir <%s> flags=%s\n", \
+    debug_printf_indent("EXIM_DBOPEN: file <%s> dir <%s> flags=%s\n", \
       (name), (dirname),               \
       (flags) == O_RDONLY ? "O_RDONLY" \
       : (flags) == O_RDWR ? "O_RDWR"   \
       : (flags) == (O_RDWR|O_CREAT) ? "O_RDWR|O_CREAT" \
       : "??"); \
-  EXIM_DBOPEN__(name, dirname, flags, mode, dbpp); \
-  DEBUG(D_hints_lookup) debug_printf("returned from EXIM_DBOPEN: %p\n", *dbpp); \
+  if (is_tainted2(name, LOG_MAIN|LOG_PANIC, "Tainted name '%s' for DB file not permitted", name) \
+      || is_tainted2(dirname, LOG_MAIN|LOG_PANIC, "Tainted name '%s' for DB directory not permitted", dirname)) \
+    *dbpp = NULL; \
+  else \
+    { EXIM_DBOPEN__(name, dirname, flags, mode, dbpp); } \
+  DEBUG(D_hints_lookup) debug_printf_indent("returned from EXIM_DBOPEN: %p\n", *dbpp); \
   } while(0)
 #  define EXIM_DBCLOSE(db) \
   do { \
-  DEBUG(D_hints_lookup) debug_printf("EXIM_DBCLOSE(%p)\n", db); \
+  DEBUG(D_hints_lookup) debug_printf_indent("EXIM_DBCLOSE(%p)\n", db); \
   EXIM_DBCLOSE__(db); \
   } while(0)
 
@@ -787,4 +789,44 @@ typedef struct {
 } dbdata_ratelimit_unique;
 
 
+/* For "seen" ACL condition */
+typedef struct {
+  time_t time_stamp;
+} dbdata_seen;
+
+#ifndef DISABLE_PIPE_CONNECT
+/* This structure records the EHLO responses, cleartext and crypted,
+for an IP, as bitmasks (cf. OPTION_TLS).  For LIMITS, also values
+advertised for MAILMAX, RCPTMAX and RCPTDOMAINMAX; zero meaning no
+value advertised. */
+
+typedef struct {
+  unsigned short cleartext_features;
+  unsigned short crypted_features;
+  unsigned short cleartext_auths;
+  unsigned short crypted_auths;
+
+# ifdef EXPERIMENTAL_ESMTP_LIMITS
+  unsigned int limit_mail;
+  unsigned int limit_rcpt;
+  unsigned int limit_rcptdom;
+# endif
+} ehlo_resp_precis;
+
+typedef struct {
+  time_t time_stamp;
+  /*************/
+  ehlo_resp_precis data;
+} dbdata_ehlo_resp;
+#endif
+
+typedef struct {
+  time_t time_stamp;
+  /*************/
+  uschar verify_override:1;
+  uschar ocsp:3;
+  uschar session[1];
+} dbdata_tls_session;
+
+
 /* End of dbstuff.h */