* [PATCH] credential/wincred: include wincred.h
@ 2023-03-25 1:23 M Hickford via GitGitGadget
2023-03-28 12:15 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: M Hickford via GitGitGadget @ 2023-03-25 1:23 UTC (permalink / raw)
To: git
Cc: Johannes Schindelin, Johannes Sixt, Harshil Jani, M Hickford,
M Hickford
From: M Hickford <mirth.hickford@gmail.com>
Delete redundant definitions. Mingw-w64 has wincred.h since 2007 [1].
[1] https://github.com/mingw-w64/mingw-w64/blob/9d937a7f4f766f903c9433044f77bfa97a0bc1d8/mingw-w64-headers/include/wincred.h
Signed-off-by: M Hickford <mirth.hickford@gmail.com>
---
credential/wincred: include wincred.h
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1496%2Fhickford%2Fwincred-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1496/hickford/wincred-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1496
.../wincred/git-credential-wincred.c | 61 +------------------
1 file changed, 1 insertion(+), 60 deletions(-)
diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
index ead6e267c78..6e5a91a7168 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 <wincred.h>
/* common helpers */
@@ -33,64 +34,6 @@ static void *xmalloc(size_t size)
return ret;
}
-/* MinGW doesn't have wincred.h, so we need to define stuff */
-
-typedef struct _CREDENTIAL_ATTRIBUTEW {
- LPWSTR Keyword;
- DWORD Flags;
- DWORD ValueSize;
- LPBYTE Value;
-} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
-
-typedef struct _CREDENTIALW {
- DWORD Flags;
- DWORD Type;
- LPWSTR TargetName;
- LPWSTR Comment;
- FILETIME LastWritten;
- DWORD CredentialBlobSize;
- LPBYTE CredentialBlob;
- DWORD Persist;
- DWORD AttributeCount;
- PCREDENTIAL_ATTRIBUTEW Attributes;
- LPWSTR TargetAlias;
- LPWSTR UserName;
-} CREDENTIALW, *PCREDENTIALW;
-
-#define CRED_TYPE_GENERIC 1
-#define CRED_PERSIST_LOCAL_MACHINE 2
-#define CRED_MAX_ATTRIBUTES 64
-
-typedef BOOL (WINAPI *CredWriteWT)(PCREDENTIALW, DWORD);
-typedef BOOL (WINAPI *CredEnumerateWT)(LPCWSTR, DWORD, DWORD *,
- PCREDENTIALW **);
-typedef VOID (WINAPI *CredFreeT)(PVOID);
-typedef BOOL (WINAPI *CredDeleteWT)(LPCWSTR, DWORD, DWORD);
-
-static HMODULE advapi;
-static CredWriteWT CredWriteW;
-static CredEnumerateWT CredEnumerateW;
-static CredFreeT CredFree;
-static CredDeleteWT CredDeleteW;
-
-static void load_cred_funcs(void)
-{
- /* load DLLs */
- advapi = LoadLibraryExA("advapi32.dll", NULL,
- LOAD_LIBRARY_SEARCH_SYSTEM32);
- if (!advapi)
- die("failed to load advapi32.dll");
-
- /* get function pointers */
- CredWriteW = (CredWriteWT)GetProcAddress(advapi, "CredWriteW");
- CredEnumerateW = (CredEnumerateWT)GetProcAddress(advapi,
- "CredEnumerateW");
- CredFree = (CredFreeT)GetProcAddress(advapi, "CredFree");
- CredDeleteW = (CredDeleteWT)GetProcAddress(advapi, "CredDeleteW");
- if (!CredWriteW || !CredEnumerateW || !CredFree || !CredDeleteW)
- die("failed to load functions");
-}
-
static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
static void write_item(const char *what, LPCWSTR wbuf, int wlen)
@@ -300,8 +243,6 @@ int main(int argc, char *argv[])
read_credential();
- load_cred_funcs();
-
if (!protocol || !(host || path))
return 0;
base-commit: 27d43aaaf50ef0ae014b88bba294f93658016a2e
--
gitgitgadget
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] credential/wincred: include wincred.h
2023-03-25 1:23 [PATCH] credential/wincred: include wincred.h M Hickford via GitGitGadget
@ 2023-03-28 12:15 ` Johannes Schindelin
2023-03-30 6:04 ` M Hickford
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2023-03-28 12:15 UTC (permalink / raw)
To: M Hickford via GitGitGadget
Cc: git, Johannes Sixt, Harshil Jani, M Hickford, M Hickford
Hi M,
On Sat, 25 Mar 2023, M Hickford via GitGitGadget wrote:
> From: M Hickford <mirth.hickford@gmail.com>
>
> Delete redundant definitions. Mingw-w64 has wincred.h since 2007 [1].
>
> [1] https://github.com/mingw-w64/mingw-w64/blob/9d937a7f4f766f903c9433044f77bfa97a0bc1d8/mingw-w64-headers/include/wincred.h
Sounds good, and the diffstat is nice. But not as nice as it would look if
we retired the `wincred` helper. As I pointed out in
https://lore.kernel.org/git/35e1ebe6-e15b-1712-f030-70ab708740db@gmx.de/,
I'd much rather spend my time on other things than reviewing patches to a
credential helper I consider unsafe.
Ciao,
Johannes
>
> Signed-off-by: M Hickford <mirth.hickford@gmail.com>
> ---
> credential/wincred: include wincred.h
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1496%2Fhickford%2Fwincred-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1496/hickford/wincred-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1496
>
> .../wincred/git-credential-wincred.c | 61 +------------------
> 1 file changed, 1 insertion(+), 60 deletions(-)
>
> diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
> index ead6e267c78..6e5a91a7168 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 <wincred.h>
>
> /* common helpers */
>
> @@ -33,64 +34,6 @@ static void *xmalloc(size_t size)
> return ret;
> }
>
> -/* MinGW doesn't have wincred.h, so we need to define stuff */
> -
> -typedef struct _CREDENTIAL_ATTRIBUTEW {
> - LPWSTR Keyword;
> - DWORD Flags;
> - DWORD ValueSize;
> - LPBYTE Value;
> -} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
> -
> -typedef struct _CREDENTIALW {
> - DWORD Flags;
> - DWORD Type;
> - LPWSTR TargetName;
> - LPWSTR Comment;
> - FILETIME LastWritten;
> - DWORD CredentialBlobSize;
> - LPBYTE CredentialBlob;
> - DWORD Persist;
> - DWORD AttributeCount;
> - PCREDENTIAL_ATTRIBUTEW Attributes;
> - LPWSTR TargetAlias;
> - LPWSTR UserName;
> -} CREDENTIALW, *PCREDENTIALW;
> -
> -#define CRED_TYPE_GENERIC 1
> -#define CRED_PERSIST_LOCAL_MACHINE 2
> -#define CRED_MAX_ATTRIBUTES 64
> -
> -typedef BOOL (WINAPI *CredWriteWT)(PCREDENTIALW, DWORD);
> -typedef BOOL (WINAPI *CredEnumerateWT)(LPCWSTR, DWORD, DWORD *,
> - PCREDENTIALW **);
> -typedef VOID (WINAPI *CredFreeT)(PVOID);
> -typedef BOOL (WINAPI *CredDeleteWT)(LPCWSTR, DWORD, DWORD);
> -
> -static HMODULE advapi;
> -static CredWriteWT CredWriteW;
> -static CredEnumerateWT CredEnumerateW;
> -static CredFreeT CredFree;
> -static CredDeleteWT CredDeleteW;
> -
> -static void load_cred_funcs(void)
> -{
> - /* load DLLs */
> - advapi = LoadLibraryExA("advapi32.dll", NULL,
> - LOAD_LIBRARY_SEARCH_SYSTEM32);
> - if (!advapi)
> - die("failed to load advapi32.dll");
> -
> - /* get function pointers */
> - CredWriteW = (CredWriteWT)GetProcAddress(advapi, "CredWriteW");
> - CredEnumerateW = (CredEnumerateWT)GetProcAddress(advapi,
> - "CredEnumerateW");
> - CredFree = (CredFreeT)GetProcAddress(advapi, "CredFree");
> - CredDeleteW = (CredDeleteWT)GetProcAddress(advapi, "CredDeleteW");
> - if (!CredWriteW || !CredEnumerateW || !CredFree || !CredDeleteW)
> - die("failed to load functions");
> -}
> -
> static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
>
> static void write_item(const char *what, LPCWSTR wbuf, int wlen)
> @@ -300,8 +243,6 @@ int main(int argc, char *argv[])
>
> read_credential();
>
> - load_cred_funcs();
> -
> if (!protocol || !(host || path))
> return 0;
>
>
> base-commit: 27d43aaaf50ef0ae014b88bba294f93658016a2e
> --
> gitgitgadget
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] credential/wincred: include wincred.h
2023-03-28 12:15 ` Johannes Schindelin
@ 2023-03-30 6:04 ` M Hickford
0 siblings, 0 replies; 3+ messages in thread
From: M Hickford @ 2023-03-30 6:04 UTC (permalink / raw)
To: Johannes Schindelin
Cc: M Hickford via GitGitGadget, git, Johannes Sixt, Harshil Jani,
M Hickford
On Tue, 28 Mar 2023 at 13:15, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi M,
>
> On Sat, 25 Mar 2023, M Hickford via GitGitGadget wrote:
>
> > From: M Hickford <mirth.hickford@gmail.com>
> >
> > Delete redundant definitions. Mingw-w64 has wincred.h since 2007 [1].
> >
> > [1] https://github.com/mingw-w64/mingw-w64/blob/9d937a7f4f766f903c9433044f77bfa97a0bc1d8/mingw-w64-headers/include/wincred.h
>
> Sounds good, and the diffstat is nice. But not as nice as it would look if
> we retired the `wincred` helper. As I pointed out in
> https://lore.kernel.org/git/35e1ebe6-e15b-1712-f030-70ab708740db@gmx.de/,
> I'd much rather spend my time on other things than reviewing patches to a
> credential helper I consider unsafe.
Thanks Johannes for your reply. What do you mean by "unsafe"? Not
useful in the modern world of 2FA? Doch! You can use
git-credential-wincred to store OAuth credentials [1].
For storage, both git-credential-wincred and Git Credential Manager
use the same wincred.h CredWrite API [2]. This is surely preferable
to plaintext git-credential-store [3].
[1] https://lore.kernel.org/git/CAGJzqs=D8hmcxJKGCcz-NqEQ+QDYgi_aO02fj59kQoHZgiW3OQ@mail.gmail.com/T/#md6a0bbf7a36801652c16afe6f5c9dbd19914b2a7
[2] https://github.com/git-ecosystem/git-credential-manager/blob/main/src/shared/Core/Interop/Windows/WindowsCredentialManager.cs
[3] https://lore.kernel.org/git/CAGJzqskRYN49SeS8kSEN5-vbB_Jt1QvAV9QhS6zNuKh0u8wxPQ@mail.gmail.com/
>
> Ciao,
> Johannes
>
> >
> > Signed-off-by: M Hickford <mirth.hickford@gmail.com>
> > ---
> > credential/wincred: include wincred.h
> >
> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1496%2Fhickford%2Fwincred-v1
> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1496/hickford/wincred-v1
> > Pull-Request: https://github.com/gitgitgadget/git/pull/1496
> >
> > .../wincred/git-credential-wincred.c | 61 +------------------
> > 1 file changed, 1 insertion(+), 60 deletions(-)
> >
> > diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
> > index ead6e267c78..6e5a91a7168 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 <wincred.h>
> >
> > /* common helpers */
> >
> > @@ -33,64 +34,6 @@ static void *xmalloc(size_t size)
> > return ret;
> > }
> >
> > -/* MinGW doesn't have wincred.h, so we need to define stuff */
> > -
> > -typedef struct _CREDENTIAL_ATTRIBUTEW {
> > - LPWSTR Keyword;
> > - DWORD Flags;
> > - DWORD ValueSize;
> > - LPBYTE Value;
> > -} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
> > -
> > -typedef struct _CREDENTIALW {
> > - DWORD Flags;
> > - DWORD Type;
> > - LPWSTR TargetName;
> > - LPWSTR Comment;
> > - FILETIME LastWritten;
> > - DWORD CredentialBlobSize;
> > - LPBYTE CredentialBlob;
> > - DWORD Persist;
> > - DWORD AttributeCount;
> > - PCREDENTIAL_ATTRIBUTEW Attributes;
> > - LPWSTR TargetAlias;
> > - LPWSTR UserName;
> > -} CREDENTIALW, *PCREDENTIALW;
> > -
> > -#define CRED_TYPE_GENERIC 1
> > -#define CRED_PERSIST_LOCAL_MACHINE 2
> > -#define CRED_MAX_ATTRIBUTES 64
> > -
> > -typedef BOOL (WINAPI *CredWriteWT)(PCREDENTIALW, DWORD);
> > -typedef BOOL (WINAPI *CredEnumerateWT)(LPCWSTR, DWORD, DWORD *,
> > - PCREDENTIALW **);
> > -typedef VOID (WINAPI *CredFreeT)(PVOID);
> > -typedef BOOL (WINAPI *CredDeleteWT)(LPCWSTR, DWORD, DWORD);
> > -
> > -static HMODULE advapi;
> > -static CredWriteWT CredWriteW;
> > -static CredEnumerateWT CredEnumerateW;
> > -static CredFreeT CredFree;
> > -static CredDeleteWT CredDeleteW;
> > -
> > -static void load_cred_funcs(void)
> > -{
> > - /* load DLLs */
> > - advapi = LoadLibraryExA("advapi32.dll", NULL,
> > - LOAD_LIBRARY_SEARCH_SYSTEM32);
> > - if (!advapi)
> > - die("failed to load advapi32.dll");
> > -
> > - /* get function pointers */
> > - CredWriteW = (CredWriteWT)GetProcAddress(advapi, "CredWriteW");
> > - CredEnumerateW = (CredEnumerateWT)GetProcAddress(advapi,
> > - "CredEnumerateW");
> > - CredFree = (CredFreeT)GetProcAddress(advapi, "CredFree");
> > - CredDeleteW = (CredDeleteWT)GetProcAddress(advapi, "CredDeleteW");
> > - if (!CredWriteW || !CredEnumerateW || !CredFree || !CredDeleteW)
> > - die("failed to load functions");
> > -}
> > -
> > static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
> >
> > static void write_item(const char *what, LPCWSTR wbuf, int wlen)
> > @@ -300,8 +243,6 @@ int main(int argc, char *argv[])
> >
> > read_credential();
> >
> > - load_cred_funcs();
> > -
> > if (!protocol || !(host || path))
> > return 0;
> >
> >
> > base-commit: 27d43aaaf50ef0ae014b88bba294f93658016a2e
> > --
> > gitgitgadget
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-30 6:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-25 1:23 [PATCH] credential/wincred: include wincred.h M Hickford via GitGitGadget
2023-03-28 12:15 ` Johannes Schindelin
2023-03-30 6:04 ` M Hickford
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).