From f9737e50a6118203398d0c97959af5adced60018 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 3 Dec 2016 21:19:10 -0500 Subject: [PATCH] [mod_fastcgi,mod_scgi] warn if invalid "bin-path" e.g. if /usr/bin/php-cgi does not exist A distribution package might need to be installed: 'php-cli' Fedora package; 'php7.0-cgi' or 'php5-cgi' Debian package --- src/mod_fastcgi.c | 12 ++++++++++++ src/mod_scgi.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index ce47cdae..1e38befd 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -1469,6 +1469,18 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) { /* a local socket + self spawning */ size_t pno; + struct stat st; + size_t nchars = strcspn(host->bin_path->ptr, " \t"); + char c = host->bin_path->ptr[nchars]; + host->bin_path->ptr[nchars] = '\0'; + if (0 == nchars || 0 != stat(host->bin_path->ptr, &st) || !S_ISREG(st.st_mode) || !(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { + host->bin_path->ptr[nchars] = c; + log_error_write(srv, __FILE__, __LINE__, "SSs", + "invalid \"bin-path\" => \"", host->bin_path->ptr, + "\" (check that file exists, is regular file, and is executable by lighttpd)"); + } + host->bin_path->ptr[nchars] = c; + if (s->debug) { log_error_write(srv, __FILE__, __LINE__, "ssbsdsbsd", "--- fastcgi spawning local", diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 9b827c3b..348dd1c6 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -1214,6 +1214,18 @@ SETDEFAULTS_FUNC(mod_scgi_set_defaults) { /* a local socket + self spawning */ size_t pno; + struct stat st; + size_t nchars = strcspn(df->bin_path->ptr, " \t"); + char c = df->bin_path->ptr[nchars]; + df->bin_path->ptr[nchars] = '\0'; + if (0 == nchars || 0 != stat(df->bin_path->ptr, &st) || !S_ISREG(st.st_mode) || !(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { + df->bin_path->ptr[nchars] = c; + log_error_write(srv, __FILE__, __LINE__, "SSs", + "invalid \"bin-path\" => \"", df->bin_path->ptr, + "\" (check that file exists, is regular file, and is executable by lighttpd)"); + } + df->bin_path->ptr[nchars] = c; + /* HACK: just to make sure the adaptive spawing is disabled */ df->min_procs = df->max_procs;