Merge pull request #1032 from urbit/cherry-pick-33cd4b7-to-release-candidate

Disable terminal echo on passcode entry
This commit is contained in:
Elliot Glaysher 2018-10-05 14:29:12 -07:00 committed by GitHub
commit 3a8fcdb818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}