From: Joey Hess Date: Thu, 10 Sep 2009 20:18:23 +0000 (-0400) Subject: Merge branch 'master' into cvs X-Git-Tag: 3.14159265~72 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/93cd30bc0a882037ae2c65c8d6d3a9dc3d09c899?hp=-c Merge branch 'master' into cvs --- 93cd30bc0a882037ae2c65c8d6d3a9dc3d09c899 diff --combined IkiWiki/Receive.pm index 31ab3a500,101c13ee5..cd94d0938 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@@ -1,5 -1,4 +1,4 @@@ #!/usr/bin/perl - package IkiWiki::Receive; use warnings; @@@ -20,9 -19,9 +19,9 @@@ sub trusted () ! grep { $_ eq $user } @{$config{untrusted_committers}}; } - sub gen_wrapper () { + sub genwrapper () { # Test for commits from untrusted committers in the wrapper, to - # avoid loading ikiwiki at all for trusted commits. + # avoid starting ikiwiki proper at all for trusted commits. my $ret=<<"EOF"; { @@@ -37,6 -36,8 +36,8 @@@ EO "u != $uid"; } @{$config{untrusted_committers}}). ") exit(0);\n"; + + $ret.=<<"EOF"; asprintf(&s, "CALLER_UID=%i", u); newenviron[i++]=s; @@@ -114,7 -115,7 +115,7 @@@ sub test () # by not testing the removal in such pairs of changes. # (The add is still tested, just to make sure that # no data is added to the repo that a web edit - # could add.) + # could not add.) next if $newfiles{$file}; if (IkiWiki::Plugin::remove->can("check_canremove")) { diff --combined IkiWiki/Wrapper.pm index 0baf112ff,ff110b5ff..53ac5099a --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@@ -37,16 -37,10 +37,13 @@@ sub gen_wrapper () addenv("$var", s); EOF } - - my $test_receive=""; - if ($config{test_receive}) { - require IkiWiki::Receive; - $test_receive=IkiWiki::Receive::gen_wrapper(); - } + + my @wrapper_hooks; + run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() }); + my $check_args=" return 0;"; + run_hooks(wrapperargcheck => sub { $check_args = shift->(); }); + my $check_commit_hook=""; my $pre_exec=""; if ($config{post_commit}) { @@@ -119,18 -113,11 +116,18 @@@ addenv(char *var, char *val) newenviron[i++]=s; } +int checkargs(int argc, char **argv) { +$check_args +} + int main (int argc, char **argv) { char *s; + if (!checkargs(argc, argv)) + exit(0); + $check_commit_hook - $test_receive + @wrapper_hooks $envsave newenviron[i++]="HOME=$ENV{HOME}"; newenviron[i++]="WRAPPED_OPTIONS=$configstring"; @@@ -154,7 -141,6 +151,6 @@@ $pre_exe exit(1); } EOF - close OUT; my $cc=exists $ENV{CC} ? possibly_foolish_untaint($ENV{CC}) : 'cc'; if (system($cc, "$wrapper.c", "-o", "$wrapper.new") != 0) {