The branch, master has been updated
       via  493fe1a4315 build: reduce printf() calls in generated 
build_options.c
       via  7a8c6c362e0 build: reduce fp.write calls for build_options.c 
generation
       via  6a463c40d75 s3:smbd: handle --build-options without parsing smb.conf
      from  da2e1047f1f WHATSNEW: Document CTDB leader and cluster lock changes

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 493fe1a4315a8da3403b18233cbcbdc4e43fb4ee
Author: David Disseldorp <dd...@samba.org>
Date:   Fri Jan 14 10:38:40 2022 +0100

    build: reduce printf() calls in generated build_options.c
    
    build_options.c is inefficient in multiple ways:
    1) it's generated via one python fp.write() call per line
    2) the generated code calls output() for each and every build option
    
    This commit addresses (2), modifying write_build_options_header() and
    write_build_options_footer(). write_build_options_section() could also
    be collapsed into a single output() call, but this may lead to oversize
    string literals, so has been left as is.
    
    I observe no change in smbd --build-options output.
    
    Signed-off-by: David Disseldorp <dd...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    
    Autobuild-User(master): David Disseldorp <dd...@samba.org>
    Autobuild-Date(master): Mon Jan 17 13:17:53 UTC 2022 on sn-devel-184

commit 7a8c6c362e0151bc1bbd9cca8e2bfb03ba8320de
Author: David Disseldorp <dd...@samba.org>
Date:   Fri Jan 14 10:38:40 2022 +0100

    build: reduce fp.write calls for build_options.c generation
    
    build_options.c is inefficient in multiple ways:
    1) it's generated via one python fp.write() call per line
    2) the generated code calls output() for each and every build option
    
    This commit reduces fp.write() calls for (1). I observe no change in the
    generated build_options.c .
    
    Signed-off-by: David Disseldorp <dd...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>

commit 6a463c40d755b75b02884f123c19cc2c2845d729
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Jan 13 15:31:33 2022 +0100

    s3:smbd: handle --build-options without parsing smb.conf
    
    The smb.conf is parsed in post mode of a popt callback. The smbd
    --build-options parameter should be handled when first encountered
    to avoid requiring smb.conf presence.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14945
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: David Disseldorp <dd...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_patterns.py | 238 +++++++++++++++++++---------------
 source3/smbd/server.c                 |   9 +-
 2 files changed, 136 insertions(+), 111 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_patterns.py 
b/buildtools/wafsamba/samba_patterns.py
index bf62ee88070..a9c5fcc4b4c 100644
--- a/buildtools/wafsamba/samba_patterns.py
+++ b/buildtools/wafsamba/samba_patterns.py
@@ -32,112 +32,142 @@ Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
 
 def write_build_options_header(fp):
     '''write preamble for build_options.c'''
