From 5ee107579037882ae549f35e9bc1b30e0acdb1ab Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 10 Aug 2014 21:26:39 +0100 Subject: [PATCH 1/1] Check for rpush protocol version incompatibility and crash early if incompatible. --- debian/changelog | 2 ++ dgit | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3dd38e4c..d89b41ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ dgit (0.22~experimental1) experimental; urgency=low Minor improvements: * Include canonicalised suite name in signed tag message. * Mention cross-version dgit rpush incompatibility in manpage. + * Check for rpush protocol version incompatibility and crash early + if incompatible. * New script tests/using-intree for running tests on the source tree. * Do not spew diff output to terminal (by default). Print sensible message instead. Closes:#736526. diff --git a/dgit b/dgit index 40953871..53ca56c0 100755 --- a/dgit +++ b/dgit @@ -34,6 +34,8 @@ use Config; our $our_version = 'UNRELEASED'; ###substituted### +our $rpushprotovsn = 2; + our $isuite = 'unstable'; our $idistro; our $package; @@ -1727,12 +1729,15 @@ sub cmd_push { #---------- remote commands' implementation ---------- -sub cmd_remote_push_responder { +sub cmd_remote_push_build_host { my ($nrargs) = shift @ARGV; my (@rargs) = @ARGV[0..$nrargs-1]; @ARGV = @ARGV[$nrargs..$#ARGV]; die unless @rargs; - my ($dir) = @rargs; + my ($dir,$vsnwant) = @rargs; + # vsnwant is a comma-separated list; we report which we have + # chosen in our ready response (so other end can tell if they + # offered several) $debugprefix = ' '; $we_are_responder = 1; @@ -1743,12 +1748,21 @@ sub cmd_remote_push_responder { open STDOUT, ">&STDERR" or die $!; autoflush STDOUT 1; - responder_send_command("dgit-remote-push-ready"); + $vsnwant //= 1; + fail "build host has dgit rpush protocol version". + " $rpushprotovsn but invocation host has $vsnwant" + unless grep { $rpushprotovsn eq $_ } split /,/, $vsnwant; + + responder_send_command("dgit-remote-push-ready $rpushprotovsn"); changedir $dir; &cmd_push; } +sub cmd_remote_push_responder { cmd_remote_push_build_host(); } +# ... for compatibility with proto vsn.1 dgit (just so that user gets +# a good error message) + our $i_tmp; sub i_cleanup { @@ -1784,11 +1798,11 @@ sub cmd_rpush { $dir = nextarg; } $dir =~ s{^-}{./-}; - my @rargs = ($dir); + my @rargs = ($dir,$rpushprotovsn); my @rdgit; push @rdgit, @dgit; push @rdgit, @ropts; - push @rdgit, qw(remote-push-responder), (scalar @rargs), @rargs; + push @rdgit, qw(remote-push-build-host), (scalar @rargs), @rargs; push @rdgit, @ARGV; my @cmd = (@ssh, $host, shellquote @rdgit); printcmd \*DEBUG,$debugprefix."+",@cmd; -- 2.30.2