Project

General

Profile

Bug #222

ssi virtual include uses wrong path

Added by Anonymous over 11 years ago. Updated 11 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_ssi
Target version:
Start date:
Due date:
% Done:

100%

Missing in 1.5.x:

Description

I'm trying to execute something like <!--#include virtual="cgi/counter.cgi" --> in user home directory and lighttpd instead of referering to user's home directory eg. /home/user/www/cgi/counter.cgi it always refers to server document root (/var/www/html) eg.


2005-08-23 19:12:48: (mod_ssi.c.578) ssi: stating failed /var/www/html/~user/cgi/counter.cgi No such file or directory

-- gringo at slonko d0t net

lighttpd-mod-ssi-basic-tests.patch View - Testcases for common include statements (2.52 KB) conny, 2006-02-10 14:07

Associated revisions

Revision ede4d179 (diff)
Added by gstrauss 11 months ago

[mod_ssi] include relative to alias,userdir (fixes #222)

adjust paths relative to changes made by mod_alias and mod_userdir

Note: this still works only for direct file inclusion.
lighttpd mod_ssi does not perform an "internal subrequest" for the
virtual path, so things like virtual include of CGI are not supported

x-ref:
"ssi virtual include uses wrong path"
https://redmine.lighttpd.net/issues/222

History

#1 Updated by conny about 11 years ago

"include virtual" works for me, but then instead scripts aren't executed!?

#2 Updated by conny about 11 years ago

So the

#3 Updated by Anonymous about 11 years ago

In general virtual works, but not in combination with mod_userdir (that was my problem). I cannot make lighttpd to execute certain executable from user's home directory. I haven't tried the latest lighttpd from svn repository, but I believe it still does not work..

Some explanation to initial bug report:
/var/www/html - server document root
/home/user/www - user's homepage root
/home/user/www/cgi/counter.cgi - CGI I want to execute
/home/user/www/index.html - SHTML file containing '<!--#include virtual="cgi/counter.cgi" -->'

Normally I would expect that /home/user/www/cgi/counter.cgi would be executed by instead lighttpd looks for '/var/www/html/~user/cgi/counter.cgi' which isn't what I was looking for..

-- gringo

#4 Updated by Anonymous over 10 years ago

=)

-- Hillary

#5 Updated by stbuehler over 8 years ago

  • Target version changed from 1.4.20 to 1.4.21

#6 Updated by icy about 8 years ago

  • Target version changed from 1.4.21 to 1.4.22
  • Patch available set to No

#7 Updated by stbuehler about 8 years ago

  • Target version changed from 1.4.22 to 1.4.23

#8 Updated by stbuehler almost 8 years ago

  • Assignee deleted (jan)
  • Target version changed from 1.4.23 to 1.4.x

mod_ssi has low priority, especially if there is no patch.

#9 Updated by gstrauss about 1 year ago

untested, but would using con->physical.basedir instead of con->physical.doc_root work?

diff --git a/src/mod_ssi.c b/src/mod_ssi.c
index f3f255b..b5fe3b5 100644
--- a/src/mod_ssi.c
+++ b/src/mod_ssi.c
@@ -537,7 +537,7 @@ static int process_ssi_stmt(server *srv, connection *con, plugin_data *p, const

                        /* we have an uri */

-                       buffer_copy_buffer(p->stat_fn, con->physical.doc_root);
+                       buffer_copy_buffer(p->stat_fn, con->physical.basedir);
                        buffer_append_string_buffer(p->stat_fn, srv->tmp_buf);
                }

#10 Updated by gstrauss about 1 year ago

Please note that other than for limited error handling, lighttpd does not have the concept of "internal subrequest" as Apache does. Adding such a feature is possible, but probably a substantial amount of work. SSI includes in lighttpd are currently limited to direct inclusion of file, not the output of processing the path through an "internal subrequest", so no "#include virtual" executing a CGI. SSI in lighttpd does not support "#exec cgi", either, though "#exec cmd" is supported. I mention this because one of the tests you suggested in your attached patch expect #include virtual=cgi.pl to work. (BTW, thanks for writing some tests!)

It should be simpler to patch lighttpd to support the common case of "#include virtual" of a file relative to a userdir from within that userdir. Alas, the patch I posted in a prior comment (above) is too simple. It does not remove /~username from paths. I have a slightly larger patch, but still localized in mod_ssi.c, which does so. If there is interest in this small extension to lighttpd SSI, I'll test and post the patch. However, it seems as if there might be a desire for a much more featureful mod_ssi.c, more than what a small patch can provide for this issue ticket.

#11 Updated by gstrauss 12 months ago

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

I am submitting a patch to adjust paths relative to changes made by mod_alias and mod_userdir.
This addresses the bug described by the ticket title "ssi virtual include uses wrong path"

Note: this still works only for direct file inclusion using #include virtual="..."
lighttpd mod_ssi does not perform an "internal subrequest" for the
virtual path, so things like virtual include of CGI are not supported

If interested in more featureful #include virtual functionality, please file a new issue as a feature request, not as a bug.

#12 Updated by gstrauss 11 months ago

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

Also available in: Atom