aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-09 09:10:26 +0200
committerJohannes Berg <johannes@sipsolutions.net>2008-09-09 09:10:26 +0200
commitc0dd0943168cdcac3efcb0744767eef241a11112 (patch)
treeee4473441a3032aa5e7d75643d597a204582a243
parentea27a882ce5b26967fc68c32970d61e77a15042c (diff)
downloaddovecot-antispam-c0dd0943168cdcac3efcb0744767eef241a11112.tar.gz
dovecot-antispam-c0dd0943168cdcac3efcb0744767eef241a11112.tar.xz
dovecot-antispam-c0dd0943168cdcac3efcb0744767eef241a11112.zip
some more verbose debugging, untested
-rw-r--r--antispam-plugin.h4
-rw-r--r--crm114-exec.c6
-rw-r--r--debug.c31
-rw-r--r--dspam-exec.c11
4 files changed, 45 insertions, 7 deletions
diff --git a/antispam-plugin.h b/antispam-plugin.h
index ff1294e..6ca975f 100644
--- a/antispam-plugin.h
+++ b/antispam-plugin.h
@@ -46,11 +46,15 @@ int backend_commit(struct mailbox_transaction_context *ctx,
#ifdef CONFIG_DEBUG
void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+void debugv(char **args);
#else
static void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
static inline void debug(const char *fmt __attribute__((unused)), ...)
{
}
+static inline void debugv(char **args __attribute__((unused)))
+{
+}
#endif
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE)
diff --git a/crm114-exec.c b/crm114-exec.c
index 88b14c4..360346b 100644
--- a/crm114-exec.c
+++ b/crm114-exec.c
@@ -111,13 +111,15 @@ static int call_reaver(const char *signature, enum classification wanted)
argv[0] = (char *)reaver_binary;
argv[1] = (char *)class_arg;
- debug("%s %s ...", reaver_binary, class_arg);
-
for (i = 0; i < extra_args_num; i++)
argv[i + FIXED_ARGS_NUM] = (char *)extra_args[i];
+ debugv(argv);
+
execv(reaver_binary, argv);
/* fall through if reaver can't be found */
+ debug("executing %s failed: %d (uid=%d, gid=%d)",
+ reaver_binary, errno, getuid(), getgid());
exit(127);
/* not reached */
return -1;
diff --git a/debug.c b/debug.c
index 6af5823..7183f33 100644
--- a/debug.c
+++ b/debug.c
@@ -31,3 +31,34 @@ void debug(const char *fmt, ...)
_debug(fmt, args);
va_end(args);
}
+
+void debugv(char **args)
+{
+ size_t len, pos, buflen = 1024;
+ char *buf;
+ const char *str;
+
+ t_push();
+ buf = t_buffer_get(buflen);
+
+ while (1) {
+ str = *args;
+ if (!str)
+ break;
+ len = strlen(str);
+ if (pos + len + 1 >= buflen) {
+ buflen = nearest_power(pos + len + 2);
+ buf = t_buffer_reget(buf, buflen);
+ }
+
+ memcpy(buf + pos, str, len);
+ pos += len;
+ buf[pos++] = ' ';
+ args++;
+ }
+
+ buf[pos++] = '\0';
+
+ debug(stringify(PLUGINNAME) ": %s", buf);
+ t_pop();
+}
diff --git a/dspam-exec.c b/dspam-exec.c
index fffb61b..2f37c36 100644
--- a/dspam-exec.c
+++ b/dspam-exec.c
@@ -130,19 +130,20 @@ static int call_dspam(const char *signature, enum classification wanted)
argv[2] = (char *)class_arg;
argv[3] = (char *)sign_arg;
+ for (i = 0; i < extra_args_num; i++)
+ argv[i + 4] = (char *)extra_args[i];
+
#ifdef DEBUG_SYSLOG
/*
* not good with stderr debuggin since we then write to
* stderr which our parent takes as a bug
*/
- debug("%s --source=error %s %s ...",
- dspam_binary, class_arg, sign_arg);
+ debugv(argv);
#endif
- for (i = 0; i < extra_args_num; i++)
- argv[i + 4] = (char *)extra_args[i];
-
execv(dspam_binary, argv);
+ debug("executing %s failed: %d (uid=%d, gid=%d)",
+ dspam_binary, errno, getuid(), getgid());
/* fall through if dspam can't be found */
exit(127);
/* not reached */