about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/GitCredential.pm8
-rw-r--r--lib/PublicInbox/NetReader.pm4
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/GitCredential.pm b/lib/PublicInbox/GitCredential.pm
index c83fed43..b18bba1e 100644
--- a/lib/PublicInbox/GitCredential.pm
+++ b/lib/PublicInbox/GitCredential.pm
@@ -31,8 +31,12 @@ sub run ($$;$) {
         close $out_r or die "`git credential $op' failed: \$!=$! \$?=$?\n";
 }
 
-sub check_netrc ($) {
-        my ($self) = @_;
+sub check_netrc {
+        my ($self, $lei) = @_;
+
+        # n.b. lei doesn't load ~/.netrc by default, public-inbox-watch does,
+        # which may've been a mistake, but we have to live with it.
+        return if ($lei && !$lei->{opt}->{netrc});
 
         # part of the standard library, but distributions may split it out
         eval { require Net::Netrc };
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index a0e52fc5..f0f56431 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -96,7 +96,7 @@ sub mic_for ($$$$) { # mic = Mail::IMAPClient
                 $cred = undef;
         }
         if ($cred) {
-                my $p = $cred->{password} // $cred->check_netrc;
+                my $p = $cred->{password} // $cred->check_netrc($lei);
                 $cred->fill($lei) unless defined($p); # may prompt user here
                 $mic->User($mic_arg->{User} = $cred->{username});
                 $mic->Password($mic_arg->{Password} = $cred->{password});
@@ -191,7 +191,7 @@ sub nn_for ($$$$) { # nn = Net::NNTP
                 }, 'PublicInbox::GitCredential';
                 ($u, $p) = split(/:/, $ui, 2);
                 ($cred->{username}, $cred->{password}) = ($u, $p);
-                $p //= $cred->check_netrc;
+                $p //= $cred->check_netrc($lei);
         }
         my $common = $nn_common->{$sec} // {};
         my $nn_arg = {