mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 06:25:35 +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 <LM.h>
|
||||
#include <sddl.h>
|
||||
#include <DsGetDC.h>
|
||||
#define SECURITY_WIN32
|
||||
#include <security.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];
|
||||
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;
|
||||
}
|
||||
|
||||
|
25
scp.c
25
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user