mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +02:00
Minor fixes to agent updates
This commit is contained in:
parent
d6d93e6446
commit
6b7d17dd27
@ -192,8 +192,7 @@ sys_auth_passwd(Authctxt *authctxt, const char *password)
|
|||||||
disable_forwarding();
|
disable_forwarding();
|
||||||
authctxt->force_pwchange = 1;
|
authctxt->force_pwchange = 1;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!expire_checked) {
|
if (!expire_checked) {
|
||||||
expire_checked = 1;
|
expire_checked = 1;
|
||||||
warn_expiry(authctxt, as);
|
warn_expiry(authctxt, as);
|
||||||
|
@ -165,7 +165,7 @@ char *GetHomeDirFromToken(char *userName, HANDLE token)
|
|||||||
RegCloseKey(reg_key);
|
RegCloseKey(reg_key);
|
||||||
|
|
||||||
{ /* retrieve and set env variables. */
|
{ /* retrieve and set env variables. */
|
||||||
/* TODO - Get away with fixed limits and dynamically allocated required memory*/
|
/* TODO - Get away with fixed limits and dynamically allocate required memory, cleanup this logic*/
|
||||||
#define MAX_VALUE_LEN 1000
|
#define MAX_VALUE_LEN 1000
|
||||||
#define MAX_DATA_LEN 2000
|
#define MAX_DATA_LEN 2000
|
||||||
#define MAX_EXPANDED_DATA_LEN 5000
|
#define MAX_EXPANDED_DATA_LEN 5000
|
||||||
@ -176,7 +176,8 @@ char *GetHomeDirFromToken(char *userName, HANDLE token)
|
|||||||
int i;
|
int i;
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
|
||||||
ImpersonateLoggedOnUser(token);
|
if (ImpersonateLoggedOnUser(token) == FALSE)
|
||||||
|
debug("Failed to impersonate user token, %d", GetLastError());
|
||||||
SET_USER_ENV(FOLDERID_LocalAppData, L"LOCALAPPDATA");
|
SET_USER_ENV(FOLDERID_LocalAppData, L"LOCALAPPDATA");
|
||||||
SET_USER_ENV(FOLDERID_Profile, L"USERPROFILE");
|
SET_USER_ENV(FOLDERID_Profile, L"USERPROFILE");
|
||||||
SET_USER_ENV(FOLDERID_RoamingAppData, L"APPDATA");
|
SET_USER_ENV(FOLDERID_RoamingAppData, L"APPDATA");
|
||||||
|
@ -201,7 +201,7 @@ generate_user_token(wchar_t* user) {
|
|||||||
&token,
|
&token,
|
||||||
"as,
|
"as,
|
||||||
&subStatus) != STATUS_SUCCESS) {
|
&subStatus) != STATUS_SUCCESS) {
|
||||||
debug("LsaLogonUser failed");
|
debug("LsaLogonUser failed %d", ret);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,12 +256,16 @@ int process_passwordauth_request(struct sshbuf* request, struct sshbuf* response
|
|||||||
*tmp = L'\0';
|
*tmp = L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogonUserW(userW, domW, pwdW, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &token) == FALSE ||
|
if (LogonUserW(userW, domW, pwdW, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &token) == FALSE) {
|
||||||
(FALSE == GetNamedPipeClientProcessId(con->connection, &client_pid)) ||
|
debug("failed to logon user");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((FALSE == GetNamedPipeClientProcessId(con->connection, &client_pid)) ||
|
||||||
((client_proc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, client_pid)) == NULL) ||
|
((client_proc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, client_pid)) == NULL) ||
|
||||||
(FALSE == DuplicateHandle(GetCurrentProcess(), token, client_proc, &dup_token, TOKEN_QUERY | TOKEN_IMPERSONATE, FALSE, DUPLICATE_SAME_ACCESS)) ||
|
(FALSE == DuplicateHandle(GetCurrentProcess(), token, client_proc, &dup_token, TOKEN_QUERY | TOKEN_IMPERSONATE, FALSE, DUPLICATE_SAME_ACCESS)) ||
|
||||||
(sshbuf_put_u32(response, dup_token) != 0)) {
|
(sshbuf_put_u32(response, dup_token) != 0)) {
|
||||||
debug("failed to authenticate user");
|
debug("failed to duplicate user token");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +167,7 @@ done:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO - move this to common header*/
|
||||||
#define SSH_AGENT_AUTHENTICATE 100
|
#define SSH_AGENT_AUTHENTICATE 100
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user