Hi,

On Tue, 2007-10-23 at 21:21 +0200, Luca Capello wrote:
> a test case thanks to Filippo Giunchedi cooperation:
> =====
> [EMAIL PROTECTED]:~/test$ debcheckout -p -a -u gismo -t git \
>  http://git.debian.org/git/users/filippo/test.git/.git
[...]
> error: failed to push to 'git+ssh://[EMAIL 
> PROTECTED]/git/users/filippo/test.git/.git'
[...]
> At least for this particular case, i.e. the personal repositories on
> Alioth, when in authentication mode debcheckout should check if the
> repository belongs to the user specified with -u or the login one.

Would the attached patch, based on your original darcs patch in #445714,
be sufficient, at least for git?

Regards,

Adam
--- scripts/debcheckout.pl	2008-03-23 17:22:34.000000000 +0000
+++ debcheckout.pl	2008-03-23 17:22:29.000000000 +0000
@@ -228,15 +228,15 @@
 
   my $old_url = $url;
   $user .= "@" if length $user;
+  my $user_local = $user;
+  $user_local =~ s|(.*)(@)|$1|;
+  my $user_url = $url;
   switch ($repo_type) {
     case "bzr"	  { $url =~ s|^\w+://(bzr\.debian\.org)/(.*)|sftp://$user$1/bzr/$2|;
 		    $url =~ s[^\w+://(?:(bazaar|code)\.)?(launchpad\.net/.*)][bzr+ssh://${user}bazaar.$2];}
     case "darcs"  {
+      $user_url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*)/.*|$3|;
        if ($url =~ m|(~)|) {
-           my $user_local = $user;
-           $user_local =~ s|(.*)(@)|$1|;
-           my $user_url = $url;
-           $user_url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*)/.*|$3|;
            die "the local user '$user_local' doesn't own the personal repository '$url'\n"
                if $user_local ne $user_url;
            $url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*)/(.*)|$user$1:~/public_darcs/$4|;
@@ -244,7 +244,14 @@
            $url =~ s|^\w+://(darcs\.debian\.org)/(.*)|$user$1:/darcs/$2|;
         }
     }
-    case "git"    { $url =~ s|^\w+://(git\.debian\.org/.*)|git+ssh://$user$1|; }
+    case "git"    {
+      $user_url =~ s|^\w+://(git\.debian\.org)/git/users/(.*)/.*|$2|;
+      if ($url =~ m|/users/|) {
+        die "the local user '$user_local' doesn't own the personal repository '$url'\n"
+          if $user_local ne $user_url;
+      }
+      $url =~ s|^\w+://(git\.debian\.org/.*)|git+ssh://$user$1|;
+    }
     case "hg"     { $url =~ s|^\w+://(hg\.debian\.org/.*)|ssh://$user$1|; }
     case "svn"	  { $url =~ s|^\w+://(svn\.debian\.org)/(.*)|svn+ssh://$user$1/svn/$2|; }
     else { die "sorry, don't know how to enable authentication for $repo_type repositories (patches welcome!)\n"; }

Reply via email to