Skip to content

Commit

Permalink
Stop option for ACL control of debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Harris committed Jan 27, 2022
1 parent dad53f7 commit 9f69166
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions doc/doc-docbook/spec.xfpt
Expand Up @@ -31604,8 +31604,10 @@ The filename can be adjusted with the &'tag'& option, which
may access any variables already defined. The logging may be adjusted with
the &'opts'& option, which takes the same values as the &`-d`& command-line
option.
Logging started this way may be stopped, and the file removed,
with the &'kill'& option.
.new
Logging started this way may be stopped by using the &'stop'& option.
The &'kill'& option additionally removes the debug file.
.wen
Some examples (which depend on variables that don't exist in all
contexts):
.code
Expand Down
7 changes: 7 additions & 0 deletions doc/doc-txt/NewStuff
Expand Up @@ -17,6 +17,13 @@ Version 4.96

4. An event for failing TLS connects to the daemon.

5. Tainted data used for a query-style lookup should be quoted using the
expansion item for the lookup type. If not, a warning will be written to
the main and panic logs. A future release will enforce this by failing
the lookup.

6. The ACL "debug" control gains a "stop" option.


Version 4.95
------------
Expand Down
11 changes: 9 additions & 2 deletions src/src/acl.c
Expand Up @@ -3481,7 +3481,7 @@ for (; cb; cb = cb->next)
{
uschar * debug_tag = NULL;
uschar * debug_opts = NULL;
BOOL kill = FALSE;
BOOL kill = FALSE, stop = FALSE;

while (*p == '/')
{
Expand All @@ -3501,13 +3501,20 @@ for (; cb; cb = cb->next)
for (pp += 4; *pp && *pp != '/';) pp++;
kill = TRUE;
}
else if (Ustrncmp(pp, "stop", 4) == 0)
{
for (pp += 4; *pp && *pp != '/';) pp++;
stop = TRUE;
}
else
while (*pp && *pp != '/') pp++;
p = pp;
}

if (kill)
debug_logging_stop();
debug_logging_stop(TRUE);
else if (stop)
debug_logging_stop(FALSE);
else
debug_logging_activate(debug_tag, debug_opts);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/src/functions.h
Expand Up @@ -186,7 +186,7 @@ extern int dcc_process(uschar **);
#endif

extern void debug_logging_activate(uschar *, uschar *);
extern void debug_logging_stop(void);
extern void debug_logging_stop(BOOL);
extern void debug_print_argv(const uschar **);
extern void debug_print_ids(uschar *);
extern void debug_printf_indent(const char *, ...) PRINTF_FUNCTION(1,2);
Expand Down
4 changes: 2 additions & 2 deletions src/src/log.c
Expand Up @@ -1510,14 +1510,14 @@ else


void
debug_logging_stop(void)
debug_logging_stop(BOOL kill)
{
if (!debug_file || !debuglog_name[0]) return;

debug_selector = 0;
fclose(debug_file);
debug_file = NULL;
unlink_log(lt_debug);
if (kill) unlink_log(lt_debug);
}

/* Called from the appendfile transport setup. */
Expand Down

0 comments on commit 9f69166

Please sign in to comment.