Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 321135 - www-apps/trac: runs if called manually; init.d script crashes
Summary: www-apps/trac: runs if called manually; init.d script crashes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Dirkjan Ochtman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-23 02:22 UTC by Dusten Sobotta
Modified: 2012-02-12 12:06 UTC (History)
5 users (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 Dusten Sobotta 2010-05-23 02:22:37 UTC
I realize there has been many issues with the init.d script for tracd for some time.   (mostly involving pidfiles; I'm not sure if that's the problem here or not..  For reference here is one of the possibly related posts: http://bugs.gentoo.org/215127 )

After fixing the (hardcoded?!?) paths for parent dir and egg cache, the init.d script fails while attempting to run tracd.

~ # /etc/init.d/tracd start
* Caching service dependencies ...               [ ok ]
* Starting tracd ...                             [ !! ]

/var/log/messages only reveals:
rc-scripts: WARNING:   tracd has not yet been started.



Not sure what's going wrong here.  tracd runs fine if I call it manually.

Reproducible: Always

Steps to Reproduce:
Comment 1 Anthony Basile gentoo-dev 2010-05-23 10:56:30 UTC
Its not clear this is a hardened issue.  Can you post your emerge --info.
Comment 2 Dusten Sobotta 2010-05-23 17:36:40 UTC
li15-235 ~ # emerge --info
Portage 2.1.8.3 (hardened/linux/x86/10.0, gcc-4.1.2, glibc-2.10.1-r1, 2.6.18.8-linode19 i686)
=================================================================
System uname: Linux-2.6.18.8-linode19-i686-Intel-R-_Xeon-R-_CPU_5130_@_2.00GHz-with-gentoo-1.12.13
Timestamp of tree: Sat, 22 May 2010 22:00:19 +0000
app-shells/bash:     4.0_p37
dev-lang/python:     2.4.3-r4, 2.5.2-r7, 2.6.4-r1
dev-python/pycrypto: 2.1.0_beta1
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.13, 2.65
sys-devel/automake:  1.7.9-r1, 1.10.3, 1.11.1
sys-devel/binutils:  2.18-r3
sys-devel/gcc:       4.1.2, 4.3.4
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=i686 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LDFLAGS="-Wl,-O1"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="apache2 berkdb bzip2 cli cracklib crypt cxx dri gdbm hardened hash iconv ithreads modules mudflap ncurses nptl nptlonly openmp pam pcre perl php pic pppd python readline reflection session spl ssl sysfs tcpd threads tokenizer urandom x86 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1    emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m      maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="php access auth auth_dbm auth_anon auth_digest alias file-cache echo charset-lite cache disk-cache mem-cache ext-filter case_filter case-filter-in deflate mime-magic cern-meta expires headers usertrack unique-id proxy proxy-connect proxy-ftp proxy-http info include cgi cgid dav dav_fs dav_lock vhost-alias speling rewrite log_config logio env setenvif mime status autoindex asis negotiation dir imap actions userdir so filter authz_host authn_file authz_user" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 intel       mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage      siliconmotion sis sisusb tdfx tga trident tseng v4l vesa via vmware    voodoo" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 3 Dusten Sobotta 2010-05-23 21:36:03 UTC
====UPDATE====

After screwing around with the init.d script some more, as well as starting tracd manually, I discovered that ports were being eaten (Python was complaining) with each failed init.d script attempt.  (IE the -first- time I attempted to run tracd from the init.d script)  This may have been causing a lot of the failed attempts up until this point.


-HOWEVER-

I discovered that despite not being a solution, the following works:

#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/www-apps/trac/files/tracd.initd.2,v 1.1 2008/09/10 07:50:30 wrobel Exp $

depend() {
        need net
}

start() {
        ebegin "Starting tracd"
        # tracd fails to create pidfile if started as non-root user, thus we are asking
        # s-s-d to do that. To have correct pid we avoid -d option of tracd and use
        # --background option of s-s-d.
        start-stop-daemon --start --quiet \
                --pidfile=/var/run/tracd.pid --make-pidfile \
                --chuid ${TRACD_USER:-apache}:${TRACD_GROUP:-apache} \
                --env PYTHON_EGG_CACHE="/var/www/trac/egg-cache" \
                --exec /usr/bin/python /usr/bin/tracd -- -p ${TRACD_PORT:-8097} \
                ${TRACD_OPTS:---env-parent-dir /var/www/trac/} \
        eend $?
}

stop() {
        ebegin "Stopping tracd"
        start-stop-daemon --stop --quiet --pidfile /var/run/tracd.pid
        eend $?
}



Specifically, the exclusion of the --background parameter. For some reason using --background crashes tracd immediately.  Does this also have something to do with the pidfiles, or is the start-stop-daemon incompatible with tracd somehow?


Note:  I've killed all zombie processes, and tried running with the --background option; that didn't work.  Neither did restarting the machine.  Simply removing --background allows the process to run.
Comment 4 nicolas fischer 2010-10-13 12:35:36 UTC
having the same problem.
Something I don't understand:
I put "echo" infront of "start-stop-daemon" in the init-script, started it and copy-pasted the start-stop-daemon call into bash. It works!

why?

Comment 5 Sr. Cv. 2010-10-22 20:16:56 UTC
(In reply to comment #4)
> having the same problem.
> Something I don't understand:
> I put "echo" infront of "start-stop-daemon" in the init-script, started it and
> copy-pasted the start-stop-daemon call into bash. It works!

Same thing here.

And this is not hardened issue.
Comment 6 Sr. Cv. 2010-10-23 15:19:56 UTC
OK, I solved it for myself: removed /usr/bin/python from the startup command:

--- /etc/init.d/tracd.orig      2010-10-23 17:10:27.000000000 +0200
+++ /etc/init.d/tracd   2010-10-23 17:10:37.000000000 +0200
@@ -15,7 +15,7 @@
        start-stop-daemon --start --chuid ${TRACD_USER:-tracd}:${TRACD_GROUP:-tracd} \
                 --pidfile /var/run/tracd.pid --make-pidfile --background \
                --env PYTHON_EGG_CACHE="/var/lib/trac/egg-cache" \
-               --exec /usr/bin/python -- /usr/bin/tracd \
+               --exec /usr/bin/tracd -- \
                -p ${TRACD_PORT:-8000} ${TRACD_OPTS:---env-parent-dir /var/lib/trac/}
        eend $?
 }

It works for me. Are there any indications against such solution?
Comment 7 Raman Ng 2010-11-23 09:34:52 UTC
Same problem here.  Used the exact same start-stop-daemon command in shell and start tracd successfully. 
Comment 8 Dmitry Grigoriev 2011-01-06 08:21:51 UTC
I confirm, standard desktop KDE profile, amd64. Patch from comment #6 works.
Comment 9 Anthony Basile gentoo-dev 2011-04-04 21:02:16 UTC
This is not a hardened issue.  I'm going to reassign it to the maintainer and cc the herd.  The fix in comment 6 looks okay and I suspect it has something to do with how "/usr/bin/python -- /usr/bin/tracd" is mangled when passed to --exec.

Dirkjan: are you okay with this fix?
Comment 10 Dirkjan Ochtman (RETIRED) gentoo-dev 2012-02-12 12:06:30 UTC
This has been fixed in the tree for a while; closing.