}
sub genwrapper () {
- my $check_args=<<"EOF";
+ return <<EOF;
{
int j;
for (j = 1; j < argc; j++)
exit(0);
}
EOF
- return $check_args;
}
sub checkconfig () {
cvs_wrapper => {
type => "string",
example => "/cvs/wikirepo/CVSROOT/post-commit",
- description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry",
+ description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry)",
safe => 0, # file
rebuild => 0,
},
if (defined($filemime) && $filemime eq 'text/plain') {
cvs_runcvs('add', $file) ||
warn("cvs add $file failed\n");
- } else {
+ }
+ else {
cvs_runcvs('add', '-kb', $file) ||
warn("cvs add binary $file failed\n");
}
- } else {
+ }
+ else {
# directory
cvs_runcvs('add', $file) ||
warn("cvs add $file failed\n");
system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile");
if ($? == -1) {
error "couldn't run cvsps: $!\n";
- } elsif (($? >> 8) != 0) {
+ }
+ elsif (($? >> 8) != 0) {
error "cvsps exited " . ($? >> 8) . ": $!\n";
}
$message[0]->{line}=~/$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3";
$message[0]->{line}=$4;
- } else {
+ }
+ else {
$committype="cvs";
}
$line = <SPSVC>;
if ($line =~ /^Author: (.*)$/) {
$user = $1 unless defined $user && length $user;
- } else {
+ }
+ else {
error "expected Author, got $line";
}
$line = <SPSVC>;
if ($line =~ /^Date: (.*)$/) {
$when = str2time($1, 'UTC');
- } else {
+ }
+ else {
error "expected Date, got $line";
}
$line = <SPSVC>;
if ($line =~ /^PatchSet (.*)$/) {
$rev = $1;
- } else {
+ }
+ else {
error "expected PatchSet, got $line";
}
if (wantarray) {
return @cvsps;
- } else {
+ }
+ else {
return join("", @cvsps);
}
}
sub import {
hook(type => "checkconfig", id => "git", call => \&checkconfig);
hook(type => "getsetup", id => "git", call => \&getsetup);
+ hook(type => "genwrapper", id => "git", call => \&genwrapper);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
+
if (defined $config{git_test_receive_wrapper} &&
length $config{git_test_receive_wrapper}) {
push @{$config{wrappers}}, {
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
+
+ # Run receive test only if being called by the wrapper, and not
+ # when generating same.
+ if ($config{test_receive} && ! exists $config{wrapper}) {
+ require IkiWiki::Receive;
+ IkiWiki::Receive::test();
+ }
}
sub getsetup () {
},
}
+sub genwrapper {
+ if ($config{test_receive}) {
+ require IkiWiki::Receive;
+ return IkiWiki::Receive::genwrapper();
+ }
+ else {
+ return "";
+ }
+}
+
sub safe_git (&@) {
# Start a child process safely without resorting /bin/sh.
# Return command output or success state (in scalar context).
+++ /dev/null
-#!/usr/bin/perl
-package IkiWiki::Plugin::rsync;
-
-use warnings;
-use strict;
-use IkiWiki 3.00;
-
-sub import {
- hook(type => "getsetup", id => "rsync", call => \&getsetup);
- hook(type => "checkconfig", id => "rsync", call => \&checkconfig);
- hook(type => "postrefresh", id => "rsync", call => \&postrefresh);
-}
-
-sub getsetup () {
- return
- plugin => {
- safe => 0,
- rebuild => 0,
- },
- rsync_command => {
- type => "string",
- example => "rsync -qa --delete /path/to/destdir/ user\@host:/path/to/docroot/",
- description => "unattended command to upload regenerated pages",
- safe => 0,
- rebuild => 0,
- },
-}
-
-sub checkconfig {
- if (! exists $config{rsync_command} ||
- ! defined $config{rsync_command}) {
- error("Must specify rsync_command");
- }
-}
-
-sub postrefresh () {
- system $config{rsync_command};
- if ($? == -1) {
- error("failed to execute rsync_command: $!");
- } elsif ($? != 0) {
- error(sprintf("rsync_command exited %d", $? >> 8));
- }
-}
-
-1
+++ /dev/null
-#!/usr/bin/perl
-# Ikiwiki unixauth authentication.
-package IkiWiki::Plugin::unixauth;
-
-use warnings;
-use strict;
-use IkiWiki 2.00;
-
-sub import {
- hook(type => "getsetup", id => "unixauth", call => \&getsetup);
- hook(type => "formbuilder_setup", id => "unixauth",
- call => \&formbuilder_setup);
- hook(type => "formbuilder", id => "unixauth",
- call => \&formbuilder);
- hook(type => "sessioncgi", id => "unixauth", call => \&sessioncgi);
-}
-
-sub getsetup () {
- return
- unixauth_type => {
- type => "string",
- example => "checkpassword",
- description => "type of authenticator; can be 'checkpassword' or 'pwauth'",
- safe => 0,
- rebuild => 1,
- },
- unixauth_command => {
- type => "string",
- example => "/path/to/checkpassword",
- description => "full path and any arguments",
- safe => 0,
- rebuild => 1,
- },
- unixauth_requiressl => {
- type => "boolean",
- example => "1",
- description => "require SSL? strongly recommended",
- safe => 0,
- rebuild => 1,
- },
- plugin => {
- description => "Unix user authentication",
- safe => 0,
- rebuild => 1,
- },
-}
-
-# Checks if a string matches a user's password, and returns true or false.
-sub checkpassword ($$;$) {
- my $user=shift;
- my $password=shift;
- my $field=shift || "password";
-
- # It's very important that the user not be allowed to log in with
- # an empty password!
- if (! length $password) {
- return 0;
- }
-
- my $ret=0;
- if (! exists $config{unixauth_type}) {
- # admin needs to carefully think over his configuration
- return 0;
- }
- elsif ($config{unixauth_type} eq "checkpassword") {
- open UNIXAUTH, "|$config{unixauth_command} true 3<&0" or die("Could not run $config{unixauth_type}");
- print UNIXAUTH "$user\0$password\0Y123456\0";
- close UNIXAUTH;
- $ret=!($?>>8);
- }
- elsif ($config{unixauth_type} eq "pwauth") {
- open UNIXAUTH, "|$config{unixauth_command}" or die("Could not run $config{unixauth_type}");
- print UNIXAUTH "$user\n$password\n";
- close UNIXAUTH;
- $ret=!($?>>8);
- }
- else {
- # no such authentication type
- return 0;
- }
-
- if ($ret) {
- my $userinfo=IkiWiki::userinfo_retrieve();
- if (! length $user || ! defined $userinfo ||
- ! exists $userinfo->{$user} || ! ref $userinfo->{$user}) {
- IkiWiki::userinfo_setall($user, {
- 'email' => '',
- 'regdate' => time,
- });
- }
- }
-
- return $ret;
-}
-
-sub formbuilder_setup (@) {
- my %params=@_;
-
- my $form=$params{form};
- my $session=$params{session};
- my $cgi=$params{cgi};
-
- # if not under SSL, die before even showing a login form,
- # unless the admin explicitly says it's fine
- if (! exists $config{unixauth_requiressl}) {
- $config{unixauth_requiressl} = 1;
- }
- if ($config{unixauth_requiressl}) {
- if ((! $config{sslcookie}) || (! exists $ENV{'HTTPS'})) {
- die("SSL required to login. Contact your administrator.<br>");
- }
- }
-
- if ($form->title eq "signin") {
- $form->field(name => "name", required => 0);
- $form->field(name => "password", type => "password", required => 0);
-
- if ($form->submitted) {
- my $submittype=$form->submitted;
- # Set required fields based on how form was submitted.
- my %required=(
- "Login" => [qw(name password)],
- );
- foreach my $opt (@{$required{$submittype}}) {
- $form->field(name => $opt, required => 1);
- }
-
- # Validate password against name for Login.
- if ($submittype eq "Login") {
- $form->field(
- name => "password",
- validate => sub {
- checkpassword($form->field("name"), shift);
- },
- );
- }
-
- # XXX is this reachable? looks like no
- elsif ($submittype eq "Login") {
- $form->field(
- name => "name",
- validate => sub {
- my $name=shift;
- length $name &&
- IkiWiki::userinfo_get($name, "regdate");
- },
- );
- }
- }
- else {
- # First time settings.
- $form->field(name => "name");
- if ($session->param("name")) {
- $form->field(name => "name", value => $session->param("name"));
- }
- }
- }
- elsif ($form->title eq "preferences") {
- $form->field(name => "name", disabled => 1,
- value => $session->param("name"), force => 1,
- fieldset => "login");
- $form->field(name => "password", disabled => 1, type => "password",
- fieldset => "login"),
- }
-}
-
-sub formbuilder (@) {
- my %params=@_;
-
- my $form=$params{form};
- my $session=$params{session};
- my $cgi=$params{cgi};
- my $buttons=$params{buttons};
-
- if ($form->title eq "signin") {
- if ($form->submitted && $form->validate) {
- if ($form->submitted eq 'Login') {
- $session->param("name", $form->field("name"));
- IkiWiki::cgi_postsignin($cgi, $session);
- }
- }
- }
- elsif ($form->title eq "preferences") {
- if ($form->submitted eq "Save Preferences" && $form->validate) {
- my $user_name=$form->field('name');
- }
- }
-}
-
-sub sessioncgi ($$) {
- my $q=shift;
- my $session=shift;
-}
-
-1
#!/usr/bin/perl
-
package IkiWiki::Receive;
use warnings;
! 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";
{
"u != $uid";
} @{$config{untrusted_committers}}).
") exit(0);\n";
+
+
$ret.=<<"EOF";
asprintf(&s, "CALLER_UID=%i", u);
newenviron[i++]=s;
# 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")) {
if (%rendered) {
run_hooks(change => sub { shift->(keys %rendered) });
}
- run_hooks(postrefresh => sub { shift->() });
}
sub commandline_render () {
addenv("$var", s);
EOF
}
-
- if ($config{test_receive}) {
- require IkiWiki::Receive;
- }
my @wrapper_hooks;
run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
for template files in.
* Fix parsing web commits from ipv6 addresses.
* Add genwrapper hook, that can be used to add code into the C wrapper.
+ * cvs: Yeah, ikiwiki even supports CVS now. Plugin contributed by
+ Amitai Schlair.
-- Joey Hess <joeyh@debian.org> Wed, 02 Sep 2009 15:01:27 -0400
libtext-markdown-perl | markdown,
libtimedate-perl, libhtml-template-perl,
libhtml-scrubber-perl, wdg-html-validator,
- libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34)
+ libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
+ libfile-chdir-perl
Maintainer: Joey Hess <joeyh@debian.org>
Uploaders: Josh Triplett <josh@freedesktop.org>
Standards-Version: 3.8.1
# SYNOPSIS
-ikiwiki-makerepo svn|git|monotone|darcs srcdir repository
+ikiwiki-makerepo git|svn|monotone|darcs|cvs srcdir repository
ikiwiki-makerepo bzr|mercurial srcdir
+++ /dev/null
-[[!template id=plugin name=cvs core=0 author="[[schmonz]]"]]
-
-[[!template id=gitbranch branch=schmonz author="[[schmonz]]"]]
-
-This plugin allows ikiwiki to use [[!wikipedia desc="CVS" Concurrent Versions System]] as an [[rcs]].
-
-### Usage
-7. Install [[!cpan File::chdir]], [[!cpan File::ReadBackwards]],
-[cvsps](http://www.cobite.com/cvsps/), and
-[cvsweb](http://www.freebsd.org/projects/cvsweb.html) or the like.
-7. Adjust CVS-related parameters in your setup file.
-
-Consider creating `$HOME/.cvsrc` if you don't have one already; the plugin doesn't need it, but you yourself might. Here's a good general-purpose one:
-
- cvs -q
- checkout -P
- update -dP
- diff -u
- rdiff -u
-
-### Implementation details
-* `cvs.pm` started life as a copy of [[3.14159|news/version_3.14159]]'s `svn.pm`.
-* `IkiWiki.pm:wiki_file_prune_regexps` avoids copying CVS metadata
-into `$DESTDIR`.
-* `IkiWiki/Wrapper.pm` provides a new "wrapperargcheck" hook, which
-the plugin implements to avoid calling ikiwiki from post-commit
-(and locking against itself) if it's a directory being `cvs add`ed.
-* [[ikiwiki-makerepo]]:
- * creates a repository,
- * imports `$SRCDIR` into top-level module `ikiwiki` (vendor tag IKIWIKI, release tag PRE_CVS),
- * configures the post-commit hook in `CVSROOT/loginfo`.
-* CVS multi-directory commits happen separately; the post-commit hook sees only the first directory's changes in time for [[recentchanges|plugins/recentchanges]]. The next run of `ikiwiki --setup` will correctly re-render such a recentchanges entry. It should be possible to solve this problem with NetBSD's `commit_prep` and `log_accum` scripts (see below).
-
-### To do
-* Instead of resource-intensively scraping changesets with `cvsps`, have `ikiwiki-makerepo` set up NetBSD-like `log_accum` and `commit_prep` scripts that coalesce and keep records of commits. `cvsps` can be used as a fallback for repositories without such records.
-* Perhaps prevent web edits from attempting to create `.../CVS/foo.mdwn` (and `.../cvs/foo.mdwn` on case-insensitive filesystems); thanks to the CVS metadata directory, the attempt will fail anyway (and much more confusingly) if we don't.
+++ /dev/null
-I've started reviewing this, and the main thing I don't like is the
-post-commit wrapper wrapper that ikiwiki-makerepo is patched to set up.
-That just seems unnecessarily complicated. Why can't ikiwiki itself detect
-the "cvs add <directory>" call and avoid doing anything in that case?
---[[Joey]]
-
-> The wrapper wrapper does three things:
->
-> 7. It ignores `cvs add <directory>`, since this is a weird CVS
-> behavior that ikiwiki gets confused by and doesn't need to act on.
-> 7. It prevents `cvs` locking against itself: `cvs commit` takes a
-> write lock and runs the post-commit hook, which runs `cvs update`,
-> which wants a read lock and sleeps forever -- unless the post-commit
-> hook runs in the background so the commit can "finish".
-> 7. It fails silently if the ikiwiki post-commit hook is missing.
-> CVS doesn't have any magic post-commit filenames, so hooks have to
-> be configured explicitly. I don't think a commit will actually fail
-> if a configured post-commit hook is missing (though I can't test
-> this at the moment).
->
-> Thing 1 can probably be handled within ikiwiki, if that seems less
-> gross to you.
-
->> It seems like it might be. You can use a `getopt` hook to check
->> `@ARGV` to see how it was called. --[[Joey]]
-
->>> This does the trick iff the post-commit wrapper passes its args
->>> along. Committed on my branch. This seems potentially dangerous,
->>> since the args passed to ikiwiki are influenced by web commits.
->>> I don't see an exploit, but for paranoia's sake, maybe the wrapper
->>> should only be built with execv() if the cvs plugin is loaded?
->>> --[[schmonz]]
-
->>>> Hadn't considered that. While in wrapper mode the normal getopt is not
->>>> done, plugin getopt still runs, and so any unsafe options that
->>>> other plugins support could be a problem if another user runs
->>>> the setuid wrapper and passes those options through. --[[Joey]]
-
->>>>> I've tried compiling the argument check into the wrapper as
->>>>> the first thing main() does, and was surprised to find that
->>>>> this doesn't prevent the `cvs add <dir>` deadlock in a web
->>>>> commit. I was convinced this'd be a reasonable solution,
->>>>> especially if conditionalized on the cvs plugin being loaded,
->>>>> but it doesn't work. And I stuck debug printfs at the beginning
->>>>> of all the rcs_foo() subs, and whatever `cvs add <dir>` is
->>>>> doing to ikiwiki isn't visible to my plugin, because none of
->>>>> those subs are getting called. Nuts. Can you think of anything
->>>>> else that might solve the problem, or should I go back to
->>>>> generating a minimal wrapper wrapper that checks for just
->>>>> this one thing? --[[schmonz]]
-
->>>>>> I don't see how there could possibly be a difference between
->>>>>> ikiwiki's C wrapper and your shell wrapper wrapper here. --[[Joey]]
-
->>>>>>> I was comparing strings overly precisely. Fixed on my branch.
->>>>>>> I've also knocked off the two most pressing to-do items. I
->>>>>>> think the plugin's ready for prime time. --[[schmonz]]
-
-> Thing 2 I'm less sure of. (I'd like to see the web UI return
-> immediately on save anyway, to a temporary "rebuilding, please wait
-> if you feel like knowing when it's done" page, but this problem
-> with CVS happens with any kind of commit, and could conceivably
-> happen with some other VCS.)
-
->> None of the other VCSes let a write lock block a read lock, apparently.
->>
->> Anyway, re the backgrounding, when committing via the web, the
->> post-commit hook doesn't run anyway; the rendering is done via the
->> ikiwiki CGI. It would certianly be nice if it popped up a quick "working"
->> page and replaced it with the updated page when done, but that's
->> unrelated; the post-commit
->> hook only does rendering when committing using the VCS directly. The
->> backgrounding you do actually seems safe enough -- but tacking
->> on a " &" to the ikiwiki wrapper call doesn't need a wrapper script,
->> does it? --[[Joey]]
-
->>> Nope, it works fine to append it to the `CVSROOT/loginfo` line.
->>> Fixed on my branch. --[[schmonz]]
-
-> Thing 3 I think I did in order to squelch the error messages that
-> were bollixing up the CGI. It was easy to do this in the wrapper
-> wrapper, but if that's going away, it can be done just as easily
-> with output redirection in `CVSROOT/loginfo`.
->
-> --[[schmonz]]
-
->> If the error messages screw up the CGI they must go to stdout.
->> I thought we had stderr even in the the CVS dark ages. ;-) --[[Joey]]
-
->>> Some messages go to stderr, but definitely not all. That's why
->>> I wound up reaching for IPC::Cmd, to execute the command line
->>> safely while shutting CVS up. Anyway, I've tested what happens
->>> if a configured post-commit hook is missing, and it seems fine,
->>> probably also thanks to IPC::Cmd.
->>> --[[schmonz]]
-
-----
-
-
-Further review.. --[[Joey]]
-
-I don't understand what `cvs_shquote_commit` is
-trying to do with the test message, but it seems
-highly likely to be insecure; I never trust anything
-that relies on safely quoting user input passed to the shell.
-
-(As an aside, `shell_quote` can die on certian inputs.)
-
-Seems to me that, if `IPC::Cmd` exposes input to the shell
-(which I have not verified but its docs don't specify; a bad sign)
-you chose the wrong tool and ended up doing down the wrong
-route, dragging in shell quoting problems and fixes. Since you
-chose to use `IPC::Cmd` just because you wanted to shut
-up CVS stderr, my suggestion would be to use plain `system`
-to run the command, with stderr temporarily sent to /dev/null:
-
- open(my $savederr, ">&STDERR");
- open(STDERR, ">", "/dev/null");
- my $ret=system("cvs", "-Q", @_);
- open(STDERR, ">$savederr");
-
-`cvs_runcvs` should not take an array reference. It's
-usual for this type of function to take a list of parameters
-to pass to the command.
-
-> Thanks for reading carefully. I've tested your suggestions and
-> applied them on my branch. --[[schmonz]]
-
-----
-
-I've abstracted out CVS's involvement in the wrapper, adding a new
-"wrapperargcheck" hook to examine `argc/argv` and return success or
-failure (failure causes the wrapper to terminate) and implementing
-this hook in the plugin. In the non-CVS case, the check immediately
-returns success, so the added overhead is just a function call.
-
-Given how rarely anything should need to reach in and modify the
-wrapper -- I'd go so far as to say we shouldn't make it too easy
--- I don't think it's worth the effort to try and design a more
-general-purpose way to do so. If and when some other problem thinks
-it wants to be solved by a new wrapper hook, it's easy enough to add
-one. Until then, I'd say it's more important to keep the wrapper as
-short and clear as possible. --[[schmonz]]
-
-> I've committed a slightly different hook, which should be general enough
-> that `IkiWiki::Receive` can also use it, so please adapt your code to
-> that. --[[Joey]]
>>> Aaaaaand I was wrong about the second half of the conjecture being
>>> wrong. The wrapper script wasn't correctly identifying directories;
>>> with that fixed, everything works. I've created a
->>> [[plugins/contrib/cvs]] plugin page. Thanks for listening. :-)
+>>> [[rcs/cvs]] page. Thanks for listening. :-)
>>> --[[Schmonz]]
>> Here is a comment I committed to my laptop from Madrid Airport before
--- /dev/null
+If you really need to, you can use [[!wikipedia desc="CVS" Concurrent Versions System]]
+with ikiwiki.
+
+### Usage
+7. Install [[!cpan File::chdir]], [[!cpan File::ReadBackwards]],
+[cvsps](http://www.cobite.com/cvsps/), and
+[cvsweb](http://www.freebsd.org/projects/cvsweb.html) or the like.
+7. Adjust CVS-related parameters in your setup file.
+
+Consider creating `$HOME/.cvsrc` if you don't have one already; the plugin doesn't need it, but you yourself might. Here's a good general-purpose one:
+
+ cvs -q
+ checkout -P
+ update -dP
+ diff -u
+ rdiff -u
+
+### Implementation details
+* [[ikiwiki-makerepo]]:
+ * creates a repository,
+ * imports `$SRCDIR` into top-level module `ikiwiki` (vendor tag IKIWIKI, release tag PRE_CVS),
+ * configures the post-commit hook in `CVSROOT/loginfo`.
+* CVS multi-directory commits happen separately; the post-commit hook sees only the first directory's changes in time for [[recentchanges|plugins/recentchanges]]. The next run of `ikiwiki --setup` will correctly re-render such a recentchanges entry. It should be possible to solve this problem with NetBSD's `commit_prep` and `log_accum` scripts (see below).
+
+### To do
+* Instead of resource-intensively scraping changesets with `cvsps`, have `ikiwiki-makerepo` set up NetBSD-like `log_accum` and `commit_prep` scripts that coalesce and keep records of commits. `cvsps` can be used as a fallback for repositories without such records.
+* Perhaps prevent web edits from attempting to create `.../CVS/foo.mdwn` (and `.../cvs/foo.mdwn` on case-insensitive filesystems); thanks to the CVS metadata directory, the attempt will fail anyway (and much more confusingly) if we don't.
--- /dev/null
+I've started reviewing this, and the main thing I don't like is the
+post-commit wrapper wrapper that ikiwiki-makerepo is patched to set up.
+That just seems unnecessarily complicated. Why can't ikiwiki itself detect
+the "cvs add <directory>" call and avoid doing anything in that case?
+--[[Joey]]
+
+> The wrapper wrapper does three things:
+>
+> 7. It ignores `cvs add <directory>`, since this is a weird CVS
+> behavior that ikiwiki gets confused by and doesn't need to act on.
+> 7. It prevents `cvs` locking against itself: `cvs commit` takes a
+> write lock and runs the post-commit hook, which runs `cvs update`,
+> which wants a read lock and sleeps forever -- unless the post-commit
+> hook runs in the background so the commit can "finish".
+> 7. It fails silently if the ikiwiki post-commit hook is missing.
+> CVS doesn't have any magic post-commit filenames, so hooks have to
+> be configured explicitly. I don't think a commit will actually fail
+> if a configured post-commit hook is missing (though I can't test
+> this at the moment).
+>
+> Thing 1 can probably be handled within ikiwiki, if that seems less
+> gross to you.
+
+>> It seems like it might be. You can use a `getopt` hook to check
+>> `@ARGV` to see how it was called. --[[Joey]]
+
+>>> This does the trick iff the post-commit wrapper passes its args
+>>> along. Committed on my branch. This seems potentially dangerous,
+>>> since the args passed to ikiwiki are influenced by web commits.
+>>> I don't see an exploit, but for paranoia's sake, maybe the wrapper
+>>> should only be built with execv() if the cvs plugin is loaded?
+>>> --[[schmonz]]
+
+>>>> Hadn't considered that. While in wrapper mode the normal getopt is not
+>>>> done, plugin getopt still runs, and so any unsafe options that
+>>>> other plugins support could be a problem if another user runs
+>>>> the setuid wrapper and passes those options through. --[[Joey]]
+
+>>>>> I've tried compiling the argument check into the wrapper as
+>>>>> the first thing main() does, and was surprised to find that
+>>>>> this doesn't prevent the `cvs add <dir>` deadlock in a web
+>>>>> commit. I was convinced this'd be a reasonable solution,
+>>>>> especially if conditionalized on the cvs plugin being loaded,
+>>>>> but it doesn't work. And I stuck debug printfs at the beginning
+>>>>> of all the rcs_foo() subs, and whatever `cvs add <dir>` is
+>>>>> doing to ikiwiki isn't visible to my plugin, because none of
+>>>>> those subs are getting called. Nuts. Can you think of anything
+>>>>> else that might solve the problem, or should I go back to
+>>>>> generating a minimal wrapper wrapper that checks for just
+>>>>> this one thing? --[[schmonz]]
+
+>>>>>> I don't see how there could possibly be a difference between
+>>>>>> ikiwiki's C wrapper and your shell wrapper wrapper here. --[[Joey]]
+
+>>>>>>> I was comparing strings overly precisely. Fixed on my branch.
+>>>>>>> I've also knocked off the two most pressing to-do items. I
+>>>>>>> think the plugin's ready for prime time. --[[schmonz]]
+
+> Thing 2 I'm less sure of. (I'd like to see the web UI return
+> immediately on save anyway, to a temporary "rebuilding, please wait
+> if you feel like knowing when it's done" page, but this problem
+> with CVS happens with any kind of commit, and could conceivably
+> happen with some other VCS.)
+
+>> None of the other VCSes let a write lock block a read lock, apparently.
+>>
+>> Anyway, re the backgrounding, when committing via the web, the
+>> post-commit hook doesn't run anyway; the rendering is done via the
+>> ikiwiki CGI. It would certianly be nice if it popped up a quick "working"
+>> page and replaced it with the updated page when done, but that's
+>> unrelated; the post-commit
+>> hook only does rendering when committing using the VCS directly. The
+>> backgrounding you do actually seems safe enough -- but tacking
+>> on a " &" to the ikiwiki wrapper call doesn't need a wrapper script,
+>> does it? --[[Joey]]
+
+>>> Nope, it works fine to append it to the `CVSROOT/loginfo` line.
+>>> Fixed on my branch. --[[schmonz]]
+
+> Thing 3 I think I did in order to squelch the error messages that
+> were bollixing up the CGI. It was easy to do this in the wrapper
+> wrapper, but if that's going away, it can be done just as easily
+> with output redirection in `CVSROOT/loginfo`.
+>
+> --[[schmonz]]
+
+>> If the error messages screw up the CGI they must go to stdout.
+>> I thought we had stderr even in the the CVS dark ages. ;-) --[[Joey]]
+
+>>> Some messages go to stderr, but definitely not all. That's why
+>>> I wound up reaching for IPC::Cmd, to execute the command line
+>>> safely while shutting CVS up. Anyway, I've tested what happens
+>>> if a configured post-commit hook is missing, and it seems fine,
+>>> probably also thanks to IPC::Cmd.
+>>> --[[schmonz]]
+
+----
+
+
+Further review.. --[[Joey]]
+
+I don't understand what `cvs_shquote_commit` is
+trying to do with the test message, but it seems
+highly likely to be insecure; I never trust anything
+that relies on safely quoting user input passed to the shell.
+
+(As an aside, `shell_quote` can die on certian inputs.)
+
+Seems to me that, if `IPC::Cmd` exposes input to the shell
+(which I have not verified but its docs don't specify; a bad sign)
+you chose the wrong tool and ended up doing down the wrong
+route, dragging in shell quoting problems and fixes. Since you
+chose to use `IPC::Cmd` just because you wanted to shut
+up CVS stderr, my suggestion would be to use plain `system`
+to run the command, with stderr temporarily sent to /dev/null:
+
+ open(my $savederr, ">&STDERR");
+ open(STDERR, ">", "/dev/null");
+ my $ret=system("cvs", "-Q", @_);
+ open(STDERR, ">$savederr");
+
+`cvs_runcvs` should not take an array reference. It's
+usual for this type of function to take a list of parameters
+to pass to the command.
+
+> Thanks for reading carefully. I've tested your suggestions and
+> applied them on my branch. --[[schmonz]]
+
+----
+
+I've abstracted out CVS's involvement in the wrapper, adding a new
+"wrapperargcheck" hook to examine `argc/argv` and return success or
+failure (failure causes the wrapper to terminate) and implementing
+this hook in the plugin. In the non-CVS case, the check immediately
+returns success, so the added overhead is just a function call.
+
+Given how rarely anything should need to reach in and modify the
+wrapper -- I'd go so far as to say we shouldn't make it too easy
+-- I don't think it's worth the effort to try and design a more
+general-purpose way to do so. If and when some other problem thinks
+it wants to be solved by a new wrapper hook, it's easy enough to add
+one. Until then, I'd say it's more important to keep the wrapper as
+short and clear as possible. --[[schmonz]]
+
+> I've committed a slightly different hook, which should be general enough
+> that `IkiWiki::Receive` can also use it, so please adapt your code to
+> that. --[[Joey]]
+
+>> Done. --[[schmonz]].
revision gets committed to the repository.
## [[bzr]]
+
+## [[cvs]]
Here's another one with *emphasised* text.
+test 2
+
# Header
## Subheader
>> No, although the existing svn backend could fairly esily be modified into
>> a CVS backend, by someone who doesn't mind working with CVS. --[[Joey]]
>>
->>> Wouldn't say I don't mind, but I needed it. See [[plugins/contrib/cvs]]. --[[Schmonz]]
+>>> Wouldn't say I don't mind, but I needed it. See [[rcs/cvs]]. --[[Schmonz]]
+
+[[done]]
[[!tag wishlist]]
repository="$3"
usage () {
- echo "usage: ikiwiki-makerepo cvs|svn|git|monotone|darcs srcdir repository" >&2
+ echo "usage: ikiwiki-makerepo svn|git|svn|monotone|darcs|cvs srcdir repository" >&2
echo " ikiwiki-makerepo bzr|mercurial srcdir" >&2
exit 1
}
elsif ($config{post_commit} && ! commit_hook_enabled()) {
# do nothing
}
- elsif ($config{test_receive}) {
- require IkiWiki::Receive;
- IkiWiki::Receive::test();
- }
else {
if ($config{rebuild}) {
debug(gettext("rebuilding wiki.."));
$dir="/tmp/ikiwiki-test-cvs.$$";
my $cvs=`which cvs`;
chomp $cvs;
- if (! -x $cvs || ! mkdir($dir)) {
+ my $cvsps=`which cvsps`;
+ chomp $cvsps;
+ if (! -x $cvs || ! -x $cvsps || ! mkdir($dir)) {
eval q{
- use Test::More skip_all => "cvs not available or could not make test dir"
+ use Test::More skip_all => "cvs or cvsps not available or could not make test dir"
}
}
}