diff options
Diffstat (limited to 'src/lib/libcrypto/ui')
-rw-r--r-- | src/lib/libcrypto/ui/ui.h | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/ui/ui_err.c | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/ui/ui_lib.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/ui/ui_locl.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/ui/ui_openssl.c | 48 | ||||
-rw-r--r-- | src/lib/libcrypto/ui/ui_util.c | 2 |
6 files changed, 61 insertions, 31 deletions
diff --git a/src/lib/libcrypto/ui/ui.h b/src/lib/libcrypto/ui/ui.h index 735a2d988e..018296412b 100644 --- a/src/lib/libcrypto/ui/ui.h +++ b/src/lib/libcrypto/ui/ui.h | |||
@@ -59,25 +59,19 @@ | |||
59 | #ifndef HEADER_UI_H | 59 | #ifndef HEADER_UI_H |
60 | #define HEADER_UI_H | 60 | #define HEADER_UI_H |
61 | 61 | ||
62 | #ifndef OPENSSL_NO_DEPRECATED | ||
62 | #include <openssl/crypto.h> | 63 | #include <openssl/crypto.h> |
64 | #endif | ||
63 | #include <openssl/safestack.h> | 65 | #include <openssl/safestack.h> |
66 | #include <openssl/ossl_typ.h> | ||
64 | 67 | ||
65 | #ifdef __cplusplus | 68 | #ifdef __cplusplus |
66 | extern "C" { | 69 | extern "C" { |
67 | #endif | 70 | #endif |
68 | 71 | ||
69 | /* The UI type is a holder for a specific user interface session. It can | 72 | /* Declared already in ossl_typ.h */ |
70 | contain an illimited number of informational or error strings as well | 73 | /* typedef struct ui_st UI; */ |
71 | as things to prompt for, both passwords (noecho mode) and others (echo | 74 | /* typedef struct ui_method_st UI_METHOD; */ |
72 | mode), and verification of the same. All of these are called strings, | ||
73 | and are further described below. */ | ||
74 | typedef struct ui_st UI; | ||
75 | |||
76 | /* All instances of UI have a reference to a method structure, which is a | ||
77 | ordered vector of functions that implement the lower level things to do. | ||
78 | There is an instruction on the implementation further down, in the section | ||
79 | for method implementors. */ | ||
80 | typedef struct ui_method_st UI_METHOD; | ||
81 | 75 | ||
82 | 76 | ||
83 | /* All the following functions return -1 or NULL on error and in some cases | 77 | /* All the following functions return -1 or NULL on error and in some cases |
@@ -217,7 +211,7 @@ int UI_process(UI *ui); | |||
217 | /* Give a user interface parametrised control commands. This can be used to | 211 | /* Give a user interface parametrised control commands. This can be used to |
218 | send down an integer, a data pointer or a function pointer, as well as | 212 | send down an integer, a data pointer or a function pointer, as well as |
219 | be used to get information from a UI. */ | 213 | be used to get information from a UI. */ |
220 | int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()); | 214 | int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); |
221 | 215 | ||
222 | /* The commands */ | 216 | /* The commands */ |
223 | /* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the | 217 | /* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the |
diff --git a/src/lib/libcrypto/ui/ui_err.c b/src/lib/libcrypto/ui/ui_err.c index d983cdd66f..786bd0dbc3 100644 --- a/src/lib/libcrypto/ui/ui_err.c +++ b/src/lib/libcrypto/ui/ui_err.c | |||
@@ -101,15 +101,12 @@ static ERR_STRING_DATA UI_str_reasons[]= | |||
101 | 101 | ||
102 | void ERR_load_UI_strings(void) | 102 | void ERR_load_UI_strings(void) |
103 | { | 103 | { |
104 | static int init=1; | 104 | #ifndef OPENSSL_NO_ERR |
105 | 105 | ||
106 | if (init) | 106 | if (ERR_func_error_string(UI_str_functs[0].error) == NULL) |
107 | { | 107 | { |
108 | init=0; | ||
109 | #ifndef OPENSSL_NO_ERR | ||
110 | ERR_load_strings(0,UI_str_functs); | 108 | ERR_load_strings(0,UI_str_functs); |
111 | ERR_load_strings(0,UI_str_reasons); | 109 | ERR_load_strings(0,UI_str_reasons); |
112 | #endif | ||
113 | |||
114 | } | 110 | } |
111 | #endif | ||
115 | } | 112 | } |
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c index dbc9711a2d..7ab249c3be 100644 --- a/src/lib/libcrypto/ui/ui_lib.c +++ b/src/lib/libcrypto/ui/ui_lib.c | |||
@@ -57,12 +57,12 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <string.h> | 59 | #include <string.h> |
60 | #include "cryptlib.h" | ||
60 | #include <openssl/e_os2.h> | 61 | #include <openssl/e_os2.h> |
61 | #include <openssl/buffer.h> | 62 | #include <openssl/buffer.h> |
62 | #include <openssl/ui.h> | 63 | #include <openssl/ui.h> |
63 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
64 | #include "ui_locl.h" | 65 | #include "ui_locl.h" |
65 | #include "cryptlib.h" | ||
66 | 66 | ||
67 | IMPLEMENT_STACK_OF(UI_STRING_ST) | 67 | IMPLEMENT_STACK_OF(UI_STRING_ST) |
68 | 68 | ||
@@ -545,7 +545,7 @@ int UI_process(UI *ui) | |||
545 | return ok; | 545 | return ok; |
546 | } | 546 | } |
547 | 547 | ||
548 | int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()) | 548 | int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)) |
549 | { | 549 | { |
550 | if (ui == NULL) | 550 | if (ui == NULL) |
551 | { | 551 | { |
@@ -620,8 +620,10 @@ UI_METHOD *UI_create_method(char *name) | |||
620 | UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD)); | 620 | UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD)); |
621 | 621 | ||
622 | if (ui_method) | 622 | if (ui_method) |
623 | { | ||
623 | memset(ui_method, 0, sizeof(*ui_method)); | 624 | memset(ui_method, 0, sizeof(*ui_method)); |
624 | ui_method->name = BUF_strdup(name); | 625 | ui_method->name = BUF_strdup(name); |
626 | } | ||
625 | return ui_method; | 627 | return ui_method; |
626 | } | 628 | } |
627 | 629 | ||
diff --git a/src/lib/libcrypto/ui/ui_locl.h b/src/lib/libcrypto/ui/ui_locl.h index 7d3a75a619..aa4a55637d 100644 --- a/src/lib/libcrypto/ui/ui_locl.h +++ b/src/lib/libcrypto/ui/ui_locl.h | |||
@@ -60,6 +60,11 @@ | |||
60 | #define HEADER_UI_LOCL_H | 60 | #define HEADER_UI_LOCL_H |
61 | 61 | ||
62 | #include <openssl/ui.h> | 62 | #include <openssl/ui.h> |
63 | #include <openssl/crypto.h> | ||
64 | |||
65 | #ifdef _ | ||
66 | #undef _ | ||
67 | #endif | ||
63 | 68 | ||
64 | struct ui_method_st | 69 | struct ui_method_st |
65 | { | 70 | { |
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c index d03aeba91a..8446673ed4 100644 --- a/src/lib/libcrypto/ui/ui_openssl.c +++ b/src/lib/libcrypto/ui/ui_openssl.c | |||
@@ -117,6 +117,17 @@ | |||
117 | 117 | ||
118 | #include <openssl/e_os2.h> | 118 | #include <openssl/e_os2.h> |
119 | 119 | ||
120 | /* need for #define _POSIX_C_SOURCE arises whenever you pass -ansi to gcc | ||
121 | * [maybe others?], because it masks interfaces not discussed in standard, | ||
122 | * sigaction and fileno included. -pedantic would be more appropriate for | ||
123 | * the intended purposes, but we can't prevent users from adding -ansi. | ||
124 | */ | ||
125 | #define _POSIX_C_SOURCE 1 | ||
126 | #include <signal.h> | ||
127 | #include <stdio.h> | ||
128 | #include <string.h> | ||
129 | #include <errno.h> | ||
130 | |||
120 | #if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) | 131 | #if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) |
121 | # ifdef OPENSSL_UNISTD | 132 | # ifdef OPENSSL_UNISTD |
122 | # include OPENSSL_UNISTD | 133 | # include OPENSSL_UNISTD |
@@ -145,10 +156,6 @@ | |||
145 | /* 06-Apr-92 Luke Brennan Support for VMS */ | 156 | /* 06-Apr-92 Luke Brennan Support for VMS */ |
146 | #include "ui_locl.h" | 157 | #include "ui_locl.h" |
147 | #include "cryptlib.h" | 158 | #include "cryptlib.h" |
148 | #include <signal.h> | ||
149 | #include <stdio.h> | ||
150 | #include <string.h> | ||
151 | #include <errno.h> | ||
152 | 159 | ||
153 | #ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ | 160 | #ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ |
154 | # include <starlet.h> | 161 | # include <starlet.h> |
@@ -199,6 +206,12 @@ | |||
199 | #undef SGTTY | 206 | #undef SGTTY |
200 | #endif | 207 | #endif |
201 | 208 | ||
209 | #if defined(OPENSSL_SYS_NETWARE) | ||
210 | #undef TERMIOS | ||
211 | #undef TERMIO | ||
212 | #undef SGTTY | ||
213 | #endif | ||
214 | |||
202 | #ifdef TERMIOS | 215 | #ifdef TERMIOS |
203 | # include <termios.h> | 216 | # include <termios.h> |
204 | # define TTY_STRUCT struct termios | 217 | # define TTY_STRUCT struct termios |
@@ -247,7 +260,7 @@ struct IOSB { | |||
247 | typedef int sig_atomic_t; | 260 | typedef int sig_atomic_t; |
248 | #endif | 261 | #endif |
249 | 262 | ||
250 | #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) | 263 | #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE) |
251 | /* | 264 | /* |
252 | * This one needs work. As a matter of fact the code is unoperational | 265 | * This one needs work. As a matter of fact the code is unoperational |
253 | * and this is only a trick to get it compiled. | 266 | * and this is only a trick to get it compiled. |
@@ -461,7 +474,7 @@ static int open_console(UI *ui) | |||
461 | CRYPTO_w_lock(CRYPTO_LOCK_UI); | 474 | CRYPTO_w_lock(CRYPTO_LOCK_UI); |
462 | is_a_tty = 1; | 475 | is_a_tty = 1; |
463 | 476 | ||
464 | #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) | 477 | #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) |
465 | tty_in=stdin; | 478 | tty_in=stdin; |
466 | tty_out=stderr; | 479 | tty_out=stderr; |
467 | #else | 480 | #else |
@@ -477,7 +490,7 @@ static int open_console(UI *ui) | |||
477 | #endif | 490 | #endif |
478 | 491 | ||
479 | #if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) | 492 | #if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) |
480 | if (TTY_get(fileno(tty_in),&tty_orig) == -1) | 493 | if (TTY_get(fileno(tty_in),&tty_orig) == -1) |
481 | { | 494 | { |
482 | #ifdef ENOTTY | 495 | #ifdef ENOTTY |
483 | if (errno == ENOTTY) | 496 | if (errno == ENOTTY) |
@@ -566,7 +579,9 @@ static int close_console(UI *ui) | |||
566 | /* Internal functions to handle signals and act on them */ | 579 | /* Internal functions to handle signals and act on them */ |
567 | static void pushsig(void) | 580 | static void pushsig(void) |
568 | { | 581 | { |
582 | #ifndef OPENSSL_SYS_WIN32 | ||
569 | int i; | 583 | int i; |
584 | #endif | ||
570 | #ifdef SIGACTION | 585 | #ifdef SIGACTION |
571 | struct sigaction sa; | 586 | struct sigaction sa; |
572 | 587 | ||
@@ -574,6 +589,14 @@ static void pushsig(void) | |||
574 | sa.sa_handler=recsig; | 589 | sa.sa_handler=recsig; |
575 | #endif | 590 | #endif |
576 | 591 | ||
592 | #ifdef OPENSSL_SYS_WIN32 | ||
593 | savsig[SIGABRT]=signal(SIGABRT,recsig); | ||
594 | savsig[SIGFPE]=signal(SIGFPE,recsig); | ||
595 | savsig[SIGILL]=signal(SIGILL,recsig); | ||
596 | savsig[SIGINT]=signal(SIGINT,recsig); | ||
597 | savsig[SIGSEGV]=signal(SIGSEGV,recsig); | ||
598 | savsig[SIGTERM]=signal(SIGTERM,recsig); | ||
599 | #else | ||
577 | for (i=1; i<NX509_SIG; i++) | 600 | for (i=1; i<NX509_SIG; i++) |
578 | { | 601 | { |
579 | #ifdef SIGUSR1 | 602 | #ifdef SIGUSR1 |
@@ -594,6 +617,7 @@ static void pushsig(void) | |||
594 | savsig[i]=signal(i,recsig); | 617 | savsig[i]=signal(i,recsig); |
595 | #endif | 618 | #endif |
596 | } | 619 | } |
620 | #endif | ||
597 | 621 | ||
598 | #ifdef SIGWINCH | 622 | #ifdef SIGWINCH |
599 | signal(SIGWINCH,SIG_DFL); | 623 | signal(SIGWINCH,SIG_DFL); |
@@ -602,8 +626,15 @@ static void pushsig(void) | |||
602 | 626 | ||
603 | static void popsig(void) | 627 | static void popsig(void) |
604 | { | 628 | { |
629 | #ifdef OPENSSL_SYS_WIN32 | ||
630 | signal(SIGABRT,savsig[SIGABRT]); | ||
631 | signal(SIGFPE,savsig[SIGFPE]); | ||
632 | signal(SIGILL,savsig[SIGILL]); | ||
633 | signal(SIGINT,savsig[SIGINT]); | ||
634 | signal(SIGSEGV,savsig[SIGSEGV]); | ||
635 | signal(SIGTERM,savsig[SIGTERM]); | ||
636 | #else | ||
605 | int i; | 637 | int i; |
606 | |||
607 | for (i=1; i<NX509_SIG; i++) | 638 | for (i=1; i<NX509_SIG; i++) |
608 | { | 639 | { |
609 | #ifdef SIGUSR1 | 640 | #ifdef SIGUSR1 |
@@ -620,6 +651,7 @@ static void popsig(void) | |||
620 | signal(i,savsig[i]); | 651 | signal(i,savsig[i]); |
621 | #endif | 652 | #endif |
622 | } | 653 | } |
654 | #endif | ||
623 | } | 655 | } |
624 | 656 | ||
625 | static void recsig(int i) | 657 | static void recsig(int i) |
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c index 46bc8c1a9a..5d9760bb7b 100644 --- a/src/lib/libcrypto/ui/ui_util.c +++ b/src/lib/libcrypto/ui/ui_util.c | |||
@@ -54,7 +54,7 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include <string.h> | 56 | #include <string.h> |
57 | #include <openssl/ui.h> | 57 | #include "ui_locl.h" |
58 | 58 | ||
59 | int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify) | 59 | int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify) |
60 | { | 60 | { |