]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/patchqueue/lib-fixup.mdwn
web commit by http://id.inelegant.org/
[git.ikiwiki.info.git] / doc / patchqueue / lib-fixup.mdwn
1 I'm using Ikiwiki on a box where I don't have root access, so I install all of my Perl modules in `~/lib`. The `ikiwiki.in` script is ran in Taint mode, which means that it ignores the contents of `$ENV{PERL5LIB}`. The result is that the current versions of the pre-requisite modules I've installed in `~/lib` are ignored by `./make`, which uses the outdated, and therefore incompatible versions, from the system-wide `@INC`... ;-)
3 I imagine that there's a clean and elegant solution to this, but the hack I'm currently using is to have `./make` alter `ikiwki.in` before it's run, by inserting `use lib ...` lines for each of the directories in `$ENV{PERL5LIB}`. Again, this is clearly ugly, but it allows me to run `./make`, so I'm submitting it FWIW.
5 > I don't like this patch because it's not expected that an environment
6 > variable will stick around outside the shell that it's set in. It could
7 > lead to suprising behavior if PERL5LIB happened to be set during build,
8 > and it's even possible for it to lead to security issues, imagine if I
9 > accidentially built the debian package of ikiwiki with PERL5LIB set --
10 > then it would be hardcoded to look in /home/joey for libraries, which
11 > someone with a "joey" account elsewhere could use to exploit it.
12 >
13 > You could remove the taint switch locally, it's very unlikely to find
14 > tainting problems that nobody else has noticed. --[[Joey]]
16 >> I completely understand rejecting this patch, but would you accept one to automate the removal of -T as a `make` option, then? I was trying to install Ikiwiki on a very popular
17 >> web host, and the aforementioned issue took quite a while to debug; I imagine many people would have simply given up. -- Ben
19 <pre> 
20 Index: Makefile.PL
21 ===================================================================
22 --- Makefile.PL (revision 2630)
23 +++ Makefile.PL (working copy)
24 @@ -24,6 +24,7 @@
25  )
26  
27  extra_build:
28 +       LANG=C ./lib-fixup.pl ikiwiki.in
29         LANG=C ./ikiwiki.in doc html --templatedir=templates \
30                 --underlaydir=basewiki \
31                 --wikiname="ikiwiki" --verbose --no-rcs \
32 Index: lib-fixup.pl
33 ===================================================================
34 --- lib-fixup.pl        (revision 0)
35 +++ lib-fixup.pl        (revision 0)
36 @@ -0,0 +1,9 @@
37 +#!/usr/bin/perl -i.bak -p
38 +use strict;
39 +use warnings;
40 +my @dirs = $ENV{PERL5LIB} =~ /:/ ? split /:/, $ENV{PERL5LIB} : $ENV{PERL5LIB};
41 +if (@dirs) {
42 +    my $libs = join('', map { " use lib '$_';\n" } @dirs);
43 +    s/(use IkiWiki;)/$libs$1/;
44 +}
45
47 Property changes on: lib-fixup.pl
48 ___________________________________________________________________
49 Name: svn:executable
50    + *
52 </pre>