Disable terminal echo on passcode entry

This commit is contained in:
Joseph Lukasik 2018-09-26 22:24:50 -07:00
parent 76720288d3
commit 33cd4b7ebf

View File

@ -295,14 +295,28 @@ _sist_cask(c3_c* dir_c, u3_noun nun)
{
c3_c paw_c[60];
u3_noun key;
u3_utty* uty_u = calloc(1, sizeof(u3_utty));
uty_u->fid_i = 0;
uH;
// disable terminal echo when typing in passcode
if ( 0 != tcgetattr(uty_u->fid_i, &uty_u->bak_u) ) {
c3_assert(!"init-tcgetattr");
}
uty_u->raw_u = uty_u->bak_u;
uty_u->raw_u.c_lflag &= ~ECHO;
if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->raw_u) ) {
c3_assert(!"init-tcsetattr");
}
while ( 1 ) {
printf("passcode for %s%s? ~", dir_c, (c3y == nun) ? " [none]" : "");
paw_c[0] = 0;
c3_fpurge(stdin);
fgets(paw_c, 59, stdin);
printf("\n");
if ( '\n' == paw_c[0] ) {
if ( c3y == nun ) {
@ -334,6 +348,10 @@ _sist_cask(c3_c* dir_c, u3_noun nun)
break;
}
}
if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) {
c3_assert(!"init-tcsetattr");
}
free(uty_u);
uL(0);
return key;
}