Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/httpd Add a -q option to make http quiet (no log mes...
details: https://anonhg.NetBSD.org/src/rev/af8a867d9328
branches: trunk
changeset: 370011:af8a867d9328
user: martin <martin%NetBSD.org@localhost>
date: Mon Sep 12 10:30:39 2022 +0000
description:
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:
libexec/httpd/bozohttpd.c | 46 ++++++++++++++++++++++++++++------------------
libexec/httpd/bozohttpd.h | 3 ++-
libexec/httpd/main.c | 10 ++++++++--
libexec/httpd/ssl-bozo.c | 29 ++++++++++++++++++-----------
4 files changed, 56 insertions(+), 32 deletions(-)
diffs (193 lines):
diff -r e2d33cac7904 -r af8a867d9328 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Mon Sep 12 08:14:55 2022 +0000
+++ b/libexec/httpd/bozohttpd.c Mon Sep 12 10:30:39 2022 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 -r e2d33cac7904 -r af8a867d9328 libexec/httpd/bozohttpd.h
--- a/libexec/httpd/bozohttpd.h Mon Sep 12 08:14:55 2022 +0000
+++ b/libexec/httpd/bozohttpd.h Mon Sep 12 10:30:39 2022 +0000
@@ -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 @@
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 -r e2d33cac7904 -r af8a867d9328 libexec/httpd/main.c
--- a/libexec/httpd/main.c Mon Sep 12 08:14:55 2022 +0000
+++ b/libexec/httpd/main.c Mon Sep 12 10:30:39 2022 +0000
@@ -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 @@
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 @@
*/
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 @@
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 -r e2d33cac7904 -r af8a867d9328 libexec/httpd/ssl-bozo.c
--- a/libexec/httpd/ssl-bozo.c Mon Sep 12 08:14:55 2022 +0000
+++ b/libexec/httpd/ssl-bozo.c Mon Sep 12 10:30:39 2022 +0000
@@ -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 @@
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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index