Skip to content

Commit

Permalink
Added a version number to the plugin ABI to prevent semantic mismatches.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceg committed Nov 12, 2006
1 parent bd1afee commit e008829
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Changes in version 1.10

- Added a ClamAV virus scanner plugin.

- Modified the plugin API to add a flags word and to (optionally) save
messages to a temporary file (needed by the ClamAV plugin).
- Modified the plugin API to add a version code, a flags word, and to
(optionally) save messages to a temporary file.

Development of this version has been sponsored by FutureQuest, Inc.
[email protected] http://www.FutureQuest.net/
Expand Down
1 change: 1 addition & 0 deletions backend-echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static const response* message_end(int fd)
}

struct plugin backend = {
.version = PLUGIN_VERSION,
.reset = reset,
.sender = sender,
.recipient = recipient,
Expand Down
1 change: 1 addition & 0 deletions backend-qmail.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ static const response* message_end(int fd)
}

struct plugin backend = {
.version = PLUGIN_VERSION,
.reset = reset,
.sender = do_sender,
.recipient = do_recipient,
Expand Down
6 changes: 6 additions & 0 deletions mailfront.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

#define FLAG_NEED_FILE (1<<0)

#define PLUGIN_VERSION 2

struct plugin
{
unsigned version;
struct plugin* next;
const char* name;
unsigned flags;
Expand All @@ -24,8 +27,11 @@ struct plugin
const response* (*message_end)(int fd);
};

#define PROTOCOL_VERSION 2

struct protocol
{
unsigned version;
const char* name;
int (*respond_line)(unsigned number, int final,
const char* msg, unsigned long len);
Expand Down
9 changes: 9 additions & 0 deletions modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "conf_modules.c"

static response resp_load = { 451, 0 };
static RESPONSE(backend_version,451,"4.3.0 Backend ABI version mismatch");
static RESPONSE(plugin_version,451,"4.3.0 Plugin ABI version mismatch");
static RESPONSE(protocol_version,451,"4.3.0 Protocol ABI version mismatch");

struct plugin* plugin_list = 0;
struct plugin* plugin_tail = 0;
Expand Down Expand Up @@ -97,6 +100,8 @@ static const response* load_plugin(const char* name)
if ((plugin = find_builtin_plugin(name)) == 0) {
if ((plugin = load_object("plugin", name)) == 0)
return &resp_load;
if (plugin->version != PLUGIN_VERSION)
return &resp_plugin_version;
if ((plugin->name = strdup(name)) == 0)
return &resp_oom;
}
Expand Down Expand Up @@ -140,8 +145,12 @@ const response* load_modules(const char* protocol_name,
module_path = conf_modules;
if ((session.protocol = load_object("protocol", protocol_name)) == 0)
return &resp_load;
if (session.protocol->version != PROTOCOL_VERSION)
return &resp_protocol_version;
if ((session.backend = load_object("backend", backend_name)) == 0)
return &resp_load;
if (session.backend->version != PLUGIN_VERSION)
return &resp_backend_version;
module_flags |= session.backend->flags;
while (*plugins != 0)
if ((r = load_plugins(*plugins++)) != 0)
Expand Down
1 change: 1 addition & 0 deletions plugin-add-received.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static const response* data_start(int fd)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.init = init,
.data_start = data_start,
};
1 change: 1 addition & 0 deletions plugin-check-fqdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static const response* either(str* s)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.sender = either,
.recipient = either,
};
1 change: 1 addition & 0 deletions plugin-clamav.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static const response* message_end(int fd)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.flags = FLAG_NEED_FILE,
.message_end = message_end,
};
1 change: 1 addition & 0 deletions plugin-counters.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static const response* block(const char* bytes, unsigned long len)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.init = init,
.reset = reset,
.sender = sender,
Expand Down
1 change: 1 addition & 0 deletions plugin-cvm-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static const response* validate_recipient(str* recipient)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.init = validate_init,
.recipient = validate_recipient,
};
1 change: 1 addition & 0 deletions plugin-mailrules.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ static const response* validate_recipient(str* recipient)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.init = init,
.reset = reset,
.sender = validate_sender,
Expand Down
1 change: 1 addition & 0 deletions plugin-patterns.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static const response* check(const char* bytes, unsigned long len)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.data_start = init,
.data_block = check,
};
1 change: 1 addition & 0 deletions plugin-qmail-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static const response* validate_recipient(str* recipient)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.init = validate_init,
.sender = validate_sender,
.recipient = validate_recipient,
Expand Down
1 change: 1 addition & 0 deletions plugin-reject.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ static const response* sender(str* s)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.sender = sender,
};
1 change: 1 addition & 0 deletions plugin-relayclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ static const response* do_recipient(str* recipient)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.recipient = do_recipient,
};
1 change: 1 addition & 0 deletions plugin-require-auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ static const response* sender(str* s)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.sender = sender,
};
1 change: 1 addition & 0 deletions plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static const response* message_end(int fd)
}

struct plugin plugin = {
.version = PLUGIN_VERSION,
.flags = 0,
.init = init,
.helo = helo,
Expand Down
1 change: 1 addition & 0 deletions protocol-qmqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static int mainloop(void)
}

struct protocol protocol = {
.version = PROTOCOL_VERSION,
.name = "QMQP",
.respond_line = qmtp_respond_line,
.mainloop = mainloop,
Expand Down
1 change: 1 addition & 0 deletions protocol-qmtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static int mainloop(void)
}

struct protocol protocol = {
.version = PROTOCOL_VERSION,
.name = "QMTP",
.respond_line = qmtp_respond_line,
.mainloop = mainloop,
Expand Down
1 change: 1 addition & 0 deletions protocol-smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ static int smtp_respond_line(unsigned num, int final,
}

struct protocol protocol = {
.version = PROTOCOL_VERSION,
.name = "SMTP",
.respond_line = smtp_respond_line,
.init = init,
Expand Down

0 comments on commit e008829

Please sign in to comment.