Module Name:    src
Committed By:   mrg
Date:           Sat May 15 06:48:27 UTC 2010

Modified Files:
        src/libexec/httpd: CHANGES bozohttpd.8 bozohttpd.c ssl-bozo.c

Log Message:
merge bozohttpd 20100512


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/libexec/httpd/CHANGES
cvs rdiff -u -r1.18 -r1.19 src/libexec/httpd/bozohttpd.8 \
    src/libexec/httpd/bozohttpd.c
cvs rdiff -u -r1.7 -r1.8 src/libexec/httpd/ssl-bozo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/httpd/CHANGES
diff -u src/libexec/httpd/CHANGES:1.6 src/libexec/httpd/CHANGES:1.7
--- src/libexec/httpd/CHANGES:1.6	Mon May 10 03:37:45 2010
+++ src/libexec/httpd/CHANGES	Sat May 15 06:48:27 2010
@@ -1,4 +1,8 @@
-$eterna: CHANGES,v 1.70 2010/05/10 02:24:30 mrg Exp $
+$eterna: CHANGES,v 1.71 2010/05/13 04:19:04 mrg Exp $
+
+changes since bozohttpd 20100509:
+	o  fix some compile issues
+	o  fix SSL mode.  from rtr.
 
 changes since bozohttpd 20090522:
 	o  major rework and clean up of internal interfaces.  move the main

Index: src/libexec/httpd/bozohttpd.8
diff -u src/libexec/httpd/bozohttpd.8:1.18 src/libexec/httpd/bozohttpd.8:1.19
--- src/libexec/httpd/bozohttpd.8:1.18	Mon May 10 14:53:17 2010
+++ src/libexec/httpd/bozohttpd.8	Sat May 15 06:48:27 2010
@@ -1,6 +1,6 @@
-.\"	$NetBSD: bozohttpd.8,v 1.18 2010/05/10 14:53:17 mrg Exp $
+.\"	$NetBSD: bozohttpd.8,v 1.19 2010/05/15 06:48:27 mrg Exp $
 .\"
-.\"	$eterna: bozohttpd.8,v 1.94 2010/05/10 14:49:19 mrg Exp $
+.\"	$eterna: bozohttpd.8,v 1.95 2010/05/13 04:17:58 mrg Exp $
 .\"
 .\" Copyright (c) 1997-2010 Matthew R. Green
 .\" All rights reserved.
@@ -459,7 +459,7 @@
 and regular code audits.
 This manual documents
 .Nm
-version 20100510.
+version 20100512.
 .Sh AUTHORS
 .Nm
 was written by Matthew R. Green
Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.18 src/libexec/httpd/bozohttpd.c:1.19
--- src/libexec/httpd/bozohttpd.c:1.18	Mon May 10 14:53:17 2010
+++ src/libexec/httpd/bozohttpd.c	Sat May 15 06:48:27 2010
@@ -1,6 +1,6 @@
-/*	$NetBSD: bozohttpd.c,v 1.18 2010/05/10 14:53:17 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.19 2010/05/15 06:48:27 mrg Exp $	*/
 
-/*	$eterna: bozohttpd.c,v 1.168 2010/05/10 14:49:19 mrg Exp $	*/
+/*	$eterna: bozohttpd.c,v 1.169 2010/05/13 04:17:58 mrg Exp $	*/
 
 /*
  * Copyright (c) 1997-2010 Matthew R. Green
@@ -109,7 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20100510"
+#define SERVER_SOFTWARE		"bozohttpd/20100512"
 #endif
 #ifndef DIRECT_ACCESS_FILE
 #define DIRECT_ACCESS_FILE	".bzdirect"

Index: src/libexec/httpd/ssl-bozo.c
diff -u src/libexec/httpd/ssl-bozo.c:1.7 src/libexec/httpd/ssl-bozo.c:1.8
--- src/libexec/httpd/ssl-bozo.c:1.7	Mon May 10 03:37:45 2010
+++ src/libexec/httpd/ssl-bozo.c	Sat May 15 06:48:27 2010
@@ -1,6 +1,6 @@
-/*	$NetBSD: ssl-bozo.c,v 1.7 2010/05/10 03:37:45 mrg Exp $	*/
+/*	$NetBSD: ssl-bozo.c,v 1.8 2010/05/15 06:48:27 mrg Exp $	*/
 
