diff --git a/contrib/win32/openssh/Win32-OpenSSH.VC.db b/contrib/win32/openssh/Win32-OpenSSH.VC.db index 2b7ed30..abc8e44 100644 Binary files a/contrib/win32/openssh/Win32-OpenSSH.VC.db and b/contrib/win32/openssh/Win32-OpenSSH.VC.db differ diff --git a/contrib/win32/win32compat/pwd.c b/contrib/win32/win32compat/pwd.c index e5c9593..4e8242a 100644 --- a/contrib/win32/win32compat/pwd.c +++ b/contrib/win32/win32compat/pwd.c @@ -33,6 +33,7 @@ #include #include #include +#include #define SECURITY_WIN32 #include #include "inc\pwd.h" @@ -70,6 +71,7 @@ get_passwd(const char *user_utf8, LPWSTR user_sid) { wchar_t reg_path[MAX_PATH], profile_home[MAX_PATH]; HKEY reg_key = 0; int tmp_len = MAX_PATH; + PDOMAIN_CONTROLLER_INFOW pdc = NULL; errno = 0; @@ -98,12 +100,26 @@ get_passwd(const char *user_utf8, LPWSTR user_sid) { } if (user_sid == NULL) { - if (NetUserGetInfo(udom_utf16, uname_utf16, 23, &user_info) != NERR_Success || + if (NetUserGetInfo(udom_utf16, uname_utf16, 23, &user_info) != NERR_Success) { + if (DsGetDcNameW(NULL, udom_utf16, NULL, NULL, DS_DIRECTORY_SERVICE_PREFERRED, &pdc) == ERROR_SUCCESS) { + if (NetUserGetInfo(pdc->DomainControllerName, uname_utf16, 23, &user_info) != NERR_Success || ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) { errno = ENOMEM; //?? goto done; + } } - user_sid = user_sid_local; + else { + errno = ENOMEM; //?? + goto done; + } + } + else { + if (ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) { + errno = ENOMEM; //?? + goto done; + } + } + user_sid = user_sid_local; } if (swprintf(reg_path, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\%ls", user_sid) == MAX_PATH || @@ -135,6 +151,8 @@ done: LocalFree(user_sid_local); if (reg_key) RegCloseKey(reg_key); + if (pdc) + NetApiBufferFree(pdc); return ret; } diff --git a/scp.c b/scp.c index 5d17447..38aed10 100644 --- a/scp.c +++ b/scp.c @@ -1135,15 +1135,18 @@ main(int argc, char **argv) throughlocal = 1; break; case 'o': - case 'c': + addargs(&remote_remote_args, "-%c", ch); + addargs(&remote_remote_args, "%s", optarg); + addargs(&args, "-%c", ch); + addargs(&args, "%s", optarg); + break; + case 'c': addargs(&remote_remote_args, "-%c", ch); addargs(&remote_remote_args, "%s", optarg); addargs(&args, "-%c", ch); addargs(&args, "%s", optarg); - cipher = malloc(strlen(optarg) + 1); - if (cipher) - strcpy(cipher, optarg); + cipher = xstrdup(optarg);; break; case 'i': addargs(&remote_remote_args, "-%c", ch); @@ -1151,9 +1154,7 @@ main(int argc, char **argv) addargs(&args, "-%c", ch); addargs(&args, "%s", optarg); - identity = malloc(strlen(optarg) + 1); - if (identity) - strcpy(identity, optarg); + identity = xstrdup(optarg);; break; case 'F': addargs(&remote_remote_args, "-%c", ch); @@ -1161,9 +1162,7 @@ main(int argc, char **argv) addargs(&args, "-%c", ch); addargs(&args, "%s", optarg); - ssh_config = malloc(strlen(optarg) + 1); - if (ssh_config) - strcpy(ssh_config, optarg); + ssh_config = xstrdup(optarg);; break; case 'P': addargs(&remote_remote_args, "-p"); @@ -1171,9 +1170,7 @@ main(int argc, char **argv) addargs(&args, "-p"); addargs(&args, "%s", optarg); - port = malloc(strlen(optarg) + 1); - if (port) - strcpy(port, optarg); + port = xstrdup(optarg);; break; case 'B': addargs(&remote_remote_args, "\"-oBatchmode yes\""); @@ -1361,7 +1358,7 @@ toremote(char *targ, int argc, char **argv) return; } - for (i = 0; i < argc - 1; i++) { + for (i = 0; i < argc - 1; i++) { src = colon(argv[i]); if (src && throughlocal) { /* extended remote to remote */ *src++ = 0;