git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/4] wincred: port to generic credential helper (UNTESTED)

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Aug 30, 2012, 18:27 UTC
Message-ID
<CABPQNSZsXnf2kjcN+Qma8pApjGRF6SD5iJjB2Ow6GuGts0Z=Kg@mail.gmail.com>
In-Reply-To
<1346018649-3002-1-git-send-email-pah@qo.cx>
On Mon, Aug 27, 2012 at 12:04 AM, Philipp A. Hartmann <pah@qo.cx> wrote:
Show 17 quoted lines
> From: "Philipp A. Hartmann" <pah@qo.cx>
>
> This patch is an experiment to port the wincred helper
> to the generic implementation.  As of know, it is
> completely untested.
>
> In addition to porting the helper to the generic API,
> this patch clears up all passwords from memory, which
> reduces the total amount to saved lines.
>
> Signed-off-by: Philipp A. Hartmann <pah@qo.cx>
> ---
>
> The porting was fairly easy, but due to the lack of a testing
> platform, it is completely untested.
>
> Erik: Can you try to have look?
Sorry for the late reply, I'm currently in bed with pneumonia.
But I gave it a quick go, but as-is it's a NACK; a wall of warnings and errors.
But with this patch on top, it seems to at least compile OK:
---8<---
diff --git a/contrib/credential/helper/credential_helper.h
b/contrib/credential/helper/credential_helper.h
index 7e73fc6..13b611e 100644
--- a/contrib/credential/helper/credential_helper.h
+++ b/contrib/credential/helper/credential_helper.h
@@ -125,6 +125,7 @@ static inline char *xstrdup(const char *str)
 	return ret;
 }

+#ifndef NO_STRNDUP
 static inline char *xstrndup(const char *str, size_t len)
 {
 	char *ret = strndup(str,len);
@@ -133,5 +134,6 @@ static inline char *xstrndup(const char *str, size_t len)

 	return ret;
 }
+#endif

 #endif /* CREDENTIAL_HELPER_H_INCLUDED_ */
diff --git a/contrib/credential/wincred/Makefile
b/contrib/credential/wincred/Makefile
index ee7a8ef..3900322 100644
--- a/contrib/credential/wincred/Makefile
+++ b/contrib/credential/wincred/Makefile
@@ -1,9 +1,10 @@
 MAIN:=git-credential-wincred
-all:: $(MAIN)
+all:: $(MAIN).exe

 CC = gcc
 RM = rm -f
 CFLAGS = -O2 -Wall
+CPPFLAGS = -DNO_STRNDUP

 -include ../../../config.mak.autogen
 -include ../../../config.mak
diff --git a/contrib/credential/wincred/git-credential-wincred.c
b/contrib/credential/wincred/git-credential-wincred.c
index 721e59f..e26ba47 100644
--- a/contrib/credential/wincred/git-credential-wincred.c
+++ b/contrib/credential/wincred/git-credential-wincred.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <io.h>
 #include <fcntl.h>
+#include <credential_helper.h>

 /* MinGW doesn't have wincred.h, so we need to define stuff */

@@ -124,9 +125,8 @@ static int prepare_credential(struct credential *c)
 		wusername = utf8_to_utf16_dup(c->username);
 	if (c->password)
 		wpassword = utf8_to_utf16_dup(c->password);
-	if (c->port) {
-		snprintf(port_buf,"%hd",c->port);
-	}
+	if (c->port)
+		snprintf(port_buf, sizeof(port_buf), "%hd", c->port);
 	return EXIT_SUCCESS;
 }

@@ -170,7 +170,7 @@ static int get_credential(struct credential *c)

 	/* search for the first credential that matches username */
 	for (i = 0; i < num_creds; ++i)
-		if (match_cred(creds[i])) {
+		if (match_cred(creds[i], c)) {
 			cred = creds[i];
 			break;
 		}
---8<---

However, I haven't been able to successfully run the tests on the
result. When I did, I got this error:

---8<---
rm: cannot remove `t/trash directory.t0303-credential-external/stderr': Permissi
on denied
rm: cannot remove `t/trash directory.t0303-credential-external/stdout': Permissi
on denied
rm: cannot remove directory `t/trash directory.t0303-credential-external': Direc
tory not empty
---8<---

And I'm not currently feeling up to debugging stuck processes or whatever it is.
Previous: Philipp A. HartmannNext: Junio C Hamano
Message 13 of 16 in “contrib: GnomeKeyring support + generic helper implementation”
  1. contrib: GnomeKeyring support + generic helper implementationPhilipp A. Hartmann, Aug 23, 2012
  2. 1/4 contrib: add credential helper for GnomeKeyringPhilipp A. Hartmann, Aug 23, 2012
  3. 2/4 contrib: add generic credential helperPhilipp A. Hartmann, Aug 23, 2012
  4. 3/4 gnome-keyring: port to generic helper implementationPhilipp A. Hartmann, Aug 23, 2012
  5. 4/4 osxkeychain: port to generic credential helper implementationPhilipp A. Hartmann, Aug 23, 2012
  6. Junio C HamanoAug 24, 2012
  7. Jeff KingAug 24, 2012
  8. Junio C HamanoAug 24, 2012
  9. Junio C HamanoAug 26, 2012
  10. Philipp A. HartmannAug 26, 2012
  11. 5/4 wincred: port to generic credential helper (UNTESTED)Philipp A. Hartmann, Aug 26, 2012
  12. 5/4 wincred: port to generic credential helper (UNTESTED)Philipp A. Hartmann, Aug 26, 2012
  13. Erik Faye-LundAug 30, 2012
  14. Junio C HamanoAug 30, 2012
  15. Erik Faye-LundAug 31, 2012
  16. 5/4 wincred: port to generic credential helperPhilipp A. Hartmann, Sep 1, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.