All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] Add contrib/credentials/netrc with GPG support, try #2
Date: Tue, 05 Feb 2013 12:01:31 -0500	[thread overview]
Message-ID: <87k3qmr8yc.fsf@lifelogs.com> (raw)
In-Reply-To: <7vvca6u47f.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 05 Feb 2013 08:15:48 -0800")

On Tue, 05 Feb 2013 08:15:48 -0800 Junio C Hamano <gitster@pobox.com> wrote: 

JCH> Ted Zlatanov <tzz@lifelogs.com> writes:
>> +# build reverse token map
>> +my %rmap;
>> +foreach my $k (keys %{$options{tmap}}) {
>> +	push @{$rmap{$options{tmap}->{$k}}}, $k;
>> +}

JCH> Mental note: "$rmap{foo} -eq 'bar'" means that what Git calls 'bar'
JCH> is found as 'foo' in the netrc/authinfo file.  Keys in %rmap are
JCH> what we expect to read from the netrc/authinfo file.

I'll document that better in PATCHv4.

JCH> So you grabbed one line of input, split them into token pairs, and
JCH> built %tokens = ('key Git may want to see' => 'value read from file')
JCH> mapping.

This will be fixed with PATCHv4 to do multiple lines (as defined by the
netrc manpage, etc.).

>> +	# for "host X port Y" where Y is an integer (captured by
>> +	# $num_port above), set the host to "X:Y"
>> +	$tokens{host} = join(':', $tokens{host}, $num_port)
>> +		if defined $tokens{host} && defined $num_port;

JCH> What happens when 'host' does not exist?  netrc/authinfo should be a
JCH> stream of SP/HT/LF delimited tokens and 'machine' token (or
JCH> 'default') begins a new entry, so it would mean the input file is
JCH> corrupt if we do not have $tokens{host} when we get here, I think.

Yes.  I'll make the host/machine token required, which will avoid this
issue.

JCH> Oh, another thing. 'default' is like 'machine' followed by any
JCH> machine name, so the above while loop that reads two tokens
JCH> pair-wise needs to be aware that 'default' is not followed by a
JCH> value.  I think the loop will fail to parse this:

JCH>         default       login anonymous    password me@home
JCH>         machine k.org login me           password mysecret

I'd prefer to ignore "default" because it should not be used for the Git
credential helpers (its only use case is for anonymous services AFAIK).
So I'll add a case to ignore it in PATCHv4, if that's OK.

JCH> Hmph, aren't you checking what you read a bit too early?  This is a
JCH> valid input:

JCH>         default       
JCH>                 login anonymous
JCH>                 password me@home
JCH>         machine k.org
JCH>                 login me
JCH>                 password mysecret

JCH> but does this loop gives mysecret back to me when asked for
JCH> host=k.org and user=me? 

To be fixed in PATCHv4, which will require the host/machine, use it as
the primary key, and only examine entries with it.

JCH> I would probably structure this part like this: [...]

I will do it like that, thank you for the suggestion.

I'll also add a simple testing Makefile for my own use, and you can
consider adding tests to the general framework later.

Ted

  reply	other threads:[~2013-02-05 17:01 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 19:54 [PATCH] Add contrib/credentials/netrc with GPG support Ted Zlatanov
2013-02-04 21:17 ` Jeff King
2013-02-04 21:32   ` Ted Zlatanov
2013-02-04 21:44   ` [PATCH] Add contrib/credentials/netrc with GPG support, try #2 Ted Zlatanov
2013-02-04 22:56     ` Junio C Hamano
2013-02-04 23:23       ` Jeff King
2013-02-04 23:36         ` Junio C Hamano
2013-02-04 23:42         ` Ted Zlatanov
2013-02-04 23:28       ` [PATCHv3] Add contrib/credentials/netrc with GPG support Ted Zlatanov
2013-02-04 23:31       ` [PATCH] Add contrib/credentials/netrc with GPG support, try #2 Ted Zlatanov
2013-02-04 23:40         ` Junio C Hamano
2013-02-04 23:54           ` Ted Zlatanov
2013-02-05  0:15             ` Junio C Hamano
2013-02-05 13:39               ` Ted Zlatanov
2013-02-05 16:07                 ` Junio C Hamano
2013-02-05 16:18                   ` Junio C Hamano
2013-02-05 16:15     ` Junio C Hamano
2013-02-05 17:01       ` Ted Zlatanov [this message]
2013-02-05 18:55         ` [PATCHv4] Add contrib/credentials/netrc with GPG support Ted Zlatanov
2013-02-05 19:53           ` Junio C Hamano
2013-02-05 20:47             ` Ted Zlatanov
2013-02-05 22:09               ` Junio C Hamano
2013-02-05 22:30                 ` Ted Zlatanov
2013-02-05 20:55             ` [PATCHv5] " Ted Zlatanov
2013-02-05 22:24               ` Junio C Hamano
2013-02-05 23:58                 ` Junio C Hamano
2013-02-06  0:38                   ` [PATCHv6] " Ted Zlatanov
2013-02-07 23:52                     ` Junio C Hamano
2013-02-08  1:53                       ` Ted Zlatanov
2013-02-08  6:15                         ` Junio C Hamano
2013-02-08  6:18                     ` Jeff King
2013-02-25 16:24                       ` Ted Zlatanov
2013-02-25 15:49                     ` [PATCH v7] " Ted Zlatanov
2013-02-06  0:34                 ` [PATCHv5] " Ted Zlatanov
2013-02-05 19:47         ` [PATCH] Add contrib/credentials/netrc with GPG support, try #2 Junio C Hamano
2013-02-05 20:03           ` Ted Zlatanov
2013-02-05 20:23             ` Junio C Hamano
2013-02-05 21:00               ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3qmr8yc.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.