Commit 40ee5f3f4065bc4fdb16fc48c74a1ffdea64f982
1 parent
38620986
Exists in
master
and in
3 other branches
Adding host & crl default settings.
Showing
6 changed files
with
61 additions
and
18 deletions
Show diff stats
configure.ac
| ... | ... | @@ -344,6 +344,8 @@ if test "$app_cv_self_signed_certs" == "yes"; then |
| 344 | 344 | AC_DEFINE(SSL_ENABLE_CRL_CHECK) |
| 345 | 345 | fi |
| 346 | 346 | |
| 347 | +AC_ARG_WITH([default-crl], [AS_HELP_STRING([--with-default-crl], [Set lib3270 default crl url])], [ AC_DEFINE_UNQUOTED(LIB3270_DEFAULT_CRL,"$withval") ],[ AC_MSG_NOTICE(No default crl)]) | |
| 348 | + | |
| 347 | 349 | dnl --------------------------------------------------------------------------- |
| 348 | 350 | dnl Check for pic |
| 349 | 351 | dnl --------------------------------------------------------------------------- |
| ... | ... | @@ -387,6 +389,8 @@ AC_ARG_WITH([sdk-version], [AS_HELP_STRING([--with-sdk-version], [Setup library |
| 387 | 389 | AC_DEFINE(LIB3270_SDK_VERSION,$app_cv_sdkversion) |
| 388 | 390 | AC_SUBST(LIB3270_SDK_VERSION,$app_cv_sdkversion) |
| 389 | 391 | |
| 392 | +AC_ARG_WITH([default-host], [AS_HELP_STRING([--with-default-host], [Set lib3270 default host url])], [ AC_DEFINE_UNQUOTED(LIB3270_DEFAULT_HOST,"$withval") ],[ AC_MSG_NOTICE(No default host)]) | |
| 393 | + | |
| 390 | 394 | dnl --------------------------------------------------------------------------- |
| 391 | 395 | dnl Check for headers |
| 392 | 396 | dnl --------------------------------------------------------------------------- | ... | ... |
src/include/config.h.in
| ... | ... | @@ -31,10 +31,15 @@ |
| 31 | 31 | |
| 32 | 32 | #define LIB3270_CONFIG_INCLUDED 1 |
| 33 | 33 | |
| 34 | + /* Version info */ | |
| 34 | 35 | #undef PACKAGE_NAME |
| 35 | 36 | #undef PACKAGE_VERSION |
| 36 | 37 | #undef PACKAGE_RELEASE |
| 37 | 38 | |
| 39 | + /* Defaults */ | |
| 40 | + #undef LIB3270_DEFAULT_HOST | |
| 41 | + | |
| 42 | + /* Libraries */ | |
| 38 | 43 | #undef HAVE_GNUC_VISIBILITY |
| 39 | 44 | #undef HAVE_LIBINTL |
| 40 | 45 | #undef HAVE_GETADDRINFO |
| ... | ... | @@ -50,6 +55,7 @@ |
| 50 | 55 | #undef HAVE_LIBSSL |
| 51 | 56 | #undef SSL_ALLOW_SELF_SIGNED_CERT |
| 52 | 57 | #undef SSL_ENABLE_CRL_CHECK |
| 58 | + #undef LIB3270_DEFAULT_CRL | |
| 53 | 59 | |
| 54 | 60 | /* Windows Options */ |
| 55 | 61 | #ifdef WIN32 | ... | ... |
src/lib3270/host.c
| ... | ... | @@ -232,12 +232,6 @@ static void update_host(H3270 *h) |
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) | |
| 236 | -{ | |
| 237 | - CHECK_SESSION_HANDLE(hSession); | |
| 238 | - return hSession->host.full; | |
| 239 | -} | |
| 240 | - | |
| 241 | 235 | LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) |
| 242 | 236 | { |
| 243 | 237 | FAIL_IF_ONLINE(hSession); |
| ... | ... | @@ -245,11 +239,37 @@ LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) |
| 245 | 239 | return 0; |
| 246 | 240 | } |
| 247 | 241 | |
| 242 | +LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) | |
| 243 | +{ | |
| 244 | + CHECK_SESSION_HANDLE(hSession); | |
| 245 | + | |
| 246 | + if(hSession->host.full) | |
| 247 | + return hSession->host.full; | |
| 248 | + | |
| 249 | +#ifdef LIB3270_DEFAULT_HOST | |
| 250 | + return LIB3270_DEFAULT_HOST; | |
| 251 | +#else | |
| 252 | + return getenv("LIB3270_DEFAULT_HOST"); | |
| 253 | +#endif // LIB3270_DEFAULT_HOST | |
| 254 | + | |
| 255 | +} | |
| 256 | + | |
| 248 | 257 | LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
| 249 | 258 | { |
| 250 | 259 | FAIL_IF_ONLINE(h); |
| 251 | 260 | |
| 252 | - if(n && n != h->host.full) | |
| 261 | + if(!n) | |
| 262 | + { | |
| 263 | +#ifdef LIB3270_DEFAULT_HOST | |
| 264 | + n = LIB3270_DEFAULT_HOST; | |
| 265 | +#else | |
| 266 | + n = getenv("LIB3270_DEFAULT_HOST"); | |
| 267 | + if(!n) | |
| 268 | + return errno = EINVAL; | |
| 269 | +#endif // LIB3270_DEFAULT_HOST | |
| 270 | + } | |
| 271 | + | |
| 272 | + if(!h->host.full || strcmp(n,h->host.full)) | |
| 253 | 273 | { |
| 254 | 274 | static const struct _sch |
| 255 | 275 | { | ... | ... |
src/lib3270/session.c
| ... | ... | @@ -320,14 +320,6 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
| 320 | 320 | hSession->unlock_delay_ms = 350; // 0.35s after last unlock |
| 321 | 321 | hSession->pointer = (unsigned short) LIB3270_POINTER_LOCKED; |
| 322 | 322 | |
| 323 | -#ifdef SSL_ENABLE_CRL_CHECK | |
| 324 | - char *env = getenv("LIB3270_DEFAULT_CRL"); | |
| 325 | - if(env) | |
| 326 | - { | |
| 327 | - hSession->ssl.crl = strdup(env); | |
| 328 | - } | |
| 329 | -#endif // SSL_ENABLE_CRL_CHECK | |
| 330 | - | |
| 331 | 323 | // CSD |
| 332 | 324 | for(f=0;f<4;f++) |
| 333 | 325 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; | ... | ... |
src/lib3270/ssl/linux/getcrl.c
| ... | ... | @@ -47,6 +47,7 @@ |
| 47 | 47 | #endif // HAVE_LDAP |
| 48 | 48 | |
| 49 | 49 | #include "../../private.h" |
| 50 | +#include <trace_dsc.h> | |
| 50 | 51 | #include <errno.h> |
| 51 | 52 | #include <lib3270.h> |
| 52 | 53 | |
| ... | ... | @@ -97,6 +98,24 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
| 97 | 98 | { |
| 98 | 99 | X509_CRL * crl = NULL; |
| 99 | 100 | |
| 101 | + if(!hSession->ssl.crl) | |
| 102 | + { | |
| 103 | +#ifdef LIB3270_DEFAULT_CRL | |
| 104 | + hSession->ssl.crl = strdup(LIB3270_DEFAULT_CRL); | |
| 105 | +#else | |
| 106 | + char *env = getenv("LIB3270_DEFAULT_CRL"); | |
| 107 | + if(env) | |
| 108 | + hSession->ssl.crl = strdup(env); | |
| 109 | +#endif // LIB3270_DEFAULT_CRL | |
| 110 | + } | |
| 111 | + | |
| 112 | + if(!hSession->ssl.crl) | |
| 113 | + { | |
| 114 | + return NULL; | |
| 115 | + } | |
| 116 | + | |
| 117 | + trace_ssl(hSession, "crl=%s",hSession->ssl.crl); | |
| 118 | + | |
| 100 | 119 | if(strncasecmp(hSession->ssl.crl,"file://",7) == 0) |
| 101 | 120 | { |
| 102 | 121 | lib3270_autoptr(FILE) hCRL = fopen(hSession->ssl.crl+7,"r"); | ... | ... |
src/lib3270/testprogram/testprogram.c
| ... | ... | @@ -11,16 +11,18 @@ int main(int numpar, char *param[]) |
| 11 | 11 | { |
| 12 | 12 | H3270 * h; |
| 13 | 13 | int rc = 0; |
| 14 | - const char * url = getenv("LIB3270_DEFAULT_HOST"); | |
| 15 | - | |
| 16 | 14 | |
| 17 | 15 | h = lib3270_session_new(""); |
| 18 | 16 | printf("3270 session %p created\n]",h); |
| 19 | 17 | |
| 18 | + // lib3270_set_url(h,url ? url : "tn3270://fandezhi.efglobe.com"); | |
| 19 | + | |
| 20 | + if(lib3270_set_url(h,NULL)) | |
| 21 | + lib3270_set_url(h,"tn3270://fandezhi.efglobe.com"); | |
| 22 | + | |
| 20 | 23 | // lib3270_set_toggle(h,LIB3270_TOGGLE_DS_TRACE,1); |
| 21 | 24 | lib3270_set_toggle(h,LIB3270_TOGGLE_SSL_TRACE,1); |
| 22 | 25 | |
| 23 | - lib3270_set_url(h,url ? url : "tn3270://fandezhi.efglobe.com"); | |
| 24 | 26 | rc = lib3270_connect(h,120); |
| 25 | 27 | |
| 26 | 28 | printf("\nConnect %s exits with rc=%d\n",lib3270_get_url(h),rc); | ... | ... |