Hello, We created a patch to enable selection of shared sasl library build with static-linked plugins. The patch is separated into three files for convenience: 1-static-plugin-autotools.patch 2-static-plugin-nmake.patch 3-deleting-build-warnings.patch We hope the patch will be merged to the official distribution. The following contents are the detail description of the patch. ******************************************************************************** * Changes ******************************************************************************** * Added --enable-staticplugin option for configure script. * Added SASLDB, SASL_DB_PATH, and STATIC_PLUGIN options for nmake build on Windows. * Fixed to delete several build warnings. ******************************************************************************** * Status ******************************************************************************** * Verified build target: Linux 32bit/64bit and Windows 32bit/64bit. Test environment: Windows: Windows server 2008 standard SP1 64bit with Visual Studio 2008 SP Linux: CentOS 5.3 64bit with gcc-4.3.4 * Verified plugins: anonymous, plain, login, cram-md5, digest-md5, ntlm. ******************************************************************************** * How to build ******************************************************************************** **************************************** * Build on Linux **************************************** 1. Extract source archive and apply the patch files. > tar xzf cyrus-sasl-2.1.24rc1.tar.gz > cd cyrus-sasl.2.1.24 > patch -p1 < ../1-static-plugin-autotools.patch > patch -p1 < ../2-static-plugin-nmake.patch > patch -p1 < ../3-deleting-build-warnings.patch 2. Rebuild configure script. On the top directory of source tree: > rm -rf autom4te.cache > > aclocal -I cmulocal -I config > autoheader > automake -c -f -a > autoconf > > cd saslauthd > aclocal -I ../cmulocal -I ../config > autoheader > automake -c -f -a > autoconf > cd .. 3. Run configure script to create Makefile > ./configure --enable-staticplugin 4. Build the library and plugins. > make **************************************** * Build on Windows (with nmake) **************************************** 1. Extract source archive and apply the patch files. Do the equivalent operation as the linux build. 2. Open Visual Studio Command Line Prompt Run the following command to select your required compiler: for 32bit build, > "%VCINSTALLDIR%\vcvarsall.bat" x86 for 64bit build, > "%VCINSTALLDIR%\vcvarsall.bat" amd64 3. Build the library and plugins. On the top directory of source tree: > nmake -f NTMakefile STATIC_PLUGIN=yes You can specify SASLDB=1 SASL_DB_PATH=c:\\\\sasl\\\\sasldb options to enable sasldb plugin with berkeley db. You need also DB_LIBPATH, DB_INCLUDE, and DB_LIB options. The plugin will be also statically linked with STATIC_PLUGIN=yes option. ******************************************************************************** Regards, Takashi HOSHINO <hoshino@xxxxxxxxxxxxxxxxx> Cybozu Labs, Inc.
diff --git a/configure.in b/configure.in index f7f1a23..b028985 100644 --- a/configure.in +++ b/configure.in @@ -129,7 +129,7 @@ if test "$enable_staticdlopen" = yes; then fi if test "$ac_cv_prog_gcc" = yes; then - CFLAGS="-Wall -W ${CFLAGS}" + CFLAGS="-Wall -W -Wno-unused ${CFLAGS}" fi AC_ARG_WITH(purecov,[ --with-purecov link with purecov]) diff --git a/include/sasl.h b/include/sasl.h index dfc4d6a..4ee816a 100755 --- a/include/sasl.h +++ b/include/sasl.h @@ -130,6 +130,7 @@ #define SASL_VERSION_FULL ((SASL_VERSION_MAJOR << 16) |\ (SASL_VERSION_MINOR << 8) | SASL_VERSION_STEP) +#include <stdlib.h> #include "prop.h" /************* @@ -223,9 +224,9 @@ extern "C" { /* memory allocation functions which may optionally be replaced: */ -typedef void *sasl_malloc_t(unsigned long); -typedef void *sasl_calloc_t(unsigned long, unsigned long); -typedef void *sasl_realloc_t(void *, unsigned long); +typedef void *sasl_malloc_t(size_t); +typedef void *sasl_calloc_t(size_t, size_t); +typedef void *sasl_realloc_t(void *, size_t); typedef void sasl_free_t(void *); LIBSASL_API void sasl_set_alloc(sasl_malloc_t *, diff --git a/lib/common.c b/lib/common.c index b76df23..5731d1e 100644 --- a/lib/common.c +++ b/lib/common.c @@ -386,7 +386,7 @@ _sasl_encodev (sasl_conn_t *conn, conn->multipacket_encoded_data.curlen += *outputlen; *output = conn->multipacket_encoded_data.data; - *outputlen = conn->multipacket_encoded_data.curlen; + *outputlen = (unsigned) conn->multipacket_encoded_data.curlen; } (*p_num_packets)++; @@ -454,7 +454,7 @@ int sasl_encodev(sasl_conn_t *conn, /* Fit as many bytes in last_invec, so that we have conn->oparams.maxoutbuf bytes in total. */ - last_invec.iov_len = conn->oparams.maxoutbuf - total_size; + last_invec.iov_len = (long) (conn->oparams.maxoutbuf - total_size); /* Point to the first byte of the current record. */ last_invec.iov_base = invec[i].iov_base; @@ -520,7 +520,7 @@ int sasl_encodev(sasl_conn_t *conn, next_buf = (char *) last_invec.iov_base + last_invec.iov_len; /* Note - remainder_len is how many bytes left to be encoded in the current IOV slot. */ - remainder_len = (total_size + invec[i].iov_len) - conn->oparams.maxoutbuf; + remainder_len = (unsigned) ((total_size + invec[i].iov_len) - conn->oparams.maxoutbuf); /* Skip all consumed IOV records */ invec += i + 1; diff --git a/lib/server.c b/lib/server.c index 4bd987c..04422cc 100644 --- a/lib/server.c +++ b/lib/server.c @@ -621,7 +621,7 @@ static int load_config(const sasl_callback_t *verifyfile_cb) goto done; } - snprintf(config_filename, len, "%.*s%c%s.conf", path_len, path_to_config, + snprintf(config_filename, len, "%.*s%c%s.conf", (int) path_len, path_to_config, HIER_DELIMITER, global_callbacks.appname); /* Ask the application if it's safe to use this file */ diff --git a/plugins/ntlm.c b/plugins/ntlm.c index 5188d69..828eb9b 100644 --- a/plugins/ntlm.c +++ b/plugins/ntlm.c @@ -57,6 +57,7 @@ #ifdef WIN32 # include <process.h> /* for getpid */ typedef int pid_t; +# define getpid _getpid #else # include <unistd.h> # include <sys/types.h> @@ -275,7 +276,7 @@ static void load_buffer(u_char *buf, const u_char *str, uint16 len, { if (len) { if (unicode) { - to_unicode(base + *offset, str, len); + to_unicode(base + *offset, (char *) str, len); len *= 2; } else { @@ -373,10 +374,10 @@ static unsigned char *P16_lm(unsigned char *P16, sasl_secret_t *passwd, char P14[14]; unsigned char S8[] = { 0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; - strncpy(P14, passwd->data, sizeof(P14)); + strncpy(P14, (char *) passwd->data, sizeof(P14)); ucase(P14, sizeof(P14)); - E(P16, P14, sizeof(P14), S8, sizeof(S8)); + E(P16, (unsigned char *) P14, sizeof(P14), S8, sizeof(S8)); *result = SASL_OK; return P16; } @@ -390,8 +391,8 @@ static unsigned char *P16_nt(unsigned char *P16, sasl_secret_t *passwd, *result = SASL_NOMEM; } else { - to_unicode(*buf, passwd->data, passwd->len); - MD4(*buf, 2 * passwd->len, P16); + to_unicode(*(unsigned char **) buf, (char *) passwd->data, passwd->len); + MD4(*(unsigned char **) buf, 2 * passwd->len, P16); *result = SASL_OK; } return P16; @@ -444,9 +445,9 @@ static unsigned char *V2(unsigned char *V2, sasl_secret_t *passwd, strcpy(upper, authid); if (target) strcat(upper, target); ucase(upper, len); - to_unicode(*buf, upper, len); + to_unicode(*(unsigned char **) buf, upper, len); - HMAC(EVP_md5(), hash, MD4_DIGEST_LENGTH, *buf, 2 * len, hash, &len); + HMAC(EVP_md5(), hash, MD4_DIGEST_LENGTH, *(unsigned char **) buf, 2 * len, hash, &len); /* V2 = HMAC-MD5(NTLMv2hash, challenge + blob) + blob */ HMAC_Init(&ctx, hash, len, EVP_md5()); @@ -768,8 +769,8 @@ static void make_netbios_name(const char *in, unsigned char out[]) */ n = strcspn(in, "."); if (n > 16) n = 16; - strncpy(out+18, in, n); - in = out+18; + strncpy((char *) out+18, in, n); + in = (char *) out+18; ucase(in, n); out[j++] = 0x20; @@ -831,7 +832,7 @@ static SOCKET smb_connect_server(const sasl_utils_t *utils, const char *client, s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); if (s < 0) continue; - if (connect(s, r->ai_addr, r->ai_addrlen) >= 0) + if (connect(s, r->ai_addr, (int) r->ai_addrlen) >= 0) break; #ifdef WIN32 saved_errno = WSAGetLastError(); @@ -845,7 +846,7 @@ static SOCKET smb_connect_server(const sasl_utils_t *utils, const char *client, if (r->ai_family == AF_INET6) niflags |= NI_WITHSCOPEID; #endif - if (getnameinfo(r->ai_addr, r->ai_addrlen, hbuf, sizeof(hbuf), + if (getnameinfo(r->ai_addr, (socklen_t) r->ai_addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), niflags) != 0) { strcpy(hbuf, "unknown"); strcpy(pbuf, "unknown"); @@ -862,7 +863,7 @@ static SOCKET smb_connect_server(const sasl_utils_t *utils, const char *client, utils->free (error_str); } if (s < 0) { - if (getnameinfo(ai->ai_addr, ai->ai_addrlen, NULL, 0, + if (getnameinfo(ai->ai_addr, (socklen_t) ai->ai_addrlen, NULL, 0, pbuf, sizeof(pbuf), NI_NUMERICSERV) != 0) { strcpy(pbuf, "unknown"); } @@ -1033,7 +1034,7 @@ static int smb_negotiate_protocol(const sasl_utils_t *utils, "NTLM: error reading NEGPROT response"); return SASL_FAIL; } - p = text->out_buf; + p = (unsigned char *) text->out_buf; /* parse the header */ if (len < SMB_HDR_SIZE) { @@ -1115,7 +1116,7 @@ static int smb_negotiate_protocol(const sasl_utils_t *utils, return SASL_NOMEM; } memcpy(*domain, p, len); - from_unicode(*domain, *domain, len); + from_unicode(*domain, *(unsigned char **) domain, len); text->flags |= NTLM_TARGET_IS_DOMAIN; } @@ -1256,7 +1257,7 @@ static int smb_session_setup(const sasl_utils_t *utils, server_context_t *text, "NTLM: error reading SESSIONSETUP response"); return SASL_FAIL; } - p = text->out_buf; + p = (unsigned char *) text->out_buf; /* parse the header */ if (len < SMB_HDR_SIZE) { @@ -1343,12 +1344,12 @@ static int create_challenge(const sasl_utils_t *utils, return SASL_NOMEM; } - base = *buf; + base = *(u_char **) buf; memset(base, 0, *outlen); memcpy(base + NTLM_SIG_OFFSET, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE)); htoil(base + NTLM_TYPE_OFFSET, NTLM_TYPE_CHALLENGE); load_buffer(base + NTLM_TYPE2_TARGET_OFFSET, - ucase(target, 0), (uint16) xstrlen(target), flags & NTLM_USE_UNICODE, + (u_char *) ucase(target, 0), (uint16) xstrlen(target), flags & NTLM_USE_UNICODE, base, &offset); htoil(base + NTLM_TYPE2_FLAGS_OFFSET, flags); memcpy(base + NTLM_TYPE2_CHALLENGE_OFFSET, nonce, NTLM_NONCE_LENGTH); @@ -1500,26 +1501,26 @@ static int ntlm_server_mech_step2(server_context_t *text, return SASL_BADPROT; } - result = unload_buffer(sparams->utils, clientin + NTLM_TYPE3_LMRESP_OFFSET, + result = unload_buffer(sparams->utils, (u_char *) clientin + NTLM_TYPE3_LMRESP_OFFSET, (u_char **) &lm_resp, &lm_resp_len, 0, - clientin, clientinlen); + (u_char *) clientin, clientinlen); if (result != SASL_OK) goto cleanup; - result = unload_buffer(sparams->utils, clientin + NTLM_TYPE3_NTRESP_OFFSET, + result = unload_buffer(sparams->utils, (u_char *) clientin + NTLM_TYPE3_NTRESP_OFFSET, (u_char **) &nt_resp, &nt_resp_len, 0, - clientin, clientinlen); + (u_char *) clientin, clientinlen); if (result != SASL_OK) goto cleanup; - result = unload_buffer(sparams->utils, clientin + NTLM_TYPE3_DOMAIN_OFFSET, + result = unload_buffer(sparams->utils, (u_char *) clientin + NTLM_TYPE3_DOMAIN_OFFSET, (u_char **) &domain, &domain_len, text->flags & NTLM_USE_UNICODE, - clientin, clientinlen); + (u_char *) clientin, clientinlen); if (result != SASL_OK) goto cleanup; - result = unload_buffer(sparams->utils, clientin + NTLM_TYPE3_USER_OFFSET, + result = unload_buffer(sparams->utils, (u_char *) clientin + NTLM_TYPE3_USER_OFFSET, (u_char **) &authid, &authid_len, text->flags & NTLM_USE_UNICODE, - clientin, clientinlen); + (u_char *) clientin, clientinlen); if (result != SASL_OK) goto cleanup; /* require at least one response and an authid */ @@ -1582,7 +1583,7 @@ static int ntlm_server_mech_step2(server_context_t *text, } password->len = (unsigned) pass_len; - strncpy(password->data, auxprop_values[0].values[0], pass_len + 1); + strncpy((char *) password->data, auxprop_values[0].values[0], pass_len + 1); /* erase the plaintext password */ sparams->utils->prop_erase(sparams->propctx, password_request[0]); @@ -1800,15 +1801,15 @@ static int create_request(const sasl_utils_t *utils, return SASL_NOMEM; } - base = *buf; + base = *(u_char **) buf; memset(base, 0, *outlen); memcpy(base + NTLM_SIG_OFFSET, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE)); htoil(base + NTLM_TYPE_OFFSET, NTLM_TYPE_REQUEST); htoil(base + NTLM_TYPE1_FLAGS_OFFSET, flags); load_buffer(base + NTLM_TYPE1_DOMAIN_OFFSET, - domain, (uint16) xstrlen(domain), 0, base, &offset); + (u_char *) domain, (uint16) xstrlen(domain), 0, base, &offset); load_buffer(base + NTLM_TYPE1_WORKSTN_OFFSET, - wkstn, (uint16) xstrlen(wkstn), 0, base, &offset); + (u_char *) wkstn, (uint16) xstrlen(wkstn), 0, base, &offset); return SASL_OK; } @@ -1853,7 +1854,7 @@ static int create_response(const sasl_utils_t *utils, return SASL_NOMEM; } - base = *buf; + base = *(u_char **) buf; memset(base, 0, *outlen); memcpy(base + NTLM_SIG_OFFSET, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE)); htoil(base + NTLM_TYPE_OFFSET, NTLM_TYPE_RESPONSE); @@ -1862,15 +1863,15 @@ static int create_response(const sasl_utils_t *utils, load_buffer(base + NTLM_TYPE3_NTRESP_OFFSET, nt_resp, nt_resp ? NTLM_RESP_LENGTH : 0, 0, base, &offset); load_buffer(base + NTLM_TYPE3_DOMAIN_OFFSET, - ucase(domain, 0), (uint16) xstrlen(domain), flags & NTLM_USE_UNICODE, + (u_char *) ucase(domain, 0), (uint16) xstrlen(domain), flags & NTLM_USE_UNICODE, base, &offset); load_buffer(base + NTLM_TYPE3_USER_OFFSET, - user, (uint16) xstrlen(user), flags & NTLM_USE_UNICODE, base, &offset); + (u_char *) user, (uint16) xstrlen(user), flags & NTLM_USE_UNICODE, base, &offset); load_buffer(base + NTLM_TYPE3_WORKSTN_OFFSET, - ucase(wkstn, 0), (uint16) xstrlen(wkstn), flags & NTLM_USE_UNICODE, + (u_char *) ucase(wkstn, 0), (uint16) xstrlen(wkstn), flags & NTLM_USE_UNICODE, base, &offset); load_buffer(base + NTLM_TYPE3_SESSIONKEY_OFFSET, - key, key ? NTLM_SESSKEY_LENGTH : 0, 0, base, &offset); + (u_char *) key, key ? NTLM_SESSKEY_LENGTH : 0, 0, base, &offset); htoil(base + NTLM_TYPE3_FLAGS_OFFSET, flags); return SASL_OK; @@ -2006,7 +2007,7 @@ static int ntlm_client_mech_step2(client_context_t *text, flags &= NTLM_FLAGS_MASK; /* mask off the bits we don't support */ - result = unload_buffer(params->utils, serverin + NTLM_TYPE2_TARGET_OFFSET, + result = unload_buffer(params->utils, (u_char *) serverin + NTLM_TYPE2_TARGET_OFFSET, (u_char **) &domain, NULL, flags & NTLM_USE_UNICODE, (u_char *) serverin, serverinlen); @@ -2022,7 +2023,7 @@ static int ntlm_client_mech_step2(client_context_t *text, (*sendv2 == 'o' && *sendv2 == 'n') || *sendv2 == 't')) { /* put the cnonce in place after the LMv2 HMAC */ - char *cnonce = resp + MD5_DIGEST_LENGTH; + char *cnonce = (char *) resp + MD5_DIGEST_LENGTH; params->utils->log(NULL, SASL_LOG_DEBUG, "calculating LMv2 response"); @@ -2030,7 +2031,7 @@ static int ntlm_client_mech_step2(client_context_t *text, params->utils->rand(params->utils->rpool, cnonce, NTLM_NONCE_LENGTH); V2(resp, password, oparams->authid, domain, - serverin + NTLM_TYPE2_CHALLENGE_OFFSET, cnonce, NTLM_NONCE_LENGTH, + (u_char *) serverin + NTLM_TYPE2_CHALLENGE_OFFSET, (u_char *) cnonce, NTLM_NONCE_LENGTH, params->utils, &text->out_buf, &text->out_buf_len, &result); lm_resp = resp; diff --git a/plugins/plugin_common.c b/plugins/plugin_common.c index 45d83e9..aaaca4a 100644 --- a/plugins/plugin_common.c +++ b/plugins/plugin_common.c @@ -152,7 +152,7 @@ int _plug_ipfromstring(const sasl_utils_t *utils, const char *addr, return SASL_BADPARAM; } - len = ai->ai_addrlen; + len = (socklen_t) ai->ai_addrlen; memcpy(&ss, ai->ai_addr, len); freeaddrinfo(ai); sockaddr_unmapped((struct sockaddr *)&ss, &len); @@ -230,7 +230,7 @@ int _plug_buf_alloc(const sasl_utils_t *utils, char **rwbuf, } *curlen = newlen; } else if(*rwbuf && *curlen < newlen) { - size_t needed = 2*(*curlen); + unsigned needed = 2*(*curlen); while(needed < newlen) needed *= 2; @@ -251,7 +251,7 @@ int _plug_buf_alloc(const sasl_utils_t *utils, char **rwbuf, int _plug_strdup(const sasl_utils_t * utils, const char *in, char **out, int *outlen) { - size_t len = strlen(in); + int len = (int) strlen(in); if(!utils || !in || !out) { if(utils) PARAMERROR(utils); @@ -280,7 +280,7 @@ void _plug_free_string(const sasl_utils_t *utils, char **str) len = strlen(*str); - utils->erasebuffer(*str, len); + utils->erasebuffer(*str, (unsigned) len); utils->free(*str); *str=NULL; diff --git a/plugins/sasldb.c b/plugins/sasldb.c index 1edbb8b..e4b5e7c 100644 --- a/plugins/sasldb.c +++ b/plugins/sasldb.c @@ -248,7 +248,7 @@ static int sasldb_auxprop_store(void *glob_context __attribute__((unused)), ret = SASL_OK; for (cur = to_store; cur->name; cur++) { - char * value = (cur->values && cur->values[0]) ? cur->values[0] : NULL; + const char * value = (cur->values && cur->values[0]) ? cur->values[0] : NULL; if (cur->name[0] == '*') { continue; diff --git a/sample/client.c b/sample/client.c index 0ddb16c..6db16df 100644 --- a/sample/client.c +++ b/sample/client.c @@ -169,7 +169,7 @@ getsecret(sasl_conn_t *conn, } x->len = len; - strcpy(x->data, password); + strcpy((char *) x->data, password); memset(password, 0, len); *psecret = x; @@ -232,7 +232,7 @@ int mysasl_negotiate(FILE *in, FILE *out, sasl_conn_t *conn) char buf[8192]; const char *data; const char *chosenmech; - int len; + unsigned int len; int r, c; /* get the capability list */ @@ -334,7 +334,7 @@ int main(int argc, char *argv[]) sasl_conn_t *conn; FILE *in, *out; int fd; - int salen; + unsigned int salen; int niflags, error; struct sockaddr_storage local_ip, remote_ip; diff --git a/sample/sample-client.c b/sample/sample-client.c index 7a962a6..8c9fca1 100644 --- a/sample/sample-client.c +++ b/sample/sample-client.c @@ -41,6 +41,9 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#define _XOPEN_SOURCE 500 + #include <config.h> #include <limits.h> #include <stdio.h> @@ -50,7 +53,8 @@ # include <winsock2.h> __declspec(dllimport) char *optarg; __declspec(dllimport) int optind; -__declspec(dllimport) int getsubopt(char **optionp, const char * const *tokens, char **valuep); +__declspec(dllimport) int getsubopt(char **optionp, char * const *tokens, char **valuep); +#define HAVE_GETSUBOPT #else /* WIN32 */ # include <netinet/in.h> #endif /* WIN32 */ @@ -83,7 +87,7 @@ int main(void) #endif #ifndef HAVE_GETSUBOPT -int getsubopt(char **optionp, const char * const *tokens, char **valuep); +int getsubopt(char **optionp, char * const *tokens, char **valuep); #endif static const char @@ -403,7 +407,7 @@ samp_recv() fail("Line must start with 'S: '"); } - len = strlen(buf); + len = (unsigned) strlen(buf); if (len > 0 && buf[len-1] == '\n') { buf[len-1] = '\0'; } @@ -475,7 +479,7 @@ main(int argc, char *argv[]) case 'b': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)bit_subopts, &value)) { + switch(getsubopt(&options, (char * const *)bit_subopts, &value)) { case OPT_MIN: if (! value) errflag = 1; @@ -505,7 +509,7 @@ main(int argc, char *argv[]) case 'e': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)ext_subopts, &value)) { + switch(getsubopt(&options, (char * const *)ext_subopts, &value)) { case OPT_EXT_SSF: if (! value) errflag = 1; @@ -531,7 +535,7 @@ main(int argc, char *argv[]) case 'f': options = optarg; while (*options != '\0') { - switch(getsubopt(&options, (const char * const *)flag_subopts, &value)) { + switch(getsubopt(&options, (char * const *)flag_subopts, &value)) { case OPT_NOPLAIN: secprops.security_flags |= SASL_SEC_NOPLAINTEXT; break; @@ -561,7 +565,7 @@ main(int argc, char *argv[]) case 'i': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)ip_subopts, &value)) { + switch(getsubopt(&options, (char * const *)ip_subopts, &value)) { case OPT_IP_LOCAL: if (! value) errflag = 1; diff --git a/sample/sample-server.c b/sample/sample-server.c index db13d55..fd44c2e 100644 --- a/sample/sample-server.c +++ b/sample/sample-server.c @@ -42,6 +42,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define _XOPEN_SOURCE 500 + #include <config.h> #include <limits.h> #include <stdio.h> @@ -57,16 +59,17 @@ # include <winsock2.h> __declspec(dllimport) char *optarg; __declspec(dllimport) int optind; -__declspec(dllimport) int getsubopt(char **optionp, const char * const *tokens, char **valuep); +__declspec(dllimport) int getsubopt(char **optionp, char * const *tokens, char **valuep); #define HAVE_GETSUBOPT #else /* WIN32 */ # include <netinet/in.h> +# include <strings.h> #endif /* WIN32 */ #include <sasl.h> #include <saslutil.h> #ifndef HAVE_GETSUBOPT -int getsubopt(char **optionp, const char * const *tokens, char **valuep); +int getsubopt(char **optionp, char * const *tokens, char **valuep); #endif static const char @@ -262,7 +265,7 @@ samp_recv() fail("Line must start with 'C: '"); } - len = strlen(buf); + len = (unsigned) strlen(buf); if (len > 0 && buf[len-1] == '\n') { buf[len-1] = '\0'; } @@ -287,7 +290,8 @@ main(int argc, char *argv[]) sasl_ssf_t extssf = 0; const char *ext_authid = NULL; char *options, *value; - unsigned len, count; + unsigned len; + int count; const char *data; int serverlast = 0; sasl_ssf_t *ssf; @@ -322,7 +326,7 @@ main(int argc, char *argv[]) case 'b': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)bit_subopts, &value)) { + switch(getsubopt(&options, (char * const *)bit_subopts, &value)) { case OPT_MIN: if (! value) errflag = 1; @@ -344,7 +348,7 @@ main(int argc, char *argv[]) case 'e': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)ext_subopts, &value)) { + switch(getsubopt(&options, (char * const *)ext_subopts, &value)) { case OPT_EXT_SSF: if (! value) errflag = 1; @@ -370,7 +374,7 @@ main(int argc, char *argv[]) case 'f': options = optarg; while (*options != '\0') { - switch(getsubopt(&options, (const char * const *)flag_subopts, &value)) { + switch(getsubopt(&options, (char * const *)flag_subopts, &value)) { case OPT_NOPLAIN: secprops.security_flags |= SASL_SEC_NOPLAINTEXT; break; @@ -404,7 +408,7 @@ main(int argc, char *argv[]) case 'i': options = optarg; while (*options != '\0') - switch(getsubopt(&options, (const char * const *)ip_subopts, &value)) { + switch(getsubopt(&options, (char * const *)ip_subopts, &value)) { case OPT_IP_LOCAL: if (! value) errflag = 1; diff --git a/sample/server.c b/sample/server.c index e0af99c..00822e0 100644 --- a/sample/server.c +++ b/sample/server.c @@ -181,7 +181,7 @@ int mysasl_negotiate(FILE *in, FILE *out, sasl_conn_t *conn) dprintf(1, "generating client mechanism list... "); r = sasl_listmech(conn, NULL, NULL, " ", NULL, - &data, &len, &count); + &data, (unsigned *) &len, &count); if (r != SASL_OK) saslfail(r, "generating mechanism list"); dprintf(1, "%d mechanisms\n", count); } @@ -219,10 +219,10 @@ int mysasl_negotiate(FILE *in, FILE *out, sasl_conn_t *conn) /* start libsasl negotiation */ r = sasl_server_start(conn, chosenmech, buf, len, - &data, &len); + &data, (unsigned *) &len); } else { r = sasl_server_start(conn, chosenmech, NULL, 0, - &data, &len); + &data, (unsigned *) &len); } if (r != SASL_OK && r != SASL_CONTINUE) { @@ -250,7 +250,7 @@ int mysasl_negotiate(FILE *in, FILE *out, sasl_conn_t *conn) return -1; } - r = sasl_server_step(conn, buf, len, &data, &len); + r = sasl_server_step(conn, buf, len, &data, (unsigned *) &len); if (r != SASL_OK && r != SASL_CONTINUE) { saslerr(r, "performing SASL negotiation"); fputc('N', out); /* send NO to client */ @@ -326,7 +326,7 @@ int main(int argc, char *argv[]) char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; struct sockaddr_storage local_ip, remote_ip; int niflags, error; - int salen; + socklen_t salen; int nfds, fd = -1; FILE *in, *out; fd_set readfds; diff --git a/saslauthd/auth_pam.c b/saslauthd/auth_pam.c index 5af938f..f0f1906 100644 --- a/saslauthd/auth_pam.c +++ b/saslauthd/auth_pam.c @@ -43,13 +43,14 @@ */ /* PUBLIC DEPENDENCIES */ -#include "mechanisms.h" -#include <stdio.h> - #ifdef HAVE_CONFIG_H #include <config.h> +#undef PACKAGE #endif +#include "mechanisms.h" +#include <stdio.h> + #ifdef AUTH_PAM # include <string.h> diff --git a/saslauthd/auth_sasldb.c b/saslauthd/auth_sasldb.c index 720d339..862e698 100644 --- a/saslauthd/auth_sasldb.c +++ b/saslauthd/auth_sasldb.c @@ -36,12 +36,15 @@ #endif /* PUBLIC DEPENDENCIES */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#undef PACKAGE +#endif #include "mechanisms.h" #include <string.h> #include <stdlib.h> #include <pwd.h> -#include <config.h> /* END PUBLIC DEPENDENCIES */ #define RETURN(x) return strdup(x) diff --git a/saslauthd/md5.c b/saslauthd/md5.c index d38425d..1f8b8ac 100644 --- a/saslauthd/md5.c +++ b/saslauthd/md5.c @@ -25,7 +25,10 @@ These notices must be retained in any copies of any part of this documentation and/or software. */ +#ifdef HAVE_CONFIG_H #include <config.h> +#endif + #include "md5global.h" #include "md5.h" #include "hmac-md5.h" diff --git a/utils/pluginviewer.c b/utils/pluginviewer.c index a8c3bae..e090109 100644 --- a/utils/pluginviewer.c +++ b/utils/pluginviewer.c @@ -42,6 +42,9 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#define _XOPEN_SOURCE 500 + #include <config.h> #include <limits.h> #include <stdio.h> @@ -51,9 +54,11 @@ # include <winsock.h> __declspec(dllimport) char *optarg; __declspec(dllimport) int optind; -__declspec(dllimport) int getsubopt(char **optionp, const char * const *tokens, char **valuep); +__declspec(dllimport) int getsubopt(char **optionp, char * const *tokens, char **valuep); +#define HAVE_GETSUBOPT #else /* WIN32 */ # include <netinet/in.h> +# include <strings.h> #endif /* WIN32 */ #include <sasl.h> #include <saslutil.h> @@ -234,7 +239,7 @@ sasl_getopt ( if (len != NULL) { /* This might be NULL, which means "all mechanisms" */ - *len = sasl_mech ? strlen(sasl_mech) : 0; + *len = sasl_mech ? (unsigned) strlen(sasl_mech) : 0; } return (SASL_OK); } @@ -379,7 +384,7 @@ main(int argc, char *argv[]) char *options, *value; const char *available_mechs = NULL; unsigned len; - unsigned count; + int count; sasl_callback_t callbacks[N_CALLBACKS], *callback; char *searchpath = NULL; char *service = "test"; @@ -437,7 +442,7 @@ main(int argc, char *argv[]) case 'b': options = optarg; while (*options != '\0') { - switch(getsubopt(&options, (const char * const *)bit_subopts, &value)) { + switch(getsubopt(&options, (char * const *)bit_subopts, &value)) { case OPT_MIN: if (! value) { errflag = 1; @@ -462,7 +467,7 @@ main(int argc, char *argv[]) case 'e': options = optarg; while (*options != '\0') { - switch(getsubopt(&options, (const char * const *)ext_subopts, &value)) { + switch(getsubopt(&options, (char * const *)ext_subopts, &value)) { case OPT_EXT_SSF: if (! value) { errflag = 1; @@ -491,7 +496,7 @@ main(int argc, char *argv[]) case 'f': options = optarg; while (*options != '\0') { - switch(getsubopt(&options, (const char * const *)flag_subopts, &value)) { + switch(getsubopt(&options, (char * const *)flag_subopts, &value)) { case OPT_NOPLAIN: secprops.security_flags |= SASL_SEC_NOPLAINTEXT; break;
diff --git a/cmulocal/berkdb.m4 b/cmulocal/berkdb.m4 index dbcdbc8..99a39ee 100644 --- a/cmulocal/berkdb.m4 +++ b/cmulocal/berkdb.m4 @@ -213,7 +213,7 @@ AC_DEFUN([CYRUS_BERKELEY_DB_CHK_LIB], fi saved_LIBS=$LIBS - for dbname in ${with_bdb} db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db + for dbname in ${with_bdb} db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db do LIBS="$saved_LIBS -l$dbname" AC_TRY_LINK([#include <stdio.h> diff --git a/config/plain.m4 b/config/plain.m4 index ee9e0c4..3fb5ebb 100644 --- a/config/plain.m4 +++ b/config/plain.m4 @@ -21,7 +21,7 @@ dnl PLAIN if test "$plain" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS libplain.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_OBJS="$SASL_STATIC_OBJS plain.o" SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/plain.c" AC_DEFINE(STATIC_PLAIN,[],[Link PLAIN Staticly]) diff --git a/config/sasldb.m4 b/config/sasldb.m4 index b28b087..13cca34 100644 --- a/config/sasldb.m4 +++ b/config/sasldb.m4 @@ -127,7 +127,7 @@ case "$dblib" in ;; esac -if test "$enable_static" = yes; then +if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then if test "$dblib" != "none"; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/sasldb.c $SASL_DB_BACKEND_STATIC_SRCS" SASL_STATIC_OBJS="$SASL_STATIC_OBJS sasldb.o $SASL_DB_BACKEND_STATIC" diff --git a/configure.in b/configure.in index 47138d9..f7f1a23 100644 --- a/configure.in +++ b/configure.in @@ -113,12 +113,19 @@ else SASL_STATIC_LIBS= fi +AC_ARG_ENABLE(staticplugin, [ --enable-staticplugin link plugins statically [[no]] ], + enable_staticplugin=$enableval, + enable_staticplugin=no) +if test "$enable_staticplugin" = yes; then + AC_DEFINE(STATIC_PLUGIN,[],[link plugins statically]) +fi + AC_ARG_ENABLE(staticdlopen, [ --enable-staticdlopen try dynamic plugins when we are a static libsasl [[no]] ], enable_staticdlopen=$enableval, enable_staticdlopen=no) if test "$enable_staticdlopen" = yes; then - AC_DEFINE(TRY_DLOPEN_WHEN_STATIC,[],[Should we try to dlopen() plugins while staticly compiled?]) + AC_DEFINE(TRY_DLOPEN_WHEN_STATIC,[],[Should we try to dlopen() plugins while statically compiled?]) fi if test "$ac_cv_prog_gcc" = yes; then @@ -382,10 +389,10 @@ AC_MSG_CHECKING(CRAM-MD5) if test "$cram" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS libcrammd5.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_OBJS="$SASL_STATIC_OBJS cram.o" SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/cram.c" - AC_DEFINE(STATIC_CRAMMD5, [], [Link CRAM-MD5 Staticly]) + AC_DEFINE(STATIC_CRAMMD5, [], [Link CRAM-MD5 Statically]) fi else AC_MSG_RESULT(disabled) @@ -417,10 +424,10 @@ AC_MSG_CHECKING(DIGEST-MD5) if test "$digest" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS libdigestmd5.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/digestmd5.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS digestmd5.o" - AC_DEFINE(STATIC_DIGESTMD5, [], [Link DIGEST-MD5 Staticly]) + AC_DEFINE(STATIC_DIGESTMD5, [], [Link DIGEST-MD5 Statically]) fi else AC_MSG_RESULT(disabled) @@ -442,10 +449,10 @@ if test "$otp" != no; then OTP_LIBS="-lcrypto $LIB_RSAREF" SASL_MECHS="$SASL_MECHS libotp.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/otp.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS otp.o" - AC_DEFINE(STATIC_OTP, [], [Link OTP Staticly]) + AC_DEFINE(STATIC_OTP, [], [Link OTP Statically]) fi dnl Test for OPIE @@ -499,10 +506,10 @@ if test "$srp" != no; then SRP_LIBS="-lcrypto $LIB_RSAREF" SASL_MECHS="$SASL_MECHS libsrp.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/srp.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS srp.o" - AC_DEFINE(STATIC_SRP, [], [Link SRP Staticly]) + AC_DEFINE(STATIC_SRP, [], [Link SRP Statically]) fi dnl srp_setpass support @@ -528,7 +535,7 @@ SASL_KERBEROS_V4_CHK SASL_GSSAPI_CHK if test "$gssapi" != "no"; then - AC_DEFINE(STATIC_GSSAPIV2,[],[Link GSSAPI Staticly]) + AC_DEFINE(STATIC_GSSAPIV2,[],[Link GSSAPI Statically]) mutex_default="no" if test "$gss_impl" = "mit"; then mutex_default="yes" @@ -555,10 +562,10 @@ AC_MSG_CHECKING(ANONYMOUS) if test "$anon" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS libanonymous.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_OBJS="$SASL_STATIC_OBJS anonymous.o" SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/anonymous.c" - AC_DEFINE(STATIC_ANONYMOUS, [], [Link ANONYMOUS Staticly]) + AC_DEFINE(STATIC_ANONYMOUS, [], [Link ANONYMOUS Statically]) fi else AC_MSG_RESULT(disabled) @@ -573,10 +580,10 @@ AC_MSG_CHECKING(LOGIN) if test "$login" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS liblogin.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/login.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS login.o" - AC_DEFINE(STATIC_LOGIN,[],[Link LOGIN Staticly]) + AC_DEFINE(STATIC_LOGIN,[],[Link LOGIN Statically]) fi else AC_MSG_RESULT(disabled) @@ -599,10 +606,10 @@ if test "$ntlm" != no; then AC_SUBST(NTLM_LIBS) SASL_MECHS="$SASL_MECHS libntlm.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/ntlm.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS ntlm.o" - AC_DEFINE(STATIC_NTLM,[],[Link NTLM Staticly]) + AC_DEFINE(STATIC_NTLM,[],[Link NTLM Statically]) fi else AC_MSG_RESULT(disabled) @@ -625,10 +632,10 @@ if test "$passdss" != no; then AC_SUBST(PASSDSS_LIBS) SASL_MECHS="$SASL_MECHS libpassdss.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_OBJS="$SASL_STATIC_OBJS passdss.o" SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/passdss.c" - AC_DEFINE(STATIC_PASSDSS,[],[Link PASSDSS Staticly]) + AC_DEFINE(STATIC_PASSDSS,[],[Link PASSDSS Statically]) fi else AC_MSG_RESULT(disabled) @@ -656,10 +663,10 @@ AC_MSG_CHECKING(SQL) if test "$sql" != no; then AC_MSG_RESULT(enabled) SASL_MECHS="$SASL_MECHS libsql.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/sql.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS sql.o" - AC_DEFINE(STATIC_SQL,[],[Link SQL plugin staticly]) + AC_DEFINE(STATIC_SQL,[],[Link SQL plugin statically]) fi else AC_MSG_RESULT(disabled) @@ -902,7 +909,7 @@ if test "$sql" = yes -a "$with_pgsql" = no -a "$with_mysql" = no -a "$with_sqlit AC_ERROR([--enable-sql chosen but neither Postgres nor MySQL nor SQLite nor SQLite3 found]) fi -if test "$enable_shared" = yes; then +if test "$enable_shared" = yes -a "$enable_staticplugin" != yes; then AC_DEFINE(DO_DLOPEN,[],[Should we build a shared plugin (via dlopen) library?]) fi @@ -948,10 +955,10 @@ if test "$ldapdb" != no; then AC_SUBST(LIB_LDAP) SASL_MECHS="$SASL_MECHS libldapdb.la" - if test "$enable_static" = yes; then + if test "$enable_static" = yes -o "$enable_staticplugin" = yes; then SASL_STATIC_SRCS="$SASL_STATIC_SRCS \$(top_srcdir)/plugins/ldapdb.c" SASL_STATIC_OBJS="$SASL_STATIC_OBJS ldapdb.o" - AC_DEFINE(STATIC_LDAPDB,[],[Link ldapdb plugin Staticly]) + AC_DEFINE(STATIC_LDAPDB,[],[Link ldapdb plugin Statically]) fi fi fi @@ -969,6 +976,13 @@ AC_SUBST(SASL_STATIC_SRCS) AC_SUBST(SASL_STATIC_OBJS) AC_SUBST(SASL_STATIC_LIBS) +SASL_STATIC_PLUGIN_SRCS="$SASL_STATIC_SRCS" +SASL_STATIC_PLUGIN_OBJS="$SASL_STATIC_OBJS" +SASL_STATIC_PLUGIN_LTOBJS=`echo "$SASL_STATIC_PLUGIN_@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` +AC_SUBST(SASL_STATIC_PLUGIN_SRCS) +AC_SUBST(SASL_STATIC_PLUGIN_OBJS) +AC_SUBST(SASL_STATIC_PLUGIN_LTOBJS) + AC_ARG_WITH(plugindir, [ --with-plugindir=DIR set the directory where plugins will be found [[/usr/lib/sasl2]] ], plugindir=$withval, diff --git a/lib/Makefile.am b/lib/Makefile.am index b73e45c..d6eebcd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -55,8 +55,8 @@ BUILT_SOURCES = $(SASL_STATIC_SRCS) common_headers = saslint.h common_sources = auxprop.c canonusr.c checkpw.c client.c common.c config.c external.c md5.c saslutil.c server.c seterror.c dlopen.c ../plugins/plugin_common.c -LTLIBOBJS = @LTLIBOBJS@ -LIBOBJS = @LIBOBJS@ +LTLIBOBJS = @LTLIBOBJS@ @SASL_STATIC_PLUGIN_LTOBJS@ +LIBOBJS = @LIBOBJS@ @SASL_STATIC_PLUGIN_OBJS@ LIB_DOOR= @LIB_DOOR@ lib_LTLIBRARIES = libsasl2.la diff --git a/lib/dlopen.c b/lib/dlopen.c index b9c1c80..75b5923 100644 --- a/lib/dlopen.c +++ b/lib/dlopen.c @@ -56,7 +56,7 @@ #include <sasl.h> #include "saslint.h" -#ifndef PIC +#if !defined(PIC) || defined(STATIC_PLUGIN) #include <saslplug.h> #include "staticopen.h" #endif @@ -407,7 +407,7 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, DIR *dp; struct dirent *dir; #endif -#ifndef PIC +#if !defined(PIC) || defined(STATIC_PLUGIN) add_plugin_t *add_plugin; _sasl_plug_type type; _sasl_plug_rec *p; @@ -422,7 +422,7 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, || ! verifyfile_cb->proc) return SASL_BADPARAM; -#ifndef PIC +#if !defined(PIC) || defined(STATIC_PLUGIN) /* do all the static plugins first */ for(cur_ep = entrypoints; cur_ep->entryname; cur_ep++) { @@ -449,7 +449,7 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, result = add_plugin(p->name, p->plug); } } -#endif /* !PIC */ +#endif /* !PIC || STATIC_PLUGIN */ /* only do the following if: * diff --git a/sample/Makefile.am b/sample/Makefile.am index 0e18483..d39e764 100644 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -44,8 +44,8 @@ INCLUDES=-I$(top_srcdir)/include -noinst_PROGRAMS = client server -EXTRA_PROGRAMS = sample-client sample-server +noinst_PROGRAMS = client server sample-client sample-server +EXTRA_PROGRAMS = CLEANFILES=sample-client sample-server ./.libs/*sample-client ./.libs/*sample-server sample_client_SOURCES = sample-client.c @@ -54,10 +54,10 @@ sample_server_SOURCES = sample-server.c server_SOURCES = server.c common.c common.h client_SOURCES = client.c common.c common.h -server_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) -client_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) +server_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) $(LIB_DES) $(SASL_DB_LIB) +client_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) $(LIB_DES) $(SASL_DB_LIB) -sample_client_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) -sample_server_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) +sample_client_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) $(LIB_DES) $(SASL_DB_LIB) +sample_server_LDADD = ../lib/libsasl2.la $(LIB_SOCKET) $(LIB_DES) $(SASL_DB_LIB) EXTRA_DIST = NTMakefile diff --git a/utils/Makefile.am b/utils/Makefile.am index 7e2f983..f15d0a9 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -42,7 +42,7 @@ # ################################################################ -all_sasl_libs = ../lib/libsasl2.la $(SASL_DB_LIB) $(LIB_SOCKET) +all_sasl_libs = ../lib/libsasl2.la $(SASL_DB_LIB) $(LIB_SOCKET) $(LIB_DES) all_sasl_static_libs = ../lib/.libs/libsasl2.a $(SASL_DB_LIB) $(LIB_SOCKET) $(GSSAPIBASE_LIBS) $(GSSAPI_LIBS) $(SASL_KRB_LIB) $(LIB_DES) $(PLAIN_LIBS) $(SRP_LIBS) $(LIB_MYSQL) $(LIB_PGSQL) $(LIB_SQLITE) sbin_PROGRAMS = @SASL_DB_UTILS@ @SMTPTEST_PROGRAM@ pluginviewer
diff --git a/lib/NTMakefile b/lib/NTMakefile index 7a85763..ba3bdcd 100755 --- a/lib/NTMakefile +++ b/lib/NTMakefile @@ -1,5 +1,9 @@ !INCLUDE ..\win32\common.mak +!IF "$(STATIC_PLUGIN)" == "yes" +!INCLUDE ..\plugins\plugin.mak +!ENDIF + # WS2tcpip.h included in Visual Studio 7 provides getaddrinfo, ... # emulation on Windows, so there is no need to build getaddrinfo.c @@ -8,17 +12,27 @@ compat_sources = getaddrinfo.c getnameinfo.c compat_objs = getaddrinfo.obj getnameinfo.obj !ENDIF - libsasl_sources = auxprop.c canonusr.c checkpw.c client.c common.c config.c external.c md5.c saslutil.c server.c seterror.c windlopen.c getsubopt.c plugin_common.c plugin_common.h $(compat_sources) libsasl_objs = auxprop.obj canonusr.obj checkpw.obj client.obj common.obj config.obj external.obj md5.obj saslutil.obj server.obj seterror.obj windlopen.obj getsubopt.obj plugin_common.obj $(compat_objs) libsasl_res = libsasl.res libsasl_out = libsasl.dll libsasl.exp libsasl.lib $(libsasl_res) -CPPFLAGS = /wd4996 /Wp64 /D NEED_GETOPT /I "..\win32\include" /I "." /I "..\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSASL_EXPORTS" +# add sources for static-linked plugins +!IF "$(STATIC_PLUGIN)" == "yes" +libsasl_sources = $(libsasl_sources) $(STATIC_PLUGIN_SRC) +libsasl_objs = $(libsasl_objs) $(STATIC_PLUGIN_OBJ) +!ENDIF + +CPPFLAGS = /wd4996 /D NEED_GETOPT /I "..\win32\include" /I "." /I "..\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSASL_EXPORTS" /D "_CRT_SECURE_NO_WARNINGS" /D "_SCL_SECURE_NO_WARNINGS" !IF $(TARGET_WIN_SYSTEM) >= 51 CPPFLAGS = /D TARGET_WIN_SYSTEM=$(TARGET_WIN_SYSTEM) $(CPPFLAGS) -!ENDIF +!ENDIF + +!IF "$(STATIC_PLUGIN)" == "yes" +CPPFLAGS = $(CPPFLAGS) $(EXTRA_FLAGS) /D "STATIC_PLUGIN" $(STATIC_PLUGIN_CFLAGS) +LINK32DLL_FLAGS = $(LINK32DLL_FLAGS) $(STATIC_PLUGIN_EXTLIBS) +!ENDIF all_objs = $(libsasl_objs) all_out = $(libsasl_out) @@ -70,6 +84,7 @@ CLEAN : -@erase $(all_out) -@erase plugin_common.h -@erase plugin_common.c + -@erase $(STATIC_PLUGIN_SRCS) -@erase $(exclude_list) $(libsasl_res): NTMakefile diff --git a/lib/windlopen.c b/lib/windlopen.c index f514e0d..d0c8442 100644 --- a/lib/windlopen.c +++ b/lib/windlopen.c @@ -50,6 +50,11 @@ #include <sasl.h> #include "saslint.h" +#ifdef STATIC_PLUGIN +#include <saslplug.h> +#include "staticopen.h" +#endif + #define DLL_SUFFIX ".dll" #define DLL_MASK "*" DLL_SUFFIX #define DLL_MASK_LEN 5 @@ -168,19 +173,27 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, const sasl_callback_t *verifyfile_cb) { int result; + const add_plugin_list_t *cur_ep; + +#ifdef STATIC_PLUGIN /* STATIC_PLUGIN 2 */ + add_plugin_t *add_plugin; + _sasl_plug_type type; + _sasl_plug_rec *p; +#else /* STATIC_PLUGIN 2 */ char cur_dir[PATH_MAX], full_name[PATH_MAX+2], prefix[PATH_MAX+2]; /* 1 for '\\' 1 for trailing '\0' */ + char * pattern; char c; int pos; const char *path=NULL; int position; - const add_plugin_list_t *cur_ep; struct stat statbuf; /* filesystem entry information */ intptr_t fhandle; /* file handle for _findnext function */ struct _finddata_t finddata; /* data returned by _findnext() */ size_t prefix_len; - +#endif /* STATIC_PLUGIN 2 */ + if (! entrypoints || ! getpath_cb || getpath_cb->id != SASL_CB_GETPATH @@ -190,6 +203,33 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, || ! verifyfile_cb->proc) return SASL_BADPARAM; +#ifdef STATIC_PLUGIN /* STATIC_PLUGIN 3 */ + /* do all the static plugins first */ + for(cur_ep = entrypoints; cur_ep->entryname; cur_ep++) { + + /* What type of plugin are we looking for? */ + if(!strcmp(cur_ep->entryname, "sasl_server_plug_init")) { + type = SERVER; + add_plugin = (add_plugin_t *)sasl_server_add_plugin; + } else if (!strcmp(cur_ep->entryname, "sasl_client_plug_init")) { + type = CLIENT; + add_plugin = (add_plugin_t *)sasl_client_add_plugin; + } else if (!strcmp(cur_ep->entryname, "sasl_auxprop_plug_init")) { + type = AUXPROP; + add_plugin = (add_plugin_t *)sasl_auxprop_add_plugin; + } else if (!strcmp(cur_ep->entryname, "sasl_canonuser_init")) { + type = CANONUSER; + add_plugin = (add_plugin_t *)sasl_canonuser_add_plugin; + } else { + /* What are we looking for then? */ + return SASL_FAIL; + } + for (p=_sasl_static_plugins; p->type; p++) { + if(type == p->type) + result = add_plugin(p->name, p->plug); + } + } +#else /* STATIC_PLUGIN 3 */ /* get the path to the plugins */ result = ((sasl_getpath_t *)(getpath_cb->proc))(getpath_cb->context, &path); @@ -307,6 +347,7 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints, _findclose (fhandle); } while ((c!='=') && (c!=0)); +#endif /* STATIC_PLUGIN 3 */ return SASL_OK; } diff --git a/plugins/NTMakefile b/plugins/NTMakefile index a0a57a6..fcc0229 100755 --- a/plugins/NTMakefile +++ b/plugins/NTMakefile @@ -1,52 +1,6 @@ !INCLUDE ..\win32\common.mak -!IF "$(NTLM)" == "1" -PLUGINS_EXT=saslNTLM.dll -!ELSE -PLUGINS_EXT= -!ENDIF - -!IF "$(GSSAPI)" == "CyberSafe" -PLUGINS_EXT=$(PLUGINS_EXT) saslGSSAPI.dll -!ENDIF - -!IF "$(SRP)" == "1" -PLUGINS_EXT=$(PLUGINS_EXT) saslSRP.dll -!IF "$(DO_SRP_SETPASS)" == "1" -SRP_FLAGS=/DDO_SRP_SETPASS=1 -!ENDIF -!ENDIF - -!IF "$(OTP)" == "1" -PLUGINS_EXT=$(PLUGINS_EXT) saslOTP.dll -!ENDIF - -!IF "$(LDAP)" == "1" -PLUGINS_EXT=$(PLUGINS_EXT) saslLDAPDB.dll - -# NB: linking to libsasl itself!!! -LDAP_FLAGS = /I $(LDAP_INCLUDE) -LDAP_LIBS = $(LDAP_LIB_BASE)\olber32.lib $(LDAP_LIB_BASE)\oldap32.lib ..\lib\libsasl.lib -!ENDIF - -!IF "$(SQL)" == "SQLITE" -PLUGINS_EXT=$(PLUGINS_EXT) saslSQLITE.dll -SQL_FLAGS= $(SQLITE_INCLUDES) /DHAVE_SQLITE=1 -SQLITE_LIBS = /libpath:$(SQLITE_LIBPATH) libsqlite.lib -!ENDIF -!IF "$(SQL)" == "SQLITE3" -PLUGINS_EXT=$(PLUGINS_EXT) saslSQLITE.dll -SQL_FLAGS= $(SQLITE_INCLUDES3) /DHAVE_SQLITE3=1 -SQLITE_LIBS = /libpath:$(SQLITE_LIBPATH3) libsqlite3.lib -!ENDIF - -PLUGINS=saslANONYMOUS.dll \ - saslPLAIN.dll \ - saslCRAMMD5.dll \ - saslDIGESTMD5.dll \ - saslLOGIN.dll \ - $(PLUGINS_EXT) \ - saslSASLDB.dll +!INCLUDE .\plugin.mak generated_rc=saslANONYMOUS.rc saslPLAIN.rc saslCRAMMD5.rc saslDIGESTMD5.rc saslLOGIN.rc saslNTLM.rc saslGSSAPI.rc saslSRP.rc saslOTP.rc saslSASLDB.rc saslSQLITE.rc saslLDAPDB.rc @@ -93,7 +47,7 @@ saslSRP_sources = srp.c srp_init.c $(common_sources) saslSRP_objs = srp.obj srp_init.obj $(common_objs) saslSRP_out = saslSRP.dll saslSRP.exp saslSRP.lib -saslOTP_sources = otp.c otp_init.c $(common_sources) +saslOTP_sources = otp.c otp_init.c otp.h $(common_sources) saslOTP_objs = otp.obj otp_init.obj $(common_objs) saslOTP_out = saslOTP.dll saslOTP.exp saslOTP.lib @@ -106,22 +60,6 @@ saslLDAPDB_sources = ldapdb.c $(common_sources) saslLDAPDB_objs = ldapdb.obj $(common_objs) saslLDAPDB_out = saslLDAPDB.dll saslLDAPDB.exp saslLDAPDB.lib -!IF "$(NTLM)" == "1" || "$(SRP)" == "1" || "$(OTP)" == "1" -OPENSSL_FLAGS= /I $(OPENSSL_INCLUDE) -!ELSE -OPENSSL_FLAGS= -!ENDIF - -!IF "$(GSSAPI)" == "CyberSafe" -GSS_FLAGS= /I $(GSSAPI_INCLUDE) /D "HAVE_GSS_C_NT_HOSTBASED_SERVICE" /D "HAVE_GSS_C_NT_USER_NAME" -GSS_LIBS=/libpath:$(GSSAPI_LIBPATH) gssapi32.lib -!ELSE -GSS_FLAGS= -GSS_LIBS= -!ENDIF - -DIGEST_FLAGS=/D "WITH_RC4" - # Auxprop Plugin libsasldb_sources = allockey.c db_berkeley.c libsasldb_objs = allockey.obj db_berkeley.obj @@ -133,24 +71,16 @@ saslSASLDB_out = saslSASLDB.dll saslSASLDB.exp saslSASLDB.lib all_objs = $(saslANONYMOUS_objs) $(saslPLAIN_objs) $(saslCRAMMD5_objs) $(saslDIGESTMD5_objs) $(saslLOGIN_objs) $(saslNTLM_objs) $(saslGSSAPI_objs) $(saslSRP_objs) $(saslOTP_objs) $(saslSASLDB_objs) $(saslSQL_objs) $(saslLDAPDB_objs) all_out = $(saslANONYMOUS_out) $(saslPLAIN_out) $(saslCRAMMD5_out) $(saslDIGESTMD5_out) $(saslLOGIN_out) $(saslNTLM_out) $(saslGSSAPI_out) $(saslSRP_out) $(saslOTP_out) $(saslSASLDB_out) $(saslSQL_out) $(saslLDAPDB_out) -# LIBSASL_EXPORTS is required to export additional DB routines from sasldb -DB_FLAGS = /I $(DB_INCLUDE) /I "..\sasldb" /D "LIBSASL_EXPORTS" /D "KEEP_DB_OPEN" - -!IF $(TARGET_WIN_SYSTEM) >= 51 -EXTRA_FLAGS = /D TARGET_WIN_SYSTEM=$(TARGET_WIN_SYSTEM) $(EXTRA_FLAGS) -!ENDIF - -EXTRA_FLAGS=$(EXTRA_FLAGS) $(DB_FLAGS) $(OPENSSL_FLAGS) $(GSS_FLAGS) $(SRP_FLAGS) $(SQL_FLAGS) $(DIGEST_FLAGS) $(LDAP_FLAGS) -CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(EXTRA_FLAGS) /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" - -DB_LIBS=/libpath:$(DB_LIBPATH) $(DB_LIB) -OPENSSL_LIBS=/libpath:$(OPENSSL_LIBPATH) libeay32.lib ssleay32.lib # Where to install files from this directory libdir = $(prefix)\lib bindir = $(prefix)\bin\sasl2 +!IF "$(STATIC_PLUGIN)" == "yes" +all : +!ELSE all : all-recursive +!ENDIF # # /I flag to xcopy tells to treat the last parameter as directory and create all missing levels @@ -167,17 +97,6 @@ install: $(PLUGINS) all-recursive : $(PLUGINS) -getaddrinfo.c: ..\lib\getaddrinfo.c - copy ..\lib\getaddrinfo.c . - -getnameinfo.c: ..\lib\getnameinfo.c - copy ..\lib\getnameinfo.c . - -allockey.c: ..\sasldb\allockey.c - copy ..\sasldb\allockey.c . - -db_berkeley.c: ..\sasldb\db_berkeley.c - copy ..\sasldb\db_berkeley.c . #Add /pdb: option? diff --git a/plugins/plugin.mak b/plugins/plugin.mak new file mode 100755 index 0000000..5404cfb --- /dev/null +++ b/plugins/plugin.mak @@ -0,0 +1,213 @@ +#!INCLUDE ..\win32\common.mak + +!IF "$(NTLM)" == "1" +PLUGINS_EXT=saslNTLM.dll +STATIC_PLUGIN_SRC=ntlm.c +STATIC_PLUGIN_OBJ=ntlm.obj +STATIC_PLUGIN_CFLAGS=/D "STATIC_NTLM" +!ELSE +PLUGINS_EXT= +STATIC_PLUGIN_SRC= +STATIC_PLUGIN_OBJ= +STATIC_PLUGIN_CFLAGS= +!ENDIF + +!IF "$(GSSAPI)" == "CyberSafe" +PLUGINS_EXT=$(PLUGINS_EXT) saslGSSAPI.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) gssapi.c +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) gssapi.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_GSSAPIV2" +!ENDIF + +!IF "$(SRP)" == "1" +PLUGINS_EXT=$(PLUGINS_EXT) saslSRP.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) srp.c +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) srp.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_SRP" +!IF "$(DO_SRP_SETPASS)" == "1" +SRP_FLAGS=/DDO_SRP_SETPASS=1 +!ENDIF +!ENDIF + +!IF "$(OTP)" == "1" +PLUGINS_EXT=$(PLUGINS_EXT) saslOTP.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) otp.c otp.h +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) otp.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_OTP" +!ENDIF + +!IF "$(LDAP)" == "1" +PLUGINS_EXT=$(PLUGINS_EXT) saslLDAPDB.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) ldapdb.c +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) ldapdb.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_LDAPDB" +!ENDIF + +!IF "$(SQL)" == "SQLITE" || "$(SQL)" == "SQLITE3" +PLUGINS_EXT=$(PLUGINS_EXT) saslSQLITE.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) sql.c +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) sql.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_SQL" +!ENDIF + +!IF "$(SASLDB)" == "1" +PLUGINS_EXT=$(PLUGINS_EXT) saslSASLDB.dll +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) sasldb.c sasldb.h +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) sasldb.obj +STATIC_PLUGIN_CFLAGS=$(STATIC_PLUGIN_CFLAGS) /D "STATIC_SASLDB" +!IF "$(DBLIB)" == "berkeley" +SASLDB_SRC=allockey.c db_berkeley.c +SASLDB_OBJ=allockey.obj db_berkeley.obj +!ELSE +DBLIB="no" +SASLDB_SRC=db_none.c +SASLDB_OBJ=db_none.obj +!ENDIF # DBLIB +STATIC_PLUGIN_SRC=$(STATIC_PLUGIN_SRC) $(SASLDB_SRC) +STATIC_PLUGIN_OBJ=$(STATIC_PLUGIN_OBJ) $(SASLDB_OBJ) +!ENDIF # SASLDB + + +STATIC_PLUGIN_SRC=anonymous.c \ + plain.c \ + cram.c \ + digestmd5.c \ + login.c \ + $(STATIC_PLUGIN_SRC) + +STATIC_PLUGIN_OBJ=anonymous.obj \ + plain.obj \ + cram.obj \ + digestmd5.obj \ + login.obj \ + $(STATIC_PLUGIN_OBJ) + +STATIC_PLUGIN_CFLAGS=/D "STATIC_ANONYMOUS" \ + /D "STATIC_PLAIN" \ + /D "STATIC_CRAMMD5" \ + /D "STATIC_DIGESTMD5" \ + /D "STATIC_LOGIN" \ + $(STATIC_PLUGIN_CFLAGS) + +PLUGINS=saslANONYMOUS.dll \ + saslPLAIN.dll \ + saslCRAMMD5.dll \ + saslDIGESTMD5.dll \ + saslLOGIN.dll \ + $(PLUGINS_EXT) + + +anonymous.c: ..\plugins\anonymous.c + copy ..\plugins\anonymous.c . + +plain.c: ..\plugins\plain.c + copy ..\plugins\plain.c . + +cram.c: ..\plugins\cram.c + copy ..\plugins\cram.c . + +digestmd5.c: ..\plugins\digestmd5.c + copy ..\plugins\digestmd5.c . + +login.c: ..\plugins\login.c + copy ..\plugins\login.c . + +ntlm.c: ..\plugins\ntlm.c + copy ..\plugins\ntlm.c . + +gssapi.c: ..\plugins\gssapi.c + copy ..\plugins\gssapi.c . + +srp.c: ..\plugins\srp.c + copy ..\plugins\srp.c . + +otp.c: ..\plugins\otp.c otp.h + copy ..\plugins\otp.c . + +otp.h: ..\plugins\otp.h + copy ..\plugins\otp.h . + +ldapdb.c: ..\plugins\ldapdb.c + copy ..\plugins\ldapdb.c . + +sql.c: ..\plugins\sql.c + copy ..\plugins\sql.c . + +sasldb.c: ..\plugins\sasldb.c ..\sasldb\sasldb.h + copy ..\plugins\sasldb.c . + +#sasldb.h: ..\sasldb\sasldb.h +# copy ..\sasldb\sasldb.h . + +getaddrinfo.c: ..\lib\getaddrinfo.c + copy ..\lib\getaddrinfo.c . + +getnameinfo.c: ..\lib\getnameinfo.c + copy ..\lib\getnameinfo.c . + +allockey.c: ..\sasldb\allockey.c + copy ..\sasldb\allockey.c . + +db_berkeley.c: ..\sasldb\db_berkeley.c + copy ..\sasldb\db_berkeley.c . + +db_none.c: ..\sasldb\db_none.c + copy ..\sasldb\db_none.c . + + + +# +# COMPILER FLAGS +# + +!IF "$(NTLM)" == "1" || "$(SRP)" == "1" || "$(OTP)" == "1" +OPENSSL_FLAGS= /I $(OPENSSL_INCLUDE) +OPENSSL_LIBS=/libpath:$(OPENSSL_LIBPATH) libeay32.lib ssleay32.lib +!ELSE +OPENSSL_FLAGS= +OPENSSL_LIBS= +!ENDIF + +!IF "$(GSSAPI)" == "CyberSafe" +GSS_FLAGS= /I $(GSSAPI_INCLUDE) /D "HAVE_GSS_C_NT_HOSTBASED_SERVICE" /D "HAVE_GSS_C_NT_USER_NAME" +GSS_LIBS=/libpath:$(GSSAPI_LIBPATH) gssapi32.lib +!ELSE +GSS_FLAGS= +GSS_LIBS= +!ENDIF + +!IF "$(LDAP)" == "1" +LDAP_FLAGS = /I $(LDAP_INCLUDE) +LDAP_LIBS = $(LDAP_LIB_BASE)\olber32.lib $(LDAP_LIB_BASE)\oldap32.lib ..\lib\libsasl.lib +!ENDIF + +!IF "$(SQL)" == "SQLITE" +SQL_FLAGS= $(SQLITE_INCLUDES) /DHAVE_SQLITE=1 +SQLITE_LIBS = /libpath:$(SQLITE_LIBPATH) libsqlite.lib +!ELSEIF "$(SQL)" == "SQLITE3" +SQL_FLAGS= $(SQLITE_INCLUDES3) /DHAVE_SQLITE3=1 +SQLITE_LIBS = /libpath:$(SQLITE_LIBPATH3) libsqlite3.lib +!ENDIF + +DIGEST_FLAGS=/D "WITH_RC4" + +# LIBSASL_EXPORTS is required to export additional DB routines from sasldb +!IF "$(SASLDB)" == "1" +DB_FLAGS = /I $(DB_INCLUDE) /I "..\sasldb" /D "LIBSASL_EXPORTS" /D "KEEP_DB_OPEN" /D "SASL_DB_PATH=\"$(SASL_DB_PATH)\"" +!IF "$(DBLIB)" == "berkeley" +DB_FLAGS = $(DB_FLAGS) /D "SASL_BERKELEYDB" +!ENDIF #DBLIB +DB_LIBS=/libpath:$(DB_LIBPATH) $(DB_LIB) +!ELSE +DB_FLAGS= +DB_LIBS= +!ENDIF #SASLDB + +!IF $(TARGET_WIN_SYSTEM) >= 51 +EXTRA_FLAGS = /D TARGET_WIN_SYSTEM=$(TARGET_WIN_SYSTEM) $(EXTRA_FLAGS) +!ENDIF + +EXTRA_FLAGS=$(EXTRA_FLAGS) $(DB_FLAGS) $(OPENSSL_FLAGS) $(GSS_FLAGS) $(SRP_FLAGS) $(SQL_FLAGS) $(DIGEST_FLAGS) $(LDAP_FLAGS) +CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(EXTRA_FLAGS) /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_SCL_SECURE_NO_WARNINGS" + +STATIC_PLUGIN_EXTLIBS=$(OPENSSL_LIBS) $(GSS_LIBS) $(DB_LIBS) $(SQLITE_LIBS) $(LDAP_LIBS) diff --git a/sample/NTMakefile b/sample/NTMakefile index 62c38bc..434d2a9 100644 --- a/sample/NTMakefile +++ b/sample/NTMakefile @@ -25,7 +25,7 @@ all_objs = $(common_objs) $(server_objs) $(client_objs) $(sample_client_objs) $( all_out = $(sample_apps) $(sample_out) DB_FLAGS = /I $(DB_INCLUDE) -CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(DB_FLAGS) /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" +CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(DB_FLAGS) /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_SCL_SECURE_NO_WARNINGS" CPPFLAGS = $(CPPFLAGS) /DNEED_GETOPT !IF $(TARGET_WIN_SYSTEM) >= 51 diff --git a/utils/NTMakefile b/utils/NTMakefile index 1d0a0fa..cfed384 100644 --- a/utils/NTMakefile +++ b/utils/NTMakefile @@ -1,7 +1,11 @@ !INCLUDE ..\win32\common.mak -sasl_apps=saslpasswd2.exe sasldblistusers2.exe testsuite.exe pluginviewer.exe -sasl_out=saslpasswd2.pdb sasldblistusers2.pdb testsuite.pdb pluginviewer.pdb +sasl_apps=pluginviewer.exe +sasl_out=pluginviewer.pdb +!IF "$(SASLDB)" == "1" +sasl_apps=$(sasl_apps) saslpasswd2.exe sasldblistusers2.exe testsuite.exe +sasl_out=$(sasl_out) saslpasswd2.pdb sasldblistusers2.pdb testsuite.pdb +!ENDIF saslpwd_objs = saslpasswd.obj sasldblistusers_objs = sasldblistusers.obj @@ -11,14 +15,18 @@ pluginviewer_objs = pluginviewer.obj all_objs = $(saslpwd_objs) $(sasldblistusers_objs) $(testsuite_objs) $(pluginviewer_objs) all_out = $(sasl_apps) $(sasl_out) -DB_FLAGS = /I $(DB_INCLUDE) /I "..\sasldb" -CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(DB_FLAGS) /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" +DB_FLAGS = /I $(DB_INCLUDE) /I "..\sasldb" /D "SASL_DB_PATH=\"$(SASL_DB_PATH)\"" +CPPFLAGS = /I "..\win32\include" /I "." /I "..\include" $(DB_FLAGS) /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_SCL_SECURE_NO_WARNINGS" CPPFLAGS = $(CPPFLAGS) /DNEED_GETOPT DB_LIBS=/libpath:$(DB_LIBPATH) $(DB_LIB) SASL_LIB=/libpath:"..\lib" libsasl.lib +!IF "$(STATIC_PLUGIN)" == "yes" +SASL_DB_LIB= +!ELSE SASL_DB_LIB=/libpath:"..\plugins" saslSASLDB.lib +!ENDIF # EXTRA_LIBS is automatically included into LINK32EXE_FLAGS/LINK32DLL_FLAGS EXTRA_LIBS=$(SASL_LIB) diff --git a/win32/common.mak b/win32/common.mak index 41d4103..6ed6e4d 100644 --- a/win32/common.mak +++ b/win32/common.mak @@ -5,17 +5,70 @@ SASL_VERSION_MINOR=1 SASL_VERSION_STEP=24 !IF "$(STATIC)" == "" -STATIC=yes +STATIC=no +!ENDIF + +!IF "$(STATIC_PLUGIN)" == "" +STATIC_PLUGIN=no +!ENDIF + +# Detect Visual Studio Version +# Reference: http://mateusz.loskot.net/2009/03/29/detecting-visual-c-version-in-nmake-makefile/ +!IF "$(_NMAKE_VER)" == "" +MSVC_VER = 4.0 +VCVER = 4 +!ERROR *** Prehistoric version of Visual C++ +!ELSEIF "$(_NMAKE_VER)" == "162" +MSVC_VER = 5.0 +VCVER = 5 +!ERROR *** Prehistoric version of Visual C++ +!ELSEIF "$(_NMAKE_VER)" == "6.00.8168.0" +MSVC_VER = 6.0 +VCVER = 6 +MSC_VER = 1200 +!ERROR *** Prehistoric version of Visual C++ +!ELSEIF "$(_NMAKE_VER)" == "7.00.9466" +MSVC_VER = 7.0 +VCVER = 7 +MSC_VER = 1300 +!ELSEIF "$(_NMAKE_VER)" == "7.10.3077" +MSVC_VER = 7.1 +VCVER = 7 +MSC_VER = 1310 +!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42" +MSVC_VER = 8.0 +VCVER = 8 +MSC_VER = 1400 +!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762" +MSVC_VER = 8.0 +VCVER = 8 +MSC_VER = 1400 +!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08" +MSVC_VER = 9.0 +VCVER = 9 +MSC_VER = 1500 +!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01" +MSVC_VER = 9.0 +VCVER = 9 +MSC_VER = 1500 +!ELSE +MSVC_VER = 0.0 +VCVER = 0 +MSC_VER = 0 !ENDIF +!MESSAGE *** Using Microsoft NMAKE version $(_NMAKE_VER) +!MESSAGE *** Using Microsoft Visual C++ version $(MSVC_VER) -# Uncomment the following line, if you want to use Visual Studio 6 -#VCVER=6 +!IF "$(VCVER)" == "6" || "$(VCVER)" == "7" # Use in Visual Studio 6 & 7: -#EXCEPTHANDLING=/GX - -# Use in Visual Studio 8: +EXCEPTHANDLING=/GX +RUNTIMEERRORCHECK=/GZ +!ELSE +# Use in Visual Studio 8 & 9: EXCEPTHANDLING=/EHsc +RUNTIMEERRORCHECK=/RTC1 +!ENDIF # Define compiler/linker/etc. @@ -61,21 +114,21 @@ CFG=Release !IF "$(DB_LIB)" == "" DB_LIB=libdb41s.lib !IF "$(VERBOSE)" != "0" -!MESSAGE Defaulting SleepyCat library name to $(DB_LIB). +!MESSAGE Defaulting BerkeleyDB to $(DB_LIB). !ENDIF !ENDIF !IF "$(DB_INCLUDE)" == "" DB_INCLUDE=c:\work\isode\db\build_win32 !IF "$(VERBOSE)" != "0" -!MESSAGE Defaulting SleepyCat include path to $(DB_INCLUDE). +!MESSAGE Defaulting BerkeleyDB include path to $(DB_INCLUDE). !ENDIF !ENDIF !IF "$(DB_LIBPATH)" == "" DB_LIBPATH=c:\work\isode\db\build_win32\Release_static !IF "$(VERBOSE)" != "0" -!MESSAGE Defaulting SleepyCat library path to $(DB_LIBPATH). +!MESSAGE Defaulting BerkeleyDB library path to $(DB_LIBPATH). !ENDIF !ENDIF @@ -149,6 +202,10 @@ LDAP_INCLUDE = c:\work\open_source\openldap\openldap-head\ldap\include !ENDIF !ENDIF +!IF "$(SASL_DB_PATH)" == "" +SASL_DB_PATH="C:\\CMU\\SASLDB" +!ENDIF + !IF "$(OS)" == "Windows_NT" NULL= !ELSE @@ -169,11 +226,11 @@ CODEGEN=/MD !ENDIF !ENDIF -!IF "$(VCVER)" != "6" +!IF "$(VCVER)" == "7" || "$(VCVER)" == "8" ENABLE_WIN64_WARNINGS=/Wp64 !ENDIF -CPP_PROJ= $(CODEGEN) /W3 $(EXCEPTHANDLING) /O2 $(ENABLE_WIN64_WARNINGS) /Zi /D "NDEBUG" $(CPPFLAGS) /FD /c +CPP_PROJ= $(CODEGEN) /W3 $(EXCEPTHANDLING) /O2 $(ENABLE_WIN64_WARNINGS) /Zi /D "NDEBUG" $(CPPFLAGS) /c incremental=no @@ -194,13 +251,14 @@ CODEGEN=/MDd !ENDIF !ENDIF -CPP_PROJ=$(CODEGEN) /W3 /Gm $(EXCEPTHANDLING) /ZI /Od /D "_DEBUG" $(CPPFLAGS) /FD /GZ /c +CPP_PROJ=$(CODEGEN) /W3 /Gm $(EXCEPTHANDLING) /Zi /Od /D "_DEBUG" $(CPPFLAGS) $(RUNTIMEERRORCHECK) /c incremental=yes # This use to contain /machine:I386. This breaks cross compiling to Windows 64. # It doesn't seem that the /machine option is needed anyway. -LINK32_FLAGS=/debug /pdbtype:sept +LINK32_FLAGS=/debug + !ENDIF diff --git a/win32/include/config.h b/win32/include/config.h index 3d74e2a..32b9a46 100644 --- a/win32/include/config.h +++ b/win32/include/config.h @@ -84,25 +84,30 @@ typedef int intptr_t; /* : This should probably be replaced with a call to a function : that gets the proper value from Registry */ -#define SASL_DB_PATH "c:\\CMU\\sasldb2" +/* now this is set automatically as compiler flag in plugin.mak */ +/* #define SASL_DB_PATH "c:\\CMU\\sasldb2" */ /* what db package are we using? */ +/* now this is set automatically as compiler flag in plugin.mak. */ /* #undef SASL_GDBM */ /* #undef SASL_NDBM */ -#define SASL_BERKELEYDB 1 +/* #undef SASL_BERKELEYDB */ +/* #undef SASL_BERKELEYDB */ /* which mechs can we link staticly? */ -#define STATIC_ANONYMOUS 1 -#define STATIC_CRAMMD5 1 -#define STATIC_DIGESTMD5 1 -#define STATIC_GSSAPIV2 1 +/* now this is set automatically as compiler flag in plugin.mak. */ +/* #undef STATIC_ANONYMOUS */ +/* #undef STATIC_CRAMMD5 */ +/* #undef STATIC_DIGESTMD5 */ +/* #undef STATIC_GSSAPIV2 */ /* #undef STATIC_KERBEROS4 */ -#define STATIC_LOGIN 1 +/* #undef STATIC_LOGIN */ /* #undef STATIC_MYSQL */ -#define STATIC_OTP 1 -#define STATIC_PLAIN 1 -#define STATIC_SASLDB 1 -#define STATIC_SRP 1 +/* #undef STATIC_NTLM */ +/* #undef STATIC_OTP */ +/* #undef STATIC_PLAIN */ +/* #undef STATIC_SASLDB */ +/* #undef STATIC_SRP */ /* ------------------------------------------------------------ */ @@ -115,9 +120,11 @@ typedef int intptr_t; /* Windows calls these functions something else */ -#define strcasecmp stricmp -#define snprintf _snprintf -#define strncasecmp strnicmp +#define strcasecmp _stricmp +#define snprintf _snprintf +#define strncasecmp _strnicmp +#define strdup _strdup +#define fdopen _fdopen #define MAXHOSTNAMELEN 1024