Skip to content

Commit 5b06ebb

Browse files
committed
sftp-server.exe first code drop that works
sftp-server.exe code modified to work in Windows as NoMachine never finished it to work. I/O handling to work as a subsystem and openssh7.1p1 sshbuf_new() buffer system code had to be used. sshd_config file need location of sftp subsystem to be specified.
1 parent df2ea38 commit 5b06ebb

File tree

4 files changed

+115
-153
lines changed

4 files changed

+115
-153
lines changed

contrib/win32/win32compat/pwd.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static char pw_gecos[UNLEN + 1] = {'\0'};
9393
static char pw_username[UNLEN + 1] = {'\0'};
9494
static char pw_passwd[UNLEN + 1] = {'\0'};
9595
static wchar_t pw_homedir[MAX_PATH] = {L'\0'};
96+
static char pw_homedir_ascii[MAX_PATH] = {'\0'};
9697
static char pw_password[MAX_PATH] = {'\0'};
9798
static char pw_shellpath[MAX_PATH] = {'\0'};
9899

@@ -226,7 +227,7 @@ struct passwd *getpwuid(uid_t uid)
226227
pw.pw_passwd = pw_password;
227228
pw.pw_gecos = pw_gecos;
228229
pw.pw_shell = pw_shellpath;
229-
pw.pw_dir = pw_homedir;
230+
pw.pw_dir = pw_homedir_ascii;
230231

231232
/*
232233
* Get the current user's name.
@@ -275,19 +276,31 @@ struct passwd *getpwuid(uid_t uid)
275276

276277
debug3("getpwuid: homedir [%ls]", homedir_w);
277278

278-
wcsncpy(pw_homedir, homedir_w, sizeof(pw_homedir));
279-
279+
//wcsncpy(pw_homedir, homedir_w, sizeof(pw_homedir));
280+
// convert to ascii from widechar(unicode)
281+
int rc = WideCharToMultiByte( CP_UTF8, // UTF8/ANSI Code Page
282+
0, // No special handling of unmapped chars
283+
homedir_w, // wide-character string to be converted
284+
-1, // Unicode src str len, -1 means calc it
285+
pw_homedir_ascii,
286+
sizeof(pw_homedir_ascii),
287+
NULL, NULL ); // Unrepresented char replacement - Use Default
288+
280289
free(homedir_w);
281290

291+
if ( rc == 0 ) {
292+
debug3("Could not convert homedirectory [%ls]from unicode to utf8", homedir_w);
293+
}
294+
282295
/*
283296
* Point to the username static variable.
284297
*/
285298

286-
pw.pw_name = pw_username;
287-
pw.pw_passwd = pw_passwd;
288-
pw.pw_gecos = pw_gecos;
289-
pw.pw_shell = pw_shellpath;
290-
pw.pw_dir = pw_homedir;
299+
//pw.pw_name = pw_username;
300+
//pw.pw_passwd = pw_passwd;
301+
//pw.pw_gecos = pw_gecos;
302+
//pw.pw_shell = pw_shellpath;
303+
//pw.pw_dir = pw_homedir;
291304

292305
return &pw;
293306
}

contrib/win32/win32compat/ssh_config/sshd_config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ AuthorizedKeysFile .ssh/authorized_keys
112112
#Banner none
113113

114114
# override default of no subsystems
115-
Subsystem sftp /usr/libexec/sftp-server
115+
#Subsystem sftp /usr/libexec/sftp-server
116+
Subsystem sftp /win32openssh/bin/sftp-server.exe
116117

117118
# Example of overriding settings on a per-user basis
118119
#Match User anoncvs

0 commit comments

Comments
 (0)