60 #if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
62 # include OPENSSL_UNISTD
68 #if defined(_POSIX_VERSION)
71 # if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
81 #undef OPENSSL_SYS_WIN16
95 #ifdef OPENSSL_SYS_VMS
98 #pragma message disable DOLLARID
102 #ifdef WIN_CONSOLE_BUG
104 #ifndef OPENSSL_SYS_WINCE
114 #if defined(__sgi) && !defined(TERMIOS)
120 #if defined(linux) && !defined(TERMIO)
132 #if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
138 #if defined(OPENSSL_SYS_VXWORKS)
146 #define TTY_STRUCT struct termios
147 #define TTY_FLAGS c_lflag
148 #define TTY_get(tty,data) tcgetattr(tty,data)
149 #define TTY_set(tty,data) tcsetattr(tty,TCSANOW,data)
154 #define TTY_STRUCT struct termio
155 #define TTY_FLAGS c_lflag
156 #define TTY_get(tty,data) ioctl(tty,TCGETA,data)
157 #define TTY_set(tty,data) ioctl(tty,TCSETA,data)
162 #define TTY_STRUCT struct sgttyb
163 #define TTY_FLAGS sg_flags
164 #define TTY_get(tty,data) ioctl(tty,TIOCGETP,data)
165 #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
168 #if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
169 #include <sys/ioctl.h>
172 #if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
174 #define fgets(a,b,c) noecho_fgets(a,b,c)
177 #ifdef OPENSSL_SYS_VMS
189 #if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
195 #define TTY_STRUCT int
202 static void read_till_nl(FILE *);
203 static void recsig(
int);
204 static void pushsig(
void);
205 static void popsig(
void);
206 #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
207 static int noecho_fgets(
char *buf,
int size, FILE *tty);
210 static struct sigaction savsig[
NX509_SIG];
222 ret=
des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
227 #ifdef OPENSSL_SYS_WINCE
229 int des_read_pw(
char *buf,
char *buff,
int size,
const char *prompt,
int verify)
236 #elif defined(OPENSSL_SYS_WIN16)
238 int des_read_pw(
char *buf,
char *buff,
int size,
char *prompt,
int verify)
247 static void read_till_nl(FILE *in)
254 }
while (strchr(buf,
'\n') == NULL);
259 int des_read_pw(
char *buf,
char *buff,
int size,
const char *prompt,
262 #ifdef OPENSSL_SYS_VMS
264 $DESCRIPTOR(terminal,
"TT");
265 long tty_orig[3], tty_new[3];
267 unsigned short channel = 0;
269 #if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
294 #ifdef OPENSSL_SYS_MSDOS
295 if ((tty=fopen(
"con",
"r")) == NULL)
297 #elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
300 #ifndef OPENSSL_SYS_MPE
301 if ((tty=fopen(
"/dev/tty",
"r")) == NULL)
306 #if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
307 if (
TTY_get(fileno(tty),&tty_orig) == -1)
323 memcpy(&(tty_new),&(tty_orig),
sizeof(tty_orig));
325 #ifdef OPENSSL_SYS_VMS
326 status = sys$assign(&terminal,&channel,0,0);
327 if (status != SS$_NORMAL)
329 status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
330 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
338 tty_new.TTY_FLAGS &= ~ECHO;
341 #if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
342 if (is_a_tty && (
TTY_set(fileno(tty),&tty_new) == -1))
343 #ifdef OPENSSL_SYS_MPE
349 #ifdef OPENSSL_SYS_VMS
350 tty_new[0] = tty_orig[0];
351 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
352 tty_new[2] = tty_orig[2];
353 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
354 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
359 while ((!ok) && (number--))
361 fputs(prompt,stderr);
366 if (feof(tty))
goto error;
367 if (ferror(tty))
goto error;
368 if ((p=(
char *)strchr(buf,
'\n')) != NULL)
370 else read_till_nl(tty);
373 fprintf(stderr,
"\nVerifying password - %s",prompt);
376 fgets(buff,size,tty);
377 if (feof(tty))
goto error;
378 if ((p=(
char *)strchr(buff,
'\n')) != NULL)
380 else read_till_nl(tty);
382 if (strcmp(buf,buff) != 0)
384 fprintf(stderr,
"\nVerify failure");
394 fprintf(stderr,
"\n");
396 perror(
"fgets(tty)");
399 #if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
400 if (ps >= 2)
TTY_set(fileno(tty),&tty_orig);
402 #ifdef OPENSSL_SYS_VMS
404 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
405 ,tty_orig,12,0,0,0,0);
408 if (ps >= 1) popsig();
409 if (stdin != tty) fclose(tty);
410 #ifdef OPENSSL_SYS_VMS
411 status = sys$dassgn(channel);
416 static void pushsig(
void)
422 memset(&sa,0,
sizeof sa);
423 sa.sa_handler=recsig;
437 sigaction(i,&sa,&savsig[i]);
439 savsig[i]=signal(i,recsig);
444 signal(SIGWINCH,SIG_DFL);
448 static void popsig(
void)
463 sigaction(i,&savsig[i],NULL);
470 static void recsig(
int i)
478 #ifdef OPENSSL_SYS_MSDOS
479 static int noecho_fgets(
char *buf,
int size, FILE *tty)
498 if (i ==
'\r') i=
'\n';
506 #ifdef WIN_CONSOLE_BUG
514 inh = GetStdHandle(STD_INPUT_HANDLE);
515 FlushConsoleInputBuffer(inh);