summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew DeVore <matvore@google.com>2020-08-07 13:27:39 -0700
committerJeremy Allison <jra@samba.org>2020-08-28 02:18:40 +0000
commit232054c09b1932b3940f08aa818703b51d29d968 (patch)
tree05e50eab4cb37908c92857e9bd1a9e60a9d089ad
parentc2ac923c6a5d089fe110eb3eb6cf78298b46992d (diff)
downloadsamba-232054c09b1932b3940f08aa818703b51d29d968.tar.gz
lib/util: remove extra safe_string.h file
lib/util/safe_string.h is similar to source3/include/safe_string.h, but the former has fewer checks. It is missing bcopy, strcasecmp, and strncasecmp. Add the missing elements to lib/util/safe_string.h remove the other safe_string.h which is in the source3-specific path. To accomodate existing uses of str(n?)casecmp, add #undef lines to source files where they are used. Signed-off-by: Matthew DeVore <matvore@google.com> Reviewed-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Aug 28 02:18:40 UTC 2020 on sn-devel-184
-rw-r--r--auth/credentials/credentials_krb5.c2
-rw-r--r--auth/gensec/gensec_start.c2
-rw-r--r--dfs_server/dfs_server_ad.c2
-rw-r--r--lib/ldb/include/ldb.h1
-rw-r--r--lib/util/charset/tests/charset.c3
-rw-r--r--lib/util/charset/util_str.c4
-rw-r--r--lib/util/safe_string.h22
-rw-r--r--lib/util/util_net.c2
-rw-r--r--libcli/http/gensec/generic.c2
-rw-r--r--libcli/http/http.c1
-rw-r--r--libcli/http/http_auth.c3
-rw-r--r--libcli/security/util_sid.c3
-rw-r--r--librpc/rpc/dcerpc_util.c2
-rw-r--r--librpc/rpc/dcesrv_core.c2
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/safe_string.h65
-rw-r--r--source3/modules/vfs_vxfs.c2
-rw-r--r--source4/auth/ntlm/auth_developer.c2
-rw-r--r--source4/client/client.c2
-rw-r--r--source4/dns_server/dlz_bind9.c2
-rw-r--r--source4/dns_server/dnsserver_common.c2
-rw-r--r--source4/dsdb/common/util.c2
-rw-r--r--source4/dsdb/common/util_trusts.c2
-rw-r--r--source4/dsdb/repl/drepl_partitions.c2
-rw-r--r--source4/dsdb/samdb/cracknames.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/acl.c3
-rw-r--r--source4/dsdb/samdb/ldb_modules/count_attrs.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/encrypted_secrets.c1
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn_in.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn_out.c3
-rw-r--r--source4/dsdb/samdb/ldb_modules/linked_attributes.c1
-rw-r--r--source4/dsdb/samdb/ldb_modules/netlogon.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/ranged_results.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_data.c2
-rw-r--r--source4/dsdb/schema/schema_convert_to_ol.c2
-rw-r--r--source4/dsdb/schema/schema_description.c2
-rw-r--r--source4/dsdb/schema/schema_init.c1
-rw-r--r--source4/dsdb/schema/schema_query.c3
-rw-r--r--source4/dsdb/schema/schema_set.c2
-rw-r--r--source4/dsdb/schema/schema_syntax.c2
-rw-r--r--source4/kdc/db-glue.c2
-rw-r--r--source4/ldap_server/ldap_server.c2
-rw-r--r--source4/lib/com/dcom/main.c2
-rw-r--r--source4/lib/registry/interface.c1
-rw-r--r--source4/lib/registry/patchfile_preg.c3
-rw-r--r--source4/lib/registry/regf.c1
-rw-r--r--source4/lib/socket/socket_ip.c2
-rw-r--r--source4/libcli/dgram/mailslot.c2
-rw-r--r--source4/libcli/resolve/resolve.c2
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c2
-rw-r--r--source4/librpc/rpc/dcerpc_smb.c2
-rw-r--r--source4/nbt_server/wins/winsdb.c2
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c2
-rw-r--r--source4/ntvfs/ntvfs_generic.c2
-rw-r--r--source4/ntvfs/posix/pvfs_shortname.c2
-rw-r--r--source4/ntvfs/sysdep/sys_lease.c2
-rw-r--r--source4/ntvfs/sysdep/sys_notify.c2
-rw-r--r--source4/param/share_ldb.c2
-rw-r--r--source4/rpc_server/backupkey/dcesrv_backupkey.c2
-rw-r--r--source4/rpc_server/common/share_info.c2
-rw-r--r--source4/rpc_server/dnsserver/dcerpc_dnsserver.c2
-rw-r--r--source4/rpc_server/dnsserver/dnsdata.c1
-rw-r--r--source4/rpc_server/dnsserver/dnsdb.c2
-rw-r--r--source4/rpc_server/dnsserver/dnsutils.c2
-rw-r--r--source4/rpc_server/drsuapi/writespn.c2
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c2
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c2
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c2
-rw-r--r--source4/rpc_server/srvsvc/dcesrv_srvsvc.c3
-rw-r--r--source4/smb_server/smb/service.c2
-rw-r--r--source4/smbd/service.c2
-rw-r--r--source4/torture/basic/mangle_test.c2
-rw-r--r--source4/torture/gpo/apply.c2
-rw-r--r--source4/torture/krb5/kdc-canon-heimdal.c2
-rw-r--r--source4/torture/ldap/basic.c1
-rw-r--r--source4/torture/ldap/netlogon.c2
-rw-r--r--source4/torture/libnetapi/libnetapi_group.c2
-rw-r--r--source4/torture/libnetapi/libnetapi_user.c2
-rw-r--r--source4/torture/raw/search.c1
-rw-r--r--source4/torture/rpc/drsuapi_cracknames.c2
-rw-r--r--source4/torture/rpc/forest_trust.c2
-rw-r--r--source4/torture/rpc/netlogon.c2
-rw-r--r--source4/torture/rpc/samr.c2
-rw-r--r--source4/torture/smb2/mangle.c2
-rw-r--r--source4/torture/unix/whoami.c1
-rw-r--r--source4/utils/oLschema2ldif/lib.c2
90 files changed, 195 insertions, 67 deletions
diff --git a/auth/credentials/credentials_krb5.c b/auth/credentials/credentials_krb5.c
index 259b35b73b0..c321f713130 100644
--- a/auth/credentials/credentials_krb5.c
+++ b/auth/credentials/credentials_krb5.c
@@ -38,6 +38,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
+#undef strncasecmp
+
static void cli_credentials_invalidate_client_gss_creds(
struct cli_credentials *cred,
enum credentials_obtained obtained);
diff --git a/auth/gensec/gensec_start.c b/auth/gensec/gensec_start.c
index d2d62d6652e..d34ef2d5e39 100644
--- a/auth/gensec/gensec_start.c
+++ b/auth/gensec/gensec_start.c
@@ -37,6 +37,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
+#undef strcasecmp
+
/* the list of currently registered GENSEC backends */
static const struct gensec_security_ops **generic_security_ops;
static int gensec_num_backends;
diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
index 84a19bd3805..7f4384f443e 100644
--- a/dfs_server/dfs_server_ad.c
+++ b/dfs_server/dfs_server_ad.c
@@ -31,6 +31,8 @@
#define MAX_DFS_RESPONSE 56*1024 /* 56 Kb */
+#undef strcasecmp
+
/* A DC set is a group of DC, they might have been grouped together
because they belong to the same site, or to site with same cost ...
*/
diff --git a/lib/ldb/include/ldb.h b/lib/ldb/include/ldb.h
index 7f53e6420e1..08e2096b914 100644
--- a/lib/ldb/include/ldb.h
+++ b/lib/ldb/include/ldb.h
@@ -1944,6 +1944,7 @@ int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn);
strcasecmp and toupper here is ok.
return 0 for match
*/
+#undef strcasecmp
#define ldb_attr_cmp(a, b) strcasecmp(a, b)
char *ldb_attr_casefold(TALLOC_CTX *mem_ctx, const char *s);
int ldb_attr_dn(const char *attr);
diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c
index 71635c6fea3..547dc51e59d 100644
--- a/lib/util/charset/tests/charset.c
+++ b/lib/util/charset/tests/charset.c
@@ -21,6 +21,9 @@
#include "includes.h"
#include "torture/torture.h"
+#undef strcasecmp
+#undef strncasecmp
+
struct torture_suite *torture_local_charset(TALLOC_CTX *mem_ctx);
static bool test_toupper_m(struct torture_context *tctx)
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index 3f5b247bd92..d1148c7387a 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -28,6 +28,10 @@
#ifdef strcasecmp
#undef strcasecmp
#endif
+#ifdef strncasecmp
+#undef strncasecmp
+#endif
+
/**
Case insensitive string compararison, handle specified for testing
diff --git a/lib/util/safe_string.h b/lib/util/safe_string.h
index a6c052f8746..edff296f028 100644
--- a/lib/util/safe_string.h
+++ b/lib/util/safe_string.h
@@ -2,6 +2,7 @@
Unix SMB/CIFS implementation.
Safe string handling routines.
Copyright (C) Andrew Tridgell 1994-1998
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,11 +20,16 @@
#ifndef _SAFE_STRING_H
#define _SAFE_STRING_H
-
#ifndef _SPLINT_ /* http://www.splint.org */
+
/* Some macros to ensure people don't use buffer overflow vulnerable string
functions. */
+#ifdef bcopy
+#undef bcopy
+#endif /* bcopy */
+#define bcopy(src,dest,size) __ERROR__XX__NEVER_USE_BCOPY___;
+
#ifdef strcpy
#undef strcpy
#endif /* strcpy */
@@ -39,6 +45,20 @@
#endif /* sprintf */
#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
+/*
+ * strcasecmp/strncasecmp aren't an error, but it means you're not thinking about
+ * multibyte. Don't use them. JRA.
+ */
+#ifdef strcasecmp
+#undef strcasecmp
+#endif
+#define strcasecmp __ERROR__XX__NEVER_USE_STRCASECMP__;
+
+#ifdef strncasecmp
+#undef strncasecmp
+#endif
+#define strncasecmp __ERROR__XX__NEVER_USE_STRNCASECMP__;
+
#endif /* !_SPLINT_ */
#endif
diff --git a/lib/util/util_net.c b/lib/util/util_net.c
index daaf9808b8f..8376f8876a4 100644
--- a/lib/util/util_net.c
+++ b/lib/util/util_net.c
@@ -28,7 +28,9 @@
#include "system/locale.h"
#include "system/filesys.h"
#include "lib/util/util_net.h"
+
#undef strcasecmp
+#undef strncasecmp
/*******************************************************************
Set an address to INADDR_ANY.
diff --git a/libcli/http/gensec/generic.c b/libcli/http/gensec/generic.c
index 5bafb839d65..2f09b9d5eac 100644
--- a/libcli/http/gensec/generic.c
+++ b/libcli/http/gensec/generic.c
@@ -27,6 +27,8 @@
#include "auth/gensec/gensec_internal.h"
#include "lib/util/base64.h"
+#undef strncasecmp
+
_PUBLIC_ NTSTATUS gensec_http_generic_init(TALLOC_CTX *);
struct gensec_http_generic_state {
diff --git a/libcli/http/http.c b/libcli/http/http.c
index 6be053136c8..d20fc25f9e2 100644
--- a/libcli/http/http.c
+++ b/libcli/http/http.c
@@ -26,6 +26,7 @@
#include "util/tevent_werror.h"
#include "lib/util/dlinklist.h"
+#undef strcasecmp
/**
* Determines if a response should have a body.
diff --git a/libcli/http/http_auth.c b/libcli/http/http_auth.c
index ece660584f6..3dcf52c626e 100644
--- a/libcli/http/http_auth.c
+++ b/libcli/http/http_auth.c
@@ -29,6 +29,9 @@
#include "auth/credentials/credentials.h"
#include "lib/util/data_blob.h"
+#undef strcasecmp
+#undef strncasecmp
+
/**
* Copy the request headers from src to dst
*/
diff --git a/libcli/security/util_sid.c b/libcli/security/util_sid.c
index e47ed04c30f..634628f04d9 100644
--- a/libcli/security/util_sid.c
+++ b/libcli/security/util_sid.c
@@ -28,6 +28,9 @@
#include "../librpc/gen_ndr/netlogon.h"
#include "../libcli/security/security.h"
+#undef strcasecmp
+#undef strncasecmp
+
/*
* Some useful sids, more well known sids can be found at
* http://support.microsoft.com/kb/243330/EN-US/
diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c
index 3d622b2be49..42e8e611019 100644
--- a/librpc/rpc/dcerpc_util.c
+++ b/librpc/rpc/dcerpc_util.c
@@ -33,6 +33,8 @@
#include "lib/crypto/gnutls_helpers.h"
#include <gnutls/crypto.h>
+#undef strncasecmp
+
/* we need to be able to get/set the fragment length without doing a full
decode */
void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v)
diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c
index 88838121f2f..a12bf134077 100644
--- a/librpc/rpc/dcesrv_core.c
+++ b/librpc/rpc/dcesrv_core.c
@@ -37,6 +37,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
+#undef strcasecmp
+
static NTSTATUS dcesrv_negotiate_contexts(struct dcesrv_call_state *call,
const struct dcerpc_bind *b,
struct dcerpc_ack_ctx *ack_ctx_list);
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 8fa65cc3122..33bca3363b7 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -297,7 +297,7 @@ typedef char fstring[FSTRING_LEN];
/* String routines */
#include "srvstr.h"
-#include "safe_string.h"
+#include "lib/util/safe_string.h"
#ifndef SIGCLD
#define SIGCLD SIGCHLD
diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h
deleted file mode 100644
index 4609e3a45fd..00000000000
--- a/source3/include/safe_string.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Safe string handling routines.
- Copyright (C) Andrew Tridgell 1994-1998
- Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _SAFE_STRING_H
-#define _SAFE_STRING_H
-
-#ifndef _SPLINT_ /* http://www.splint.org */
-
-/* Some macros to ensure people don't use buffer overflow vulnerable string
- functions. */
-
-#ifdef bcopy
-#undef bcopy
-#endif /* bcopy */
-#define bcopy(src,dest,size) __ERROR__XX__NEVER_USE_BCOPY___;
-
-#ifdef strcpy
-#undef strcpy
-#endif /* strcpy */
-#define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
-
-#ifdef strcat
-#undef strcat
-#endif /* strcat */
-#define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
-
-#ifdef sprintf
-#undef sprintf
-#endif /* sprintf */
-#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
-
-/*
- * strcasecmp/strncasecmp aren't an error, but it means you're not thinking about
- * multibyte. Don't use them. JRA.
- */
-#ifdef strcasecmp
-#undef strcasecmp
-#endif
-#define strcasecmp __ERROR__XX__NEVER_USE_STRCASECMP__;
-
-#ifdef strncasecmp
-#undef strncasecmp
-#endif
-#define strncasecmp __ERROR__XX__NEVER_USE_STRNCASECMP__;
-
-#endif /* !_SPLINT_ */
-
-#endif
diff --git a/source3/modules/vfs_vxfs.c b/source3/modules/vfs_vxfs.c
index fbc68d6bec5..5c1aa5fb7ac 100644
--- a/source3/modules/vfs_vxfs.c
+++ b/source3/modules/vfs_vxfs.c
@@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "system/filesys.h"
#include "vfs_vxfs.h"
+#undef strcasecmp
+
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
diff --git a/source4/auth/ntlm/auth_developer.c b/source4/auth/ntlm/auth_developer.c
index b655283975b..209786b63b2 100644
--- a/source4/auth/ntlm/auth_developer.c
+++ b/source4/auth/ntlm/auth_developer.c
@@ -27,6 +27,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
+#undef strncasecmp
+
_PUBLIC_ NTSTATUS auth4_developer_init(TALLOC_CTX *);
static NTSTATUS name_to_ntstatus_want_check(struct auth_method_context *ctx,
diff --git a/source4/client/client.c b/source4/client/client.c
index 27e20975156..549e5343f84 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -58,6 +58,8 @@
#define DEFAULT_PAGER "more"
#endif
+#undef strncasecmp
+
struct smbclient_context {
char *remote_cur_dir;
struct smbcli_state *cli;
diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 990f4dc2eda..687313b0a78 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -41,6 +41,8 @@
#include "dnsserver_common.h"
#include "lib/util/smb_strtox.h"
+#undef strcasecmp
+
struct b9_options {
const char *url;
const char *debug;
diff --git a/source4/dns_server/dnsserver_common.c b/source4/dns_server/dnsserver_common.c
index 8635d075be8..bcb0d087faf 100644
--- a/source4/dns_server/dnsserver_common.c
+++ b/source4/dns_server/dnsserver_common.c
@@ -37,6 +37,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DNS
+#undef strncasecmp
+
uint8_t werr_to_dns_err(WERROR werr)
{
if (W_ERROR_EQUAL(WERR_OK, werr)) {
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index a4d90135b41..77b77de887b 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -51,6 +51,8 @@
#include "libcli/util/ntstatus.h"
#include "lib/util/smb_strtox.h"
+#undef strncasecmp
+
/*
* This included to allow us to handle DSDB_FLAG_REPLICATED_UPDATE in
* dsdb_request_add_controls()
diff --git a/source4/dsdb/common/util_trusts.c b/source4/dsdb/common/util_trusts.c
index b4571dca957..0f4d5584192 100644
--- a/source4/dsdb/common/util_trusts.c
+++ b/source4/dsdb/common/util_trusts.c
@@ -35,6 +35,8 @@
#include "lib/crypto/md4.h"
#include "libcli/ldap/ldap_ndr.h"
+#undef strcasecmp
+
NTSTATUS dsdb_trust_forest_info_from_lsa(TALLOC_CTX *mem_ctx,
const struct lsa_ForestTrustInformation *lfti,
struct ForestTrustInfo **_fti)
diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c
index a3ffd350ab0..57b82131225 100644
--- a/source4/dsdb/repl/drepl_partitions.c
+++ b/source4/dsdb/repl/drepl_partitions.c
@@ -37,6 +37,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DRS_REPL
+#undef strcasecmp
+
/*
load the partitions list based on replicated NC attributes in our
NTDSDSA object
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index b4bd9d8f9c9..544a5f6a88c 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -37,6 +37,8 @@
#include "dsdb/common/util.h"
#include "param/param.h"
+#undef strcasecmp
+
static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
struct smb_krb5_context *smb_krb5_context,
uint32_t format_flags, enum drsuapi_DsNameFormat format_offered,
diff --git a/source4/dsdb/samdb/ldb_modules/acl.c b/source4/dsdb/samdb/ldb_modules/acl.c
index b1bbf936006..802969d50d5 100644
--- a/source4/dsdb/samdb/ldb_modules/acl.c
+++ b/source4/dsdb/samdb/ldb_modules/acl.c
@@ -43,6 +43,9 @@
#include "system/kerberos.h"
#include "auth/kerberos/kerberos.h"
+#undef strcasecmp
+#undef strncasecmp
+
struct extended_access_check_attribute {
const char *oa_name;
const uint32_t requires_rights;
diff --git a/source4/dsdb/samdb/ldb_modules/count_attrs.c b/source4/dsdb/samdb/ldb_modules/count_attrs.c
index aa9e2807e05..c72898a7862 100644
--- a/source4/dsdb/samdb/ldb_modules/count_attrs.c
+++ b/source4/dsdb/samdb/ldb_modules/count_attrs.c
@@ -38,6 +38,8 @@
#define NULL_REQ_PSEUDO_N -2LL;
#define STAR_REQ_PSEUDO_N -4LL;
+#undef strcasecmp
+
struct count_attrs_private {
struct tdb_wrap *requested;
struct tdb_wrap *duplicates;
diff --git a/source4/dsdb/samdb/ldb_modules/encrypted_secrets.c b/source4/dsdb/samdb/ldb_modules/encrypted_secrets.c
index d3ce7e31642..8c59418c3c1 100644
--- a/source4/dsdb/samdb/ldb_modules/encrypted_secrets.c
+++ b/source4/dsdb/samdb/ldb_modules/encrypted_secrets.c
@@ -50,6 +50,7 @@ static const size_t num_secret_attributes = ARRAY_SIZE(secret_attributes);
#define NUMBER_OF_KEYS 1
#define SECRETS_KEY_FILE "encrypted_secrets.key"
+#undef strcasecmp
struct es_data {
/*
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c
index b7ca636598f..5c5521d0b21 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c
@@ -37,6 +37,8 @@
#include "dsdb/samdb/ldb_modules/util.h"
#include "lib/ldb-samba/ldb_matching_rules.h"
+#undef strncasecmp
+
/*
TODO: if relax is not set then we need to reject the fancy RMD_* and
DELETED extended DN codes
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
index 2b680a32532..53cbe345070 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
@@ -42,6 +42,9 @@
#include "dsdb/samdb/samdb.h"
#include "dsdb/samdb/ldb_modules/util.h"
+#undef strcasecmp
+#undef strncasecmp
+
struct extended_dn_out_private {
bool dereference;
bool normalise;
diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
index d8ccd38537d..5ef075f2037 100644
--- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c
+++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
@@ -53,6 +53,7 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "dsdb/samdb/ldb_modules/util.h"
+#undef strcasecmp
struct la_private_transaction {
struct la_context *la_list;
diff --git a/source4/dsdb/samdb/ldb_modules/netlogon.c b/source4/dsdb/samdb/ldb_modules/netlogon.c
index 1e74d1b9627..e5ca65f3b36 100644
--- a/source4/dsdb/samdb/ldb_modules/netlogon.c
+++ b/source4/dsdb/samdb/ldb_modules/netlogon.c
@@ -39,6 +39,8 @@
#include "libds/common/flag_mapping.h"
#include "lib/util/util_net.h"
+#undef strcasecmp
+
/*
fill in the cldap netlogon union for a given version
*/
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index bfdfa51595a..5a05bf2952e 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -65,6 +65,8 @@
#define MINIMUM_GPGME_VERSION "1.2.0"
#endif
+#undef strncasecmp
+
/* If we have decided there is a reason to work on this request, then
* setup all the password hash types correctly.
*
diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c
index 98438799997..b010abb8ab4 100644
--- a/source4/dsdb/samdb/ldb_modules/ranged_results.c
+++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c
@@ -32,6 +32,8 @@
#include "includes.h"
#include "ldb_module.h"
+#undef strncasecmp
+
struct rr_context {
struct ldb_module *module;
struct ldb_request *req;
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 58c04da5f53..fbeab0b1825 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -52,6 +52,8 @@
#include "lib/util/tsort.h"
#include "lib/util/binsearch.h"
+#undef strcasecmp
+
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DRS_REPL
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 55340fa4f1e..4607300bf3a 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -38,6 +38,8 @@
#include "cldap_server/cldap_server.h"
#include "lib/events/events.h"
+#undef strcasecmp
+
struct rootdse_private_data {
unsigned int num_controls;
char **controls;
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 2a43807272c..71338340c81 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -47,6 +47,8 @@
#include "librpc/gen_ndr/irpc.h"
#include "lib/util/smb_strtox.h"
+#undef strcasecmp
+
struct samldb_ctx;
enum samldb_add_type {
SAMLDB_TYPE_USER,
diff --git a/source4/dsdb/samdb/ldb_modules/schema_data.c b/source4/dsdb/samdb/ldb_modules/schema_data.c
index 127a6be9f64..697ce218bcd 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_data.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_data.c
@@ -30,6 +30,8 @@
#include "param/param.h"
#include "dsdb/samdb/ldb_modules/util.h"
+#undef strcasecmp
+
static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg,
const struct dsdb_schema *schema);
static int generate_attributeTypes(struct ldb_context *ldb, struct ldb_message *msg,
diff --git a/source4/dsdb/schema/schema_convert_to_ol.c b/source4/dsdb/schema/schema_convert_to_ol.c
index 71a417ed843..ebb886da677 100644
--- a/source4/dsdb/schema/schema_convert_to_ol.c
+++ b/source4/dsdb/schema/schema_convert_to_ol.c
@@ -23,6 +23,8 @@
#include "dsdb/samdb/samdb.h"
#include "system/locale.h"
+#undef strcasecmp
+
#define SEPERATOR "\n "
struct attr_map {
diff --git a/source4/dsdb/schema/schema_description.c b/source4/dsdb/schema/schema_description.c
index 7d51e813873..36a3ff2f3bb 100644
--- a/source4/dsdb/schema/schema_description.c
+++ b/source4/dsdb/schema/schema_description.c
@@ -22,6 +22,8 @@
#include "dsdb/samdb/samdb.h"
#include "librpc/ndr/libndr.h"
+#undef strcasecmp
+
#define IF_NULL_FAIL_RET(x) do { \
if (!x) { \
return NULL; \
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index e79e3e7dfc6..a3b00497b6b 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -32,6 +32,7 @@
#include <ldb_module.h>
#include "../lib/util/asn1.h"
+#undef strcasecmp
struct dsdb_schema *dsdb_new_schema(TALLOC_CTX *mem_ctx)
{
diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c
index 4042aa6966b..fc34764881c 100644
--- a/source4/dsdb/schema/schema_query.c
+++ b/source4/dsdb/schema/schema_query.c
@@ -27,6 +27,9 @@
#include "lib/util/tsort.h"
#include "util/dlinklist.h"
+#undef strcasecmp
+#undef strncasecmp
+
static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx,
const struct dsdb_schema *schema,
const char **class_list,
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 2ee2596570e..f4934917c7c 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -30,6 +30,8 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "lib/util/tsort.h"
+#undef strcasecmp
+
/* change this when we change something in our schema code that
* requires a re-index of the database
*/
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index 60a26a2620b..fcf9ca4ce3c 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -32,6 +32,8 @@
#include "librpc/ndr/libndr.h"
#include "../lib/util/asn1.h"
+#undef strcasecmp
+
/**
* Initialize dsdb_syntax_ctx with default values
* for common cases.
diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c
index 5fd0f431cdf..a560a1cd84b 100644
--- a/source4/kdc/db-glue.c
+++ b/source4/kdc/db-glue.c
@@ -38,6 +38,8 @@
#include "librpc/gen_ndr/ndr_irpc_c.h"
#include "lib/messaging/irpc.h"
+#undef strcasecmp
+#undef strncasecmp
#define SAMBA_KVNO_GET_KRBTGT(kvno) \
((uint16_t)(((uint32_t)kvno) >> 16))
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 5cd72d3e258..c2d53eacd3f 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -49,6 +49,8 @@
#include "libds/common/roles.h"
#include "lib/util/time.h"
+#undef strcasecmp
+
static void ldapsrv_terminate_connection_done(struct tevent_req *subreq);
/*
diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c
index 088d7fe2967..0e9eff147c5 100644
--- a/source4/lib/com/dcom/main.c
+++ b/source4/lib/com/dcom/main.c
@@ -32,6 +32,8 @@
#include "auth/credentials/credentials.h"
#include "libcli/composite/composite.h"
+#undef strncasecmp
+
#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC }
static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding **b_out, struct STRINGBINDING *bd)
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index 38f4d9007d8..2900c10419a 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -22,6 +22,7 @@
#include "lib/registry/registry.h"
#include "system/filesys.h"
+#undef strcasecmp
/**
* @file
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 1897e2c55f5..50bd1412137 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -25,6 +25,9 @@
#include "librpc/gen_ndr/winreg.h"
#include "lib/util/sys_rw.h"
+#undef strcasecmp
+#undef strncasecmp
+
struct preg_data {
int fd;
TALLOC_CTX *ctx;
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 763b0ce4319..1e0b14324af 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -26,6 +26,7 @@
#include "lib/registry/registry.h"
#include "libcli/security/security.h"
+#undef strcasecmp
static struct hive_operations reg_backend_regf;
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index 762ec3d48c4..62dbf1d2213 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -27,6 +27,8 @@
#include "system/network.h"
#include "lib/util/util_net.h"
+#undef strcasecmp
+
_PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type);
_PUBLIC_ const struct socket_ops *socket_ipv6_ops(enum socket_type type);
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index bae26e06c8c..a24800c515f 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -37,6 +37,8 @@
#include "libcli/dgram/libdgram.h"
#include "lib/socket/socket.h"
+#undef strcasecmp
+
/*
destroy a mailslot handler
*/
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 139030090be..db2606b5a32 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -30,6 +30,8 @@
#include "lib/tsocket/tsocket.h"
#include "lib/util/util_net.h"
+#undef strcasecmp
+
struct resolve_state {
struct resolve_context *ctx;
struct resolve_method *method;
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index ad355fc3c4d..9a7b9aeb8d1 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -38,6 +38,8 @@
#include "libcli/http/http.h"
#include "lib/util/util_net.h"
+#undef strcasecmp
+
struct dcerpc_pipe_connect {
struct dcecli_connection *conn;
struct dcerpc_binding *binding;
diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c
index b20b154a1cb..8719ff9821e 100644
--- a/source4/librpc/rpc/dcerpc_smb.c
+++ b/source4/librpc/rpc/dcerpc_smb.c
@@ -33,6 +33,8 @@
#include "librpc/rpc/dcerpc_proto.h"
#include "libcli/composite/composite.h"
+#undef strncasecmp
+
/* transport private information used by SMB pipe transport */
struct smb_private {
DATA_BLOB session_key;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 414a31f4931..e4a7c2042ed 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -33,6 +33,8 @@
#include "param/param.h"
#include "lib/util/smb_strtox.h"
+#undef strcasecmp
+
uint64_t winsdb_get_maxVersion(struct winsdb_handle *h)
{
int ret;
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 37660ca0a1c..967c80d2995 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -43,6 +43,8 @@
#include "system/locale.h"
#include "system/filesys.h"
+#undef strncasecmp
+
/* this is the private structure used to keep the state of an open
ipc$ connection. It needs to keep information about all open
pipes */
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 6b868df743a..a492f7e97fb 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -35,6 +35,8 @@
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
+#undef strcasecmp
+
/* a second stage function converts from the out parameters of the generic
call onto the out parameters of the specific call made */
typedef NTSTATUS (*second_stage_t)(struct ntvfs_module_context *,
diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c
index bdd86f20973..46a235429aa 100644
--- a/source4/ntvfs/posix/pvfs_shortname.c
+++ b/source4/ntvfs/posix/pvfs_shortname.c
@@ -24,6 +24,8 @@
#include "vfs_posix.h"
#include "param/param.h"
+#undef strcasecmp
+
/*
this mangling scheme uses the following format
diff --git a/source4/ntvfs/sysdep/sys_lease.c b/source4/ntvfs/sysdep/sys_lease.c
index b6e6ffc9af6..1ef72f15cd1 100644
--- a/source4/ntvfs/sysdep/sys_lease.c
+++ b/source4/ntvfs/sysdep/sys_lease.c
@@ -29,6 +29,8 @@
#include "param/param.h"
#include "lib/util/samba_modules.h"
+#undef strcasecmp
+
/* list of registered backends */
static struct sys_lease_ops *backends;
static uint32_t num_backends;
diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c
index 7e00032959a..6991461ece7 100644
--- a/source4/ntvfs/sysdep/sys_notify.c
+++ b/source4/ntvfs/sysdep/sys_notify.c
@@ -30,6 +30,8 @@
#include "param/param.h"
#include "lib/util/samba_modules.h"
+#undef strcasecmp
+
/* list of registered backends */
static struct sys_notify_backend *backends;
static uint32_t num_backends;
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
index f8b1a3f5d97..30d7f205cd1 100644
--- a/source4/param/share_ldb.c
+++ b/source4/param/share_ldb.c
@@ -27,6 +27,8 @@
#include "param/share.h"
#include "param/param.h"
+#undef strcasecmp
+
NTSTATUS share_ldb_init(TALLOC_CTX *);
static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops,
diff --git a/source4/rpc_server/backupkey/dcesrv_backupkey.c b/source4/rpc_server/backupkey/dcesrv_backupkey.c
index 36f5e5823eb..181f95a5918 100644
--- a/source4/rpc_server/backupkey/dcesrv_backupkey.c
+++ b/source4/rpc_server/backupkey/dcesrv_backupkey.c
@@ -44,6 +44,8 @@
#include "lib/crypto/gnutls_helpers.h"
+#undef strncasecmp
+
#define DCESRV_INTERFACE_BACKUPKEY_BIND(context, iface) \
dcesrv_interface_backupkey_bind(context, iface)
static NTSTATUS dcesrv_interface_backupkey_bind(struct dcesrv_connection_context *context,
diff --git a/source4/rpc_server/common/share_info.c b/source4/rpc_server/common/share_info.c
index 34330b92ca1..d7ed5ee4241 100644
--- a/source4/rpc_server/common/share_info.c
+++ b/source4/rpc_server/common/share_info.c
@@ -25,6 +25,8 @@
#include "rpc_server/dcerpc_server.h"
#include "rpc_server/common/share.h"
+#undef strcasecmp
+
/*
Here are common server info functions used by some dcerpc server interfaces
*/
diff --git a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
index 88efc01f154..a5948c7969b 100644
--- a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
+++ b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
@@ -28,6 +28,8 @@
#include "dns_server/dnsserver_common.h"
#include "dnsserver.h"
+#undef strcasecmp
+
#define DCESRV_INTERFACE_DNSSERVER_BIND(context, iface) \
dcesrv_interface_dnsserver_bind(context, iface)
static NTSTATUS dcesrv_interface_dnsserver_bind(struct dcesrv_connection_context *context,
diff --git a/source4/rpc_server/dnsserver/dnsdata.c b/source4/rpc_server/dnsserver/dnsdata.c
index 47d6f5d5c88..31d0233cf52 100644
--- a/source4/rpc_server/dnsserver/dnsdata.c
+++ b/source4/rpc_server/dnsserver/dnsdata.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/ndr_dnsp.h"
#include "librpc/gen_ndr/ndr_dnsserver.h"
+#undef strcasecmp
struct IP4_ARRAY *ip4_array_copy(TALLOC_CTX *mem_ctx, struct IP4_ARRAY *ip4)
{
diff --git a/source4/rpc_server/dnsserver/dnsdb.c b/source4/rpc_server/dnsserver/dnsdb.c
index 798c869efe5..5ac11aea270 100644
--- a/source4/rpc_server/dnsserver/dnsdb.c
+++ b/source4/rpc_server/dnsserver/dnsdb.c
@@ -29,6 +29,8 @@
#include "libcli/security/security.h"
#include "dsdb/common/util.h"
+#undef strcasecmp
+
/* There are only 2 fixed partitions for DNS */
struct dnsserver_partition *dnsserver_db_enumerate_partitions(TALLOC_CTX *mem_ctx,
struct dnsserver_serverinfo *serverinfo,
diff --git a/source4/rpc_server/dnsserver/dnsutils.c b/source4/rpc_server/dnsserver/dnsutils.c
index 880e120c39a..94407be0dcf 100644
--- a/source4/rpc_server/dnsserver/dnsutils.c
+++ b/source4/rpc_server/dnsserver/dnsutils.c
@@ -28,6 +28,8 @@
#include "lib/util/util_net.h"
#include "dnsserver_common.h"
+#undef strcasecmp
+
static struct DNS_ADDR_ARRAY *fill_dns_addr_array(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
bool listen_only)
diff --git a/source4/rpc_server/drsuapi/writespn.c b/source4/rpc_server/drsuapi/writespn.c
index c6faea39e9f..9e4b533365a 100644
--- a/source4/rpc_server/drsuapi/writespn.c
+++ b/source4/rpc_server/drsuapi/writespn.c
@@ -35,6 +35,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DRS_REPL
+#undef strcasecmp
+
/*
check that the SPN update should be allowed as an override
via sam_ctx_system
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index acd37131d79..ebe259ff81e 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -39,6 +39,8 @@
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
+#undef strcasecmp
+
#define DCESRV_INTERFACE_LSARPC_BIND(context, iface) \
dcesrv_interface_lsarpc_bind(context, iface)
static NTSTATUS dcesrv_interface_lsarpc_bind(struct dcesrv_connection_context *context,
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 0ab55afeab0..0351e2d286c 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -48,6 +48,8 @@
#define DCESRV_INTERFACE_NETLOGON_BIND(context, iface) \
dcesrv_interface_netlogon_bind(context, iface)
+#undef strcasecmp
+
/*
* This #define allows the netlogon interface to accept invalid
* association groups, because association groups are to coordinate
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index 70f914bf14c..cda887d45ee 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -41,6 +41,8 @@
#include "lib/util/tsort.h"
#include "libds/common/flag_mapping.h"
+#undef strcasecmp
+
#define DCESRV_INTERFACE_SAMR_BIND(context, iface) \
dcesrv_interface_samr_bind(context, iface)
static NTSTATUS dcesrv_interface_samr_bind(struct dcesrv_connection_context *context,
diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
index 7294c90a328..c41fbc7573f 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -31,6 +31,9 @@
#include "rpc_server/srvsvc/proto.h"
#include "param/param.h"
+#undef strcasecmp
+#undef strncasecmp
+
#define SRVSVC_CHECK_ADMIN_ACCESS do { \
struct auth_session_info *si = dcesrv_call_session_info(dce_call); \
struct security_token *t = si->security_token; \
diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c
index e25be1c382d..c23b470e472 100644
--- a/source4/smb_server/smb/service.c
+++ b/source4/smb_server/smb/service.c
@@ -23,6 +23,8 @@
#include "ntvfs/ntvfs.h"
#include "param/param.h"
+#undef strcasecmp
+
/****************************************************************************
Make a connection, given the snum to connect to, and the vuser of the
connecting user if appropriate.
diff --git a/source4/smbd/service.c b/source4/smbd/service.c
index 7c8d2cfe3a4..e939c85e689 100644
--- a/source4/smbd/service.c
+++ b/source4/smbd/service.c
@@ -24,6 +24,8 @@
#include "../lib/util/dlinklist.h"
#include "smbd/process_model.h"
+#undef strcasecmp
+
/*
a linked list of registered servers
*/
diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c
index df12b3ce821..0c3ccd54bf9 100644
--- a/source4/torture/basic/mangle_test.c
+++ b/source4/torture/basic/mangle_test.c
@@ -26,6 +26,8 @@
#include "torture/util.h"
#include "torture/basic/proto.h"
+#undef strcasecmp
+
static TDB_CONTEXT *tdb;
#define NAME_LENGTH 20
diff --git a/source4/torture/gpo/apply.c b/source4/torture/gpo/apply.c
index c4a6499f4cc..560408f7a85 100644
--- a/source4/torture/gpo/apply.c
+++ b/source4/torture/gpo/apply.c
@@ -30,6 +30,8 @@
#include "lib/util/samba_util.h"
#include "util/tevent_ntstatus.h"
+#undef strncasecmp
+
struct torture_suite *gpo_apply_suite(TALLOC_CTX *ctx)
{
struct torture_suite *suite = torture_suite_create(ctx, "apply");
diff --git a/source4/torture/krb5/kdc-canon-heimdal.c b/source4/torture/krb5/kdc-canon-heimdal.c
index 9e0808b134c..cd47182c0ef 100644
--- a/source4/torture/krb5/kdc-canon-heimdal.c
+++ b/source4/torture/krb5/kdc-canon-heimdal.c
@@ -34,6 +34,8 @@
#include "auth/gensec/gensec.h"
#include "param/param.h"
+#undef strcasecmp
+
#define TEST_CANONICALIZE 0x0000001
#define TEST_ENTERPRISE 0x0000002
#define TEST_UPPER_REALM 0x0000004
diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c
index 825ee835c65..ea3b5ddfc7f 100644
--- a/source4/torture/ldap/basic.c
+++ b/source4/torture/ldap/basic.c
@@ -29,6 +29,7 @@
#include "torture/torture.h"
#include "torture/ldap/proto.h"
+#undef strcasecmp
static bool test_bind_sasl(struct torture_context *tctx,
struct ldap_connection *conn, struct cli_credentials *creds)
diff --git a/source4/torture/ldap/netlogon.c b/source4/torture/ldap/netlogon.c
index d23ce609101..c2dd8349fc6 100644
--- a/source4/torture/ldap/netlogon.c
+++ b/source4/torture/ldap/netlogon.c
@@ -33,6 +33,8 @@
#include "torture/torture.h"
#include "torture/ldap/proto.h"
+#undef strcasecmp
+
#define CHECK_STATUS(status, correct) torture_assert_ntstatus_equal(tctx, status, correct, "incorrect status")
#define CHECK_VAL(v, correct) torture_assert_int_equal(tctx, (v), (correct), "incorrect value");
diff --git a/source4/torture/libnetapi/libnetapi_group.c b/source4/torture/libnetapi/libnetapi_group.c
index d27a99b5bfc..f4b446d89d8 100644
--- a/source4/torture/libnetapi/libnetapi_group.c
+++ b/source4/torture/libnetapi/libnetapi_group.c
@@ -22,6 +22,8 @@
#include <netapi.h>
#include "torture/libnetapi/proto.h"
+#undef strcasecmp
+
#define TORTURE_TEST_USER "testuser"
#define NETAPI_STATUS(tctx, x,y,fn) \
diff --git a/source4/torture/libnetapi/libnetapi_user.c b/source4/torture/libnetapi/libnetapi_user.c
index 134b4e8b9c0..1411d7ef41b 100644
--- a/source4/torture/libnetapi/libnetapi_user.c
+++ b/source4/torture/libnetapi/libnetapi_user.c
@@ -22,6 +22,8 @@
#include <netapi.h>
#include "torture/libnetapi/proto.h"
+#undef strcasecmp
+
#define TORTURE_TEST_USER "torture_testuser"
#define TORTURE_TEST_USER2 "torture_testuser2"
diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c
index c7bb88a6d53..14af01bffad 100644
--- a/source4/torture/raw/search.c
+++ b/source4/torture/raw/search.c
@@ -26,6 +26,7 @@
#include "lib/util/tsort.h"
#include "torture/raw/proto.h"
+#undef strncasecmp
#define BASEDIR "\\testsearch"
diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c
index a0daa608748..f23c33fed7f 100644
--- a/source4/torture/rpc/drsuapi_cracknames.c
+++ b/source4/torture/rpc/drsuapi_cracknames.c
@@ -27,6 +27,8 @@
#include <ldb.h>
#include "libcli/security/security.h"
+#undef strcasecmp
+
struct DsCrackNamesPrivate {
struct DsPrivate base;
diff --git a/source4/torture/rpc/forest_trust.c b/source4/torture/rpc/forest_trust.c
index 118f0d27c53..ceb1a7ecbd9 100644
--- a/source4/torture/rpc/forest_trust.c
+++ b/source4/torture/rpc/forest_trust.c
@@ -34,6 +34,8 @@
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
+#undef strcasecmp
+
#define TEST_DOM "torturedom"
#define TEST_DOM_DNS "torturedom.samba.example.com"
#define TEST_DOM_SID "S-1-5-21-97398-379795-10000"
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index 65188d2dc85..87c6ed548cb 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -38,6 +38,8 @@
#include "lib/replace/system/network.h"
#include "dsdb/samdb/samdb.h"
+#undef strcasecmp
+
#define TEST_MACHINE_NAME "torturetest"
static bool test_netr_broken_binding_handle(struct torture_context *tctx,
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index e02d66adaf3..5863a6d1ee6 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -44,6 +44,8 @@
#include "source3/rpc_client/init_samr.h"
#include "lib/crypto/gnutls_helpers.h"
+#undef strcasecmp
+
#define TEST_ACCOUNT_NAME "samrtorturetest"
#define TEST_ACCOUNT_NAME_PWD "samrpwdlastset"
#define TEST_ALIASNAME "samrtorturetestalias"
diff --git a/source4/torture/smb2/mangle.c b/source4/torture/smb2/mangle.c
index f489f25654c..bf140643de2 100644
--- a/source4/torture/smb2/mangle.c
+++ b/source4/torture/smb2/mangle.c
@@ -28,6 +28,8 @@
#include "torture/util.h"
#include "torture/smb2/proto.h"
+#undef strcasecmp
+
static TDB_CONTEXT *tdb;
#define NAME_LENGTH 20
diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c
index efcf910d300..e76b0b7921c 100644
--- a/source4/torture/unix/whoami.c
+++ b/source4/torture/unix/whoami.c
@@ -32,6 +32,7 @@
#include "dsdb/samdb/samdb.h"
#include "../libcli/security/security.h"
+#undef strcasecmp
/* Size (in bytes) of the required fields in the SMBwhoami response. */
#define WHOAMI_REQUIRED_SIZE 40
diff --git a/source4/utils/oLschema2ldif/lib.c b/source4/utils/oLschema2ldif/lib.c
index ad73bab5325..9bed198aba1 100644
--- a/source4/utils/oLschema2ldif/lib.c
+++ b/source4/utils/oLschema2ldif/lib.c
@@ -36,6 +36,8 @@
#include "ldb.h"
#include "../librpc/gen_ndr/ndr_misc.h"
+#undef strcasecmp
+
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>