[PATCHES v2] Fix FreeBSD developer build

Andrew Bartlett abartlet at samba.org
Wed Nov 22 00:15:11 UTC 2017


On Tue, 2017-11-21 at 21:25 +0200, Uri Simchoni via samba-technical
wrote:
> Hi,
> 
> Attached version 3 - same as v2, but with added 3 patches at the end,
> which allow FreeBSD developer build to run without the ADDITIONAL_CFLAGS
> workaround, and without breaking Linux...
> 
> Some responses below.
> 
> Thanks,
> Uri.
> 
> On 11/21/2017 12:58 AM, Timur I. Bakeyev via samba-technical wrote:
> > Hi, Uri!
> > 
> > That's quite a jumbo patch, possibly splitting it into smaller chunks could
> > be easier to review :)
> > 
> 
> That's a jumbo patch-*set*. Each patch is pretty small, concerns one
> issue, and most patches modify a single file. I believe that's more or
> less the Samba practice. Granted, it's easier for people to review a
> small patch set, but that would mean I'd get into a cycle of several
> weeks, waiting for the previous subset to land before submitting the
> next one - I don't have the patience for that so let's keep our fingers
> crossed.

I've taken a go at it.  I'll review what I can of this, so as to cut
down the set into the changes I can simply approve. 

In particular, I've dropped the pragma changes.  #pragma caused chaos
last time we used it, so I'm skipping those for now.

I'm also skipping the changes to pam_wrapper that need to go upstream
(via Andreas) first.  It looks like I also made the same mistake when
some python3 patches landed, oops. 

> > I've noticed mentioning of missing HAVE_INTPTR_T on FreeBSD, need to check
> > that, but meanwhile:
> > 
> > https://bugzilla.samba.org/show_bug.cgi?id=4635
> > 
> > Also, is that patchset against the HEAD? As traditionally we usually first
> > work with releases, so at least two patches fail to me...
> > 
> > What are the problems with the patches I sent on Linux? I believe similar
> > approach is used in couple of other places in wscripts.
> > 
> 
> I didn't want to use the patches as-is, as I don't support the notion
> of CHECK_CFLAGS(<flag-we-want-to-check> + <error flags>). CHECK_CFLAGS
> should be able to detect <flag-we-want-to-check> without having to add.
> So what I did was make a similar change to CHECK_CFLAGS itself. That
> worked on FreeBSD, but changed the set of supported flags on Fedora 25
> (GCC 6.4.1), all of the sudden claiming that -Wformat-security is not
> supported. With further examination, it turned out that
> -Wformat-security is ignored when -Wformat is not specified, hence the
> addition of "prereq_flags" to CHECK_FLAGS.

I like this approach.

Attached is what I'm happy with, which is under a private autobuild.

This should then allow broader review of the remaining changes, without
the weight of the larger patch set.

Thanks!

Andrew Bartlett
-- 
Andrew Bartlett
https://samba.org/~abartlet/
Authentication Developer, Samba Team         https://samba.org
Samba Development and Support, Catalyst IT   
https://catalyst.net.nz/services/samba



-------------- next part --------------
From 562f90db8930e533ca6f74212af879f121281010 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 05:07:54 +0000
Subject: [PATCH 01/24] sysacls: make SMB_ACL_PERMSET_T opaque

sys_acl_get_permset() returns a pointer to a uint32_t. Prior
to this change, SMB_ACL_PERMSET_T has been defined as a mode_t
pointer, where mode_t may or may not be uint32_t (on FreeBSD
it's uint16_t, which could screw up big-endian FreeBSD systems).

Since SMB_ACL_PERMSET_T is being used as an opaque
data type to the ouside world, this patch changes it
to a void*, and in the implementation casts the pointer
to a uint32_t pointer.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/include/smb_acls.h |  2 +-
 source3/lib/sysacls.c      | 20 +++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/source3/include/smb_acls.h b/source3/include/smb_acls.h
index 73b67af020e..629c243ad7e 100644
--- a/source3/include/smb_acls.h
+++ b/source3/include/smb_acls.h
@@ -27,7 +27,7 @@ struct files_struct;
 struct smb_filename;
 
 typedef int			SMB_ACL_TYPE_T;
-typedef mode_t			*SMB_ACL_PERMSET_T;
+typedef void			*SMB_ACL_PERMSET_T;
 typedef mode_t			SMB_ACL_PERM_T;
 
 typedef enum smb_acl_tag_t SMB_ACL_TAG_T;
diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c
index 0bf3c37edfa..7d5c7e14d4e 100644
--- a/source3/lib/sysacls.c
+++ b/source3/lib/sysacls.c
@@ -95,7 +95,7 @@ int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p)
 
 int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
 {
-	*permset_p = &entry_d->a_perm;
+	*permset_p = (SMB_ACL_PERMSET_T)&entry_d->a_perm;
 
 	return 0;
 }
