]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/patchqueue/lib-fixup.mdwn
response
[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 <pre> 
17 Index: Makefile.PL
18 ===================================================================
19 --- Makefile.PL (revision 2630)
20 +++ Makefile.PL (working copy)
21 @@ -24,6 +24,7 @@
22  )
23  
24  extra_build:
25 +       LANG=C ./lib-fixup.pl ikiwiki.in
26         LANG=C ./ikiwiki.in doc html --templatedir=templates \
27                 --underlaydir=basewiki \
28                 --wikiname="ikiwiki" --verbose --no-rcs \
29 Index: lib-fixup.pl
30 ===================================================================
31 --- lib-fixup.pl        (revision 0)
32 +++ lib-fixup.pl        (revision 0)
33 @@ -0,0 +1,9 @@
34 +#!/usr/bin/perl -i.bak -p
35 +use strict;
36 +use warnings;
37 +my @dirs = $ENV{PERL5LIB} =~ /:/ ? split /:/, $ENV{PERL5LIB} : $ENV{PERL5LIB};
38 +if (@dirs) {
39 +    my $libs = join('', map { " use lib '$_';\n" } @dirs);
40 +    s/(use IkiWiki;)/$libs$1/;
41 +}
42
44 Property changes on: lib-fixup.pl
45 ___________________________________________________________________
46 Name: svn:executable
47    + *
49 </pre>