]> sipb.mit.edu Git - ikiwiki.git/blob - doc/patchqueue/various_fixes.mdwn
fix mime type
[ikiwiki.git] / doc / patchqueue / various_fixes.mdwn
1 Sorry if you don't appreciate me lumping all of these patches together.
2
3 These are various fixes I had to make when installing Ikiwiki. Some are
4 due it being a non-Debian system, the others are actual bugs.
5
6     --- upstream/IkiWiki/Rcs/svn.pm 2006-09-16 01:11:55.000000000 +0100
7     +++ main/IkiWiki/Rcs/svn.pm     2006-09-16 01:12:50.000000000 +0100
8     @@ -34,7 +34,7 @@
9             my $field=shift;
10             my $file=shift;
11     
12     -       my $info=`LANG=C svn info $file`;
13     +       my $info=`svn info $file`;
14             my ($ret)=$info=~/^$field: (.*)$/m;
15             return $ret;
16      } #}}}
17     @@ -140,7 +140,7 @@
18                     if $svn_version =~ /\d\.(\d)\.\d/ && $1 >= 2;
19     
20             my $svn_url=svn_info("URL", $config{srcdir});
21     -       my $xml = XMLin(scalar `svn $svn_limit --xml -v log '$svn_url'`,
22     +       my $xml = XMLin(scalar `svn $svn_limit --xml -v log '$svn_url' --config-dir /tmp`,
23                     ForceArray => [ 'logentry', 'path' ],
24                     GroupTags => { paths => 'path' },
25                     KeyAttr => { path => 'content' },
26
27 The first hunk of this patch is strange. It just failed to work with this
28 in place, and it took me a long time to figure it out. I realise what you
29 are trying to do, and it still works here as I use a similar LANG anyway.
30
31 For reference svn version 1.3.1 (r19032), my $LANG=en_GB.utf8, but I'm not 
32 sure what the CGI was running under. 
33
34 > That's strange. Is the problem to do with setting LANG=C or to do
35 > with the way it's set and exported on the same line as the svn info call?
36 > Can you reproduce the problem running svn info outside of ikiwiki?
37 > --[[Joey]]
38
39 >> I've now managed to reproduce the problem. I'll try and give some more information.
40 >> When going to the Recent Changes link I get 
41
42     [Sat Sep 16 15:16:08 2006] [error] [client xxxx] svn: Can't check path '/home/jw2328/.subversion': Permission denied, referer: http://xxxxx/test/sandbox.html
43     [Sat Sep 16 15:16:08 2006] [error] [client xxxx] Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.3/IkiWiki/Rcs/svn.pm line 145., referer: http://xxxx/test/sandbox.html
44     [Sat Sep 16 15:16:08 2006] [error] [client xxxxx] svn: Can't check path '/home/jw2328/.subversion': Permission denied, referer: http://xxxx/test/sandbox.html
45     [Sat Sep 16 15:16:09 2006] [error] [client xxxx] File does not exist:  at /usr/lib/perl5/site_perl/5.8.3/IkiWiki/Rcs/svn.pm line 145, referer: http://xxxx/test/sandbox.html
46     [Sat Sep 16 15:16:09 2006] [error] [client xxxx] Premature end of script headers: ikitest, referer: http://xxxx/test/sandbox.html
47
48 >> which the $svn_url is causing the uninitialised value, due to the 
49 >> LANG=C it seems, as if I remove it it goes away.
50 >> The file does not exist is due to the unreadable .subversion.
51 >> echoing the LANG before it is set shows that the variable is normally 
52 >> empty for the user that is running it.
53
54 The second removes problems with cannot access /home/$user/.svnsomething in
55 the logs. I think this problem was also fatal (I should have reported these
56 sooner). 
57
58 I can try and debug these problems if you could suggest some way to do so, 
59 but I am probably losing the server in a couple of days, so I can't be of too
60 much help I'm afraid.
61
62 > I imagine that passing --config-dir /tmp would be either insecure or 
63 > would limit ikiwiki use to one user per machine. 
64 > `--config-dir /etc/subversion` might be better, though still a hack,
65 > since a user's real ~/.subversion might be needed to access some repos.
66
67 > Maybe I didn't notice this problem since I have a ~/.subversion
68 > everywhere that I've used ikiwiki. Hmm, no, I don't reproduce it, svn
69 > happily recreated the directory during an ikiwiki run after I moved it
70 > out of the way here. Maybe an issue with old versions of svn? Although
71 > AFIACR, svn has auto-created ~/.subversion for years.
72
73 > What's the error message? --[[Joey]]
74
75 >> `svn: Can't check path '/home/jw2328/.subversion': Permission denied,`
76 >> where jw2328 is my usual user. 
77 >> I have restrictive permissions of 0700 on home dirs on the server,
78 >> and the CGI is running as uid apache, euid root. (Not my setup anymore).
79 >> The way I had it set up, was jw2328 owning thesource dir, and the svn repo,
80 >> with g+sw on them both. I ran sudo ikiwiki --setup though, as I was reluctant
81 >> to adjust permissions on my cgi-dir. This seems to be the root of the 
82 >> problem.
83
84 ----
85
86     --- IkiWiki/Plugin/search.pm
87     +++ IkiWiki/Plugin/search.pm
88     @@ -99,7 +99,7 @@
89             close TEMPLATE;
90             $cgi="$estdir/".IkiWiki::basename($config{cgiurl});
91             unlink($cgi);
92     -       symlink("/usr/lib/estraier/estseek.cgi", $cgi) ||
93     +       symlink("/usr/local/libexec/estseek.cgi", $cgi) ||
94                     error("symlink $cgi: $!");
95      } # }}}
96
97 obviously I'm not asking you to include this patch, but it would
98 be good if this sort of thing was configurable (at build time?). I can
99 have a go if you like, but I'm not sure what would be acceptable to
100 you.
101
102 > This should be made configurable via an option in %IkiWiki::config,
103 > the search plugin could register a getopt hook to handle it. --[[Joey]]
104
105 >> Like this? <http://jameswestby.net/scratch/estseek.diff>
106
107 ----
108
109     --- IkiWiki.pm
110     +++ IkiWiki.pm
111     @@ -734,7 +734,18 @@
112             my $page=shift;
113             my $spec=shift;
114     
115     -       return eval pagespec_translate($spec);
116     +        my $pagespec = pagespec_translate($spec);
117     +
118     +        my $newpagespec;
119     +
120     +       local($1);
121     +       if ($pagespec =~ /(.*)/) {
122     +               $newpagespec = $1;
123     +       } else {
124     +               die "oh";
125     +       }
126     +
127     +       return eval $newpagespec;
128      } #}}}
129     
130      sub match_glob ($$) { #{{{
131
132 This works around a silly, but extremely annoying, taint bug in older
133 versions of perl. I'm not sure of the details, but it means that either
134 values become tainted from nowhere, or they don't get untainted possibly.
135 This also affects backports to sarge. `"oh"` is not going to be very 
136 informative if that code path is ever taken, but I hope that it never is.
137
138 > You're not the first person to report a problem here with older versions 
139 > of perl and pagespec tainting. I suspect that this would work around it:
140         return eval possibly_foolish_untaint(pagespec_translate($spec));
141 > I'm _very_ uncomfortable putting that in the shipping version of ikiwiki,
142 > because pagespecs are potentially _insanely_ dangerous, given how they're
143 > evaled and all. The tainting is the only sanity check there is that
144 > `pagespec_translate` manages to clean up any possibly harmful perl code
145 > in a pagespec. It's good to have belt and suspenders here. 
146
147 > For all I know, older versions of perl are keeping it tainted because
148 > `pagespec_translate` is somehow broken under old versions of perl and is
149 > in fact not fully untainting the pagespec. Ok, probably not, it's more
150 > likely that some of the regexps in there don't manage to clear the taint
151 > flag with old versions of perl, while still doing a perfectly ok job of
152 > sanitising the pagespec.
153
154 > I suppose that the version of perl ($^V) could be checked and the untaint 
155 > only be called for the old version. Though it seems it would be better
156 > to try to debug this some first. Maybe instrumenting `pagespec_translate`
157 > with calls to Scalar::Utils's tainted() function and seeing which parts
158 > of pagespecs arn't getting untainted would be a good start.
159
160 > --[[Joey]]
161
162 >> It seems like it is always the (with instrumentation)
163      
164      elsif ($word =~ /^(link|backlink|created_before|created_after|creation_month|creation_year|creation_day)\((.+)\)$/) {
165           warn("\$1 tainted=".tainted($1).", \$2 tainted=".tainted($2)." \$code tainted=".tainted($code));
166           $code.=" match_$1(\$page, ".safequote($2).")";
167           warn("\$1 tainted=".tainted($1).", \$2 tainted=".tainted($2)." \$code tainted=".tainted($code));
168           warn("safequote tainted=".tainted(safequote($2)));
169      }
170
171 >> bit that causes it. With the following trace:
172
173      $1 tainted=0, $2 tainted=0 $code tainted=0 at IkiWiki.pm line 718.
174      $1 tainted=0, $2 tainted=0 $code tainted=1 at IkiWiki.pm line 720.
175      safequote tainted=0 at IkiWiki.pm line 721.
176
177 >> which shows that `$code` appears to become tainted from nowhere.
178 >> <http://mail-archives.apache.org/mod_mbox/spamassassin-dev/200509.mbox/%3C3838.431C7D9B.5F152B8F.dev@spamassassin.apache.org%3E>
179 >> is what pointed me to find the problem/workaround.
180
181       
182
183 ----
184
185 As for backports there is a problem with the sarge version of libcgi-session-perl
186 and my sslcookie patch (complaints about a missing include file auto/CGI/Session/cookie.al IIRC).
187 This file does not and has not ever existed, but it appears to be fixed in 
188 the backport of libcgi-session-perl that I did. That puts the dependency
189 required at somewhere between 3.95-2 and 4.14-1. This could then be added
190 to debian/control. It would mean one more package to backport, but stops the
191 bug if anyone actually uses my sslcookie option except me.
192
193 > May as well, done --[[Joey]]
194
195 >> Thanks.
196
197 As for backports I managed with 
198
199  * ikiwiki_1.26
200  * libcgi-formbuilder-perl_3.03.01-1
201  * libcgi-session-perl_4.14-1
202
203 backported to sarge, with bpo in sources.list. This only covers Depends: though,
204 for instance hyperestraier needs to be backported, which I haven't got
205 round to yet as there is a chain to do.
206