Minor fixes to agent updates

This commit is contained in:
Manoj Ampalam 2016-09-21 13:49:57 -07:00
parent d6d93e6446
commit 6b7d17dd27
4 changed files with 25 additions and 20 deletions

View File

@ -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);

View File

@ -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");

View File

@ -201,7 +201,7 @@ generate_user_token(wchar_t* user) {
&token, &token,
&quotas, &quotas,
&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;
} }

View File

@ -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