2
0

Create credential helper trampoline, send stdin

Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
This commit is contained in:
Markus Olsson
2024-06-03 11:20:19 +02:00
parent f807bd740f
commit 4d5efafe2b
2 changed files with 34 additions and 1 deletions

View File

@@ -55,6 +55,24 @@
}]
]
},
{
'target_name': 'desktop-credential-helper-trampoline',
'type': 'executable',
'defines': [
'CREDENTIAL_HELPER'
],
'sources': [
'src/desktop-trampoline.c',
'src/socket.c'
],
'conditions': [
['OS=="win"', {
'link_settings': {
'libraries': [ 'Ws2_32.lib' ]
}
}]
]
},
{
'target_name': 'ssh-wrapper',
'type': 'executable',

View File

@@ -102,7 +102,15 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
WRITE_STRING_OR_EXIT("environment variable", validEnvVars[idx]);
}
// TODO: send stdin stuff?
char stdinBuffer[BUFFER_LENGTH + 1];
int stdinBytes = 0;
#ifdef CREDENTIAL_HELPER
stdinBytes = fread(stdinBuffer, sizeof(char), BUFFER_LENGTH, stdin);
#endif
stdinBuffer[stdinBytes] = '\0';
WRITE_STRING_OR_EXIT("stdin", stdinBuffer);
char buffer[BUFFER_LENGTH + 1];
size_t totalBytesRead = 0;
@@ -129,6 +137,13 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
}
int main(int argc, char **argv, char **envp) {
#ifdef CREDENTIAL_HELPER
setenv("DESKTOP_TRAMPOLINE_IDENTIFIER", "CREDENTIALHELPER");
#elif
setenv("DESKTOP_TRAMPOLINE_IDENTIFIER", "ASKPASS");
#endif
if (initializeNetwork() != 0) {
return 1;
}