From b4a4afdaf7f873a3aa08f98e248f93542dc72161 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 26 Mar 2016 11:24:15 +0000 Subject: [PATCH] [config] warn if server.upload-dirs has non-existent dirs (fixes #2508) Warn at startup if any dirs in server.upload-dirs do not exist. Take server.chroot into account, if set. From: Glenn Strauss git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3125 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/configfile.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/NEWS b/NEWS index dc5020f5..46777200 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ NEWS * [buffer] refactor buffer_path_simplify (fixes #2560) * validate return values from strtol, strtoul (fixes #2564) * [mod_ssi] Add SSI vars SCRIPT_{URI,URL} and REQUEST_SCHEME (fixes #2721) + * [config] warn if server.upload-dirs has non-existent dirs (fixes #2508) - 1.4.39 - 2016-01-02 * [core] fix memset_s call (fixes #2698) diff --git a/src/configfile.c b/src/configfile.c index 170d5b6f..758b5da0 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -1288,6 +1288,31 @@ int config_set_defaults(server *srv) { } } + if (srv->srvconf.upload_tempdirs->used) { + buffer * const b = srv->tmp_buf; + size_t len; + if (!buffer_string_is_empty(srv->srvconf.changeroot)) { + buffer_copy_buffer(b, srv->srvconf.changeroot); + buffer_append_slash(b); + } else { + buffer_reset(b); + } + len = buffer_string_length(b); + + for (i = 0; i < srv->srvconf.upload_tempdirs->used; ++i) { + const data_string * const ds = (data_string *)srv->srvconf.upload_tempdirs->data[i]; + buffer_string_set_length(b, len); /*(truncate)*/ + buffer_append_string_buffer(b, ds->value); + if (-1 == stat(b->ptr, &st1)) { + log_error_write(srv, __FILE__, __LINE__, "sb", + "server.upload-dirs doesn't exist:", b); + } else if (!S_ISDIR(st1.st_mode)) { + log_error_write(srv, __FILE__, __LINE__, "sb", + "server.upload-dirs isn't a directory:", b); + } + } + } + if (buffer_string_is_empty(s->document_root)) { log_error_write(srv, __FILE__, __LINE__, "s", "a default document-root has to be set");