]> git.madduck.net Git - code/myrepos.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Improve trust errors displayed while bootstrapping. Closes: #628234
authorJoey Hess <joey@kitenet.net>
Mon, 30 May 2011 18:55:27 +0000 (14:55 -0400)
committerJoey Hess <joey@kitenet.net>
Mon, 30 May 2011 18:55:27 +0000 (14:55 -0400)
debian/changelog
mr

index 99852ca74174d54a2060894c8dca32902da43ff9..f5f4e7cd8263466011818c13be70b35c4ca21db5 100644 (file)
@@ -1,3 +1,9 @@
+mr (1.04) UNRELEASED; urgency=low
+
+  * Improve trust errors displayed while bootstrapping. Closes: #628234
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 30 May 2011 14:55:09 -0400
+
 mr (1.03) unstable; urgency=low
 
   * Added git-subtree library. Thanks, Svend Sorensen
 mr (1.03) unstable; urgency=low
 
   * Added git-subtree library. Thanks, Svend Sorensen
diff --git a/mr b/mr
index 17f95859912aac266ae71b6e71dbb0ae0eb154c4..c58c3e17ab8b45171d50f38de948fc6c6a681f19 100755 (executable)
--- a/mr
+++ b/mr
@@ -1056,14 +1056,24 @@ sub is_trusted_checkout {
 }
 
 sub trusterror {
 }
 
 sub trusterror {
-       die shift()."\n".
-               "(To trust this file, list it in ~/.mrtrust.)\n";
+       my ($err, $file, $line, $url)=@_;
+       
+       if (defined $url) {
+               die "$err in untrusted $url line $line\n".
+                       "(To trust this url, --trust-all can be used; but please use caution;\n".
+                       "this can allow arbitrary code execution!)\n";
+       }
+       else {
+               die "$err in untrusted $file line $line\n".
+                       "(To trust this file, list it in ~/.mrtrust.)\n";
+       }
 }
 
 my %loaded;
 sub loadconfig {
        my $f=shift;
        my $dir=shift;
 }
 
 my %loaded;
 sub loadconfig {
        my $f=shift;
        my $dir=shift;
+       my $bootstrap_url=shift;
 
        my @toload;
 
 
        my @toload;
 
@@ -1133,7 +1143,7 @@ sub loadconfig {
                                if (! is_trusted_repo($section) ||
                                    $section eq 'ALIAS' ||
                                    $section eq 'DEFAULT') {
                                if (! is_trusted_repo($section) ||
                                    $section eq 'ALIAS' ||
                                    $section eq 'DEFAULT') {
-                                       trusterror "mr: illegal section \"[$section]\" in untrusted $f line $line";
+                                       trusterror("mr: illegal section \"[$section]\"", $f, $line, $bootstrap_url)
                                }
                        }
                        $section=expandenv($section) if $trusted;
                                }
                        }
                        $section=expandenv($section) if $trusted;
@@ -1160,10 +1170,10 @@ sub loadconfig {
                                # Untrusted files can only contain checkout
                                # parameters.
                                if ($parameter ne 'checkout') {
                                # Untrusted files can only contain checkout
                                # parameters.
                                if ($parameter ne 'checkout') {
-                                       trusterror "mr: illegal setting \"$parameter=$value\" in untrusted $f line $line";
+                                       trusterror("mr: illegal setting \"$parameter=$value\"", $f, $line, $bootstrap_url);
                                }
                                if (! is_trusted_checkout($value)) {
                                }
                                if (! is_trusted_checkout($value)) {
-                                       trusterror "mr: illegal checkout command \"$value\" in untrusted $f line $line";
+                                       trusterror("mr: illegal checkout command \"$value\"", $f, $line, $bootstrap_url);
                                }
                        }
 
                                }
                        }
 
@@ -1474,7 +1484,7 @@ sub bootstrap {
        # would normally be skipped.
        my $topdir=abs_path(".")."/";
        my @repo=($topdir, $topdir, ".");
        # would normally be skipped.
        my $topdir=abs_path(".")."/";
        my @repo=($topdir, $topdir, ".");
-       loadconfig($tmpconfig, $topdir);
+       loadconfig($tmpconfig, $topdir, $url);
        record(\@repo, action("checkout", @repo, 1))
                if exists $config{$topdir}{"."}{"checkout"};
 
        record(\@repo, action("checkout", @repo, 1))
                if exists $config{$topdir}{"."}{"checkout"};