]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
net_reader: fix NNTP credential use
authorEric Wong <e@80x24.org>
Wed, 10 Jan 2024 11:18:53 +0000 (11:18 +0000)
committerEric Wong <e@80x24.org>
Thu, 11 Jan 2024 03:00:13 +0000 (03:00 +0000)
Clearly this was never tested until now, as passwords being
retrieved by git-credential got completely ignored and unused.
This enables users to connect to NNTP(S) servers requiring a
password.

lib/PublicInbox/NetReader.pm

index e3e5d596ea4f85a33eb6db7170ea0e99811e49dd..751043e9cadbe5e3b27928a6b58538dfce9de40b 100644 (file)
@@ -291,7 +291,10 @@ sub nn_for ($$$$) { # nn = Net::NNTP
        return if $self->{quit};
        $nn // die "E: <$uri> new: $@".onion_hint($lei, $uri);
        if ($cred) {
-               $cred->fill($lei) unless defined($p); # may prompt user here
+               $p //= do {
+                       $cred->fill($lei); # may prompt user here
+                       $cred->{password};
+               };
                if ($nn->authinfo($u, $p)) {
                        push @{$nntp_cfg->{-postconn}}, [ 'authinfo', $u, $p ];
                } else {