Skip to content

Commit 03c8d96

Browse files
committed
5-14 C3
1 parent 5ed50c2 commit 03c8d96

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

contrib/win32/openssh/ssh-agent.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ssh-agent\connection.c" />
212212
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ssh-agent\keyagent-request.c" />
213213
<ClCompile Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\ssh-agent\pubkeyagent-request.c" />
214+
<ClCompile Include="..\..\..\auth-options.c" />
215+
<ClCompile Include="..\..\..\auth2-pubkey.c" />
214216
</ItemGroup>
215217
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
216218
<ImportGroup Label="ExtensionTargets">

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ static int use_privsep = -1;
5050
Buffer cfg;
5151
ServerOptions options;
5252
struct passwd *privsep_pw = NULL;
53-
char *forced_command = NULL;
5453
static char *config_file_name = _PATH_SERVER_CONFIG_FILE;
5554

5655
int auth2_methods_valid(const char * c, int i) {
@@ -107,4 +106,18 @@ int load_config() {
107106

108107
int config_log_level() {
109108
return options.log_level;
109+
}
110+
111+
int pubkey_allowed(struct sshkey* pubkey, wchar_t* wuser, wchar_t* wuser_home) {
112+
struct passwd pw;
113+
char user[256], user_home[MAX_PATH];
114+
memset(&pw, 0, sizeof(pw));
115+
116+
if (WideCharToMultiByte(CP_UTF8, 0, wuser, -1, user, 256, NULL, NULL) == 0)
117+
return 0;
118+
/* BUG - pw structure is assumed to be filled with unicode strings by expand_authorized_keys()*/
119+
//WideCharToMultiByte(CP_UTF8, 0, wuser_home, -1, user_home, MAX_PATH, NULL, NULL);
120+
pw.pw_dir = wuser_home;
121+
pw.pw_name = user;
122+
return user_key_allowed(&pw, pubkey, 1);
110123
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32-
#define WIN32_NO_STATUS
32+
#define UMDF_USING_NTSTATUS
3333
#include <Windows.h>
34-
#undef WIN32_NO_STATUS
3534
#include <Ntsecapi.h>
3635
#include <ntstatus.h>
36+
#include <Shlobj.h>
3737
#include "agent.h"
3838
#include "agent-request.h"
3939
#include "key.h"
@@ -170,7 +170,9 @@ int process_authagent_request(struct sshbuf* request, struct sshbuf* response, s
170170
}
171171

172172
if (key_verify(key, sig, sig_len, blob, blob_len) != 1 ||
173-
(token = generate_user_token(wuser)) == 0 ||
173+
(token = generate_user_token(wuser)) == 0 ||
174+
SHGetKnownFolderPath(&FOLDERID_Profile, 0, token, &wuser_home) != S_OK ||
175+
pubkey_allowed(key, wuser, wuser_home) != 1 ||
174176
(FALSE == GetNamedPipeClientProcessId(con->connection, &client_pid)) ||
175177
( (client_proc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, client_pid)) == NULL) ||
176178
(FALSE == DuplicateHandle(GetCurrentProcess(), token, client_proc, &dup_token, TOKEN_QUERY | TOKEN_IMPERSONATE, FALSE, DUPLICATE_SAME_ACCESS)) ||

0 commit comments

Comments
 (0)