From c21377e7bcc70d2a456409225d8b2d91990a14cd Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 20 May 2014 15:21:27 -0400 Subject: sandbox: support logfile rotation Fixes bug 12032; bugfix on 0.2.5.1-alpha --- src/common/log.c | 21 +++++++++++++++++++++ src/common/torlog.h | 3 +++ 2 files changed, 24 insertions(+) (limited to 'src/common') diff --git a/src/common/log.c b/src/common/log.c index 592dc2c5d..517fa4faa 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -562,6 +562,27 @@ tor_log_update_sigsafe_err_fds(void) UNLOCK_LOGS(); } +/** Add to out a copy of every currently configured log file name. Used + * to enable access to these filenames with the sandbox code. */ +void +tor_log_get_logfile_names(smartlist_t *out) +{ + logfile_t *lf; + tor_assert(out); + + LOCK_LOGS(); + + for (lf = logfiles; lf; lf = lf->next) { + if (lf->is_temporary || lf->is_syslog || lf->callback) + continue; + if (lf->filename == NULL) + continue; + smartlist_add(out, tor_strdup(lf->filename)); + } + + UNLOCK_LOGS(); +} + /** Output a message to the log, prefixed with a function name fn. */ #ifdef __GNUC__ /** GCC-based implementation of the log_fn backend, used when we have diff --git a/src/common/torlog.h b/src/common/torlog.h index f6ddca5d4..34f70f3c0 100644 --- a/src/common/torlog.h +++ b/src/common/torlog.h @@ -156,6 +156,9 @@ void tor_log_err_sigsafe(const char *m, ...); int tor_log_get_sigsafe_err_fds(const int **out); void tor_log_update_sigsafe_err_fds(void); +struct smartlist_t; +void tor_log_get_logfile_names(struct smartlist_t *out); + extern int log_global_min_severity_; #if defined(__GNUC__) || defined(RUNNING_DOXYGEN) -- cgit v1.2.3