Project

General

Profile

Bug #2460

(mod_cgi.c.1041) chdir failed: no such file or directory index.php

Added by jeisom about 5 years ago. Updated almost 2 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_cgi
Target version:
Start date:
2012-11-16
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:
No

Description

I am using php with pdirl and am getting
(mod_cgi.c.1041) chdir failed: no such file or directory index.php
it appears to be trying to chdir into a file. This is on an embedded system.

pdirl can be found here.
http://pdirl.newroots.de/

lighttpd.conf (10.7 KB) lighttpd.conf jeisom, 2012-11-16 19:36
cgi.conf (959 Bytes) cgi.conf jeisom, 2012-11-16 19:36

Associated revisions

Revision 3077 (diff)
Added by stbuehler almost 2 years ago

[mod_cgi] edge case chdir "/" when docroot "/" (fixes #2460)

From: Glenn Strauss <>

Revision 665cc39b (diff)
Added by gstrauss almost 2 years ago

[mod_cgi] edge case chdir "/" when docroot "/" (fixes #2460)

From: Glenn Strauss <>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3077 152afb58-edef-0310-8abb-c4023f1b3aa9

History

#1

Updated by stbuehler about 5 years ago

  • Status changed from New to Need Feedback

You mapped the request to the filename "index.php/$something"; I have no idea how you did that (usually all pathnames are absolute, i.e. should start with "/").

Try

debug.log_request_handling = "enabled" 

and check DebugVariables

#2

Updated by gstrauss almost 2 years ago

The attached lighttpd.conf contains

var.server_root = "/" 

and later
server.document-root = server_root

(This makes more sense if I also mention that the attached lighttpd.conf contains:
server.chroot   = "/usr/local/apache2/webdav/usrfolder/" 

Therefore, the bug in mod_cgi is that it does c = strrchr(path, '/') and, in addition to checking if c is NULL, needs to check if c path. If c path, then chdir("/"), else temporarily set c = '\0' and chdir(path)

Created pull request https://github.com/lighttpd/lighttpd1.4/pull/18 with fix.

As an aside, while not the issue in this ticket, the chroot setting appears to conflict with

server.upload-dirs = ( "/usr/local/apache2/webdav/usrfolder/tmp" )

Within the chroot, server.upload-dirs should probably be
server.upload-dirs = ( "/tmp" )

#3

Updated by stbuehler almost 2 years ago

  • Status changed from Need Feedback to Fixed
  • % Done changed from 0 to 100

Applied in changeset r3077.

#4

Updated by stbuehler almost 2 years ago

  • Target version set to 1.4.40

Also available in: Atom