8 char *getpass(const char *prompt
)
13 static char password
[128];
15 if ((fd
= open("/dev/tty", O_RDWR
|O_NOCTTY
|O_CLOEXEC
)) < 0) return 0;
19 t
.c_lflag
&= ~(ECHO
|ISIG
);
21 t
.c_iflag
&= ~(INLCR
|IGNCR
);
23 tcsetattr(fd
, TCSAFLUSH
, &t
);
26 dprintf(fd
, "%s", prompt
);
28 l
= read(fd
, password
, sizeof password
);
30 if (l
> 0 && password
[l
-1] == '\n' || l
==sizeof password
) l
--;
34 tcsetattr(fd
, TCSAFLUSH
, &s
);
39 return l
<0 ? 0 : password
;