summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/smtpd.h6
-rw-r--r--usr.sbin/smtpd/table.c13
-rw-r--r--usr.sbin/smtpd/table_static.c21
3 files changed, 20 insertions, 20 deletions
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 82107731448..a72a42a3385 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.402 2013/01/31 18:34:43 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.403 2013/02/05 15:23:40 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -724,8 +724,7 @@ struct mta_relay {
#define RELAY_WAIT_PREFERENCE 0x02
#define RELAY_WAIT_SECRET 0x04
#define RELAY_WAIT_SOURCE 0x08
-#define RELAY_WAIT_HELO 0x10
-#define RELAY_WAITMASK 0x1f
+#define RELAY_WAITMASK 0x0f
int status;
int refcount;
@@ -1306,6 +1305,7 @@ void table_destroy(struct table *);
void table_add(struct table *, const char *, const char *);
void table_delete(struct table *, const char *);
void table_delete_all(struct table *);
+void table_replace(struct table *, struct table *);
int table_domain_match(const char *, const char *);
int table_netaddr_match(const char *, const char *);
int table_mailaddr_match(const char *, const char *);
diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index 80dd80d0c61..d58ebbf8a45 100644
--- a/usr.sbin/smtpd/table.c
+++ b/usr.sbin/smtpd/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.2 2013/02/05 11:45:18 gilles Exp $ */
+/* $OpenBSD: table.c,v 1.3 2013/02/05 15:23:40 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -157,6 +157,17 @@ table_destroy(struct table *t)
}
void
+table_replace(struct table *orig, struct table *tnew)
+{
+ void *p = NULL;
+
+ while (dict_poproot(&orig->t_dict, NULL, (void **)&p))
+ free(p);
+ dict_merge(&orig->t_dict, &tnew->t_dict);
+ table_destroy(tnew);
+}
+
+void
table_set_configuration(struct table *t, struct table *config)
{
strlcpy(t->t_cfgtable, config->t_name, sizeof t->t_cfgtable);
diff --git a/usr.sbin/smtpd/table_static.c b/usr.sbin/smtpd/table_static.c
index e9b7dd72de6..c3bca6889fb 100644
--- a/usr.sbin/smtpd/table_static.c
+++ b/usr.sbin/smtpd/table_static.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_static.c,v 1.1 2013/01/26 09:37:24 gilles Exp $ */
+/* $OpenBSD: table_static.c,v 1.2 2013/02/05 15:23:40 gilles Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -89,7 +89,6 @@ static int
table_static_update(struct table *table)
{
struct table *t;
- char name[MAX_LINE_SIZE];
/* no config ? ok */
if (table->t_config[0] == '\0')
@@ -99,26 +98,16 @@ table_static_update(struct table *table)
if (! t->t_backend->config(t, table->t_config))
goto err;
- /* update successful, swap table names */
- strlcpy(name, table->t_name, sizeof name);
- strlcpy(table->t_name, t->t_name, sizeof table->t_name);
- strlcpy(t->t_name, name, sizeof t->t_name);
-
- /* swap, table id */
- table->t_id = table->t_id ^ t->t_id;
- t->t_id = table->t_id ^ t->t_id;
- table->t_id = table->t_id ^ t->t_id;
-
- /* destroy former table */
- table_destroy(table);
+ /* replace former table, frees t */
+ table_replace(table, t);
ok:
- log_info("info: Table \"%s\" successfully updated", name);
+ log_info("info: Table \"%s\" successfully updated", table->t_name);
return 1;
err:
table_destroy(t);
- log_info("info: Failed to update table \"%s\"", name);
+ log_info("info: Failed to update table \"%s\"", table->t_name);
return 0;
}