2 ** Copyright 2005-2006 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
22 ** Where possible, we turn off echo when entering the password.
23 ** We set up a signal handler to catch signals and restore the echo
28 static struct termios tios
;
31 static void sighandler(int signum
)
33 if (write(1, "\n", 1) < 0)
34 ; /* Ignore gcc warning */
35 tcsetattr(0, TCSANOW
, &tios
);
40 static void read_pw(char *buf
)
45 while ((c
=getchar()) != EOF
&& c
!= '\n')
48 if (c
== EOF
&& n
== 0) exit(1);
52 int main(int argc
, char **argv
)
63 sprintf(hint
, "{%1.15s}", argv
[1]);
66 /* Read the password */
70 if (tcgetattr(0, &tios
) == 0)
76 signal(SIGINT
, sighandler
);
77 signal(SIGHUP
, sighandler
);
79 tios2
.c_lflag
&= ~ECHO
;
80 tcsetattr(0, TCSANOW
, &tios2
);
84 if (write(2, "Password: ", 10) < 0)
85 ; /* Ignore gcc warning */
87 if (write(2, "\nReenter password: ", 19) < 0)
88 ; /* Ignore gcc warning */
90 if (strcmp(buf
, buf2
) == 0) break;
91 if (write(2, "\nPasswords don't match.\n\n", 25) < 0)
92 ; /* Ignore gcc warning */
104 if (write(2, "\n", 1) < 0)
105 ; /* Ignore gcc warning */
106 tcsetattr(0, TCSANOW
, &tios
);
107 signal(SIGINT
, SIG_DFL
);
108 signal(SIGHUP
, SIG_DFL
);
112 p
=authcryptpasswd(buf
, hint
);