summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2016-05-21 21:14:05 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2016-05-21 21:14:05 +0100
commitb0d68adc8b45e42b425c23e7dbf195b772878b9a (patch)
treecb7ff5a639d6dd9c90a454bc661217e459f6b320 /src
parent01f3091ab20e5b78419d2b7cff106b421600e553 (diff)
Debug: "kill" option on ACL control=debug. Bug 1831
Diffstat (limited to 'src')
-rw-r--r--src/src/acl.c43
-rw-r--r--src/src/functions.h1
-rw-r--r--src/src/log.c21
3 files changed, 49 insertions, 16 deletions
diff --git a/src/src/acl.c b/src/src/acl.c
index 474b0d181..dd59b4952 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -2976,8 +2976,6 @@ acl_check_condition(int verb, acl_condition_block *cb, int where,
{
uschar *user_message = NULL;
uschar *log_message = NULL;
-uschar *debug_tag = NULL;
-uschar *debug_opts = NULL;
int rc = OK;
#ifdef WITH_CONTENT_SCAN
int sep = -'/';
@@ -3329,24 +3327,39 @@ for (; cb != NULL; cb = cb->next)
break;
case CONTROL_DEBUG:
- while (*p == '/')
{
- if (Ustrncmp(p, "/tag=", 5) == 0)
- {
- const uschar *pp = p + 5;
- while (*pp != '\0' && *pp != '/') pp++;
- debug_tag = string_copyn(p+5, pp-p-5);
- p = pp;
- }
- else if (Ustrncmp(p, "/opts=", 6) == 0)
+ uschar * debug_tag = NULL;
+ uschar * debug_opts = NULL;
+ BOOL kill = FALSE;
+
+ while (*p == '/')
{
- const uschar *pp = p + 6;
- while (*pp != '\0' && *pp != '/') pp++;
- debug_opts = string_copyn(p+6, pp-p-6);
+ const uschar * pp = p+1;
+ if (Ustrncmp(pp, "tag=", 4) == 0)
+ {
+ for (pp += 4; *pp && *pp != '/';) pp++;
+ debug_tag = string_copyn(p+5, pp-p-5);
+ }
+ else if (Ustrncmp(pp, "opts=", 5) == 0)
+ {
+ for (pp += 5; *pp && *pp != '/';) pp++;
+ debug_opts = string_copyn(p+6, pp-p-6);
+ }
+ else if (Ustrncmp(pp, "kill", 4) == 0)
+ {
+ for (pp += 4; *pp && *pp != '/';) pp++;
+ kill = TRUE;
+ }
+ else
+ while (*pp && *pp != '/') pp++;
p = pp;
}
+
+ if (kill)
+ debug_logging_stop();
+ else
+ debug_logging_activate(debug_tag, debug_opts);
}
- debug_logging_activate(debug_tag, debug_opts);
break;
case CONTROL_SUPPRESS_LOCAL_FIXUPS:
diff --git a/src/src/functions.h b/src/src/functions.h
index f690e9fd9..ade557c2f 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -123,6 +123,7 @@ extern int dcc_process(uschar **);
#endif
extern void debug_logging_activate(uschar *, uschar *);
+extern void debug_logging_stop(void);
extern void debug_print_argv(const uschar **);
extern void debug_print_ids(uschar *);
extern void debug_print_string(uschar *);
diff --git a/src/src/log.c b/src/src/log.c
index 9e6809720..b01a179c0 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -503,6 +503,13 @@ log_write(0, LOG_PANIC_DIE, "Cannot open %s log file \"%s\": %s: "
}
+static void
+unlink_log(int type)
+{
+if (type == lt_debug) unlink(CS debuglog_name);
+}
+
+
/*************************************************
* Add configuration file info to log line *
@@ -1395,7 +1402,7 @@ int fd = -1;
if (debug_file)
{
debug_printf("DEBUGGING ACTIVATED FROM WITHIN CONFIG.\n"
- "DEBUG: Tag=\"%s\" Opts=\"%s\"\n", tag_name, opts ? opts : US"");
+ "DEBUG: Tag=\"%s\" opts=\"%s\"\n", tag_name, opts ? opts : US"");
return;
}
@@ -1426,4 +1433,16 @@ else
}
+void
+debug_logging_stop(void)
+{
+if (!debug_file || !debuglog_name[0]) return;
+
+debug_selector = 0;
+fclose(debug_file);
+debug_file = NULL;
+unlink_log(lt_debug);
+}
+
+
/* End of log.c */