mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-26 07:25:25 +02:00
Revert "Revert "Fix to domain logon and minor reformats to scp.""
This reverts commit d8f4e799da11964b7c89b1600a5e70079e477a36.
This commit is contained in:
parent
d8f4e799da
commit
18ba20f271
Binary file not shown.
@ -33,6 +33,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <LM.h>
|
#include <LM.h>
|
||||||
#include <sddl.h>
|
#include <sddl.h>
|
||||||
|
#include <DsGetDC.h>
|
||||||
#define SECURITY_WIN32
|
#define SECURITY_WIN32
|
||||||
#include <security.h>
|
#include <security.h>
|
||||||
#include "inc\pwd.h"
|
#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];
|
wchar_t reg_path[MAX_PATH], profile_home[MAX_PATH];
|
||||||
HKEY reg_key = 0;
|
HKEY reg_key = 0;
|
||||||
int tmp_len = MAX_PATH;
|
int tmp_len = MAX_PATH;
|
||||||
|
PDOMAIN_CONTROLLER_INFOW pdc = NULL;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
@ -98,12 +100,26 @@ get_passwd(const char *user_utf8, LPWSTR user_sid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user_sid == NULL) {
|
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) {
|
ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) {
|
||||||
errno = ENOMEM; //??
|
errno = ENOMEM; //??
|
||||||
goto done;
|
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 ||
|
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);
|
LocalFree(user_sid_local);
|
||||||
if (reg_key)
|
if (reg_key)
|
||||||
RegCloseKey(reg_key);
|
RegCloseKey(reg_key);
|
||||||
|
if (pdc)
|
||||||
|
NetApiBufferFree(pdc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
scp.c
25
scp.c
@ -1135,15 +1135,18 @@ main(int argc, char **argv)
|
|||||||
throughlocal = 1;
|
throughlocal = 1;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
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, "-%c", ch);
|
||||||
addargs(&remote_remote_args, "%s", optarg);
|
addargs(&remote_remote_args, "%s", optarg);
|
||||||
addargs(&args, "-%c", ch);
|
addargs(&args, "-%c", ch);
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
cipher = malloc(strlen(optarg) + 1);
|
cipher = xstrdup(optarg);;
|
||||||
if (cipher)
|
|
||||||
strcpy(cipher, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
addargs(&remote_remote_args, "-%c", ch);
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
@ -1151,9 +1154,7 @@ main(int argc, char **argv)
|
|||||||
addargs(&args, "-%c", ch);
|
addargs(&args, "-%c", ch);
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
identity = malloc(strlen(optarg) + 1);
|
identity = xstrdup(optarg);;
|
||||||
if (identity)
|
|
||||||
strcpy(identity, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
addargs(&remote_remote_args, "-%c", ch);
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
@ -1161,9 +1162,7 @@ main(int argc, char **argv)
|
|||||||
addargs(&args, "-%c", ch);
|
addargs(&args, "-%c", ch);
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
ssh_config = malloc(strlen(optarg) + 1);
|
ssh_config = xstrdup(optarg);;
|
||||||
if (ssh_config)
|
|
||||||
strcpy(ssh_config, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
addargs(&remote_remote_args, "-p");
|
addargs(&remote_remote_args, "-p");
|
||||||
@ -1171,9 +1170,7 @@ main(int argc, char **argv)
|
|||||||
addargs(&args, "-p");
|
addargs(&args, "-p");
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
port = malloc(strlen(optarg) + 1);
|
port = xstrdup(optarg);;
|
||||||
if (port)
|
|
||||||
strcpy(port, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
addargs(&remote_remote_args, "\"-oBatchmode yes\"");
|
addargs(&remote_remote_args, "\"-oBatchmode yes\"");
|
||||||
@ -1361,7 +1358,7 @@ toremote(char *targ, int argc, char **argv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc - 1; i++) {
|
for (i = 0; i < argc - 1; i++) {
|
||||||
src = colon(argv[i]);
|
src = colon(argv[i]);
|
||||||
if (src && throughlocal) { /* extended remote to remote */
|
if (src && throughlocal) { /* extended remote to remote */
|
||||||
*src++ = 0;
|
*src++ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user