summaryrefslogtreecommitdiff
path: root/libexec/httpd
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2022-09-12 10:30:39 +0000
committermartin <martin@NetBSD.org>2022-09-12 10:30:39 +0000
commitc046dfd5cca099e5bc6fe182ea4eea1d55a3b0cd (patch)
treebd7f432407dff6e4832eb9f765a85c6ec49fd894 /libexec/httpd
parent2e77e091ac5f87377622c50269ac544a6204542d (diff)
Add a -q option to make http quiet (no log messages).
Usefull when running multiple instances and some for (high traffic) APIs e.g. to receive log data from appliences - it makes not sense to duplicate the whole log in the xferlog file (but we can't configure that at the syslog level due to other httpd instances using that).
Diffstat (limited to 'libexec/httpd')
-rw-r--r--libexec/httpd/bozohttpd.c46
-rw-r--r--libexec/httpd/bozohttpd.h3
-rw-r--r--libexec/httpd/main.c10
-rw-r--r--libexec/httpd/ssl-bozo.c29
4 files changed, 56 insertions, 32 deletions
diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c
index f04efe131b6..3c8f800d3f3 100644
--- a/libexec/httpd/bozohttpd.c
+++ b/libexec/httpd/bozohttpd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bozohttpd.c,v 1.141 2022/05/18 00:37:11 mrg Exp $ */
+/* $NetBSD: bozohttpd.c,v 1.142 2022/09/12 10:30:39 martin Exp $ */
/* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */
@@ -2022,11 +2022,13 @@ debug__(bozohttpd_t *httpd, int level, const char *fmt, ...)
savederrno = errno;
va_start(ap, fmt);
- if (httpd->logstderr) {
- vfprintf(stderr, fmt, ap);
- fputs("\n", stderr);
- } else
- vsyslog(LOG_DEBUG, fmt, ap);
+ if (!httpd->nolog) {
+ if (httpd->logstderr) {
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ } else
+ vsyslog(LOG_DEBUG, fmt, ap);
+ }
va_end(ap);
errno = savederrno;
}
@@ -2039,12 +2041,14 @@ bozowarn(bozohttpd_t *httpd, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- if (httpd->logstderr || isatty(STDERR_FILENO)) {
- //fputs("warning: ", stderr);
- vfprintf(stderr, fmt, ap);
- fputs("\n", stderr);
- } else
- vsyslog(LOG_INFO, fmt, ap);
+ if (!httpd->nolog) {
+ if (httpd->logstderr || isatty(STDERR_FILENO)) {
+ //fputs("warning: ", stderr);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ } else
+ vsyslog(LOG_INFO, fmt, ap);
+ }
va_end(ap);
}
@@ -2054,12 +2058,14 @@ bozoerr(bozohttpd_t *httpd, int code, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- if (httpd->logstderr || isatty(STDERR_FILENO)) {
- //fputs("error: ", stderr);
- vfprintf(stderr, fmt, ap);
- fputs("\n", stderr);
- } else
- vsyslog(LOG_ERR, fmt, ap);
+ if (!httpd->nolog) {
+ if (httpd->logstderr || isatty(STDERR_FILENO)) {
+ //fputs("error: ", stderr);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ } else
+ vsyslog(LOG_ERR, fmt, ap);
+ }
va_end(ap);
exit(code);
}
@@ -2591,6 +2597,10 @@ bozo_setup(bozohttpd_t *httpd, bozoprefs_t *prefs, const char *vhost,
strcmp(cp, "true") == 0) {
httpd->logstderr = 1;
}
+ if ((cp = bozo_get_pref(prefs, "no log")) != NULL &&
+ strcmp(cp, "true") == 0) {
+ httpd->nolog = 1;
+ }
if ((cp = bozo_get_pref(prefs, "bind address")) != NULL) {
httpd->bindaddress = bozostrdup(httpd, NULL, cp);
}
diff --git a/libexec/httpd/bozohttpd.h b/libexec/httpd/bozohttpd.h
index 28c2a6634ca..cdfec757793 100644
--- a/libexec/httpd/bozohttpd.h
+++ b/libexec/httpd/bozohttpd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bozohttpd.h,v 1.72 2022/05/18 00:37:11 mrg Exp $ */
+/* $NetBSD: bozohttpd.h,v 1.73 2022/09/12 10:30:39 martin Exp $ */
/* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */
@@ -103,6 +103,7 @@ typedef struct bozohttpd_t {
char *virtbase; /* virtual directory base */
int unknown_slash; /* unknown vhosts go to normal slashdir */
int logstderr; /* log to stderr (even if not tty) */
+ int nolog; /* do not log anything */
int background; /* drop into daemon mode */
int foreground; /* keep daemon mode in foreground */
char *pidfile; /* path to the pid file, if any */
diff --git a/libexec/httpd/main.c b/libexec/httpd/main.c
index 15c4ec3591d..af54510aa1a 100644
--- a/libexec/httpd/main.c
+++ b/libexec/httpd/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.29 2021/08/24 09:47:36 mrg Exp $ */
+/* $NetBSD: main.c,v 1.30 2022/09/12 10:30:39 martin Exp $ */
/* $eterna: main.c,v 1.6 2011/11/18 09:21:15 mrg Exp $ */
/* from: eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp */
@@ -102,6 +102,8 @@ usage(bozohttpd_t *httpd, char *progname)
bozowarn(httpd, " -P pidfile\t\tpid file path");
if (have_user)
bozowarn(httpd, " -p dir\t\t\"public_html\" directory name");
+ if (have_core)
+ bozowarn(httpd, " -q\t\tquiet mode, no logging");
if (have_dirindex)
bozowarn(httpd, " -R readme\t\tput readme file in footer "
"of directory index");
@@ -164,7 +166,7 @@ main(int argc, char **argv)
*/
while ((c = getopt(argc, argv,
- "C:EGHI:L:M:m:P:R:S:T:U:VXZ:bc:defhi:np:st:uv:x:z:")) != -1) {
+ "C:EGHI:L:M:m:P:R:S:T:U:VXZ:bc:defhi:np:qst:uv:x:z:")) != -1) {
switch (c) {
case 'b':
@@ -310,6 +312,10 @@ main(int argc, char **argv)
bozo_set_pref(&httpd, &prefs, "public_html", optarg);
break;
+ case 'q':
+ bozo_set_pref(&httpd, &prefs, "no log", "true");
+ break;
+
case 'R':
if (!have_dirindex)
goto no_dirindex_support;
diff --git a/libexec/httpd/ssl-bozo.c b/libexec/httpd/ssl-bozo.c
index d3867fdbd7b..5e4d9436507 100644
--- a/libexec/httpd/ssl-bozo.c
+++ b/libexec/httpd/ssl-bozo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ssl-bozo.c,v 1.31 2021/08/24 09:53:26 mrg Exp $ */
+/* $NetBSD: ssl-bozo.c,v 1.32 2022/09/12 10:30:39 martin Exp $ */
/* $eterna: ssl-bozo.c,v 1.15 2011/11/18 09:21:15 mrg Exp $ */
@@ -121,6 +121,9 @@ bozo_clear_ssl_queue(bozohttpd_t *httpd)
do {
static const char sslfmt[] = "SSL Error: %s:%s:%s";
+ if (httpd->nolog)
+ continue;
+
if (httpd->logstderr || isatty(STDERR_FILENO)) {
fprintf(stderr, sslfmt,
ERR_lib_error_string(sslcode),
@@ -144,11 +147,13 @@ bozo_ssl_warn(bozohttpd_t *httpd, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- if (httpd->logstderr || isatty(STDERR_FILENO)) {
- vfprintf(stderr, fmt, ap);
- fputs("\n", stderr);
- } else
- vsyslog(LOG_ERR, fmt, ap);
+ if (!httpd->nolog) {
+ if (httpd->logstderr || isatty(STDERR_FILENO)) {
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ } else
+ vsyslog(LOG_ERR, fmt, ap);
+ }
va_end(ap);
bozo_clear_ssl_queue(httpd);
@@ -164,11 +169,13 @@ bozo_ssl_err(bozohttpd_t *httpd, int code, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- if (httpd->logstderr || isatty(STDERR_FILENO)) {
- vfprintf(stderr, fmt, ap);
- fputs("\n", stderr);
- } else
- vsyslog(LOG_ERR, fmt, ap);
+ if (!httpd->nolog) {
+ if (httpd->logstderr || isatty(STDERR_FILENO)) {
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ } else
+ vsyslog(LOG_ERR, fmt, ap);
+ }
va_end(ap);
bozo_clear_ssl_queue(httpd);