@@ -116,32 +116,37 @@ void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d)
 
 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d)
 {
-	*permset_d = 0;
+	uint32_t *perm_p = permset_d;
+	*perm_p = 0;
 
 	return 0;
 }
 
 int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm)
 {
+	uint32_t *perm_p = permset_d;
+
 	if (perm != SMB_ACL_READ && perm != SMB_ACL_WRITE
 	    && perm != SMB_ACL_EXECUTE) {
 		errno = EINVAL;
 		return -1;
 	}
 
-	if (permset_d == NULL) {
+	if (perm_p == NULL) {
 		errno = EINVAL;
 		return -1;
 	}
 
-	*permset_d |= perm;
+	*perm_p |= perm;
 
 	return 0;
 }
 
 int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm)
 {
-	return *permset_d & perm;
+	uint32_t *perm_p = permset_d;
+
+	return *perm_p & perm;
 }
 
 char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
@@ -331,12 +336,13 @@ int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p)
 
 int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d)
 {
-	if (*permset_d & ~(SMB_ACL_READ|SMB_ACL_WRITE|SMB_ACL_EXECUTE)) {
+	uint32_t *perm_p = permset_d;
+	if (*perm_p & ~(SMB_ACL_READ|SMB_ACL_WRITE|SMB_ACL_EXECUTE)) {
 		errno = EINVAL;
 		return -1;
 	}
 
-	entry_d->a_perm = *permset_d;
+	entry_d->a_perm = *perm_p;
 
 	return 0;
 }
-- 
2.11.0


From f87903f2d026d100846e98be6aeb95ce051947c2 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 05:18:03 +0000
Subject: [PATCH 02/24] nfs4acl: fix picky build in case rpc/xdr.h is not
 available

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/modules/nfs4acl_xattr_xdr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source3/modules/nfs4acl_xattr_xdr.c b/source3/modules/nfs4acl_xattr_xdr.c
index 67684dceb17..524e69c0e1f 100644
--- a/source3/modules/nfs4acl_xattr_xdr.c
+++ b/source3/modules/nfs4acl_xattr_xdr.c
@@ -403,6 +403,7 @@ NTSTATUS nfs4acl_xdr_blob_to_smb4(struct vfs_handle_struct *handle,
 }
 
 #else /* !HAVE_RPC_XDR_H */
+#include "nfs4acl_xattr_xdr.h"
 NTSTATUS nfs4acl_xdr_blob_to_smb4(struct vfs_handle_struct *handle,
 				  TALLOC_CTX *mem_ctx,
 				  DATA_BLOB *blob,
-- 
2.11.0


From 45d63f12f60ea7567d172b07db58cc5d79fd67bd Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 05:20:57 +0000
Subject: [PATCH 03/24] torture: remove spurious semicolon

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/torture/rpc/spoolss_notify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
index dd9cd31e8c0..718ae703bc9 100644
--- a/source4/torture/rpc/spoolss_notify.c
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -500,7 +500,8 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
 static struct received_packet *last_packet(struct received_packet *p)
 {
 	struct received_packet *tmp;
-	for (tmp = p; tmp->next; tmp = tmp->next) ;;
+	for (tmp = p; tmp->next; tmp = tmp->next) {
+	}
 	return tmp;
 }
 
-- 
2.11.0


From 25ef8539ef5cf7572716673ce2b3a9181f4a33e8 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 07:02:12 +0000
Subject: [PATCH 04/24] lib/crypto: remove unused code

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/crypto/sha512.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/lib/crypto/sha512.c b/lib/crypto/sha512.c
index 9c7367bb602..41be1ec0e96 100644
--- a/lib/crypto/sha512.c
+++ b/lib/crypto/sha512.c
@@ -38,26 +38,6 @@
 #define min(a,b) (((a)>(b))?(b):(a))
 #endif
 
-/* Vector Crays doesn't have a good 32-bit type, or more precisely,
-   int32_t as defined by <bind/bitypes.h> isn't 32 bits, and we don't
-   want to depend in being able to redefine this type.  To cope with
-   this we have to clamp the result in some places to [0,2^32); no
-   need to do this on other machines.  Did I say this was a mess?
-   */
-
-#ifdef _CRAY
-#define CRAYFIX(X) ((X) & 0xffffffff)
-#else
-#define CRAYFIX(X) (X)
-#endif
-
-static inline uint32_t
-cshift (uint32_t x, unsigned int n)
-{
-    x = CRAYFIX(x);
-    return CRAYFIX((x << n) | (x >> (32 - n)));
-}
-
 static inline uint64_t
 cshift64 (uint64_t x, unsigned int n)
 {
-- 
2.11.0


From 48d4b37bda8fc7860ed739534fbc655194502306 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 07:19:03 +0000
Subject: [PATCH 05/24] ldb: silence some clang warnings in picky developer
 mode

Avoid const in casting since it doesn't increase code
safety in this case and causes clang to generate const-qual
warning. Also initialize a pointer to NULL to silence clang
uninitialized variable warning.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/ldb/pyldb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 515a69e6981..e61b5b6a4f4 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -510,10 +510,10 @@ static PyObject *py_ldb_dn_set_extended_component(PyLdbDnObject *self, PyObject
 {
 	char *name;
 	int err;
-	uint8_t *value;
+	uint8_t *value = NULL;
 	Py_ssize_t size = 0;
 
-	if (!PyArg_ParseTuple(args, "sz#", &name, (const char**)&value, &size))
+	if (!PyArg_ParseTuple(args, "sz#", &name, (char **)&value, &size))
 		return NULL;
 
 	if (value == NULL) {
-- 
2.11.0


From fe9c87643cee6508729dd8b484bf11ac02bb3b0d Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 11:30:56 +0000
Subject: [PATCH 06/24] build: allow passing custom cflags to end of library
 build

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/wafsamba.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 23fd3c48342..4bb19d070e2 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -112,6 +112,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                   vnum=None,
                   soname=None,
                   cflags='',
+                  cflags_end=None,
                   ldflags='',
                   external_library=False,
                   realname=None,
@@ -195,6 +196,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                         private_headers= private_headers,
                         header_path    = header_path,
                         cflags         = cflags,
+                        cflags_end     = cflags_end,
                         group          = subsystem_group,
                         autoproto      = autoproto,
                         autoproto_extra_source=autoproto_extra_source,
-- 
2.11.0


From 24aed5c8afe8bc1704cc4f1f965b8e57a17678b1 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 11:32:16 +0000
Subject: [PATCH 07/24] build: allow adding cflags to end of python module
 build command

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/samba_python.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index f97439c945b..cb99fe9f4cc 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -109,6 +109,7 @@ def SAMBA_PYTHON(bld, name,
                  public_deps='',
                  realname=None,
                  cflags='',
+                 cflags_end=None,
                  includes='',
                  init_function_sentinel=None,
                  local_include=True,
@@ -154,6 +155,7 @@ def SAMBA_PYTHON(bld, name,
                       public_deps=public_deps,
                       includes=includes,
                       cflags=cflags,
+                      cflags_end=cflags_end,
                       local_include=local_include,
                       vars=vars,
                       realname=realname,
-- 
2.11.0


From 2443ae38463ed9bfb67e282b24dbc02436290cee Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 11:33:03 +0000
Subject: [PATCH 08/24] build: detect availability of -Wno-unused-function

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/replace/wscript | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index 7436a90c003..2f94d4937d3 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -84,6 +84,9 @@ def configure(conf):
     if conf.CHECK_CFLAGS('-Wno-format-truncation'):
         conf.define('HAVE_WNO_FORMAT_TRUNCATION', '1')
 
+    if conf.CHECK_CFLAGS('-Wno-unused-function'):
+        conf.define('HAVE_WNO_UNUSED_FUNCTION', '1')
+
     # Check for process set name support
     conf.CHECK_CODE('''
                     #include <sys/prctl.h>
-- 
2.11.0


From ee4a3dc0310d21177b08fb45ec0ab00b74330edf Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 11:34:01 +0000
Subject: [PATCH 09/24] librpc-build: ignore unused functions in generated code

Some pidl-generated code includes static functions that are
to be optimized-away by the compiler if not used. When
running picky developer with clang that breaks the build. This
change ignores this warning for the pidl-generated python binding
files.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/librpc/wscript_build | 109 +++++++++++++++++++++++++++++--------------
 1 file changed, 74 insertions(+), 35 deletions(-)

diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index eed0551824b..ce893a217c0 100644
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -172,6 +172,10 @@ bld.SAMBA_LIBRARY('dcerpc',
 	vnum='0.0.1'
 	)
 
+gen_cflags = ''
+if bld.CONFIG_SET('HAVE_WNO_UNUSED_FUNCTION'):
+    gen_cflags = '-Wno-unused-function'
+
 for env in bld.gen_python_environments():
 	pyrpc_util = bld.pyembed_libname('pyrpc_util')
 	pytalloc_util = bld.pyembed_libname('pytalloc-util')
@@ -187,221 +191,256 @@ for env in bld.gen_python_environments():
 	bld.SAMBA_PYTHON('python_dcerpc',
 		source='rpc/pyrpc.c',
 		public_deps='LIBCLI_SMB samba-util samba-hostconfig dcerpc-samr RPC_NDR_LSA DYNCONFIG %s gensec' % pyrpc_util,
-		realname='samba/dcerpc/base.so'
+		realname='samba/dcerpc/base.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_misc',
 		source='../../librpc/gen_ndr/py_misc.c',
 		deps='%s %s ndr-krb5pac' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/misc.so'
+		realname='samba/dcerpc/misc.so',
+		cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_auth',
 		source='../../librpc/gen_ndr/py_auth.c',
 		deps='NDR_AUTH %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/auth.so'
+		realname='samba/dcerpc/auth.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_security',
 		source='../../librpc/gen_ndr/py_security.c',
 		deps='%s %s NDR_SECURITY' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/security.so'
+		realname='samba/dcerpc/security.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_lsa',
 		source='../../librpc/gen_ndr/py_lsa.c',
 		deps='RPC_NDR_LSA %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/lsa.so'
+		realname='samba/dcerpc/lsa.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_krb5pac',
 		source='../../librpc/gen_ndr/py_krb5pac.c',
 		deps='ndr-krb5pac %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/krb5pac.so'
+		realname='samba/dcerpc/krb5pac.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_netlogon',
 		source='../../librpc/gen_ndr/py_netlogon.c',
 		deps='RPC_NDR_NETLOGON %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/netlogon.so'
+		realname='samba/dcerpc/netlogon.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_samr',
 		source='../../librpc/gen_ndr/py_samr.c',
 		deps='dcerpc-samr %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/samr.so'
+		realname='samba/dcerpc/samr.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_nbt',
 		source='../../librpc/gen_ndr/py_nbt.c',
 		deps='ndr_nbt RPC_NDR_NBT %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/nbt.so'
+		realname='samba/dcerpc/nbt.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_drsblobs',
 		source='../../librpc/gen_ndr/py_drsblobs.c',
 		deps='%s %s NDR_SECURITY RPC_NDR_DRSBLOBS' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/drsblobs.so'
+		realname='samba/dcerpc/drsblobs.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_ntlmssp',
 		source='../../librpc/gen_ndr/py_ntlmssp.c',
 		deps='%s %s RPC_NDR_NTLMSSP' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/ntlmssp.so'
+		realname='samba/dcerpc/ntlmssp.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_srvsvc',
 	    source='../../librpc/gen_ndr/py_srvsvc.c',
 	    deps='RPC_NDR_SRVSVC pytalloc-util pyrpc_util',
-	    realname='samba/dcerpc/srvsvc.so'
+	    realname='samba/dcerpc/srvsvc.so',
+            cflags_end=gen_cflags
 	    )
 
 	bld.SAMBA_PYTHON('python_echo',
 		source='../../librpc/gen_ndr/py_echo.c',
 		deps='RPC_NDR_ECHO pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/echo.so'
+		realname='samba/dcerpc/echo.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dns',
 		source='../../librpc/gen_ndr/py_dns.c',
 		deps='NDR_DNS pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/dns.so'
+		realname='samba/dcerpc/dns.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_winreg',
 		source='../../librpc/gen_ndr/py_winreg.c',
 		deps='RPC_NDR_WINREG pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/winreg.so'
+		realname='samba/dcerpc/winreg.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_initshutdown',
 		source='../../librpc/gen_ndr/py_initshutdown.c',
 		deps='RPC_NDR_INITSHUTDOWN pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/initshutdown.so'
+		realname='samba/dcerpc/initshutdown.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_epmapper',
 		source='../../librpc/gen_ndr/py_epmapper.c',
 		deps='dcerpc pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/epmapper.so'
+		realname='samba/dcerpc/epmapper.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_mgmt',
 		source='../../librpc/gen_ndr/py_mgmt.c',
 		deps='pytalloc-util dcerpc pyrpc_util',
-		realname='samba/dcerpc/mgmt.so'
+		realname='samba/dcerpc/mgmt.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_atsvc',
 		source='../../librpc/gen_ndr/py_atsvc.c',
 		deps='RPC_NDR_ATSVC pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/atsvc.so'
+		realname='samba/dcerpc/atsvc.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_svcctl',
 		source='../../librpc/gen_ndr/py_svcctl.c',
 		deps='RPC_NDR_SVCCTL pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/svcctl.so'
+		realname='samba/dcerpc/svcctl.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_wkssvc',
 		source='../../librpc/gen_ndr/py_wkssvc.c',
 		deps='RPC_NDR_WKSSVC pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/wkssvc.so'
+		realname='samba/dcerpc/wkssvc.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_dfs',
 		source='../../librpc/gen_ndr/py_dfs.c',
 		deps='RPC_NDR_DFS pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/dfs.so'
+		realname='samba/dcerpc/dfs.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_dcerpc',
 		source='../../librpc/gen_ndr/py_dcerpc.c',
 		deps='NDR_DCERPC pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/dcerpc.so'
+		realname='samba/dcerpc/dcerpc.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_unixinfo',
 		source='../../librpc/gen_ndr/py_unixinfo.c',
 		deps='RPC_NDR_UNIXINFO pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/unixinfo.so'
+		realname='samba/dcerpc/unixinfo.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_irpc',
 		source='gen_ndr/py_irpc.c',
 		deps='RPC_NDR_IRPC %s %s' % (pytalloc_util, pyrpc_util),
-		realname='samba/dcerpc/irpc.so'
+		realname='samba/dcerpc/irpc.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_server_id',
 		source='../../librpc/gen_ndr/py_server_id.c',
 		deps='RPC_NDR_SERVER_ID pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/server_id.so'
+		realname='samba/dcerpc/server_id.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_winbind',
 		source='../../librpc/gen_ndr/py_winbind.c',
 		deps='RPC_NDR_WINBIND pytalloc-util pyrpc_util python_netlogon',
-		realname='samba/dcerpc/winbind.so'
+		realname='samba/dcerpc/winbind.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_idmap',
 		source='../../librpc/gen_ndr/py_idmap.c',
 		deps='NDR_IDMAP pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/idmap.so'
+		realname='samba/dcerpc/idmap.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_drsuapi',
 		source='../../librpc/gen_ndr/py_drsuapi.c',
 		deps='RPC_NDR_DRSUAPI pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/drsuapi.so'
+		realname='samba/dcerpc/drsuapi.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_dnsp',
 		source='../../librpc/gen_ndr/py_dnsp.c',
 		deps='pytalloc-util pyrpc_util NDR_SECURITY NDR_DNSP',
-		realname='samba/dcerpc/dnsp.so'
+		realname='samba/dcerpc/dnsp.so',
+                cflags_end=gen_cflags
 		)
 
 
 	bld.SAMBA_PYTHON('python_dcerpc_xattr',
 		source='../../librpc/gen_ndr/py_xattr.c',
 		deps='pytalloc-util pyrpc_util RPC_NDR_XATTR',
-		realname='samba/dcerpc/xattr.so'
+		realname='samba/dcerpc/xattr.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_idmap',
 		source='../../librpc/gen_ndr/py_idmap.c',
 		deps='pytalloc-util pyrpc_util RPC_NDR_XATTR',
-		realname='samba/dcerpc/idmap.so'
+		realname='samba/dcerpc/idmap.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dnsserver',
 		source='../../librpc/gen_ndr/py_dnsserver.c',
 		deps='RPC_NDR_DNSSERVER pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/dnsserver.so'
+		realname='samba/dcerpc/dnsserver.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('python_dcerpc_smb_acl',
 		source='../../librpc/gen_ndr/py_smb_acl.c',
 		deps='pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/smb_acl.so'
+		realname='samba/dcerpc/smb_acl.so',
+                cflags_end=gen_cflags
 		)
 
 	bld.SAMBA_PYTHON('dcerpc_python_messaging',
 		source='../../librpc/gen_ndr/py_messaging.c',
 		deps='pytalloc-util pyrpc_util',
-		realname='samba/dcerpc/messaging.so'
+		realname='samba/dcerpc/messaging.so',
+                cflags_end=gen_cflags
 		)
 
 if bld.PYTHON_BUILD_IS_ENABLED():
-- 
2.11.0


From e99d6404199178b19455babef3f3d5abe1cd2e21 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 13:02:56 +0000
Subject: [PATCH 10/24] ldb-samba: use ldap enum instead of ldb enum

This silences a picky compiler warning.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/ldb-samba/ldb_ildap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ldb-samba/ldb_ildap.c b/lib/ldb-samba/ldb_ildap.c
index a4e96e4f138..0cdf738e0be 100644
--- a/lib/ldb-samba/ldb_ildap.c
+++ b/lib/ldb-samba/ldb_ildap.c
@@ -476,7 +476,7 @@ static int ildb_search(struct ildb_context *ac)
 	}
 
 	if (req->op.search.scope == LDB_SCOPE_DEFAULT) {
-		msg->r.SearchRequest.scope = LDB_SCOPE_SUBTREE;
+		msg->r.SearchRequest.scope = LDAP_SEARCH_SCOPE_SUB;
 	} else {
 		msg->r.SearchRequest.scope = req->op.search.scope;
 	}
-- 
2.11.0


From beb76dfc53a4abb562e15074d0809549a792dad7 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 16:49:46 +0000
Subject: [PATCH 11/24] dns server: fix warning about enum mismatch

Fix picky developer clang warning about assignment
of an enum value to a variable of a different enum type.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/dns_server/dns_query.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index fa9272156ab..8d3f601b708 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -133,7 +133,7 @@ static WERROR add_response_rr(const char *name,
 
 	ans[ai].name = talloc_strdup(ans, name);
 	W_ERROR_HAVE_NO_MEMORY(ans[ai].name);
-	ans[ai].rr_type = rec->wType;
+	ans[ai].rr_type = (enum dns_qtype)rec->wType;
 	ans[ai].rr_class = DNS_QCLASS_IN;
 	ans[ai].ttl = rec->dwTtlSeconds;
 	ans[ai].length = UINT16_MAX;
-- 
2.11.0


From 44cb1d97b59a226c88f2521dda5c0d36f7d13ec5 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 17:13:26 +0000
Subject: [PATCH 12/24] s4-torture: fix file time checks

NTTIME is an unsigned quantity. When comparing two
of them, first calculate a signed difference, then
take absolute value.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/torture/raw/open.c    | 2 +-
 source4/torture/smb2/create.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index c3cb4841339..44b04acda9a 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -112,7 +112,7 @@ static const char *rdwr_string(enum rdwr_mode m)
 	status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
 	CHECK_STATUS(status, NT_STATUS_OK); \
 	t2 = finfo.all_info.out.field; \
-	if (abs(t-t2) > 20000) { \
+	if (llabs((int64_t)(t-t2)) > 20000) { \
 		torture_result(tctx, TORTURE_FAIL, \
 		       "(%s) wrong time for field %s  %s - %s\n", \
 		       __location__, #field, \
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
index 397c07516dd..ead56eb5c40 100644
--- a/source4/torture/smb2/create.c
+++ b/source4/torture/smb2/create.c
@@ -81,7 +81,7 @@
 	status = smb2_getinfo_file(tree, tctx, &finfo); \
 	CHECK_STATUS(status, NT_STATUS_OK); \
 	t2 = finfo.all_info.out.field; \
-	if (abs(t-t2) > 20000) { \
+	if (llabs((int64_t)(t-t2)) > 20000) { \
 		torture_result(tctx, TORTURE_FAIL, \
 			"(%s) wrong time for field %s  %s - %s\n", \
 		       __location__, #field, \
-- 
2.11.0


From 1ef1b5a18f50c856919ca85bb0de4b00786cd332 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 17:55:14 +0000
Subject: [PATCH 13/24] s4-torture: get rid of extra parentheses

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/torture/rpc/lsa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c
index deb4b2a0ba8..988d534bed3 100644
--- a/source4/torture/rpc/lsa.c
+++ b/source4/torture/rpc/lsa.c
@@ -2409,7 +2409,7 @@ static bool test_EnumTrustDom(struct dcerpc_binding_handle *b,
 
 		in_resume_handle = out_resume_handle;
 
-	} while ((NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES)));
+	} while (NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES));
 
 	return ret;
 }
@@ -2507,7 +2507,7 @@ static bool test_EnumTrustDomEx(struct dcerpc_binding_handle *b,
 
 		ret &= test_query_each_TrustDomEx(b, tctx, handle, &domains_ex);
 
-	} while ((NT_STATUS_EQUAL(r_ex.out.result, STATUS_MORE_ENTRIES)));
+	} while (NT_STATUS_EQUAL(r_ex.out.result, STATUS_MORE_ENTRIES));
 
 	return ret;
 }
-- 
2.11.0


From b0dbc971437a1d31f93129432c196f77bca58d04 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 17:56:50 +0000
Subject: [PATCH 14/24] s4-lib-policy: fix type of enum

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/lib/policy/gp_filesys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/lib/policy/gp_filesys.c b/source4/lib/policy/gp_filesys.c
index a18c51341d9..d48fc9fd6b0 100644
--- a/source4/lib/policy/gp_filesys.c
+++ b/source4/lib/policy/gp_filesys.c
@@ -644,7 +644,7 @@ NTSTATUS gp_set_gpt_security_descriptor(struct gp_context *gp_ctx,
 	}
 
 	/* Set the security descriptor on the directory */
-	fileinfo.generic.level = RAW_FILEINFO_SEC_DESC;
+	fileinfo.generic.level = RAW_SFILEINFO_SEC_DESC;
 	fileinfo.set_secdesc.in.file.fnum = io.ntcreatex.out.file.fnum;
 	fileinfo.set_secdesc.in.secinfo_flags = SECINFO_PROTECTED_DACL |
 	                                        SECINFO_OWNER |
-- 
2.11.0


From 3621abf2829402d1a4799e5969eab110d638c3e6 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 16:51:30 +0000
Subject: [PATCH 15/24] s2-rpc-server: fix enum type in assignment

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source4/rpc_server/srvsvc/dcesrv_srvsvc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
index 71f0ac46175..4dd3e977b68 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -2101,7 +2101,7 @@ static WERROR dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state *dce_cal
 	io = talloc(mem_ctx, union smb_setfileinfo);
 	W_ERROR_HAVE_NO_MEMORY(io);
 
-	io->set_secdesc.level			= RAW_FILEINFO_SEC_DESC;
+	io->set_secdesc.level			= RAW_SFILEINFO_SEC_DESC;
 	io->set_secdesc.in.file.path		= r->in.file;
 	io->set_secdesc.in.secinfo_flags	= r->in.securityinformation;
 	io->set_secdesc.in.sd			= r->in.sd_buf->sd;
-- 
2.11.0


From 6ad84bc5556fa7ad8d687c11dee9e3b941501d6e Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 17:57:29 +0000
Subject: [PATCH 16/24] s3-rpc-server: fix type of enum in lsa server

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/rpc_server/lsa/srv_lsa_nt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/rpc_server/lsa/srv_lsa_nt.c b/source3/rpc_server/lsa/srv_lsa_nt.c
index 2d0d29e5f35..3cc87ad9081 100644
--- a/source3/rpc_server/lsa/srv_lsa_nt.c
+++ b/source3/rpc_server/lsa/srv_lsa_nt.c
@@ -4157,7 +4157,7 @@ static NTSTATUS make_ft_info(TALLOC_CTX *mem_ctx,
 
 		rec->flags = lrec->flags;
 		rec->timestamp = lrec->time;
-		rec->type = lrec->type;
+		rec->type = (enum ForestTrustInfoRecordType)lrec->type;
 
 		switch (lrec->type) {
 		case LSA_FOREST_TRUST_TOP_LEVEL_NAME:
@@ -4412,7 +4412,7 @@ static NTSTATUS own_ft_info(struct pdb_domain_info *dom_info,
 
 	rec->flags = 0;
 	rec->timestamp = 0;
-	rec->type = LSA_FOREST_TRUST_TOP_LEVEL_NAME;
+	rec->type = FOREST_TRUST_TOP_LEVEL_NAME;
 
 	rec->data.name.string = talloc_strdup(fti, dom_info->dns_forest);
 	if (!rec->data.name.string) {
@@ -4425,7 +4425,7 @@ static NTSTATUS own_ft_info(struct pdb_domain_info *dom_info,
 
 	rec->flags = 0;
 	rec->timestamp = 0;
-	rec->type = LSA_FOREST_TRUST_DOMAIN_INFO;
+	rec->type = FOREST_TRUST_DOMAIN_INFO;
 
         info = &rec->data.info;
 
-- 
2.11.0


From 88d327a0230898e783fc31f9b787c90aecec4700 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 18:34:58 +0000
Subject: [PATCH 17/24] smbspool_krb5_wrapper: fix some error messages

Make cups_smb_debug declaration printf-aware to
avoid picky warning about printf with variable
format string. This in turn revealed some formatting
errors.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/client/smbspool_krb5_wrapper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/source3/client/smbspool_krb5_wrapper.c b/source3/client/smbspool_krb5_wrapper.c
index 9a82b2a7b69..dee3b4c54be 100644
--- a/source3/client/smbspool_krb5_wrapper.c
+++ b/source3/client/smbspool_krb5_wrapper.c
@@ -37,7 +37,8 @@ enum cups_smb_dbglvl_e {
 	CUPS_SMB_LOG_DEBUG = 0,
 	CUPS_SMB_LOG_ERROR,
 };
-static void cups_smb_debug(enum cups_smb_dbglvl_e lvl, const char *format, ...);
+static void cups_smb_debug(enum cups_smb_dbglvl_e lvl, const char *format, ...)
+		PRINTF_ATTRIBUTE(2, 3);
 
 #define CUPS_SMB_DEBUG(...) cups_smb_debug(CUPS_SMB_LOG_DEBUG, __VA_ARGS__)
 #define CUPS_SMB_ERROR(...) cups_smb_debug(CUPS_SMB_LOG_DEBUG, __VA_ARGS__)
@@ -166,7 +167,7 @@ int main(int argc, char *argv[])
 	CUPS_SMB_DEBUG("Switching to gid=%d", gid);
 	rc = setgid(gid);
 	if (rc != 0) {
-		CUPS_SMB_ERROR("Failed to switch to gid=%u",
+		CUPS_SMB_ERROR("Failed to switch to gid=%u - %s",
 			       gid,
 			       strerror(errno));
 		return CUPS_BACKEND_FAILED;
@@ -175,7 +176,7 @@ int main(int argc, char *argv[])
 	CUPS_SMB_DEBUG("Switching to uid=%u", uid);
 	rc = setuid(uid);
 	if (rc != 0) {
-		CUPS_SMB_ERROR("Failed to switch to uid=%u",
+		CUPS_SMB_ERROR("Failed to switch to uid=%u - %s",
 			       uid,
 			       strerror(errno));
 		return CUPS_BACKEND_FAILED;
-- 
2.11.0


From ecea8eeaf03687d9f9e235861fb2673574adff5a Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 18:37:49 +0000
Subject: [PATCH 18/24] s3-torture: fix some truncation warnings

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/torture/torture.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 481154fc36f..f98783e46e2 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3214,7 +3214,7 @@ static bool run_attrtest(int dummy)
 		correct = False;
 	}
 
-	if (abs(t - time(NULL)) > 60*60*24*10) {
+	if (labs(t - time(NULL)) > 60*60*24*10) {
 		printf("ERROR: SMBgetatr bug. time is %s",
 		       ctime(&t));
 		t = time(NULL);
@@ -3445,13 +3445,13 @@ static bool run_trans2test(int dummy)
 			printf("modify time=%s", ctime(&m_time));
 			printf("This system appears to have sticky create times\n");
 		}
-		if ((abs(a_time - t) > 60) && (a_time % (60*60) == 0)) {
+		if ((labs(a_time - t) > 60) && (a_time % (60*60) == 0)) {
 			printf("access time=%s", ctime(&a_time));
 			printf("This system appears to set a midnight access time\n");
 			correct = False;
 		}
 
-		if (abs(m_time - t) > 60*60*24*7) {
+		if (labs(m_time - t) > 60*60*24*7) {
 			printf("ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time));
 			correct = False;
 		}
-- 
2.11.0


From 52da81a65808ae230906c02d368256a96def7f0a Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 18:38:28 +0000
Subject: [PATCH 19/24] s3-torture: fix an always-true comparison

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/torture/torture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index f98783e46e2..f3da67c95dc 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5219,7 +5219,7 @@ static bool run_rename_access(int dummy)
 	}
 
 	if (cli) {
-		if (fnum != (uint64_t)-1) {
+		if (fnum != (uint16_t)-1) {
 			cli_close(cli, fnum);
 		}
 		cli_unlink(cli, src,
-- 
2.11.0


From e5c6cb3c51ba3189e87df43d1c7220d78cf6808c Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Mon, 20 Nov 2017 10:17:16 +0200
Subject: [PATCH 20/24] build: disable format-zero-length warning

format-zero-length warns against printf-style calls with
zero-length format string. vfs_full_audit module has such
calls, and up until now there was no warning against it because
the do_log in vfs_full_audit is not recognized as printf-style
function. In a following commit the do_log will be converted to
a printf-style function, hence the need to disable this warning.

(an alternative would be to disable only for vfs_full_audit, but that
would complicate things needlessly).

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 795d13075cf..4c0400a625d 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -708,6 +708,7 @@ def SAMBA_CONFIG_H(conf, path=None):
                         testflags=True)
 
         conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
+        conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
         conf.ADD_CFLAGS('-Werror=format-security -Wformat-security', testflags=True)
         # This check is because for ldb_search(), a NULL format string
         # is not an error, but some compilers complain about that.
-- 
2.11.0


From a6613c5d8898706a106d3deec463a600c8e461e5 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 13:04:58 +0000
Subject: [PATCH 21/24] pam_wrapper: #ifdef-out unused functions

When pam_vsyslog is not available, avoid building functions
that are being used to wrap it, in order to avoid picky
compiler warnings.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/pam_wrapper/pam_wrapper.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/pam_wrapper/pam_wrapper.c b/lib/pam_wrapper/pam_wrapper.c
index 4be81460a5b..03584beb95e 100644
--- a/lib/pam_wrapper/pam_wrapper.c
+++ b/lib/pam_wrapper/pam_wrapper.c
@@ -508,6 +508,7 @@ static const char *libpam_pam_strerror(pam_handle_t *pamh, int errnum)
 	return pwrap.libpam.symbols._libpam_pam_strerror.f(discard_const_p(pam_handle_t, pamh), errnum);
 }
 
+#if defined(HAVE_PAM_VSYSLOG) || defined(HAVE_PAM_SYSLOG)
 static void libpam_pam_vsyslog(const pam_handle_t *pamh,
 			       int priority,
 			       const char *fmt,
@@ -522,6 +523,7 @@ static void libpam_pam_vsyslog(const pam_handle_t *pamh,
 						   args);
 #endif
 }
+#endif
 
 /*********************************************************
  * PWRAP INIT
@@ -1487,6 +1489,8 @@ const char *pam_strerror(pam_handle_t *pamh, int errnum)
 				  errnum);
 }
 
+#if defined(HAVE_PAM_VSYSLOG) || defined(HAVE_PAM_SYSLOG)
+
 static void pwrap_pam_vsyslog(const pam_handle_t *pamh,
 			      int priority,
 			      const char *fmt,
@@ -1533,6 +1537,7 @@ static void pwrap_pam_vsyslog(const pam_handle_t *pamh,
 
 	pwrap_vlog(dbglvl, syslog_str, fmt, args);
 }
+#endif /* defined(HAVE_PAM_VSYSLOG) || defined(HAVE_PAM_SYSLOG) */
 
 #ifdef HAVE_PAM_VSYSLOG
 void pam_vsyslog(const pam_handle_t *pamh,
-- 
2.11.0


From 391b6c412d0c04268025f0d387556a4d950cf5af Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Tue, 21 Nov 2017 20:53:30 +0200
Subject: [PATCH 22/24] build: allow specifying prerequisite flags when
 checking flags

In gcc, "-Wformat-security" is ignored unless "-Wformat" is also
specified. This patch allow adding a "prerequisite flag" to a flag
we're testing during configuration.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 4c0400a625d..682edf4215f 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -770,14 +770,15 @@ def CONFIG_PATH(conf, name, default):
             conf.env[name] = conf.env['PREFIX'] + default
 
 @conf
-def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
+def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False, prereq_flags=[]):
     '''add some CFLAGS to the command line
        optionally set testflags to ensure all the flags work
     '''
+    prereq_flags = TO_LIST(prereq_flags)
     if testflags:
         ok_flags=[]
         for f in flags.split():
-            if CHECK_CFLAGS(conf, f):
+            if CHECK_CFLAGS(conf, [f] + prereq_flags):
                 ok_flags.append(f)
         flags = ok_flags
     if not name in conf.env:
@@ -785,11 +786,12 @@ def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
     conf.env[name].extend(TO_LIST(flags))
 
 @conf
-def ADD_CFLAGS(conf, flags, testflags=False):
+def ADD_CFLAGS(conf, flags, testflags=False, prereq_flags=[]):
     '''add some CFLAGS to the command line
        optionally set testflags to ensure all the flags work
     '''
-    ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags)
+    ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags,
+                     prereq_flags=prereq_flags)
 
 @conf
 def ADD_LDFLAGS(conf, flags, testflags=False):
-- 
2.11.0


From 9fc519f91797d2f48970b7f07510c1ab4b985d9f Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Tue, 21 Nov 2017 20:55:16 +0200
Subject: [PATCH 23/24] build: specify -Wformat as a prerequisite of
 -Wformat-security

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 682edf4215f..e157b20de2c 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -709,7 +709,8 @@ def SAMBA_CONFIG_H(conf, path=None):
 
         conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
         conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
-        conf.ADD_CFLAGS('-Werror=format-security -Wformat-security', testflags=True)
+        conf.ADD_CFLAGS('-Werror=format-security -Wformat-security',
+                        testflags=True, prereq_flags='-Wformat')
         # This check is because for ldb_search(), a NULL format string
         # is not an error, but some compilers complain about that.
         if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], '''
-- 
2.11.0


From 67ac942b023999fe7f7d55d9b6816f57c2de97de Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Mon, 20 Nov 2017 20:53:12 +0000
Subject: [PATCH 24/24] build: ensure compiler flags are properly detected

While checking for compiler flag availability, treat warnings
as errors. Thus if the compiler only warns about unsupported flag,
it will fail the test and the flag shall be marked as unsupported.

Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index e157b20de2c..7940a7d4fe8 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -473,10 +473,13 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
 def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
     '''check if the given cflags are accepted by the compiler
     '''
+    check_cflags = TO_LIST(cflags)
+    if 'WERROR_CFLAGS' in conf.env:
+        check_cflags.extend(conf.env['WERROR_CFLAGS'])
     return conf.check(fragment=fragment,
                       execute=0,
                       type='nolink',
-                      ccflags=cflags,
+                      ccflags=check_cflags,
                       msg="Checking compiler accepts %s" % cflags)
 
 @conf
-- 
2.11.0



More information about the samba-technical mailing list