-    fp.write("/*\n")
-    fp.write("   Unix SMB/CIFS implementation.\n")
-    fp.write("   Build Options for Samba Suite\n")
-    fp.write("   Copyright (C) Vance Lankhaar <vlankh...@linux.ca> 2003\n")
-    fp.write("   Copyright (C) Andrew Bartlett <abart...@samba.org> 2001\n")
-    fp.write("\n")
-    fp.write("   This program is free software; you can redistribute it and/or 
modify\n")
-    fp.write("   it under the terms of the GNU General Public License as 
published by\n")
-    fp.write("   the Free Software Foundation; either version 3 of the 
License, or\n")
-    fp.write("   (at your option) any later version.\n")
-    fp.write("\n")
-    fp.write("   This program is distributed in the hope that it will be 
useful,\n")
-    fp.write("   but WITHOUT ANY WARRANTY; without even the implied warranty 
of\n")
-    fp.write("   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See 
the\n")
-    fp.write("   GNU General Public License for more details.\n")
-    fp.write("\n")
-    fp.write("   You should have received a copy of the GNU General Public 
License\n")
-    fp.write("   along with this program; if not, see 
<http://www.gnu.org/licenses/>.\n")
-    fp.write("*/\n")
-    fp.write("\n")
-    fp.write("#include \"includes.h\"\n")
-    fp.write("#include \"dynconfig/dynconfig.h\"\n")
-    fp.write("#include \"lib/cluster_support.h\"\n")
-
-    fp.write("\n")
-    fp.write("static int output(bool screen, const char *format, ...) 
PRINTF_ATTRIBUTE(2,3);\n")
-    fp.write("void build_options(bool screen);\n")
-    fp.write("\n")
-    fp.write("\n")
-    
fp.write("/****************************************************************************\n")
-    fp.write("helper function for build_options\n")
-    
fp.write("****************************************************************************/\n")
-    fp.write("static int output(bool screen, const char *format, ...)\n")
-    fp.write("{\n")
-    fp.write("       char *ptr = NULL;\n")
-    fp.write("       int ret = 0;\n")
-    fp.write("       va_list ap;\n")
-    fp.write("       \n")
-    fp.write("       va_start(ap, format);\n")
-    fp.write("       ret = vasprintf(&ptr,format,ap);\n")
-    fp.write("       va_end(ap);\n")
-    fp.write("\n")
-    fp.write("       if (screen) {\n")
-    fp.write("              d_printf(\"%s\", ptr ? ptr : \"\");\n")
-    fp.write("       } else {\n")
-    fp.write("              DEBUG(4,(\"%s\", ptr ? ptr : \"\"));\n")
-    fp.write("       }\n")
-    fp.write("       \n")
-    fp.write("       SAFE_FREE(ptr);\n")
-    fp.write("       return ret;\n")
-    fp.write("}\n")
-    fp.write("\n")
-    
fp.write("/****************************************************************************\n")
-    fp.write("options set at build time for the samba suite\n")
-    
fp.write("****************************************************************************/\n")
-    fp.write("void build_options(bool screen)\n")
-    fp.write("{\n")
-    fp.write("       if ((DEBUGLEVEL < 4) && (!screen)) {\n")
-    fp.write("              return;\n")
-    fp.write("       }\n")
-    fp.write("\n")
-    fp.write("\n")
-    fp.write("       /* Output various paths to files and directories */\n")
-    fp.write("       output(screen,\"\\nPaths:\\n\");\n")
-    fp.write("       output(screen,\"   SBINDIR: %s\\n\", 
get_dyn_SBINDIR());\n")
-    fp.write("       output(screen,\"   BINDIR: %s\\n\", get_dyn_BINDIR());\n")
-    fp.write("       output(screen,\"   CONFIGFILE: %s\\n\", 
get_dyn_CONFIGFILE());\n")
-    fp.write("       output(screen,\"   LOGFILEBASE: %s\\n\", 
get_dyn_LOGFILEBASE());\n")
-    fp.write("       output(screen,\"   LMHOSTSFILE: 
%s\\n\",get_dyn_LMHOSTSFILE());\n")
-    fp.write("       output(screen,\"   LIBDIR: %s\\n\",get_dyn_LIBDIR());\n")
-    fp.write("       output(screen,\"   DATADIR: 
%s\\n\",get_dyn_DATADIR());\n")
-    fp.write("       output(screen,\"   SAMBA_DATADIR: 
%s\\n\",get_dyn_SAMBA_DATADIR());\n")
-    fp.write("       output(screen,\"   MODULESDIR: 
%s\\n\",get_dyn_MODULESDIR());\n")
-    fp.write("       output(screen,\"   SHLIBEXT: 
%s\\n\",get_dyn_SHLIBEXT());\n")
-    fp.write("       output(screen,\"   LOCKDIR: 
%s\\n\",get_dyn_LOCKDIR());\n")
-    fp.write("       output(screen,\"   STATEDIR: 
%s\\n\",get_dyn_STATEDIR());\n")
-    fp.write("       output(screen,\"   CACHEDIR: 
%s\\n\",get_dyn_CACHEDIR());\n")
-    fp.write("       output(screen,\"   PIDDIR: %s\\n\", get_dyn_PIDDIR());\n")
-    fp.write("       output(screen,\"   SMB_PASSWD_FILE: 
%s\\n\",get_dyn_SMB_PASSWD_FILE());\n")
-    fp.write("       output(screen,\"   PRIVATE_DIR: 
%s\\n\",get_dyn_PRIVATE_DIR());\n")
-    fp.write("       output(screen,\"   BINDDNS_DIR: 
%s\\n\",get_dyn_BINDDNS_DIR());\n")
-    fp.write("\n")
+    fp.write("/*\n"
+             "   Unix SMB/CIFS implementation.\n"
+             "   Build Options for Samba Suite\n"
+             "   Copyright (C) Vance Lankhaar <vlankh...@linux.ca> 2003\n"
+             "   Copyright (C) Andrew Bartlett <abart...@samba.org> 2001\n"
+             "\n"
+             "   This program is free software; you can redistribute it and/or 
modify\n"
+             "   it under the terms of the GNU General Public License as 
published by\n"
+             "   the Free Software Foundation; either version 3 of the 
License, or\n"
+             "   (at your option) any later version.\n"
+             "\n"
+             "   This program is distributed in the hope that it will be 
useful,\n"
+             "   but WITHOUT ANY WARRANTY; without even the implied warranty 
of\n"
+             "   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See 
the\n"
+             "   GNU General Public License for more details.\n"
+             "\n"
+             "   You should have received a copy of the GNU General Public 
License\n"
+             "   along with this program; if not, see 
<http://www.gnu.org/licenses/>.\n"
+             "*/\n"
+             "\n"
+             "#include \"includes.h\"\n"
+             "#include \"dynconfig/dynconfig.h\"\n"
+             "#include \"lib/cluster_support.h\"\n"
+
+             "\n"
+             "static int output(bool screen, const char *format, ...) 
PRINTF_ATTRIBUTE(2,3);\n"
+             "void build_options(bool screen);\n"
+             "\n"
+             "\n"
+             
"/****************************************************************************\n"
+             "helper function for build_options\n"
+             
"****************************************************************************/\n"
+             "static int output(bool screen, const char *format, ...)\n"
+             "{\n"
+             "       char *ptr = NULL;\n"
+             "       int ret = 0;\n"
+             "       va_list ap;\n"
+             "       \n"
+             "       va_start(ap, format);\n"
+             "       ret = vasprintf(&ptr,format,ap);\n"
+             "       va_end(ap);\n"
+             "\n"
+             "       if (screen) {\n"
+             "              d_printf(\"%s\", ptr ? ptr : \"\");\n"
+             "       } else {\n"
+             "              DEBUG(4,(\"%s\", ptr ? ptr : \"\"));\n"
+             "       }\n"
+             "       \n"
+             "       SAFE_FREE(ptr);\n"
+             "       return ret;\n"
+             "}\n"
+             "\n"
+             
"/****************************************************************************\n"
+             "options set at build time for the samba suite\n"
+             
"****************************************************************************/\n"
+             "void build_options(bool screen)\n"
+             "{\n"
+             "       if ((DEBUGLEVEL < 4) && (!screen)) {\n"
+             "              return;\n"
+             "       }\n"
+             "\n"
+             "\n"
+             "       /* Output various paths to files and directories */\n"
+             "       output(screen,\"\\nPaths:\\n\"\n"
+             "                     \"   SBINDIR: %s\\n\"\n"
+             "                     \"   BINDIR: %s\\n\"\n"
+             "                     \"   CONFIGFILE: %s\\n\"\n"
+             "                     \"   LOGFILEBASE: %s\\n\"\n"
+             "                     \"   LMHOSTSFILE: %s\\n\"\n"
+             "                     \"   LIBDIR: %s\\n\"\n"
+             "                     \"   DATADIR: %s\\n\"\n"
+             "                     \"   SAMBA_DATADIR: %s\\n\"\n"
+             "                     \"   MODULESDIR: %s\\n\"\n"
+             "                     \"   SHLIBEXT: %s\\n\"\n"
+             "                     \"   LOCKDIR: %s\\n\"\n"
+             "                     \"   STATEDIR: %s\\n\"\n"
+             "                     \"   CACHEDIR: %s\\n\"\n"
+             "                     \"   PIDDIR: %s\\n\"\n"
+             "                     \"   SMB_PASSWD_FILE: %s\\n\"\n"
+             "                     \"   PRIVATE_DIR: %s\\n\"\n"
+             "                     \"   BINDDNS_DIR: %s\\n\",\n"
+             "                     get_dyn_SBINDIR(),\n"
+             "                     get_dyn_BINDIR(),\n"
+             "                     get_dyn_CONFIGFILE(),\n"
+             "                     get_dyn_LOGFILEBASE(),\n"
+             "                     get_dyn_LMHOSTSFILE(),\n"
+             "                     get_dyn_LIBDIR(),\n"
+             "                     get_dyn_DATADIR(),\n"
+             "                     get_dyn_SAMBA_DATADIR(),\n"
+             "                     get_dyn_MODULESDIR(),\n"
+             "                     get_dyn_SHLIBEXT(),\n"
+             "                     get_dyn_LOCKDIR(),\n"
+             "                     get_dyn_STATEDIR(),\n"
+             "                     get_dyn_CACHEDIR(),\n"
+             "                     get_dyn_PIDDIR(),\n"
+             "                     get_dyn_SMB_PASSWD_FILE(),\n"
+             "                     get_dyn_PRIVATE_DIR(),\n"
+             "                     get_dyn_BINDDNS_DIR());\n"
+             "\n")
 
 def write_build_options_footer(fp):
-    fp.write("       /* Output the sizes of the various cluster features */\n")
-    fp.write("       output(screen, \"\\n%s\", cluster_support_features());\n")
-    fp.write("\n")
-    fp.write("       /* Output the sizes of the various types */\n")
-    fp.write("       output(screen, \"\\nType sizes:\\n\");\n")
-    fp.write("       output(screen, \"   sizeof(char):         
%lu\\n\",(unsigned long)sizeof(char));\n")
-    fp.write("       output(screen, \"   sizeof(int):          
%lu\\n\",(unsigned long)sizeof(int));\n")
-    fp.write("       output(screen, \"   sizeof(long):         
%lu\\n\",(unsigned long)sizeof(long));\n")
-    fp.write("       output(screen, \"   sizeof(long long):    
%lu\\n\",(unsigned long)sizeof(long long));\n")
-    fp.write("       output(screen, \"   sizeof(uint8_t):      
%lu\\n\",(unsigned long)sizeof(uint8_t));\n")
-    fp.write("       output(screen, \"   sizeof(uint16_t):     
%lu\\n\",(unsigned long)sizeof(uint16_t));\n")
-    fp.write("       output(screen, \"   sizeof(uint32_t):     
%lu\\n\",(unsigned long)sizeof(uint32_t));\n")
-    fp.write("       output(screen, \"   sizeof(short):        
%lu\\n\",(unsigned long)sizeof(short));\n")
-    fp.write("       output(screen, \"   sizeof(void*):        
%lu\\n\",(unsigned long)sizeof(void*));\n")
-    fp.write("       output(screen, \"   sizeof(size_t):       
%lu\\n\",(unsigned long)sizeof(size_t));\n")
-    fp.write("       output(screen, \"   sizeof(off_t):        
%lu\\n\",(unsigned long)sizeof(off_t));\n")
-    fp.write("       output(screen, \"   sizeof(ino_t):        
%lu\\n\",(unsigned long)sizeof(ino_t));\n")
-    fp.write("       output(screen, \"   sizeof(dev_t):        
%lu\\n\",(unsigned long)sizeof(dev_t));\n")
-    fp.write("\n")
-    fp.write("       output(screen, \"\\nBuiltin modules:\\n\");\n")
-    fp.write("       output(screen, \"   %s\\n\", STRING_STATIC_MODULES);\n")
-    fp.write("}\n")
+    fp.write("       /* Output the sizes of the various cluster features */\n"
+             "       output(screen, \"\\n%s\", cluster_support_features());\n"
+             "\n"
+             "       /* Output the sizes of the various types */\n"
+             "       output(screen, \"\\nType sizes:\\n\"\n"
+             "                      \"   sizeof(char):         %lu\\n\"\n"
+             "                      \"   sizeof(int):          %lu\\n\"\n"
+             "                      \"   sizeof(long):         %lu\\n\"\n"
+             "                      \"   sizeof(long long):    %lu\\n\"\n"
+             "                      \"   sizeof(uint8_t):      %lu\\n\"\n"
+             "                      \"   sizeof(uint16_t):     %lu\\n\"\n"
+             "                      \"   sizeof(uint32_t):     %lu\\n\"\n"
+             "                      \"   sizeof(short):        %lu\\n\"\n"
+             "                      \"   sizeof(void*):        %lu\\n\"\n"
+             "                      \"   sizeof(size_t):       %lu\\n\"\n"
+             "                      \"   sizeof(off_t):        %lu\\n\"\n"
+             "                      \"   sizeof(ino_t):        %lu\\n\"\n"
+             "                      \"   sizeof(dev_t):        %lu\\n\",\n"
+             "                      (unsigned long)sizeof(char),\n"
+             "                      (unsigned long)sizeof(int),\n"
+             "                      (unsigned long)sizeof(long),\n"
+             "                      (unsigned long)sizeof(long long),\n"
+             "                      (unsigned long)sizeof(uint8_t),\n"
+             "                      (unsigned long)sizeof(uint16_t),\n"
+             "                      (unsigned long)sizeof(uint32_t),\n"
+             "                      (unsigned long)sizeof(short),\n"
+             "                      (unsigned long)sizeof(void*),\n"
+             "                      (unsigned long)sizeof(size_t),\n"
+             "                      (unsigned long)sizeof(off_t),\n"
+             "                      (unsigned long)sizeof(ino_t),\n"
+             "                      (unsigned long)sizeof(dev_t));\n"
+             "\n"
+             "       output(screen, \"\\nBuiltin modules:\\n\"\n"
+             "                      \"   %s\\n\", STRING_STATIC_MODULES);\n"
+             "}\n")
 
 def write_build_options_section(fp, keys, section):
     fp.write("\n\t/* Show %s */\n" % section)
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 39aa0d91624..abb54d3ced8 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1554,7 +1554,6 @@ extern void build_options(bool screen);
        char *profile_level = NULL;
        int opt;
        poptContext pc;
-       bool print_build_options = False;
        struct server_id main_server_id = {0};
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -1657,7 +1656,8 @@ extern void build_options(bool screen);
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt)  {
                case 'b':
-                       print_build_options = True;
+                       build_options(true); /* Display output to screen as 
well as debug */
+                       exit(0);
                        break;
                default:
                        d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
@@ -1674,11 +1674,6 @@ extern void build_options(bool screen);
                log_stdout = True;
        }
 
-       if (print_build_options) {
-               build_options(True); /* Display output to screen as well as 
debug */
-               exit(0);
-       }
-
 #ifdef HAVE_SETLUID
        /* needed for SecureWare on SCO */
        setluid(0);


-- 
Samba Shared Repository

Reply via email to