mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 14:21:34 +03:00
Merge pull request #1026 from jglukasik/hide-passcode-pr
Disable terminal echo on passcode entry
This commit is contained in:
commit
343ac8d252
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