1: /* @(#)getpass.c 4.2 (Berkeley) 7/1/81 */
2: #include <stdio.h>
3: #include <signal.h>
4: #include <sgtty.h>
5:
6: char *
7: getpass(prompt)
8: char *prompt;
9: {
10: struct sgttyb ttyb;
11: int flags;
12: register char *p;
13: register c;
14: FILE *fi;
15: static char pbuf[9];
16: int (*signal())();
17: int (*sig)();
18:
19: if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
20: fi = stdin;
21: else
22: setbuf(fi, (char *)NULL);
23: sig = signal(SIGINT, SIG_IGN);
24: gtty(fileno(fi), &ttyb);
25: flags = ttyb.sg_flags;
26: ttyb.sg_flags &= ~ECHO;
27: stty(fileno(fi), &ttyb);
28: fprintf(stderr, "%s", prompt);
29: for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
30: if (p < &pbuf[8])
31: *p++ = c;
32: }
33: *p = '\0';
34: fprintf(stderr, "\n");
35: ttyb.sg_flags = flags;
36: stty(fileno(fi), &ttyb);
37: signal(SIGINT, sig);
38: if (fi != stdin)
39: fclose(fi);
40: return(pbuf);
41: }
Defined functions
getpass
defined in line
6; used 25 times
- in /usr/src/cmd/crypt.c line
13,
74
- in /usr/src/cmd/login.c line
68,
175,
200
- in /usr/src/cmd/newgrp.c line
7,
40
- in /usr/src/cmd/passwd.c line
17,
71,
79,
107
- in /usr/src/cmd/su.c line
13,
66
- in /usr/src/cmd/xsend/enroll.c line
19
- in /usr/src/cmd/xsend/xget.c line
29
- in /usr/src/ucb/chfn.c line
28
- in /usr/src/ucb/chsh.c line
15
- in /usr/src/ucb/ex/ex3/ex.c line
256
- in /usr/src/ucb/ex/ex3/ex.h line
323
- in /usr/src/ucb/pwhash/src/cmd/chfn.c line
16
- in /usr/src/ucb/pwhash/src/cmd/chsh.c line
29
- in /usr/src/ucb/pwhash/src/cmd/passwd.c line
32,
81,
97,
126