-/*	$eterna: ssl-bozo.c,v 1.11 2010/05/10 02:51:28 mrg Exp $	*/
+/*	$eterna: ssl-bozo.c,v 1.13 2010/05/12 12:24:58 rtr Exp $	*/
 
 /*
  * Copyright (c) 1997-2010 Matthew R. Green
@@ -34,6 +34,7 @@
 
 #include <stdarg.h>
 #include <stdio.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include "bozohttpd.h"
@@ -56,20 +57,56 @@
 	char			*privatekey_file;
 } sslinfo_t;
 
+/*
+ * bozo_ssl_err
+ *
+ * bozo_ssl_err works just like bozo_err except in addition to printing
+ * the error provided by the caller at the point of error it pops and
+ * prints all errors from the SSL error queue.
+ */
+static void
+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);
+        va_end(ap);
+
+	unsigned int sslcode = ERR_get_error();
+	do {
+		const char *sslfmt = "SSL Error: %s:%s:%s";
+
+		if (httpd->logstderr || isatty(STDERR_FILENO)) {
+			fprintf(stderr, sslfmt,
+			    ERR_lib_error_string(sslcode),
+			    ERR_func_error_string(sslcode),
+			    ERR_reason_error_string(sslcode));
+		} else {
+			syslog(LOG_ERR, sslfmt,
+			    ERR_lib_error_string(sslcode),
+			    ERR_func_error_string(sslcode),
+			    ERR_reason_error_string(sslcode));
+		}
+	} while (0 != (sslcode = ERR_get_error()));
+	exit(code);
+}
+
 static int
-bozo_ssl_printf(bozohttpd_t *httpd, const char * fmt, ...)
+bozo_ssl_printf(bozohttpd_t *httpd, const char * fmt, va_list ap)
 {
 	sslinfo_t	*sslinfo;
-	va_list		 ap;
 	char		*buf;
 	int		 nbytes;
 
 	sslinfo = httpd->sslinfo;
 	/* XXX we need more elegant/proper handling of SSL_write return */
-	va_start(ap, fmt);
 	if ((nbytes = vasprintf(&buf, fmt, ap)) != -1) 
 		SSL_write(sslinfo->bozossl, buf, nbytes);
-	va_end(ap);
 
 	free(buf);
 
@@ -135,17 +172,26 @@
 	sslinfo->ssl_context = SSL_CTX_new(sslinfo->ssl_method);
 
 	/* XXX we need to learn how to check the SSL stack for more info */
-	if (sslinfo->ssl_context == NULL)
-		bozo_err(httpd, 1, "SSL context initialization failed.");
-
-	SSL_CTX_use_certificate_file(sslinfo->ssl_context,
-		sslinfo->certificate_file, SSL_FILETYPE_PEM);
-	SSL_CTX_use_PrivateKey_file(sslinfo->ssl_context,
-		sslinfo->privatekey_file, SSL_FILETYPE_PEM);
+	if (NULL == sslinfo->ssl_context)
+		bozo_ssl_err(httpd, EXIT_FAILURE,
+		    "SSL context creation failed");
+
+	if (1 != SSL_CTX_use_certificate_file(sslinfo->ssl_context,
+	    sslinfo->certificate_file, SSL_FILETYPE_PEM))
+		bozo_ssl_err(httpd, EXIT_FAILURE,
+		    "Unable to use certificate file '%s'",
+		    sslinfo->certificate_file);
+
+	if (1 != SSL_CTX_use_PrivateKey_file(sslinfo->ssl_context,
+	    sslinfo->privatekey_file, SSL_FILETYPE_PEM))
+		bozo_ssl_err(httpd, EXIT_FAILURE,
+		    "Unable to use private key file '%s'",
+		    sslinfo->privatekey_file);
 
 	/* check consistency of key vs certificate */
 	if (!SSL_CTX_check_private_key(sslinfo->ssl_context))
-		bozo_err(httpd, 1, "check private key failed");
+		bozo_ssl_err(httpd, EXIT_FAILURE,
+		    "Check private key failed");
 }
 
 void

Reply via email to