1#ifndef HEADER_CURL_SETUP_VMS_H 2#define HEADER_CURL_SETUP_VMS_H 3/*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. 11 * 12 * This software is licensed as described in the file COPYING, which 13 * you should have received as part of this distribution. The terms 14 * are also available at http://curl.haxx.se/docs/copyright.html. 15 * 16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 * copies of the Software, and permit persons to whom the Software is 18 * furnished to do so, under the terms of the COPYING file. 19 * 20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 * KIND, either express or implied. 22 * 23 ***************************************************************************/ 24 25/* */ 26/* JEM, 12/30/12, VMS now generates config.h, so only define wrappers for */ 27/* getenv(), getpwuid() and provide is_vms_shell() */ 28/* Also need upper case symbols for system services, and */ 29/* OpenSSL, and some Kerberos image */ 30 31#ifdef __DECC 32#pragma message save 33#pragma message disable dollarid 34#endif 35 36/* Hide the stuff we are overriding */ 37#define getenv decc_getenv 38#ifdef __DECC 39# if __INITIAL_POINTER_SIZE != 64 40# define getpwuid decc_getpwuid 41# endif 42#endif 43#include <stdlib.h> 44 char * decc$getenv(const char * __name); 45#include <pwd.h> 46 47#include <string.h> 48#include <unixlib.h> 49 50#undef getenv 51#undef getpwuid 52#define getenv vms_getenv 53#define getpwuid vms_getpwuid 54 55/* VAX needs these in upper case when compiling exact case */ 56#define sys$assign SYS$ASSIGN 57#define sys$dassgn SYS$DASSGN 58#define sys$qiow SYS$QIOW 59 60#ifdef __DECC 61# if __INITIAL_POINTER_SIZE 62# pragma __pointer_size __save 63# endif 64#endif 65 66#if __USE_LONG_GID_T 67# define decc_getpwuid DECC$__LONG_GID_GETPWUID 68#else 69# if __INITIAL_POINTER_SIZE 70# define decc_getpwuid decc$__32_getpwuid 71# else 72# define decc_getpwuid decc$getpwuid 73# endif 74#endif 75 76 struct passwd * decc_getpwuid(uid_t uid); 77 78#ifdef __DECC 79# if __INITIAL_POINTER_SIZE == 32 80/* Translate the path, but only if the path is a VMS file specification */ 81/* The translation is usually only needed for older versions of VMS */ 82static char * vms_translate_path(const char * path) { 83char * unix_path; 84char * test_str; 85 86 /* See if the result is in VMS format, if not, we are done */ 87 /* Assume that this is a PATH, not just some data */ 88 test_str = strpbrk(path, ":[<^"); 89 if(test_str == NULL) { 90 return (char *)path; 91 } 92 93 unix_path = decc$translate_vms(path); 94 95 if((int)unix_path <= 0) { 96 /* We can not translate it, so return the original string */ 97 return (char *)path; 98 } 99} 100# else 101 /* VMS translate path is actually not needed on the current 64 bit */ 102 /* VMS platforms, so instead of figuring out the pointer settings */ 103 /* Change it to a noop */ 104# define vms_translate_path(__path) __path 105# endif 106#endif 107 108#ifdef __DECC 109# if __INITIAL_POINTER_SIZE 110# pragma __pointer_size __restore 111# endif 112#endif 113 114static char * vms_getenv(const char * envvar) { 115 116char * result; 117char * vms_path; 118 119 /* first use the DECC getenv() function */ 120 result = decc$getenv(envvar); 121 if(result == NULL) { 122 return result; 123 } 124 125 vms_path = result; 126 result = vms_translate_path(vms_path); 127 128 /* note that if you backport this to use VAX C RTL, that the VAX C RTL */ 129 /* may do a malloc(2048) for each call to getenv(), so you will need */ 130 /* to add a free(vms_path) */ 131 /* Do not do a free() for DEC C RTL builds, which should be used for */ 132 /* VMS 5.5-2 and later, even if using GCC */ 133 134 return result; 135} 136 137 138static struct passwd vms_passwd_cache; 139 140static struct passwd * vms_getpwuid(uid_t uid) { 141 142struct passwd * my_passwd; 143 144/* Hack needed to support 64 bit builds, decc_getpwnam is 32 bit only */ 145#ifdef __DECC 146# if __INITIAL_POINTER_SIZE 147__char_ptr32 unix_path; 148# else 149char * unix_path; 150# endif 151#else 152char * unix_path; 153#endif 154 155 my_passwd = decc_getpwuid(uid); 156 if(my_passwd == NULL) { 157 return my_passwd; 158 } 159 160 unix_path = vms_translate_path(my_passwd->pw_dir); 161 162 if((long)unix_path <= 0) { 163 /* We can not translate it, so return the original string */ 164 return my_passwd; 165 } 166 167 /* If no changes needed just return it */ 168 if(unix_path == my_passwd->pw_dir) { 169 return my_passwd; 170 } 171 172 /* Need to copy the structure returned */ 173 /* Since curl is only using pw_dir, no need to fix up * 174 /* the pw_shell when running under Bash */ 175 vms_passwd_cache.pw_name = my_passwd->pw_name; 176 vms_passwd_cache.pw_uid = my_passwd->pw_uid; 177 vms_passwd_cache.pw_gid = my_passwd->pw_uid; 178 vms_passwd_cache.pw_dir = unix_path; 179 vms_passwd_cache.pw_shell = my_passwd->pw_shell; 180 181 return &vms_passwd_cache; 182} 183 184#ifdef __DECC 185#pragma message restore 186#endif 187 188/* Bug - VMS OpenSSL and Kerberos universal symbols are in uppercase only */ 189/* VMS libraries should have universal symbols in exact and uppercase */ 190 191#define ASN1_INTEGER_get ASN1_INTEGER_GET 192#define ASN1_STRING_data ASN1_STRING_DATA 193#define ASN1_STRING_length ASN1_STRING_LENGTH 194#define ASN1_STRING_print ASN1_STRING_PRINT 195#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8 196#define ASN1_STRING_type ASN1_STRING_TYPE 197#define BIO_ctrl BIO_CTRL 198#define BIO_free BIO_FREE 199#define BIO_new BIO_NEW 200#define BIO_s_mem BIO_S_MEM 201#define BN_bn2bin BN_BN2BIN 202#define BN_num_bits BN_NUM_BITS 203#define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA 204#define CRYPTO_free CRYPTO_FREE 205#define CRYPTO_malloc CRYPTO_MALLOC 206#define DES_ecb_encrypt DES_ECB_ENCRYPT 207#define DES_set_key DES_SET_KEY 208#define DES_set_odd_parity DES_SET_ODD_PARITY 209#define ENGINE_ctrl ENGINE_CTRL 210#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD 211#define ENGINE_finish ENGINE_FINISH 212#define ENGINE_free ENGINE_FREE 213#define ENGINE_get_first ENGINE_GET_FIRST 214#define ENGINE_get_id ENGINE_GET_ID 215#define ENGINE_get_next ENGINE_GET_NEXT 216#define ENGINE_init ENGINE_INIT 217#define ENGINE_load_builtin_engines ENGINE_LOAD_BUILTIN_ENGINES 218#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY 219#define ENGINE_set_default ENGINE_SET_DEFAULT 220#define ERR_clear_error ERR_CLEAR_ERROR 221#define ERR_error_string ERR_ERROR_STRING 222#define ERR_error_string_n ERR_ERROR_STRING_N 223#define ERR_free_strings ERR_FREE_STRINGS 224#define ERR_get_error ERR_GET_ERROR 225#define ERR_peek_error ERR_PEEK_ERROR 226#define ERR_remove_state ERR_REMOVE_STATE 227#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS 228#define EVP_PKEY_free EVP_PKEY_FREE 229#define EVP_cleanup EVP_CLEANUP 230#define GENERAL_NAMES_free GENERAL_NAMES_FREE 231#define MD4_Final MD4_FINAL 232#define MD4_Init MD4_INIT 233#define MD4_Update MD4_UPDATE 234#define MD5_Final MD5_FINAL 235#define MD5_Init MD5_INIT 236#define MD5_Update MD5_UPDATE 237#define OPENSSL_add_all_algo_noconf OPENSSL_ADD_ALL_ALGO_NOCONF 238#define PEM_read_X509 PEM_READ_X509 239#define PEM_write_bio_X509 PEM_WRITE_BIO_X509 240#define PKCS12_PBE_add PKCS12_PBE_ADD 241#define PKCS12_free PKCS12_FREE 242#define PKCS12_parse PKCS12_PARSE 243#define RAND_add RAND_ADD 244#define RAND_bytes RAND_BYTES 245#define RAND_egd RAND_EGD 246#define RAND_file_name RAND_FILE_NAME 247#define RAND_load_file RAND_LOAD_FILE 248#define RAND_status RAND_STATUS 249#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME 250#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA 251#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL 252#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY 253#define SSL_CTX_ctrl SSL_CTX_CTRL 254#define SSL_CTX_free SSL_CTX_FREE 255#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE 256#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS 257#define SSL_CTX_new SSL_CTX_NEW 258#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST 259#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD 260#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB 261#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY 262#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY 263#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE 264#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE 265#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE 266#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE 267#define SSL_SESSION_free SSL_SESSION_FREE 268#define SSL_connect SSL_CONNECT 269#define SSL_free SSL_FREE 270#define SSL_get1_session SSL_GET1_SESSION 271#define SSL_get_certificate SSL_GET_CERTIFICATE 272#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER 273#define SSL_get_error SSL_GET_ERROR 274#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN 275#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE 276#define SSL_get_privatekey SSL_GET_PRIVATEKEY 277#define SSL_get_shutdown SSL_GET_SHUTDOWN 278#define SSL_get_verify_result SSL_GET_VERIFY_RESULT 279#define SSL_library_init SSL_LIBRARY_INIT 280#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS 281#define SSL_new SSL_NEW 282#define SSL_peek SSL_PEEK 283#define SSL_pending SSL_PENDING 284#define SSL_read SSL_READ 285#define SSL_set_connect_state SSL_SET_CONNECT_STATE 286#define SSL_set_fd SSL_SET_FD 287#define SSL_set_session SSL_SET_SESSION 288#define SSL_shutdown SSL_SHUTDOWN 289#define SSL_write SSL_WRITE 290#define SSLeay SSLEAY 291#define SSLv23_client_method SSLV23_CLIENT_METHOD 292#define SSLv3_client_method SSLV3_CLIENT_METHOD 293#define TLSv1_client_method TLSV1_CLIENT_METHOD 294#define UI_OpenSSL UI_OPENSSL 295#define X509V3_EXT_print X509V3_EXT_PRINT 296#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL 297#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT 298#define X509_LOOKUP_file X509_LOOKUP_FILE 299#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA 300#define X509_NAME_get_entry X509_NAME_GET_ENTRY 301#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID 302#define X509_NAME_print_ex X509_NAME_PRINT_EX 303#define X509_STORE_CTX_get_current_cert X509_STORE_CTX_GET_CURRENT_CERT 304#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP 305#define X509_STORE_set_flags X509_STORE_SET_FLAGS 306#define X509_check_issued X509_CHECK_ISSUED 307#define X509_free X509_FREE 308#define X509_get_ext_d2i X509_GET_EXT_D2I 309#define X509_get_issuer_name X509_GET_ISSUER_NAME 310#define X509_get_pubkey X509_GET_PUBKEY 311#define X509_get_serialNumber X509_GET_SERIALNUMBER 312#define X509_get_subject_name X509_GET_SUBJECT_NAME 313#define X509_load_crl_file X509_LOAD_CRL_FILE 314#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING 315#define d2i_PKCS12_fp D2I_PKCS12_FP 316#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT 317#define sk_num SK_NUM 318#define sk_pop_free SK_POP_FREE 319#define sk_value SK_VALUE 320 321#define USE_UPPERCASE_GSSAPI 1 322#define gss_seal GSS_SEAL 323#define gss_unseal GSS_UNSEAL 324 325#define USE_UPPERCASE_KRBAPI 1 326 327/* AI_NUMERICHOST needed for IP V6 support in Curl */ 328#ifdef HAVE_NETDB_H 329#include <netdb.h> 330#ifndef AI_NUMERICHOST 331#ifdef ENABLE_IPV6 332#undef ENABLE_IPV6 333#endif 334#endif 335#endif 336 337/* VAX symbols are always in uppercase */ 338#ifdef __VAX 339#define inflate INFLATE 340#define inflateEnd INFLATEEND 341#define inflateInit2_ INFLATEINIT2_ 342#define inflateInit_ INFLATEINIT_ 343#define zlibVersion ZLIBVERSION 344#endif 345 346/* Older VAX OpenSSL port defines these as Macros */ 347/* Need to include the headers first and then redefine */ 348/* that way a newer port will also work if some one has one */ 349#ifdef __VAX 350 351# if (OPENSSL_VERSION_NUMBER < 0x00907001L) 352# define des_set_odd_parity DES_SET_ODD_PARITY 353# define des_set_key DES_SET_KEY 354# define des_ecb_encrypt DES_ECB_ENCRYPT 355 356# endif 357# include <openssl/evp.h> 358# ifndef OpenSSL_add_all_algorithms 359# define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS 360 void OPENSSL_ADD_ALL_ALGORITHMS(void); 361# endif 362 363 /* Curl defines these to lower case and VAX needs them in upper case */ 364 /* So we need static routines */ 365# if (OPENSSL_VERSION_NUMBER < 0x00907001L) 366 367# undef des_set_odd_parity 368# undef DES_set_odd_parity 369# undef des_set_key 370# undef DES_set_key 371# undef des_ecb_encrypt 372# undef DES_ecb_encrypt 373 374 static void des_set_odd_parity(des_cblock *key) { 375 DES_SET_ODD_PARITY(key); 376 } 377 378 static int des_set_key(const_des_cblock *key, 379 des_key_schedule schedule) { 380 return DES_SET_KEY(key, schedule); 381 } 382 383 static void des_ecb_encrypt(const_des_cblock *input, 384 des_cblock *output, 385 des_key_schedule ks,int enc) { 386 DES_ECB_ENCRYPT(input, output, ks, enc); 387 } 388#endif 389/* Need this to stop a macro redefinition error */ 390#if OPENSSL_VERSION_NUMBER < 0x00907000L 391# ifdef X509_STORE_set_flags 392# undef X509_STORE_set_flags 393# define X509_STORE_set_flags(x,y) Curl_nop_stmt 394# endif 395#endif 396#endif 397 398#endif /* HEADER_CURL_SETUP_VMS_H */ 399