Always prompt for password if not provided via commandline.

This fixes several issues where credentials are required
before the connection is carried out. Such as dual
authentication prompts when redirected by load balancer.
This commit is contained in:
Henrik Andersson 2017-08-15 12:37:14 +02:00
parent b25f93c0e6
commit 1aaafc80c0

View File

@ -522,7 +522,7 @@ main(int argc, char *argv[])
char domain[256]; char domain[256];
char shell[256]; char shell[256];
char directory[256]; char directory[256];
RD_BOOL prompt_password, deactivated; RD_BOOL deactivated;
struct passwd *pw; struct passwd *pw;
uint32 flags, ext_disc_reason = 0; uint32 flags, ext_disc_reason = 0;
char *p; char *p;
@ -559,7 +559,6 @@ main(int argc, char *argv[])
flags = RDP_INFO_MOUSE | RDP_INFO_DISABLECTRLALTDEL flags = RDP_INFO_MOUSE | RDP_INFO_DISABLECTRLALTDEL
| RDP_INFO_UNICODE | RDP_INFO_MAXIMIZESHELL | RDP_INFO_ENABLEWINDOWSKEY; | RDP_INFO_UNICODE | RDP_INFO_MAXIMIZESHELL | RDP_INFO_ENABLEWINDOWSKEY;
prompt_password = False;
g_seamless_spawn_cmd[0] = domain[0] = g_password[0] = shell[0] = directory[0] = 0; g_seamless_spawn_cmd[0] = domain[0] = g_password[0] = shell[0] = directory[0] = 0;
g_embed_wnd = 0; g_embed_wnd = 0;
@ -599,19 +598,16 @@ main(int argc, char *argv[])
break; break;
case 'p': case 'p':
if ((optarg[0] == '-') && (optarg[1] == 0)) if ((optarg[0] != '-') && (optarg[1] != 0))
{ {
prompt_password = True; STRNCPY(g_password, optarg, sizeof(g_password));
break; flags |= RDP_INFO_AUTOLOGON;
/* try to overwrite argument so it won't appear in ps */
p = optarg;
while (*p)
*(p++) = 'X';
} }
STRNCPY(g_password, optarg, sizeof(g_password));
flags |= RDP_INFO_AUTOLOGON;
/* try to overwrite argument so it won't appear in ps */
p = optarg;
while (*p)
*(p++) = 'X';
break; break;
#ifdef WITH_SCARD #ifdef WITH_SCARD
case 'i': case 'i':
@ -1067,9 +1063,19 @@ main(int argc, char *argv[])
if (locale) if (locale)
xfree(locale); xfree(locale);
/* If no password provided at this point, prompt for password / pin */
if (prompt_password && read_password(g_password, sizeof(g_password))) if (!g_password[0])
flags |= RDP_INFO_AUTOLOGON; {
if (read_password(g_password, sizeof(g_password)))
{
flags |= RDP_INFO_AUTOLOGON;
}
else
{
logger(Core, Error, "Failed to read password or pin from stdin");
return EX_OSERR;
}
}
if (g_title[0] == 0) if (g_title[0] == 0)
{ {