smb.conf.5: sort parameters alphabetically
authorAlexander Bokovoy <ab@samba.org>
Fri, 6 Oct 2017 19:49:11 +0000 (22:49 +0300)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 14 Oct 2017 05:28:18 +0000 (07:28 +0200)
Content of each separate parameter description file is added
into a parameters.all.xml file before compiling smb.conf.5.

The issue is that POSIX file systems generally don't give any
promises over how glob-produced files are sorted. Thus, we need to sort
them in a predictable way.

This patch adds sorting based on a file name as a string. Since all
parameter files named after the parameter itself (plus .xml), we can
use file name sorting.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13081

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-By: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
docs-xml/wscript_build

index e329ad4029580bb01a828f2646a13908f7784a2b..5670572167ffbde1f29602f0864f174cc18f37da 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 from samba_utils import save_file
+import os
 manpages='''
          manpages/cifsdd.8
          manpages/dbwrap_tool.1
@@ -131,7 +132,13 @@ def smbdotconf_generate_parameter_list(task):
     save_file(parameter_all, t , create_dir=True)
     return 0
 
-articles = bld.path.ant_glob("smbdotconf/**/*.xml", flat=True)
+# Since nothing really forces sorting in glob, we have to sort by file name
+# POSIX file systems aren't required to return sorted content but we want
+# smb.conf parameters to be sorted alphabetically
+sources = bld.path.ant_glob("smbdotconf/**/*.xml", flat=False)
+articles = " ".join(sorted([x.relpath_gen(bld.path) for x in sources],
+                           key=lambda m: m.split(os.sep)[-1]))
+
 parameter_all = 'smbdotconf/parameters.all.xml'
 bld.SAMBA_GENERATOR(parameter_all,
                     source=articles,