summaryrefslogtreecommitdiffstats
path: root/support/suexec.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2012-05-23 17:42:33 +0200
committerJoe Orton <jorton@apache.org>2012-05-23 17:42:33 +0200
commitcc9eab4c92d66e8e0f6fa169a2641858f92de951 (patch)
tree3b9423158e774337ff18dde2837383f2b7e659ad /support/suexec.c
parentrebuild (diff)
downloadapache2-cc9eab4c92d66e8e0f6fa169a2641858f92de951.tar.xz
apache2-cc9eab4c92d66e8e0f6fa169a2641858f92de951.zip
suexec: Add support for logging to syslog as an alternative to a
logfile. * support/suexec.c (err_output) [AP_LOG_SYSLOG]: Log to syslog. (main): Close syslog fd if open, before execv. Add -V output for AP_LOG_SYSLOG. * configure.in: Add --with-suexec-syslog argument; allow --without-suexec-logfile to omit definition of AP_LOG_EXEC. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1341905 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/suexec.c')
-rw-r--r--support/suexec.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/support/suexec.c b/support/suexec.c
index 2c4e2c3bf0..8d7fcfdd99 100644
--- a/support/suexec.c
+++ b/support/suexec.c
@@ -58,6 +58,10 @@
#include <grp.h>
#endif
+#ifdef AP_LOG_SYSLOG
+#include <syslog.h>
+#endif
+
#if defined(PATH_MAX)
#define AP_MAXPATH PATH_MAX
#elif defined(MAXPATHLEN)
@@ -69,7 +73,12 @@
#define AP_ENVBUF 256
extern char **environ;
+
+#ifdef AP_LOG_SYSLOG
+static int log_open;
+#else
static FILE *log = NULL;
+#endif
static const char *const safe_env_lst[] =
{
@@ -137,7 +146,14 @@ static void err_output(int is_error, const char *fmt, va_list ap)
static void err_output(int is_error, const char *fmt, va_list ap)
{
-#ifdef AP_LOG_EXEC
+#if defined(AP_LOG_SYSLOG)
+ if (!log_open) {
+ openlog("suexec", LOG_PID, LOG_DAEMON);
+ log_open = 1;
+ }
+
+ vsyslog(is_error ? LOG_ERR : LOG_INFO, fmt, ap);
+#elif defined(AP_LOG_EXEC)
time_t timevar;
struct tm *lt;
@@ -295,7 +311,9 @@ int main(int argc, char *argv[])
#ifdef AP_HTTPD_USER
fprintf(stderr, " -D AP_HTTPD_USER=\"%s\"\n", AP_HTTPD_USER);
#endif
-#ifdef AP_LOG_EXEC
+#if defined(AP_LOG_SYSLOG)
+ fprintf(stderr, " -D AP_LOG_SYSLOG\n");
+#elif defined(AP_LOG_EXEC)
fprintf(stderr, " -D AP_LOG_EXEC=\"%s\"\n", AP_LOG_EXEC);
#endif
#ifdef AP_SAFE_PATH
@@ -591,6 +609,12 @@ int main(int argc, char *argv[])
#endif /* AP_SUEXEC_UMASK */
/* Be sure to close the log file so the CGI can't mess with it. */
+#ifdef AP_LOG_SYSLOG
+ if (log_open) {
+ closelog();
+ log_open = 0;
+ }
+#else
if (log != NULL) {
#if APR_HAVE_FCNTL_H
/*
@@ -612,6 +636,7 @@ int main(int argc, char *argv[])
log = NULL;
#endif
}
+#endif
/*
* Execute the command, replacing our image with its own.