contrib: add win32 credential-helper
PATCH v2 1/1 contrib: add win32 credential-helper
Since the Windows port of Git expects binary pipes, we need to make sure the helper-end also sets up binary pipes.
Side-step CRLF-issue in test to make it pass.
---
Here's an updated version of my Windows credential-helper.
The most important difference is that it doesn't suck as much as it used to ;)
Basically, I'm now using the attribute-system to store the meta-data for the credentials.
This passes the test for me, and seems to work OK.
contrib/credential/wincred/Makefile | 8 + .../credential/wincred/git-credential-wincred.c | 352 ++++++++++++++++++++ t/lib-credential.sh | 4 + 3 files changed, 364 insertions(+), 0 deletions(-) create mode 100644 contrib/credential/wincred/Makefile create mode 100644 contrib/credential/wincred/git-credential-wincred.c
contrib/credential/wincred/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +all: git-credential-wincred.exe + +CC = gcc +RM = rm -f +CFLAGS = -O2 -Wall + +git-credential-wincred.exe : git-credential-wincred.c + $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
contrib/credential/wincred/git-credential-wincred.c new file +352 -0
352 lines not on this page · raw message
t/lib-credential.sh +4 -0
@@ -8,6 +8,10 @@ check() { read_chunk >expect-stdout && read_chunk >expect-stderr && test-credential "$@" <stdin >stdout 2>stderr && + if test_have_prereq MINGW + then + dos2unix -q stderr + fi && test_cmp expect-stdout stdout && test_cmp expect-stderr stderr }
Signature · 15 lines
1.7.9 -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en
Quoted 1 line · Erik Faye-Lund
Here's an updated version of my Windows credential-helper.
Sorry, I've been traveling and haven't had a chance to look at this in-depth yet. I'll do so next week. In the meantime, I wanted to point out this similar project:
https://github.com/anurse/git-credential-winstore
which somebody else pointed me to a few days ago. I don't know yet if your approaches are the same, or if it would be worth combining efforts or not.
-Peff
Signature · 12 lines
*** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en
Quoted 8 lines · Jeff King
Quoted 1 line · Erik Faye-Lund
Here's an updated version of my Windows credential-helper.
Sorry, I've been traveling and haven't had a chance to look at this in-depth yet. I'll do so next week. In the meantime, I wanted to point out this similar project:
Quoted 5 lines
https://github.com/anurse/git-credential-winstore
which somebody else pointed me to a few days ago. I don't know yet if your approaches are the same, or if it would be worth combining efforts or not.
Yeah, I saw that one a couple of days ago myself.
They use the same credential store, and I actually tried to make sure they can use the same data.
But apart from that, they work quite differently. My credential-helper only does storage, and passes the test-suite. The one you linked to seems to ignore any password being sent to it, and instead prompts the user if it doesn't already have a credential. It also does not seem to support storing credentials for multiple users for a domain/path.
But probably the biggest problem for Git for Windows is that it's written in C#, and we don't have a C# compiler in our tool-chain.
So I don't think there's much I can use from that helper, and I think my helper is in a healthier state. But I'm obviously biased.
Signature · 12 lines
*** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en
Quoted 8 lines · Erik Faye-Lund
Quoted 5 lines
Sorry, I've been traveling and haven't had a chance to look at this in-depth yet. I'll do so next week. In the meantime, I wanted to point out this similar project:
[...]
But probably the biggest problem for Git for Windows is that it's written in C#, and we don't have a C# compiler in our tool-chain.
Yeah, that seems like a big one. I think it would be awesome if msysgit could eventually ship with a credential helper, without people needing to grab something externally.
-Peff
Signature · 12 lines
*** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en
Quoted 9 lines · Erik Faye-Lund
Here's an updated version of my Windows credential-helper.
The most important difference is that it doesn't suck as much as it used to ;)
Basically, I'm now using the attribute-system to store the meta-data for the credentials.
This passes the test for me, and seems to work OK.
This looks much better. As usual, I can't comment on the Windows-y parts, but the credential logic looks good. One minor comment:
contrib/credential/wincred/git-credential-wincred.c line 326
Quoted 5 lines
contrib/credential/wincred/git-credential-wincred.c new file +4
-0+int main (int argc,char *argv[]) +{ +if (!protocol || !host) +return 0 ;
You could have a protocol that does not have a "host" component. Git will produce this for a cached certificate password (which will then always have a "path" field). I don't know if anybody is using it to cache certificate passwords, and I admit that it is not very well tested by me, either. So I'm not sure anybody will actually care.
The credential-store helper uses this logic:
$ sed -n '70,79p' credential-store.c
/*
* Sanity check that what we are storing is actually sensible.
* In particular, we can't make a URL without a protocol field.
* Without either a host or pathname (depending on the scheme),
* we have no primary key. And without a username and password,
* we are not actually storing a credential.
*/
if (!c->protocol || !(c->host || c->path) ||
!c->username || !c->password)
return;I'm pretty sure the OS X helper does not handle certificate passwords at all. It is harder there, because I map directly to native protocol types, and I haven't checked to see whether OS X handles this type. But since you are just storing whatever protocol information git hands you, I think for you it is just a matter of letting it through (and handling the "!host" case when writing).
-Peff
Signature · 12 lines
*** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en
Quoted 41 lines · Jeff King
Quoted 9 lines · Erik Faye-Lund
Here's an updated version of my Windows credential-helper.
The most important difference is that it doesn't suck as much as it used to ;)
Basically, I'm now using the attribute-system to store the meta-data for the credentials.
This passes the test for me, and seems to work OK.
This looks much better. As usual, I can't comment on the Windows-y parts, but the credential logic looks good. One minor comment:
Review
Quoted 5 lines
(quoted diff) +4
-0+int main(int argc, char *argv[]) +{ + if (!protocol || !host) + return 0;You could have a protocol that does not have a "host" component. Git will produce this for a cached certificate password (which will then always have a "path" field). I don't know if anybody is using it to cache certificate passwords, and I admit that it is not very well tested by me, either. So I'm not sure anybody will actually care.
The credential-store helper uses this logic:
$ sed -n '70,79p' credential-store.c /* * Sanity check that what we are storing is actually sensible. * In particular, we can't make a URL without a protocol field. * Without either a host or pathname (depending on the scheme), * we have no primary key. And without a username and password, * we are not actually storing a credential. */ if (!c->protocol || !(c->host || c->path) || !c->username || !c->password) return;
Quoted 3 lines
I'm pretty sure the OS X helper does not handle certificate passwords at all. It is harder there, because I map directly to native protocol types, and I haven't checked to see whether OS X handles this type.
Right. I copied this logic from the OSX helper.
Quoted 4 lines
But
since you are just storing whatever protocol information git hands you, I think for you it is just a matter of letting it through (and handling the "!host" case when writing).
Yeah, I agree. This on top should do it:
(quoted diff) +0 -0
b/contrib/credential/wincred/git-credential-wincred.c index e63575f..cbaec5f 100644
contrib/credential/wincred/git-credential-wincred.c +10 -5
@@ -232,16 +232,20 @@ static void store_credential(void) cred.CredentialBlobSize = auth_buf_size; cred.CredentialBlob = auth_buf; cred.Persist =CRED_PERSIST_LOCAL_MACHINE ; - cred.AttributeCount =2 ; + cred.AttributeCount =1 ; cred.Attributes = attrs; cred.TargetAlias =NULL ; cred.UserName = wusername;write_attr (attrs,L"git_protocol" , protocol); -write_attr (attrs +1 ,L"git_host" , host); + +if (host) { +write_attr (attrs + cred.AttributeCount,L"git_host" , host); + cred.AttributeCount++; + }if (path) { -write_attr (attrs +2 ,L"git_path" , path); +write_attr (attrs + cred.AttributeCount,L"git_path" , path); cred.AttributeCount++; }
@@ -322,7 +326,7 @@ int main(int argc, char *argv[])load_cred_funcs (); -if (!protocol || !host) +if (!protocol || !(host || path))return 0 ;/* prepare 'target', the unique key for the credential */
@@ -333,7 +337,8 @@ int main(int argc, char *argv[])strncat (target_buf, username,sizeof (target_buf));strncat (target_buf,"@" ,sizeof (target_buf)); } -strncat (target_buf, host,sizeof (target_buf)); +if (host) +strncat (target_buf, host,sizeof (target_buf));if (path) {strncat (target_buf,"/" ,sizeof (target_buf));strncat (target_buf, path,sizeof (target_buf));
Signature · 12 lines
*** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en