Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 110804 - thttpd doesn't changing to proper dir before chrooting as expected, using the top of the filesystem as startup-dir, exposing the entire machine.
Summary: thttpd doesn't changing to proper dir before chrooting as expected, using the...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: www-servers Herd (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 117056
  Show dependency tree
 
Reported: 2005-10-29 10:28 UTC by revertex
Modified: 2005-12-29 17:11 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description revertex 2005-10-29 10:28:32 UTC
thttpd daemon doesn't change to startup-dir pointed in /etc/conf.d/thttpd,
ignoring the variable THTTPD_DOCROOT="/var/www/localhost".
Actually it uses the root tree as startup-dir.
It seems that the init script cannot read the THTTPD_DOCROOT variable properly,
dunno why.


Reproducible: Always
Steps to Reproduce:
1.emerge thttpd
2.start daemon
3.open webpage

Actual Results:  
all my "/" tree is showed in "index of" page.

Expected Results:  
show html file in /var/www/localhost, as pointed in /etc/conf.d/thttpd.

even unmerging thttpd, removing all related config files in /etc and reemerging
thttpd the result is the same.
-------------------------------
/etc/conf.d/thttpd
THTTPD_DOCROOT="/var/www/localhost"
THTTPD_OPTS="-p 8080 -u nobody -r -i /var/run/thttpd.pid -l /var/log/thttpd.log"
-------------------------------
/etc/init.d/thttpd
depend() {
        need net
}
start() {
        ebegin "Starting thttpd"
        if [ ! -d "$THTTPD_DOCROOT" ]; then
                eend 1 "THTTPD_DOCROOT not set correctly in /etc/conf.d/thttpd"
                exit 1
        fi
        cd $THTTPD_DOCROOT
        if [ $? -ne 0 ]; then
                eend $? "ERROR: cannot change to docroot \"$THTTPD_DOCROOT\""
        fi
        start-stop-daemon --quiet --start --startas /usr/sbin/thttpd \
                --pidfile /var/run/thttpd.pid -- ${THTTPD_OPTS}
        eend $?
}
stop() {
        local rc
        ebegin "Stopping thttpd"
        start-stop-daemon --quiet --stop --pidfile /var/run/thttpd.pid
        rc=$?
        rm -f /var/run/thttpd.pid
        eend $rc
}
-------------------------------
Comment 1 Tamas Hauer 2005-12-20 01:42:31 UTC
To me it appears that this is caused by a change in sys-apps/baselayout

# start-stop-daemon --help
[...]
-C|--chdir <directory>        Change to <directory>(default is /)
[...]

Thus the initscript chdirs to $THTTPD_DOCROOT but then start-stop-daemon ignores the CWD.  Two possible solutions:
1. In /etc/init.d/thttpd use:  start-stop-daemon -C $THTTPD_DOCROOT
or
2. In /etc/conf.d/thttpd append: THTTPD_OPTS="... -d $THTTPD_DOCROOT"
tamas
Comment 2 revertex 2005-12-29 17:11:03 UTC
Thank's tamas, dunno how, but i managed to fix it removing all thttpd related files, doing a emerge -u world then reemerging thttpd.
I'm suspect that's nothing about thttpd, but something broken with enviroment variables.
Anyway thank's for your time.