Skip to content

Commit 473841c

Browse files
committed
5-8 C1
1 parent 4c0e2c2 commit 473841c

File tree

9 files changed

+116
-29
lines changed

9 files changed

+116
-29
lines changed

authfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ssh_get_authentication_socket(int *fdp)
105105
}
106106

107107
HANDLE h = CreateFile(
108-
"\\\\.\\pipe\\ssh-agent", // pipe name
108+
"\\\\.\\pipe\\ssh-keyagent", // pipe name
109109
GENERIC_READ | // read and write access
110110
GENERIC_WRITE,
111111
0, // no sharing

contrib/win32/openssh/Win32-OpenSSH.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh", "ssh.vcxproj", "{74E69D5E-A1EF-46EA-9173-19A412774104}"
77
ProjectSection(ProjectDependencies) = postProject
@@ -89,6 +89,7 @@ EndProject
8989
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-add", "ssh-add.vcxproj", "{029797FF-C986-43DE-95CD-2E771E86AEBC}"
9090
ProjectSection(ProjectDependencies) = postProject
9191
{05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7}
92+
{8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4}
9293
{DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174}
9394
{0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0}
9495
{8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0}

contrib/win32/openssh/ssh-agent.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@
206206
<ClCompile Include="..\..\..\servconf.c" />
207207
<ClCompile Include="..\win32compat\ssh-agent\agent-main.c" />
208208
<ClCompile Include="..\win32compat\ssh-agent\agent.c" />
209+
<ClCompile Include="..\win32compat\ssh-agent\authagent-request.c" />
209210
<ClCompile Include="..\win32compat\ssh-agent\config.c" />
210211
<ClCompile Include="..\win32compat\ssh-agent\connection.c" />
211-
<ClCompile Include="..\win32compat\ssh-agent\agent-request.c" />
212+
<ClCompile Include="..\win32compat\ssh-agent\keyagent-request.c" />
213+
<ClCompile Include="..\win32compat\ssh-agent\pubkeyagent-request.c" />
212214
</ItemGroup>
213215
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
214216
<ImportGroup Label="ExtensionTargets">

contrib/win32/win32compat/ssh-agent/agent-request.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ typedef unsigned __int64 u_int64_t;
1111
#include "digest.h"
1212

1313

14-
int process_add_identity(struct sshbuf*, struct sshbuf*, struct agent_connection*);
15-
int process_request_identities(struct sshbuf*, struct sshbuf*, struct agent_connection*);
16-
int process_sign_request(struct sshbuf*, struct sshbuf*, struct agent_connection*);
14+
int process_keyagent_request(struct sshbuf*, struct sshbuf*, struct agent_connection*);
15+
int process_pubkeyagent_request(struct sshbuf*, struct sshbuf*, struct agent_connection*);
16+
int process_authagent_request(struct sshbuf*, struct sshbuf*, struct agent_connection*);

contrib/win32/win32compat/ssh-agent/agent.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@
2828
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2929
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
31-
#include "agent.h"
32-
#define AGENT_PIPE_ID L"\\\\.\\pipe\\ssh-agent"
31+
#include "agent.h"s
3332
#define BUFSIZE 5 * 1024
3433

3534
static HANDLE ioc_port = NULL;
3635
static BOOL debug_mode = FALSE;
3736

38-
#define NUM_LISTENERS 1
39-
#define KEY_AGENT_PIPE_ID L"\\\\.\\pipe\\ssh-agent"
37+
#define NUM_LISTENERS 3
38+
#define KEY_AGENT_PIPE_ID L"\\\\.\\pipe\\ssh-keyagent"
39+
#define PUBKEY_AGENT_PIPE_ID L"\\\\.\\pipe\\ssh-pubkeyagent"
40+
#define AUTH_AGENT_PIPE_ID L"\\\\.\\pipe\\ssh-authagent"
4041

41-
static wchar_t *pipe_ids[NUM_LISTENERS] = { KEY_AGENT_PIPE_ID };
42-
static enum agent_type types[NUM_LISTENERS] = { KEY_AGENT };
42+
static wchar_t *pipe_ids[NUM_LISTENERS] = { KEY_AGENT_PIPE_ID, PUBKEY_AGENT_PIPE_ID, AUTH_AGENT_PIPE_ID };
43+
static enum agent_type types[NUM_LISTENERS] = { KEY_AGENT, PUBKEY_AGENT, PUBKEY_AUTH_AGENT};
4344
HANDLE event_stop_agent;
4445

4546
struct listener {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Author: Manoj Ampalam <[email protected]>
3+
* ssh-agent implementation on Windows
4+
*
5+
* Copyright (c) 2015 Microsoft Corp.
6+
* All rights reserved
7+
*
8+
* Microsoft openssh win32 port
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in the
18+
* documentation and/or other materials provided with the distribution.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#include "agent.h"
33+
#include "agent-request.h"
34+
35+
int process_authagent_request(struct sshbuf* request, struct sshbuf* response, struct agent_connection* con) {
36+
return -1;
37+
}

contrib/win32/win32compat/ssh-agent/connection.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ static int
119119
process_request(struct agent_connection* con) {
120120
int r;
121121
struct sshbuf *request = NULL, *response = NULL;
122-
u_char type;
123122

124123
request = sshbuf_from(con->io_buf.buf, con->io_buf.num_bytes);
125124
response = sshbuf_new();
@@ -128,23 +127,14 @@ process_request(struct agent_connection* con) {
128127
goto done;
129128
}
130129

131-
if ((r = sshbuf_get_u8(request, &type)) != 0)
132-
goto done;
133-
134-
switch (type) {
135-
case SSH2_AGENTC_ADD_IDENTITY:
136-
r = process_add_identity(request, response, con);
137-
break;
138-
case SSH2_AGENTC_REQUEST_IDENTITIES:
139-
r = process_request_identities(request, response, con);
140-
break;
141-
case SSH2_AGENTC_SIGN_REQUEST:
142-
r = process_sign_request(request, response, con);
143-
break;
144-
default:
130+
if (con->type == KEY_AGENT)
131+
r = process_keyagent_request(request, response, con);
132+
else if (con->type == PUBKEY_AGENT)
133+
r = process_pubkeyagent_request(request, response, con);
134+
else if (con->type == PUBKEY_AUTH_AGENT)
135+
r = process_authagent_request(request, response, con);
136+
else
145137
r = EINVAL;
146-
goto done;
147-
}
148138

149139
done:
150140
if (request)

contrib/win32/win32compat/ssh-agent/agent-request.c renamed to contrib/win32/win32compat/ssh-agent/keyagent-request.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,23 @@ process_request_identities(struct sshbuf* request, struct sshbuf* response, stru
380380
if (sub)
381381
RegCloseKey(sub);
382382
return r;
383+
}
384+
385+
386+
int process_keyagent_request(struct sshbuf* request, struct sshbuf* response, struct agent_connection* con) {
387+
int r;
388+
u_char type;
389+
390+
if ((r = sshbuf_get_u8(request, &type)) != 0)
391+
return r;
392+
switch (type) {
393+
case SSH2_AGENTC_ADD_IDENTITY:
394+
return process_add_identity(request, response, con);
395+
case SSH2_AGENTC_REQUEST_IDENTITIES:
396+
return process_request_identities(request, response, con);
397+
case SSH2_AGENTC_SIGN_REQUEST:
398+
return process_sign_request(request, response, con);
399+
default:
400+
return EINVAL;
401+
}
383402
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Author: Manoj Ampalam <[email protected]>
3+
* ssh-agent implementation on Windows
4+
*
5+
* Copyright (c) 2015 Microsoft Corp.
6+
* All rights reserved
7+
*
8+
* Microsoft openssh win32 port
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in the
18+
* documentation and/or other materials provided with the distribution.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#include "agent.h"
33+
#include "agent-request.h"
34+
35+
int process_pubkeyagent_request(struct sshbuf* request, struct sshbuf* response, struct agent_connection* con) {
36+
return -1;
37+
}

0 commit comments

Comments
 (0)