X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fdes%2Fread_pwd.c;h=5c82e2fdc1dac8a611ef783cdb6120728000920c;hp=db59c4c0403d00cdc2cf1c15d8cae23b69247cff;hb=65a6a1ff452ab7d72becfe9322d1e4bdc1786c44;hpb=fa3da3cf09af1b688295d27ac96e55f115d8ffd2 diff --git a/crypto/des/read_pwd.c b/crypto/des/read_pwd.c index db59c4c040..5c82e2fdc1 100644 --- a/crypto/des/read_pwd.c +++ b/crypto/des/read_pwd.c @@ -56,8 +56,13 @@ * [including the GNU Public Licence.] */ -#if !defined(MSDOS) && !defined(VMS) -#include +#include +#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32) +#ifdef OPENSSL_UNISTD +# include OPENSSL_UNISTD +#else +# include +#endif /* If unistd.h defines _POSIX_VERSION, we conclude that we * are on a POSIX system and have sigaction and termios. */ #if defined(_POSIX_VERSION) @@ -70,10 +75,11 @@ #endif #endif -/* #define SIGACTION */ /* Define this if you have sigaction() */ +/* Define this if you have sigaction() */ +/* #define SIGACTION */ #ifdef WIN16TTY -#undef WIN16 +#undef OPENSSL_SYS_WIN16 #undef _WINDOWS #include #endif @@ -82,14 +88,24 @@ #include "des_locl.h" #include "cryptlib.h" #include +#include #include #include #include +#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ +#include +#ifdef __DECC +#pragma message disable DOLLARID +#endif +#endif + #ifdef WIN_CONSOLE_BUG #include +#ifndef OPENSSL_SYS_WINCE #include #endif +#endif /* There are 5 types of terminal interface supported, @@ -114,12 +130,18 @@ #undef SGTTY #endif -#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) +#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE) #undef TERMIOS #undef TERMIO #define SGTTY #endif +#if defined(OPENSSL_SYS_VXWORKS) +#undef TERMIOS +#undef TERMIO +#undef SGTTY +#endif + #ifdef TERMIOS #include #define TTY_STRUCT struct termios @@ -144,16 +166,16 @@ #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #endif -#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) +#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X) #include #endif -#ifdef MSDOS +#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE) #include #define fgets(a,b,c) noecho_fgets(a,b,c) #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #include #include #include @@ -165,57 +187,65 @@ struct IOSB { }; #endif +#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE) +/* + * This one needs work. As a matter of fact the code is unoperational + * and this is only a trick to get it compiled. + * + */ +#define TTY_STRUCT int +#endif + #ifndef NX509_SIG #define NX509_SIG 32 #endif -#ifndef NOPROTO static void read_till_nl(FILE *); static void recsig(int); static void pushsig(void); static void popsig(void); -#if defined(MSDOS) && !defined(WIN16) +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) static int noecho_fgets(char *buf, int size, FILE *tty); #endif -#else -static void read_till_nl(); -static void recsig(); -static void pushsig(); -static void popsig(); -#if defined(MSDOS) && !defined(WIN16) -static int noecho_fgets(); -#endif -#endif - #ifdef SIGACTION static struct sigaction savsig[NX509_SIG]; #else -# ifndef NOPROTO static void (*savsig[NX509_SIG])(int ); -# else - static void (*savsig[NX509_SIG])(); -# endif #endif static jmp_buf save; -int des_read_pw_string(buf, length, prompt, verify) -char *buf; -int length; -const char *prompt; -int verify; +int des_read_pw_string(char *buf, int length, const char *prompt, + int verify) { char buff[BUFSIZ]; int ret; ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); - memset(buff,0,BUFSIZ); + OPENSSL_cleanse(buff,BUFSIZ); return(ret); } -#ifndef WIN16 +#ifdef OPENSSL_SYS_WINCE -static void read_till_nl(in) -FILE *in; +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 */ + +static void read_till_nl(FILE *in) { #define SIZE 4 char buf[SIZE+1]; @@ -227,21 +257,17 @@ FILE *in; /* return 0 if ok, 1 (or -1) otherwise */ -int des_read_pw(buf, buff, size, prompt, verify) -char *buf; -char *buff; -int size; -const char *prompt; -int verify; +int des_read_pw(char *buf, char *buff, int size, const char *prompt, + int verify) { -#ifdef VMS +#ifdef OPENSSL_SYS_VMS struct IOSB iosb; $DESCRIPTOR(terminal,"TT"); long tty_orig[3], tty_new[3]; long status; unsigned short channel = 0; #else -#ifndef MSDOS +#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__) TTY_STRUCT tty_orig,tty_new; #endif #endif @@ -266,15 +292,19 @@ int verify; is_a_tty=1; tty=NULL; -#ifndef MSDOS - if ((tty=fopen("/dev/tty","r")) == NULL) - tty=stdin; -#else /* MSDOS */ +#ifdef OPENSSL_SYS_MSDOS if ((tty=fopen("con","r")) == NULL) tty=stdin; -#endif /* MSDOS */ +#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS) + tty=stdin; +#else +#ifndef OPENSSL_SYS_MPE + if ((tty=fopen("/dev/tty","r")) == NULL) +#endif + tty=stdin; +#endif -#if defined(TTY_get) && !defined(VMS) +#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) if (TTY_get(fileno(tty),&tty_orig) == -1) { #ifdef ENOTTY @@ -293,11 +323,11 @@ int verify; } memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); #endif -#ifdef VMS - status = SYS$ASSIGN(&terminal,&channel,0,0); +#ifdef OPENSSL_SYS_VMS + status = sys$assign(&terminal,&channel,0,0); if (status != SS$_NORMAL) return(-1); - status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); + status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0); if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) return(-1); #endif @@ -309,15 +339,19 @@ int verify; tty_new.TTY_FLAGS &= ~ECHO; #endif -#if defined(TTY_set) && !defined(VMS) +#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) +#ifdef OPENSSL_SYS_MPE + ; /* MPE lies -- echo really has been disabled */ +#else return(-1); #endif -#ifdef VMS +#endif +#ifdef OPENSSL_SYS_VMS tty_new[0] = tty_orig[0]; tty_new[1] = tty_orig[1] | TT$M_NOECHO; tty_new[2] = tty_orig[2]; - status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); + status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0); if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) return(-1); #endif @@ -359,46 +393,36 @@ int verify; error: fprintf(stderr,"\n"); -#ifdef DEBUG +#if 0 perror("fgets(tty)"); #endif /* What can we do if there is an error? */ -#if defined(TTY_set) && !defined(VMS) +#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) if (ps >= 2) TTY_set(fileno(tty),&tty_orig); #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS if (ps >= 2) - status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0 + status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0 ,tty_orig,12,0,0,0,0); #endif if (ps >= 1) popsig(); if (stdin != tty) fclose(tty); -#ifdef VMS - status = SYS$DASSGN(channel); +#ifdef OPENSSL_SYS_VMS + status = sys$dassgn(channel); #endif return(!ok); } -#else /* WIN16 */ - -int des_read_pw(buf, buff, size, prompt, verify) -char *buf; -char *buff; -int size; -char *prompt; -int verify; - { - memset(buf,0,size); - memset(buff,0,size); - return(0); - } - -#endif - -static void pushsig() +static void pushsig(void) { int i; +#ifdef SIGACTION + struct sigaction sa; + + memset(&sa,0,sizeof sa); + sa.sa_handler=recsig; +#endif for (i=1; i