Skip to content

Commit 4d5efaf

Browse files
niiksergiou87
andcommitted
Create credential helper trampoline, send stdin
Co-Authored-By: Sergio Padrino <[email protected]>
1 parent f807bd7 commit 4d5efaf

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

binding.gyp

+18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@
5555
}]
5656
]
5757
},
58+
{
59+
'target_name': 'desktop-credential-helper-trampoline',
60+
'type': 'executable',
61+
'defines': [
62+
'CREDENTIAL_HELPER'
63+
],
64+
'sources': [
65+
'src/desktop-trampoline.c',
66+
'src/socket.c'
67+
],
68+
'conditions': [
69+
['OS=="win"', {
70+
'link_settings': {
71+
'libraries': [ 'Ws2_32.lib' ]
72+
}
73+
}]
74+
]
75+
},
5876
{
5977
'target_name': 'ssh-wrapper',
6078
'type': 'executable',

src/desktop-trampoline.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
102102
WRITE_STRING_OR_EXIT("environment variable", validEnvVars[idx]);
103103
}
104104

105-
// TODO: send stdin stuff?
105+
char stdinBuffer[BUFFER_LENGTH + 1];
106+
int stdinBytes = 0;
107+
108+
#ifdef CREDENTIAL_HELPER
109+
stdinBytes = fread(stdinBuffer, sizeof(char), BUFFER_LENGTH, stdin);
110+
#endif
111+
112+
stdinBuffer[stdinBytes] = '\0';
113+
WRITE_STRING_OR_EXIT("stdin", stdinBuffer);
106114

107115
char buffer[BUFFER_LENGTH + 1];
108116
size_t totalBytesRead = 0;
@@ -129,6 +137,13 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
129137
}
130138

131139
int main(int argc, char **argv, char **envp) {
140+
141+
#ifdef CREDENTIAL_HELPER
142+
setenv("DESKTOP_TRAMPOLINE_IDENTIFIER", "CREDENTIALHELPER");
143+
#elif
144+
setenv("DESKTOP_TRAMPOLINE_IDENTIFIER", "ASKPASS");
145+
#endif
146+
132147
if (initializeNetwork() != 0) {
133148
return 1;
134149
}

0 commit comments

Comments
 (0)