Project

General

Profile

Actions

Bug #2910

closed

include_shell behavior change in 1.4.50

Added by glen over 6 years ago. Updated over 6 years ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
ASK QUESTIONS IN Forums:

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

Actions #1

Updated by gstrauss over 6 years ago

  • Category set to core

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

Actions #2

Updated by gstrauss over 6 years 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));

Actions #3

Updated by gstrauss over 6 years 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

Actions #4

Updated by gstrauss over 6 years ago

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

Also available in: Atom