1998-12-21 10:52:47 +00:00
|
|
|
/* crypto/des/read_pwd.c */
|
1998-12-21 10:56:39 +00:00
|
|
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
1998-12-21 10:52:47 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This package is an SSL implementation written
|
|
|
|
* by Eric Young (eay@cryptsoft.com).
|
|
|
|
* The implementation was written so as to conform with Netscapes SSL.
|
|
|
|
*
|
|
|
|
* This library is free for commercial and non-commercial use as long as
|
|
|
|
* the following conditions are aheared to. The following conditions
|
|
|
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
|
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
|
|
* included with this distribution is covered by the same copyright terms
|
|
|
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
|
|
*
|
|
|
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
|
|
* the code are not to be removed.
|
|
|
|
* If this package is used in a product, Eric Young should be given attribution
|
|
|
|
* as the author of the parts of the library used.
|
|
|
|
* This can be in the form of a textual message at program startup or
|
|
|
|
* in documentation (online or textual) provided with the package.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* "This product includes cryptographic software written by
|
|
|
|
* Eric Young (eay@cryptsoft.com)"
|
|
|
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
|
|
* being used are not cryptographic related :-).
|
|
|
|
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
|
|
* the apps directory (application code) you must include an acknowledgement:
|
|
|
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* The licence and distribution terms for any publically available version or
|
|
|
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
|
|
* copied and put under another distribution licence
|
|
|
|
* [including the GNU Public Licence.]
|
|
|
|
*/
|
|
|
|
|
2001-02-22 14:37:50 +00:00
|
|
|
#include <openssl/e_os2.h>
|
2001-02-20 13:22:35 +00:00
|
|
|
#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
|
1999-12-19 22:56:23 +00:00
|
|
|
#ifdef OPENSSL_UNISTD
|
|
|
|
# include OPENSSL_UNISTD
|
|
|
|
#else
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
1999-04-08 17:10:27 +00:00
|
|
|
/* If unistd.h defines _POSIX_VERSION, we conclude that we
|
|
|
|
* are on a POSIX system and have sigaction and termios. */
|
|
|
|
#if defined(_POSIX_VERSION)
|
|
|
|
|
|
|
|
# define SIGACTION
|
|
|
|
# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
|
|
|
|
# define TERMIOS
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1998-12-21 10:56:39 +00:00
|
|
|
/* #define SIGACTION */ /* Define this if you have sigaction() */
|
1999-04-08 17:10:27 +00:00
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
#ifdef WIN16TTY
|
2001-02-20 08:13:47 +00:00
|
|
|
#undef OPENSSL_SYS_WIN16
|
1998-12-21 10:52:47 +00:00
|
|
|
#undef _WINDOWS
|
|
|
|
#include <graph.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 06-Apr-92 Luke Brennan Support for VMS */
|
|
|
|
#include "des_locl.h"
|
1999-03-08 18:41:15 +00:00
|
|
|
#include "cryptlib.h"
|
1998-12-21 10:52:47 +00:00
|
|
|
#include <signal.h>
|
1999-05-28 20:21:33 +00:00
|
|
|
#include <stdio.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
|
1999-05-13 11:37:32 +00:00
|
|
|
#include <starlet.h>
|
|
|
|
#ifdef __DECC
|
|
|
|
#pragma message disable DOLLARID
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1999-03-05 01:07:04 +00:00
|
|
|
#ifdef WIN_CONSOLE_BUG
|
|
|
|
#include <windows.h>
|
2002-11-15 22:44:08 +00:00
|
|
|
#ifndef OPENSSL_SYS_WINCE
|
1999-03-05 01:07:04 +00:00
|
|
|
#include <wincon.h>
|
|
|
|
#endif
|
2002-11-15 22:44:08 +00:00
|
|
|
#endif
|
1999-03-05 01:07:04 +00:00
|
|
|
|
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
/* There are 5 types of terminal interface supported,
|
|
|
|
* TERMIO, TERMIOS, VMS, MSDOS and SGTTY
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(__sgi) && !defined(TERMIOS)
|
|
|
|
#define TERMIOS
|
|
|
|
#undef TERMIO
|
|
|
|
#undef SGTTY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(linux) && !defined(TERMIO)
|
|
|
|
#undef TERMIOS
|
|
|
|
#define TERMIO
|
|
|
|
#undef SGTTY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
#undef TERMIOS
|
|
|
|
#define TERMIO
|
|
|
|
#undef SGTTY
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
|
1998-12-21 10:52:47 +00:00
|
|
|
#undef TERMIOS
|
|
|
|
#undef TERMIO
|
|
|
|
#define SGTTY
|
|
|
|
#endif
|
|
|
|
|
2002-10-09 13:41:31 +00:00
|
|
|
#if defined(OPENSSL_SYS_VXWORKS)
|
2002-02-14 16:23:55 +00:00
|
|
|
#undef TERMIOS
|
|
|
|
#undef TERMIO
|
|
|
|
#undef SGTTY
|
|
|
|
#endif
|
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
#ifdef TERMIOS
|
|
|
|
#include <termios.h>
|
|
|
|
#define TTY_STRUCT struct termios
|
|
|
|
#define TTY_FLAGS c_lflag
|
|
|
|
#define TTY_get(tty,data) tcgetattr(tty,data)
|
|
|
|
#define TTY_set(tty,data) tcsetattr(tty,TCSANOW,data)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TERMIO
|
|
|
|
#include <termio.h>
|
|
|
|
#define TTY_STRUCT struct termio
|
|
|
|
#define TTY_FLAGS c_lflag
|
|
|
|
#define TTY_get(tty,data) ioctl(tty,TCGETA,data)
|
|
|
|
#define TTY_set(tty,data) ioctl(tty,TCSETA,data)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SGTTY
|
|
|
|
#include <sgtty.h>
|
|
|
|
#define TTY_STRUCT struct sgttyb
|
|
|
|
#define TTY_FLAGS sg_flags
|
|
|
|
#define TTY_get(tty,data) ioctl(tty,TIOCGETP,data)
|
|
|
|
#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
|
1998-12-21 10:52:47 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
2002-11-15 22:44:08 +00:00
|
|
|
#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
|
1998-12-21 10:52:47 +00:00
|
|
|
#include <conio.h>
|
|
|
|
#define fgets(a,b,c) noecho_fgets(a,b,c)
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1998-12-21 10:52:47 +00:00
|
|
|
#include <ssdef.h>
|
|
|
|
#include <iodef.h>
|
|
|
|
#include <ttdef.h>
|
|
|
|
#include <descrip.h>
|
|
|
|
struct IOSB {
|
|
|
|
short iosb$w_value;
|
|
|
|
short iosb$w_count;
|
|
|
|
long iosb$l_info;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-12-26 22:46:49 +00:00
|
|
|
#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
|
1999-09-11 17:54:18 +00:00
|
|
|
/*
|
|
|
|
* This one needs work. As a matter of fact the code is unoperational
|
|
|
|
* and this is only a trick to get it compiled.
|
|
|
|
* <appro@fy.chalmers.se>
|
|
|
|
*/
|
|
|
|
#define TTY_STRUCT int
|
|
|
|
#endif
|
|
|
|
|
1998-12-21 10:52:47 +00:00
|
|
|
#ifndef NX509_SIG
|
|
|
|
#define NX509_SIG 32
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void read_till_nl(FILE *);
|
|
|
|
static void recsig(int);
|
|
|
|
static void pushsig(void);
|
|
|
|
static void popsig(void);
|
2001-02-20 08:13:47 +00:00
|
|
|
#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
|
1998-12-21 10:52:47 +00:00
|
|
|
static int noecho_fgets(char *buf, int size, FILE *tty);
|
|
|
|
#endif
|
1998-12-21 10:56:39 +00:00
|
|
|
#ifdef SIGACTION
|
|
|
|
static struct sigaction savsig[NX509_SIG];
|
1998-12-21 10:52:47 +00:00
|
|
|
#else
|
1998-12-21 10:56:39 +00:00
|
|
|
static void (*savsig[NX509_SIG])(int );
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
|
|
|
static jmp_buf save;
|
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
int des_read_pw_string(char *buf, int length, const char *prompt,
|
|
|
|
int verify)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
char buff[BUFSIZ];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
|
|
|
|
memset(buff,0,BUFSIZ);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2002-11-15 22:44:08 +00:00
|
|
|
#ifdef OPENSSL_SYS_WINCE
|
|
|
|
|
|
|
|
int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
|
|
|
|
{
|
|
|
|
memset(buf,0,size);
|
|
|
|
memset(buff,0,size);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(OPENSSL_SYS_WIN16)
|
|
|
|
|
|
|
|
int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
|
|
|
|
{
|
|
|
|
memset(buf,0,size);
|
|
|
|
memset(buff,0,size);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !OPENSSL_SYS_WINCE && !OPENSSL_SYS_WIN16 */
|
1998-12-21 10:52:47 +00:00
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static void read_till_nl(FILE *in)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
#define SIZE 4
|
|
|
|
char buf[SIZE+1];
|
|
|
|
|
|
|
|
do {
|
|
|
|
fgets(buf,SIZE,in);
|
|
|
|
} while (strchr(buf,'\n') == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* return 0 if ok, 1 (or -1) otherwise */
|
1999-04-19 21:31:43 +00:00
|
|
|
int des_read_pw(char *buf, char *buff, int size, const char *prompt,
|
|
|
|
int verify)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1998-12-21 10:52:47 +00:00
|
|
|
struct IOSB iosb;
|
|
|
|
$DESCRIPTOR(terminal,"TT");
|
|
|
|
long tty_orig[3], tty_new[3];
|
|
|
|
long status;
|
|
|
|
unsigned short channel = 0;
|
|
|
|
#else
|
2002-06-13 20:40:49 +00:00
|
|
|
#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
|
1998-12-21 10:52:47 +00:00
|
|
|
TTY_STRUCT tty_orig,tty_new;
|
|
|
|
#endif
|
|
|
|
#endif
|
1999-02-23 12:53:49 +00:00
|
|
|
int number;
|
|
|
|
int ok;
|
|
|
|
/* statics are simply to avoid warnings about longjmp clobbering
|
|
|
|
things */
|
|
|
|
static int ps;
|
|
|
|
int is_a_tty;
|
|
|
|
static FILE *tty;
|
1998-12-21 10:52:47 +00:00
|
|
|
char *p;
|
|
|
|
|
1999-02-23 12:53:49 +00:00
|
|
|
if (setjmp(save))
|
|
|
|
{
|
|
|
|
ok=0;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
number=5;
|
|
|
|
ok=0;
|
|
|
|
ps=0;
|
|
|
|
is_a_tty=1;
|
|
|
|
tty=NULL;
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_MSDOS
|
1998-12-21 10:52:47 +00:00
|
|
|
if ((tty=fopen("con","r")) == NULL)
|
|
|
|
tty=stdin;
|
2002-10-09 13:41:31 +00:00
|
|
|
#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
|
2000-05-15 18:59:55 +00:00
|
|
|
tty=stdin;
|
|
|
|
#else
|
2001-02-19 16:06:34 +00:00
|
|
|
#ifndef OPENSSL_SYS_MPE
|
2000-05-15 18:59:55 +00:00
|
|
|
if ((tty=fopen("/dev/tty","r")) == NULL)
|
2000-09-21 05:42:01 +00:00
|
|
|
#endif
|
2000-05-15 18:59:55 +00:00
|
|
|
tty=stdin;
|
|
|
|
#endif
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
|
1998-12-21 10:52:47 +00:00
|
|
|
if (TTY_get(fileno(tty),&tty_orig) == -1)
|
|
|
|
{
|
|
|
|
#ifdef ENOTTY
|
|
|
|
if (errno == ENOTTY)
|
|
|
|
is_a_tty=0;
|
|
|
|
else
|
1998-12-21 10:56:39 +00:00
|
|
|
#endif
|
|
|
|
#ifdef EINVAL
|
|
|
|
/* Ariel Glenn ariel@columbia.edu reports that solaris
|
|
|
|
* can return EINVAL instead. This should be ok */
|
|
|
|
if (errno == EINVAL)
|
|
|
|
is_a_tty=0;
|
|
|
|
else
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
|
|
|
|
#endif
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1999-05-13 11:37:32 +00:00
|
|
|
status = sys$assign(&terminal,&channel,0,0);
|
1998-12-21 10:52:47 +00:00
|
|
|
if (status != SS$_NORMAL)
|
|
|
|
return(-1);
|
1999-05-13 11:37:32 +00:00
|
|
|
status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
|
1998-12-21 10:52:47 +00:00
|
|
|
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
|
|
|
|
return(-1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pushsig();
|
|
|
|
ps=1;
|
|
|
|
|
|
|
|
#ifdef TTY_FLAGS
|
|
|
|
tty_new.TTY_FLAGS &= ~ECHO;
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
|
1998-12-21 10:52:47 +00:00
|
|
|
if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
|
2001-02-19 16:06:34 +00:00
|
|
|
#ifdef OPENSSL_SYS_MPE
|
2000-09-21 05:42:01 +00:00
|
|
|
; /* MPE lies -- echo really has been disabled */
|
|
|
|
#else
|
1998-12-21 10:52:47 +00:00
|
|
|
return(-1);
|
|
|
|
#endif
|
2000-09-21 05:42:01 +00:00
|
|
|
#endif
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1998-12-21 10:52:47 +00:00
|
|
|
tty_new[0] = tty_orig[0];
|
|
|
|
tty_new[1] = tty_orig[1] | TT$M_NOECHO;
|
|
|
|
tty_new[2] = tty_orig[2];
|
1999-05-13 11:37:32 +00:00
|
|
|
status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
|
1998-12-21 10:52:47 +00:00
|
|
|
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
|
|
|
|
return(-1);
|
|
|
|
#endif
|
|
|
|
ps=2;
|
|
|
|
|
|
|
|
while ((!ok) && (number--))
|
|
|
|
{
|
|
|
|
fputs(prompt,stderr);
|
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
buf[0]='\0';
|
|
|
|
fgets(buf,size,tty);
|
|
|
|
if (feof(tty)) goto error;
|
|
|
|
if (ferror(tty)) goto error;
|
|
|
|
if ((p=(char *)strchr(buf,'\n')) != NULL)
|
|
|
|
*p='\0';
|
|
|
|
else read_till_nl(tty);
|
|
|
|
if (verify)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"\nVerifying password - %s",prompt);
|
|
|
|
fflush(stderr);
|
|
|
|
buff[0]='\0';
|
|
|
|
fgets(buff,size,tty);
|
|
|
|
if (feof(tty)) goto error;
|
|
|
|
if ((p=(char *)strchr(buff,'\n')) != NULL)
|
|
|
|
*p='\0';
|
|
|
|
else read_till_nl(tty);
|
|
|
|
|
|
|
|
if (strcmp(buf,buff) != 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"\nVerify failure");
|
|
|
|
fflush(stderr);
|
|
|
|
break;
|
|
|
|
/* continue; */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
fprintf(stderr,"\n");
|
2002-02-21 14:08:47 +00:00
|
|
|
#if 0
|
1998-12-21 10:52:47 +00:00
|
|
|
perror("fgets(tty)");
|
|
|
|
#endif
|
|
|
|
/* What can we do if there is an error? */
|
2001-02-20 08:13:47 +00:00
|
|
|
#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
|
1998-12-21 10:52:47 +00:00
|
|
|
if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
|
|
|
|
#endif
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1998-12-21 10:52:47 +00:00
|
|
|
if (ps >= 2)
|
1999-05-13 11:37:32 +00:00
|
|
|
status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
|
1998-12-21 10:52:47 +00:00
|
|
|
,tty_orig,12,0,0,0,0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ps >= 1) popsig();
|
|
|
|
if (stdin != tty) fclose(tty);
|
2001-02-20 08:13:47 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
1999-05-13 11:37:32 +00:00
|
|
|
status = sys$dassgn(channel);
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
|
|
|
return(!ok);
|
|
|
|
}
|
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static void pushsig(void)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
1999-04-10 10:21:44 +00:00
|
|
|
#ifdef SIGACTION
|
|
|
|
struct sigaction sa;
|
|
|
|
|
|
|
|
memset(&sa,0,sizeof sa);
|
|
|
|
sa.sa_handler=recsig;
|
|
|
|
#endif
|
1998-12-21 10:52:47 +00:00
|
|
|
|
|
|
|
for (i=1; i<NX509_SIG; i++)
|
1998-12-21 10:56:39 +00:00
|
|
|
{
|
|
|
|
#ifdef SIGUSR1
|
|
|
|
if (i == SIGUSR1)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
#ifdef SIGUSR2
|
|
|
|
if (i == SIGUSR2)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
#ifdef SIGACTION
|
1999-04-10 10:21:44 +00:00
|
|
|
sigaction(i,&sa,&savsig[i]);
|
1998-12-21 10:56:39 +00:00
|
|
|
#else
|
1998-12-21 10:52:47 +00:00
|
|
|
savsig[i]=signal(i,recsig);
|
1998-12-21 10:56:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
|
|
|
#ifdef SIGWINCH
|
|
|
|
signal(SIGWINCH,SIG_DFL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static void popsig(void)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=1; i<NX509_SIG; i++)
|
1998-12-21 10:56:39 +00:00
|
|
|
{
|
|
|
|
#ifdef SIGUSR1
|
|
|
|
if (i == SIGUSR1)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
#ifdef SIGUSR2
|
|
|
|
if (i == SIGUSR2)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
#ifdef SIGACTION
|
|
|
|
sigaction(i,&savsig[i],NULL);
|
|
|
|
#else
|
1998-12-21 10:52:47 +00:00
|
|
|
signal(i,savsig[i]);
|
1998-12-21 10:56:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static void recsig(int i)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
longjmp(save,1);
|
|
|
|
#ifdef LINT
|
|
|
|
i=i;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-11-15 22:44:08 +00:00
|
|
|
#ifdef OPENSSL_SYS_MSDOS
|
1999-04-19 21:31:43 +00:00
|
|
|
static int noecho_fgets(char *buf, int size, FILE *tty)
|
1998-12-21 10:52:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p=buf;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
*p='\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
size--;
|
|
|
|
#ifdef WIN16TTY
|
|
|
|
i=_inchar();
|
|
|
|
#else
|
|
|
|
i=getch();
|
|
|
|
#endif
|
|
|
|
if (i == '\r') i='\n';
|
|
|
|
*(p++)=i;
|
|
|
|
if (i == '\n')
|
|
|
|
{
|
|
|
|
*p='\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-03-05 01:07:04 +00:00
|
|
|
#ifdef WIN_CONSOLE_BUG
|
|
|
|
/* Win95 has several evil console bugs: one of these is that the
|
|
|
|
* last character read using getch() is passed to the next read: this is
|
|
|
|
* usually a CR so this can be trouble. No STDIO fix seems to work but
|
|
|
|
* flushing the console appears to do the trick.
|
|
|
|
*/
|
1999-06-07 20:26:51 +00:00
|
|
|
{
|
|
|
|
HANDLE inh;
|
|
|
|
inh = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
FlushConsoleInputBuffer(inh);
|
|
|
|
}
|
1999-03-05 01:07:04 +00:00
|
|
|
#endif
|
1998-12-21 10:52:47 +00:00
|
|
|
return(strlen(buf));
|
|
|
|
}
|
|
|
|
#endif
|
2002-11-15 22:44:08 +00:00
|
|
|
#endif /* !OPENSSL_SYS_WINCE && !WIN16 */
|