mirror of https://github.com/macssh/macssh.git
check that terminal is still opened before asking for password
This commit is contained in:
parent
f0145ce772
commit
db2e4b8916
|
@ -847,29 +847,36 @@ char *getpass( const char *prompt )
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
LockDialog();
|
LockDialog();
|
||||||
context->_pindex = index;
|
/* may need to reload the window... */
|
||||||
if ( gApplicationPrefs->cachePassphrase && !wind->sshdata.password[0]
|
wind = ssh2_window();
|
||||||
&& getnextcachedpassphrase(cprompt, password, &context->_pindex) ) {
|
if ( wind ) {
|
||||||
UnlockDialog();
|
context->_pindex = index;
|
||||||
return password;
|
if ( gApplicationPrefs->cachePassphrase && !wind->sshdata.password[0]
|
||||||
}
|
&& getnextcachedpassphrase(cprompt, password, &context->_pindex) ) {
|
||||||
if ( wind->sshdata.password[0] ) {
|
UnlockDialog();
|
||||||
memcpy(password, wind->sshdata.password + 1, wind->sshdata.password[0]);
|
return password;
|
||||||
password[wind->sshdata.password[0]] = '\0';
|
}
|
||||||
wind->sshdata.password[0] = '\0';
|
if ( wind->sshdata.password[0] ) {
|
||||||
valid = 1;
|
memcpy(password, wind->sshdata.password + 1, wind->sshdata.password[0]);
|
||||||
} else {
|
password[wind->sshdata.password[0]] = '\0';
|
||||||
ppassword[0] = 0;
|
wind->sshdata.password[0] = '\0';
|
||||||
valid = SSH2PasswordDialog(prompt, ppassword, wind->wind);
|
valid = 1;
|
||||||
|
} else {
|
||||||
|
ppassword[0] = 0;
|
||||||
|
valid = SSH2PasswordDialog(prompt, ppassword, wind->wind);
|
||||||
|
if (valid) {
|
||||||
|
memcpy(password, ppassword + 1, ppassword[0]);
|
||||||
|
password[ppassword[0]] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
memcpy(password, ppassword + 1, ppassword[0]);
|
if ( gApplicationPrefs->cachePassphrase ) {
|
||||||
password[ppassword[0]] = '\0';
|
addcachedpassphrase(context, cprompt, password);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
if ( gApplicationPrefs->cachePassphrase ) {
|
|
||||||
addcachedpassphrase(context, cprompt, password);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// terminal has been closed
|
||||||
|
valid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -883,23 +890,28 @@ char *getpass( const char *prompt )
|
||||||
return context->_kpassword;
|
return context->_kpassword;
|
||||||
}
|
}
|
||||||
LockDialog();
|
LockDialog();
|
||||||
context->_kindex = index;
|
if (wind == ssh2_window()) {
|
||||||
if ( gApplicationPrefs->cachePassphrase
|
context->_kindex = index;
|
||||||
&& getnextcachedpassphrase(prompt, context->_kpassword, &context->_kindex) ) {
|
if ( gApplicationPrefs->cachePassphrase
|
||||||
UnlockDialog();
|
&& getnextcachedpassphrase(prompt, context->_kpassword, &context->_kindex) ) {
|
||||||
return context->_kpassword;
|
UnlockDialog();
|
||||||
}
|
return context->_kpassword;
|
||||||
term = ( wind ) ? wind->wind : NULL;
|
|
||||||
context->_kpassword[0] = 0;
|
|
||||||
valid = SSH2PasswordDialog(prompt, (StringPtr)context->_kpassword, term);
|
|
||||||
if (valid) {
|
|
||||||
plen = context->_kpassword[0];
|
|
||||||
password = (wind != NULL) ? wind->sshdata.currentpass : context->_kpassword;
|
|
||||||
memcpy(password, context->_kpassword + 1, plen);
|
|
||||||
password[plen] = '\0';
|
|
||||||
if ( gApplicationPrefs->cachePassphrase ) {
|
|
||||||
addcachedpassphrase(context, prompt, password);
|
|
||||||
}
|
}
|
||||||
|
term = ( wind ) ? wind->wind : NULL;
|
||||||
|
context->_kpassword[0] = 0;
|
||||||
|
valid = SSH2PasswordDialog(prompt, (StringPtr)context->_kpassword, term);
|
||||||
|
if (valid) {
|
||||||
|
plen = context->_kpassword[0];
|
||||||
|
password = (wind != NULL) ? wind->sshdata.currentpass : context->_kpassword;
|
||||||
|
memcpy(password, context->_kpassword + 1, plen);
|
||||||
|
password[plen] = '\0';
|
||||||
|
if ( gApplicationPrefs->cachePassphrase ) {
|
||||||
|
addcachedpassphrase(context, prompt, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// terminal has been closed
|
||||||
|
valid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnlockDialog();
|
UnlockDialog();
|
||||||
|
|
Loading…
Reference in New Issue