2 ** Copyright 2005-2006 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
21 static const char rcsid
[]="$Id: authpasswd.c,v 1.2 2006/06/01 10:47:32 mrsam Exp $";
23 ** Where possible, we turn off echo when entering the password.
24 ** We set up a signal handler to catch signals and restore the echo
29 static struct termios tios
;
32 static RETSIGTYPE
sighandler(int signum
)
34 if (write(1, "\n", 1) < 0)
35 ; /* Ignore gcc warning */
36 tcsetattr(0, TCSANOW
, &tios
);
38 #if RETSIGTYPE != void
44 static void read_pw(char *buf
)
49 while ((c
=getchar()) != EOF
&& c
!= '\n')
52 if (c
== EOF
&& n
== 0) exit(1);
56 int main(int argc
, char **argv
)
67 sprintf(hint
, "{%1.15s}", argv
[1]);
70 /* Read the password */
74 if (tcgetattr(0, &tios
) == 0)
80 signal(SIGINT
, sighandler
);
81 signal(SIGHUP
, sighandler
);
83 tios2
.c_lflag
&= ~ECHO
;
84 tcsetattr(0, TCSANOW
, &tios2
);
88 if (write(2, "Password: ", 10) < 0)
89 ; /* Ignore gcc warning */
91 if (write(2, "\nReenter password: ", 19) < 0)
92 ; /* Ignore gcc warning */
94 if (strcmp(buf
, buf2
) == 0) break;
95 if (write(2, "\nPasswords don't match.\n\n", 25) < 0)
96 ; /* Ignore gcc warning */
108 if (write(2, "\n", 1) < 0)
109 ; /* Ignore gcc warning */
110 tcsetattr(0, TCSANOW
, &tios
);
111 signal(SIGINT
, SIG_DFL
);
112 signal(SIGHUP
, SIG_DFL
);
116 p
=authcryptpasswd(buf
, hint
);