diff options
| author | jsing <> | 2014-04-25 13:22:38 +0000 |
|---|---|---|
| committer | jsing <> | 2014-04-25 13:22:38 +0000 |
| commit | ca472e69dbf35e3fc0a1acb2e96a7002fdb25566 (patch) | |
| tree | 966ba7b8a60f9488d4efd105aa6b4a3f5d07443f /src | |
| parent | 5f99ecd5c0822b76a1d6a7d3e8159140bfc2a787 (diff) | |
| download | openbsd-ca472e69dbf35e3fc0a1acb2e96a7002fdb25566.tar.gz openbsd-ca472e69dbf35e3fc0a1acb2e96a7002fdb25566.tar.bz2 openbsd-ca472e69dbf35e3fc0a1acb2e96a7002fdb25566.zip | |
Clean up the remaining TTY related remnants.
ok miod@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ui/ui_openssl.c | 49 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/ui/ui_openssl.c | 49 |
2 files changed, 16 insertions, 82 deletions
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c index a67cf53f2a..d3be332f19 100644 --- a/src/lib/libcrypto/ui/ui_openssl.c +++ b/src/lib/libcrypto/ui/ui_openssl.c | |||
| @@ -122,33 +122,11 @@ | |||
| 122 | #include <errno.h> | 122 | #include <errno.h> |
| 123 | 123 | ||
| 124 | #include <unistd.h> | 124 | #include <unistd.h> |
| 125 | /* If unistd.h defines _POSIX_VERSION, we conclude that we | 125 | #include <termios.h> |
| 126 | * are on a POSIX system and have sigaction and termios. */ | ||
| 127 | #if defined(_POSIX_VERSION) | ||
| 128 | |||
| 129 | #define SIGACTION | ||
| 130 | #if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY) | ||
| 131 | #define TERMIOS | ||
| 132 | #endif | ||
| 133 | |||
| 134 | #endif | ||
| 135 | 126 | ||
| 136 | #include "ui_locl.h" | 127 | #include "ui_locl.h" |
| 137 | #include "cryptlib.h" | 128 | #include "cryptlib.h" |
| 138 | 129 | ||
| 139 | |||
| 140 | /* There are 5 types of terminal interface supported, | ||
| 141 | * TERMIO, TERMIOS, VMS, MSDOS and SGTTY | ||
| 142 | */ | ||
| 143 | |||
| 144 | |||
| 145 | #include <termios.h> | ||
| 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) | ||
| 150 | |||
| 151 | |||
| 152 | #include <sys/ioctl.h> | 130 | #include <sys/ioctl.h> |
| 153 | 131 | ||
| 154 | #ifndef NX509_SIG | 132 | #ifndef NX509_SIG |
| @@ -159,7 +137,7 @@ | |||
| 159 | /* Define globals. They are protected by a lock */ | 137 | /* Define globals. They are protected by a lock */ |
| 160 | static struct sigaction savsig[NX509_SIG]; | 138 | static struct sigaction savsig[NX509_SIG]; |
| 161 | 139 | ||
| 162 | static TTY_STRUCT tty_orig, tty_new; | 140 | static struct termios tty_orig, tty_new; |
| 163 | static FILE *tty_in, *tty_out; | 141 | static FILE *tty_in, *tty_out; |
| 164 | static int is_a_tty; | 142 | static int is_a_tty; |
| 165 | 143 | ||
| @@ -331,8 +309,7 @@ open_console(UI *ui) | |||
| 331 | if ((tty_out = fopen(DEV_TTY, "w")) == NULL) | 309 | if ((tty_out = fopen(DEV_TTY, "w")) == NULL) |
| 332 | tty_out = stderr; | 310 | tty_out = stderr; |
| 333 | 311 | ||
| 334 | #if defined(TTY_get) | 312 | if (tcgetattr(fileno(tty_in), &tty_orig) == -1) { |
| 335 | if (TTY_get(fileno(tty_in), &tty_orig) == -1) { | ||
| 336 | if (errno == ENOTTY) | 313 | if (errno == ENOTTY) |
| 337 | is_a_tty = 0; | 314 | is_a_tty = 0; |
| 338 | else | 315 | else |
| @@ -346,37 +323,27 @@ open_console(UI *ui) | |||
| 346 | else | 323 | else |
| 347 | return 0; | 324 | return 0; |
| 348 | } | 325 | } |
| 349 | #endif | 326 | |
| 350 | return 1; | 327 | return 1; |
| 351 | } | 328 | } |
| 352 | 329 | ||
| 353 | static int | 330 | static int |
| 354 | noecho_console(UI *ui) | 331 | noecho_console(UI *ui) |
| 355 | { | 332 | { |
| 356 | #ifdef TTY_FLAGS | ||
| 357 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 333 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
| 358 | tty_new.TTY_FLAGS &= ~ECHO; | 334 | tty_new.c_lflag &= ~ECHO; |
| 359 | #endif | 335 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
| 360 | |||
| 361 | #if defined(TTY_set) | ||
| 362 | if (is_a_tty && (TTY_set(fileno(tty_in), &tty_new) == -1)) | ||
| 363 | return 0; | 336 | return 0; |
| 364 | #endif | ||
| 365 | return 1; | 337 | return 1; |
| 366 | } | 338 | } |
| 367 | 339 | ||
| 368 | static int | 340 | static int |
| 369 | echo_console(UI *ui) | 341 | echo_console(UI *ui) |
| 370 | { | 342 | { |
| 371 | #if defined(TTY_set) | ||
| 372 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 343 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
| 373 | tty_new.TTY_FLAGS |= ECHO; | 344 | tty_new.c_lflag |= ECHO; |
| 374 | #endif | 345 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
| 375 | |||
| 376 | #if defined(TTY_set) | ||
| 377 | if (is_a_tty && (TTY_set(fileno(tty_in), &tty_new) == -1)) | ||
| 378 | return 0; | 346 | return 0; |
| 379 | #endif | ||
| 380 | return 1; | 347 | return 1; |
| 381 | } | 348 | } |
| 382 | 349 | ||
diff --git a/src/lib/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c index a67cf53f2a..d3be332f19 100644 --- a/src/lib/libssl/src/crypto/ui/ui_openssl.c +++ b/src/lib/libssl/src/crypto/ui/ui_openssl.c | |||
| @@ -122,33 +122,11 @@ | |||
| 122 | #include <errno.h> | 122 | #include <errno.h> |
| 123 | 123 | ||
| 124 | #include <unistd.h> | 124 | #include <unistd.h> |
| 125 | /* If unistd.h defines _POSIX_VERSION, we conclude that we | 125 | #include <termios.h> |
| 126 | * are on a POSIX system and have sigaction and termios. */ | ||
| 127 | #if defined(_POSIX_VERSION) | ||
| 128 | |||
| 129 | #define SIGACTION | ||
| 130 | #if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY) | ||
| 131 | #define TERMIOS | ||
| 132 | #endif | ||
| 133 | |||
| 134 | #endif | ||
| 135 | 126 | ||
| 136 | #include "ui_locl.h" | 127 | #include "ui_locl.h" |
| 137 | #include "cryptlib.h" | 128 | #include "cryptlib.h" |
| 138 | 129 | ||
| 139 | |||
| 140 | /* There are 5 types of terminal interface supported, | ||
| 141 | * TERMIO, TERMIOS, VMS, MSDOS and SGTTY | ||
| 142 | */ | ||
| 143 | |||
| 144 | |||
| 145 | #include <termios.h> | ||
| 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) | ||
| 150 | |||
| 151 | |||
| 152 | #include <sys/ioctl.h> | 130 | #include <sys/ioctl.h> |
| 153 | 131 | ||
| 154 | #ifndef NX509_SIG | 132 | #ifndef NX509_SIG |
| @@ -159,7 +137,7 @@ | |||
| 159 | /* Define globals. They are protected by a lock */ | 137 | /* Define globals. They are protected by a lock */ |
| 160 | static struct sigaction savsig[NX509_SIG]; | 138 | static struct sigaction savsig[NX509_SIG]; |
| 161 | 139 | ||
| 162 | static TTY_STRUCT tty_orig, tty_new; | 140 | static struct termios tty_orig, tty_new; |
| 163 | static FILE *tty_in, *tty_out; | 141 | static FILE *tty_in, *tty_out; |
| 164 | static int is_a_tty; | 142 | static int is_a_tty; |
| 165 | 143 | ||
| @@ -331,8 +309,7 @@ open_console(UI *ui) | |||
| 331 | if ((tty_out = fopen(DEV_TTY, "w")) == NULL) | 309 | if ((tty_out = fopen(DEV_TTY, "w")) == NULL) |
| 332 | tty_out = stderr; | 310 | tty_out = stderr; |
| 333 | 311 | ||
| 334 | #if defined(TTY_get) | 312 | if (tcgetattr(fileno(tty_in), &tty_orig) == -1) { |
| 335 | if (TTY_get(fileno(tty_in), &tty_orig) == -1) { | ||
| 336 | if (errno == ENOTTY) | 313 | if (errno == ENOTTY) |
| 337 | is_a_tty = 0; | 314 | is_a_tty = 0; |
| 338 | else | 315 | else |
| @@ -346,37 +323,27 @@ open_console(UI *ui) | |||
| 346 | else | 323 | else |
| 347 | return 0; | 324 | return 0; |
| 348 | } | 325 | } |
| 349 | #endif | 326 | |
| 350 | return 1; | 327 | return 1; |
| 351 | } | 328 | } |
| 352 | 329 | ||
| 353 | static int | 330 | static int |
| 354 | noecho_console(UI *ui) | 331 | noecho_console(UI *ui) |
| 355 | { | 332 | { |
| 356 | #ifdef TTY_FLAGS | ||
| 357 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 333 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
| 358 | tty_new.TTY_FLAGS &= ~ECHO; | 334 | tty_new.c_lflag &= ~ECHO; |
| 359 | #endif | 335 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
| 360 | |||
| 361 | #if defined(TTY_set) | ||
| 362 | if (is_a_tty && (TTY_set(fileno(tty_in), &tty_new) == -1)) | ||
| 363 | return 0; | 336 | return 0; |
| 364 | #endif | ||
| 365 | return 1; | 337 | return 1; |
| 366 | } | 338 | } |
| 367 | 339 | ||
| 368 | static int | 340 | static int |
| 369 | echo_console(UI *ui) | 341 | echo_console(UI *ui) |
| 370 | { | 342 | { |
| 371 | #if defined(TTY_set) | ||
| 372 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 343 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
| 373 | tty_new.TTY_FLAGS |= ECHO; | 344 | tty_new.c_lflag |= ECHO; |
| 374 | #endif | 345 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
| 375 | |||
| 376 | #if defined(TTY_set) | ||
| 377 | if (is_a_tty && (TTY_set(fileno(tty_in), &tty_new) == -1)) | ||
| 378 | return 0; | 346 | return 0; |
| 379 | #endif | ||
| 380 | return 1; | 347 | return 1; |
| 381 | } | 348 | } |
| 382 | 349 | ||
