X-Git-Url: http://git.madism.org/?p=apps%2Fpfixtools.git;a=blobdiff_plain;f=postlicyd%2Fmain-postlicyd.c;h=888a39382291191726f348537dca2b945c67a6ed;hp=a4543ec3be629b0afb575c6f8c9b962a76ac905f;hb=6b977cdc115af3cebdf488f27d106788e8bd9461;hpb=5c6356faa58d3109101e88ecfce207326d89ceab diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index a4543ec..888a393 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -16,17 +16,20 @@ /* products derived from this software without specific prior written */ /* permission. */ /* */ -/* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND */ -/* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE */ -/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ -/* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS */ -/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR */ -/* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF */ -/* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */ -/* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN */ -/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) */ -/* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF */ -/* THE POSSIBILITY OF SUCH DAMAGE. */ +/* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS */ +/* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ +/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY */ +/* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */ +/* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS */ +/* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */ +/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */ +/* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */ +/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/* Copyright (c) 2006-2008 the Authors */ +/* see AUTHORS and source files for details */ /******************************************************************************/ /* @@ -44,7 +47,7 @@ #include "query.h" #define DAEMON_NAME "postlicyd" -#define DAEMON_VERSION "0.4" +#define DAEMON_VERSION "0.5" #define DEFAULT_PORT 10000 #define RUNAS_USER "nobody" #define RUNAS_GROUP "nogroup" @@ -147,13 +150,13 @@ static const filter_t *next_filter(client_t *pcy, const filter_t *filter, *ok = true; return NULL; } else if (hook->postfix) { - log_reply(INFO, "awswer %s from filter %s: \"%s\"", + log_reply(INFO, "answer %s from filter %s: \"%s\"", htokens[hook->type], filter->name, hook->value); policy_answer(pcy, hook->value); *ok = true; return NULL; } else { - log_reply(DEBUG, "awswer %s from filter %s: next filter %s", + log_reply(DEBUG, "answer %s from filter %s: next filter %s", htokens[hook->type], filter->name, (array_ptr(config->filters, hook->filter_id))->name); return array_ptr(config->filters, hook->filter_id); @@ -167,7 +170,7 @@ static bool policy_process(client_t *pcy, const config_t *mconfig) const query_t* query = &context->query; const filter_t *filter; if (mconfig->entry_points[query->state] == -1) { - warn("no filter defined for current protocol_state (%s)", smtp_state_names[query->state]); + warn("no filter defined for current protocol_state (%s)", smtp_state_names[query->state].str); return false; } if (context->context.current_filter != NULL) { @@ -225,9 +228,10 @@ static int policy_run(client_t *pcy, void* vconfig) query->eoq = eoq + strlen("\n\n"); /* The instance changed => reset the static context */ - if (query->instance == NULL || strcmp(context->context.instance, query->instance) != 0) { + if (query->instance.str == NULL || query->instance.len == 0 + || strcmp(context->context.instance, query->instance.str) != 0) { filter_context_clean(&context->context); - m_strcat(context->context.instance, 64, query->instance); + m_strcat(context->context.instance, 64, query->instance.str); } client_io_none(pcy); return policy_process(pcy, mconfig) ? 0 : -1; @@ -294,7 +298,7 @@ int main(int argc, char *argv[]) bool port_from_cli = false; bool check_conf = false; - for (int c = 0; (c = getopt(argc, argv, "ufdc" "l:p:")) >= 0; ) { + for (int c = 0; (c = getopt(argc, argv, "hufdc" "l:p:")) >= 0; ) { switch (c) { case 'p': pidfile = optarg;