Project

General

Profile

Bug #2910

include_shell behavior change in 1.4.50

Added by glen about 2 months ago. Updated about 2 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
2018-09-18
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

2018-09-17 00:22:54: (configfile.c.1451) pclose "for f in vhosts.d/*.conf ; do [ -f "$f" ] && echo "include \"$f\"" ; done"failed: Success
2018-09-17 00:22:54: (configfile.c.1289) source: /etc/lighttpd/lighttpd.conf line: 188 pos: 1 parser failed somehow near here: (EOL)

such code block started to yield "failed: Success" error and breaking config parsing and startup.

the fix is simple: add exit 0, however "failed: Success" typically means there's strerror(errno) call when errno == 0

see full mail thread here:
http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2018-September/025604.html

Associated revisions

Revision 2b40854a (diff)
Added by gstrauss about 2 months ago

[core] fix include_shell on inline shell commands (fixes #2910)

regression in lighttpd 1.4.50

x-ref:
"include_shell behavior change in 1.4.50"
https://redmine.lighttpd.net/issues/2910

History

#1

Updated by gstrauss about 2 months ago

  • Category set to core

probably a46bc4f5
first hunch is that lighttpd should wrap the command in sh -c before calling popen.

#2

Updated by gstrauss about 2 months ago

I am not a huge fan of inline shell scripting. include_shell should be used to run a script. Or, you could more simply include "vhosts.d/*.conf" and avoid directories ending ".conf" under vhost.d/

Here is a quick patch, which should work for your case, but does not cover the case where the include_shell cmd contains single-quote itself. I'll work on a more-inclusive patch this weekend.

-- a/src/configfile.c
+++ b/src/configfile.c
@@ -1411,6 +1411,8 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
        buffer *source;
        buffer *out = srv->tmp_buf;
        char *oldpwd;
+       const char *shell = getenv("SHELL");
+       if (NULL == shell) shell = "/bin/sh";

        if (NULL == (oldpwd = getCWD())) {
                log_error_write(srv, __FILE__, __LINE__, "s",
@@ -1428,8 +1430,12 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
        }

        source = buffer_init_string(cmd);
+       buffer_copy_string_len(out, shell, strlen(shell));
+       buffer_append_string_len(out, CONST_STR_LEN(" -c '"));
+       buffer_append_string_buffer(out, source);
+       buffer_append_string_len(out, CONST_STR_LEN("'"));

-       fp = popen(cmd, "r");
+       fp = popen(out->ptr, "r");
        if (NULL == fp) {
                log_error_write(srv, __FILE__, __LINE__, "SSss",
                                "popen \"", cmd, "\"failed:", strerror(errno));

#3

Updated by gstrauss about 2 months ago

  • Status changed from New to Patch Pending
  • Target version changed from 1.4.x to 1.4.51

See patch at lighttpd.net git on branch personal/gstrauss/master

#4

Updated by gstrauss about 2 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom