Revert "Fix to domain logon and minor reformats to scp."

This reverts commit d4ff0731d327cec4718a4b7a739d270581e60533.
This commit is contained in:
Ray Hayes 2016-10-25 14:41:34 -07:00
parent d4ff0731d3
commit d8f4e799da
3 changed files with 16 additions and 31 deletions

View File

@ -33,7 +33,6 @@
#include <stdio.h>
#include <LM.h>
#include <sddl.h>
#include <DsGetDC.h>
#define SECURITY_WIN32
#include <security.h>
#include "inc\pwd.h"
@ -71,7 +70,6 @@ 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;
@ -100,26 +98,12 @@ 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 (DsGetDcNameW(NULL, udom_utf16, NULL, NULL, DS_DIRECTORY_SERVICE_PREFERRED, &pdc) == ERROR_SUCCESS) {
if (NetUserGetInfo(pdc->DomainControllerName, uname_utf16, 23, &user_info) != NERR_Success ||
if (NetUserGetInfo(udom_utf16, uname_utf16, 23, &user_info) != NERR_Success ||
ConvertSidToStringSidW(((LPUSER_INFO_23)user_info)->usri23_user_sid, &user_sid_local) == FALSE) {
errno = ENOMEM; //??
goto done;
}
}
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;
user_sid = user_sid_local;
}
if (swprintf(reg_path, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\%ls", user_sid) == MAX_PATH ||
@ -151,8 +135,6 @@ done:
LocalFree(user_sid_local);
if (reg_key)
RegCloseKey(reg_key);
if (pdc)
NetApiBufferFree(pdc);
return ret;
}

25
scp.c
View File

@ -1135,18 +1135,15 @@ main(int argc, char **argv)
throughlocal = 1;
break;
case 'o':
addargs(&remote_remote_args, "-%c", ch);
addargs(&remote_remote_args, "%s", optarg);
addargs(&args, "-%c", ch);
addargs(&args, "%s", optarg);
break;
case 'c':
case 'c':
addargs(&remote_remote_args, "-%c", ch);
addargs(&remote_remote_args, "%s", optarg);
addargs(&args, "-%c", ch);
addargs(&args, "%s", optarg);
cipher = xstrdup(optarg);;
cipher = malloc(strlen(optarg) + 1);
if (cipher)
strcpy(cipher, optarg);
break;
case 'i':
addargs(&remote_remote_args, "-%c", ch);
@ -1154,7 +1151,9 @@ main(int argc, char **argv)
addargs(&args, "-%c", ch);
addargs(&args, "%s", optarg);
identity = xstrdup(optarg);;
identity = malloc(strlen(optarg) + 1);
if (identity)
strcpy(identity, optarg);
break;
case 'F':
addargs(&remote_remote_args, "-%c", ch);
@ -1162,7 +1161,9 @@ main(int argc, char **argv)
addargs(&args, "-%c", ch);
addargs(&args, "%s", optarg);
ssh_config = xstrdup(optarg);;
ssh_config = malloc(strlen(optarg) + 1);
if (ssh_config)
strcpy(ssh_config, optarg);
break;
case 'P':
addargs(&remote_remote_args, "-p");
@ -1170,7 +1171,9 @@ main(int argc, char **argv)
addargs(&args, "-p");
addargs(&args, "%s", optarg);
port = xstrdup(optarg);;
port = malloc(strlen(optarg) + 1);
if (port)
strcpy(port, optarg);
break;
case 'B':
addargs(&remote_remote_args, "\"-oBatchmode yes\"");
@ -1358,7 +1361,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;