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.3 2009/06/27 15:51:48 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 void sighandler(int signum
)
34 if (write(1, "\n", 1) < 0)
35 ; /* Ignore gcc warning */
36 tcsetattr(0, TCSANOW
, &tios
);
41 static void read_pw(char *buf
)
46 while ((c
=getchar()) != EOF
&& c
!= '\n')
49 if (c
== EOF
&& n
== 0) exit(1);
53 int main(int argc
, char **argv
)
64 sprintf(hint
, "{%1.15s}", argv
[1]);
67 /* Read the password */
71 if (tcgetattr(0, &tios
) == 0)
77 signal(SIGINT
, sighandler
);
78 signal(SIGHUP
, sighandler
);
80 tios2
.c_lflag
&= ~ECHO
;
81 tcsetattr(0, TCSANOW
, &tios2
);
85 if (write(2, "Password: ", 10) < 0)
86 ; /* Ignore gcc warning */
88 if (write(2, "\nReenter password: ", 19) < 0)
89 ; /* Ignore gcc warning */
91 if (strcmp(buf
, buf2
) == 0) break;
92 if (write(2, "\nPasswords don't match.\n\n", 25) < 0)
93 ; /* Ignore gcc warning */
105 if (write(2, "\n", 1) < 0)
106 ; /* Ignore gcc warning */
107 tcsetattr(0, TCSANOW
, &tios
);
108 signal(SIGINT
, SIG_DFL
);
109 signal(SIGHUP
, SIG_DFL
);
113 p
=authcryptpasswd(buf
, hint
);