]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/git_stderr_output_causes_problems.mdwn
884f311548ce51f4782838f93a23bd2e90220071
[ikiwiki.git] / doc / bugs / git_stderr_output_causes_problems.mdwn
1 I've just been getting ikiwiki running on a hosted server.  The server is wrapping all cgi scripts to 'harden' them.  Unfortunately, that script is sensitive to what a cgi script outputs on stderr.
2
3 Ikiwiki's git handling is sending a bunch of output to stderr.  The following patch closes stderr in the child process that ikiwiki forks to run git.  This allows me to use ikiwiki on this hosted server.  (patch inline - check source to get it)
4
5     diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm
6     index 425536f..5734bb2 100644
7     --- a/IkiWiki/Rcs/git.pm
8     +++ b/IkiWiki/Rcs/git.pm
9     @@ -24,6 +24,7 @@ sub _safe_git (&@) { #{{{
10             if (!$pid) {
11                     # In child.
12                     # Git commands want to be in wc.
13     +               open STDERR, '>/dev/null';
14                     chdir $config{srcdir}
15                         or error("Cannot chdir to $config{srcdir}: $!");
16                     exec @cmdline or error("Cannot exec '@cmdline': $!");
17
18 > This sounds like rather counter-productive "hardening" (making life harder
19 > for real users without any security improvement that I can think of),
20 > but if you have to suppress standard error of the CGI,
21 > can't you just replace ikiwiki.cgi with this...
22 >
23 >     #!/bin/sh
24 >     exec /some/where/else/ikiwiki.cgi "$@" 2>/dev/null
25 >
26 > or (if you're constrained to Perl) this?
27 >
28 >     #!/usr/bin/perl
29 >     open STDERR, '>/dev/null';
30 >     exec ("/some/where/else/ikiwiki.cgi", @ARGV);
31 >
32 > (Also indented all the lines of your patch so markdown won't eat it :-) )
33 > --[[smcv]]
34
35 > Right, I don't like throwing stderr away because stderr is supposed to be
36 > logged to error.log for a reason: To allow debugging problems.
37 > It's unfortunate that git [abuses atderr](http://bugs.debian.org/447395),
38 > outputting non-errors to it. That doesn't mean that git might not also
39 > output actual error messages there. --[[Joey]]