mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
Merge pull request #1032 from urbit/cherry-pick-33cd4b7-to-release-candidate
Disable terminal echo on passcode entry
This commit is contained in:
commit
3a8fcdb818
18
vere/sist.c
18
vere/sist.c
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user