summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2014-11-11 15:54:46 +0000
committerBob Beck <beck@cvs.openbsd.org>2014-11-11 15:54:46 +0000
commita12efea339192716b651734e013df4c0bde36316 (patch)
treefb8cc384f7185dd4b31eb55f4c26e67aac826e02 /usr.sbin
parent468de3bb3a6aeabc3a7f124039f1acf8fd861817 (diff)
Allow the log directory to be configurable in the config file, rather than
fixed as /logs within the chroot. As this httpd is properly privesp'ed this has the nice property of allowing us to put the logs outside the chroot if we want to. ok reyk@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/httpd.c8
-rw-r--r--usr.sbin/httpd/httpd.conf.512
-rw-r--r--usr.sbin/httpd/httpd.h3
-rw-r--r--usr.sbin/httpd/logger.c6
-rw-r--r--usr.sbin/httpd/parse.y10
5 files changed, 28 insertions, 11 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index d8c61d41017..6579e6b347a 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.23 2014/10/22 09:48:03 reyk Exp $ */
+/* $OpenBSD: httpd.c,v 1.24 2014/11/11 15:54:45 beck Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -231,6 +231,12 @@ main(int argc, char *argv[])
for (proc = 0; proc < nitems(procs); proc++)
procs[proc].p_chroot = env->sc_chroot;
+ if (env->sc_logdir == NULL) {
+ if (asprintf(&env->sc_logdir, "%s%s", env->sc_chroot,
+ HTTPD_LOGROOT) == -1)
+ errx(1, "malloc failed");
+ }
+
proc_init(ps, procs, nitems(procs));
setproctitle("parent");
diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5
index 6d267d6a539..8c9269afba5 100644
--- a/usr.sbin/httpd/httpd.conf.5
+++ b/usr.sbin/httpd/httpd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: httpd.conf.5,v 1.34 2014/09/01 12:22:38 jmc Exp $
+.\" $OpenBSD: httpd.conf.5,v 1.35 2014/11/11 15:54:45 beck Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 1 2014 $
+.Dd $Mdocdate: November 11 2014 $
.Dt HTTPD.CONF 5
.Os
.Sh NAME
@@ -109,7 +109,13 @@ This increases the performance and prevents delays when connecting
to a server.
.Xr httpd 8
runs 3 server processes by default.
-.El
+.It Ic logdir Ar directory
+Specifies the full path of the directory in which log files will be written.
+If not specified, it defaults to
+.Pa /logs
+within the
+.Xr chroot 2
+directory.
.Sh SERVERS
The configured web servers.
.Pp
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
index 1b43a2e36f9..5e39fe1b610 100644
--- a/usr.sbin/httpd/httpd.h
+++ b/usr.sbin/httpd/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.62 2014/11/03 18:43:24 bluhm Exp $ */
+/* $OpenBSD: httpd.h,v 1.63 2014/11/11 15:54:45 beck Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -433,6 +433,7 @@ struct httpd {
u_int16_t sc_id;
int sc_paused;
char *sc_chroot;
+ char *sc_logdir;
struct serverlist *sc_servers;
struct mediatypes *sc_mediatypes;
diff --git a/usr.sbin/httpd/logger.c b/usr.sbin/httpd/logger.c
index 8e7784dbb19..94026955c89 100644
--- a/usr.sbin/httpd/logger.c
+++ b/usr.sbin/httpd/logger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logger.c,v 1.6 2014/11/10 14:16:22 beck Exp $ */
+/* $OpenBSD: logger.c,v 1.7 2014/11/11 15:54:45 beck Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -164,8 +164,8 @@ logger_open_priv(struct imsg *imsg)
if ((size_t)snprintf(name, sizeof(name), "/%s", p) >= sizeof(name))
return (-1);
- if ((len = (size_t)snprintf(path, sizeof(path), "%s%s",
- env->sc_chroot, HTTPD_LOGROOT)) >= sizeof(path))
+ if ((len = strlcpy(path, env->sc_logdir, sizeof(path)))
+ >= sizeof(path))
return (-1);
p = path + len;
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index 69f0b4b8de1..cfb60ae7da4 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.40 2014/11/03 18:43:24 bluhm Exp $ */
+/* $OpenBSD: parse.y,v 1.41 2014/11/11 15:54:45 beck Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -129,8 +129,8 @@ typedef struct {
%token ACCESS AUTO BACKLOG BODY BUFFER CERTIFICATE CHROOT CIPHERS COMMON
%token COMBINED CONNECTION DIRECTORY ERR FCGI INDEX IP KEY LISTEN LOCATION
-%token LOG MAXIMUM NO NODELAY ON PORT PREFORK REQUEST REQUESTS ROOT SACK
-%token SERVER SOCKET SSL STYLE SYSLOG TCP TIMEOUT TYPES
+%token LOG LOGDIR MAXIMUM NO NODELAY ON PORT PREFORK REQUEST REQUESTS ROOT
+%token SACK SERVER SOCKET SSL STYLE SYSLOG TCP TIMEOUT TYPES
%token ERROR INCLUDE
%token <v.string> STRING
%token <v.number> NUMBER
@@ -191,6 +191,9 @@ main : PREFORK NUMBER {
| CHROOT STRING {
conf->sc_chroot = $2;
}
+ | LOGDIR STRING {
+ conf->sc_logdir = $2;
+ }
;
server : SERVER STRING {
@@ -871,6 +874,7 @@ lookup(char *s)
{ "listen", LISTEN },
{ "location", LOCATION },
{ "log", LOG },
+ { "logdir", LOGDIR },
{ "max", MAXIMUM },
{ "no", NO },
{ "nodelay", NODELAY },