From 3e85b960fae391af7a0592d5d38c18ae5a157209 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Apr 2011 16:39:42 +1000 Subject: [PATCH] dynconfig: Have only one dynconfig.o in the common code. --- {source4/dynconfig => dynconfig}/dynconfig.c | 20 ++-- {source4/dynconfig => dynconfig}/dynconfig.h | 10 +- lib/util/charset/codepoints.c | 2 +- source3/Makefile.in | 14 +-- source3/build/wscript | 2 +- source3/dynconfig.c | 86 ---------------- source3/include/dynconfig.h | 100 ------------------- source3/include/includes.h | 2 +- source3/script/mkbuildoptions-waf.awk | 2 +- source3/script/mkbuildoptions.awk | 2 +- source3/web/startstop.c | 2 +- source4/dynconfig/wscript | 2 +- 12 files changed, 32 insertions(+), 212 deletions(-) rename {source4/dynconfig => dynconfig}/dynconfig.c (94%) rename {source4/dynconfig => dynconfig}/dynconfig.h (99%) delete mode 100644 source3/dynconfig.c delete mode 100644 source3/include/dynconfig.h diff --git a/source4/dynconfig/dynconfig.c b/dynconfig/dynconfig.c similarity index 94% rename from source4/dynconfig/dynconfig.c rename to dynconfig/dynconfig.c index 65e57e0fc17..4bcdab35961 100644 --- a/source4/dynconfig/dynconfig.c +++ b/dynconfig/dynconfig.c @@ -1,24 +1,25 @@ -/* +/* Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. Copyright (C) Stefan Metzmacher 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 . */ #include "includes.h" +#include "nsswitch/winbind_struct_protocol.h" /** * @file dynconfig.c @@ -41,6 +42,9 @@ **/ #include "dynconfig.h" +#ifdef strdup +#undef strdup +#endif #define DEFINE_DYN_CONFIG_PARAM(name) \ const char *dyn_##name = name; \ @@ -99,13 +103,15 @@ DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) DEFINE_DYN_CONFIG_PARAM(LOCALEDIR) DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR) - -/* these are not in s3 */ DEFINE_DYN_CONFIG_PARAM(DATADIR) DEFINE_DYN_CONFIG_PARAM(SETUPDIR) -DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) +DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */ + +/* these are not in s3 */ +#if (_SAMBA_BUILD_ >= 4) DEFINE_DYN_CONFIG_PARAM(WINBINDD_PRIVILEGED_SOCKET_DIR) DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR) DEFINE_DYN_CONFIG_PARAM(PYTHONDIR) DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR) DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR) +#endif diff --git a/source4/dynconfig/dynconfig.h b/dynconfig/dynconfig.h similarity index 99% rename from source4/dynconfig/dynconfig.h rename to dynconfig/dynconfig.h index ee710f3de92..e53cd8ff5fa 100644 --- a/source4/dynconfig/dynconfig.h +++ b/dynconfig/dynconfig.h @@ -1,19 +1,19 @@ -/* +/* Unix SMB/CIFS implementation. Copyright (C) 2001 by Martin Pool Copyright (C) Jim McDonough (jmcd@us.ibm.com) 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 . */ diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index cd54420e8e2..5e8ac64ed4f 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -23,7 +23,7 @@ #include "includes.h" #include "lib/util/charset/charset.h" #include "system/locale.h" -#include "dynconfig.h" +#include "dynconfig/dynconfig.h" #ifdef strcasecmp #undef strcasecmp diff --git a/source3/Makefile.in b/source3/Makefile.in index baac3cdcafe..ae275f808c6 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -140,6 +140,7 @@ CONFIGDIR = @configdir@ VARDIR = @localstatedir@ MANDIR = @mandir@ DATADIR = @datadir@ +SETUPDIR = @datadir@/setup # The permissions to give the executables and other data INSTALLPERMS_BIN = 0755 @@ -210,7 +211,9 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \ -DCACHEDIR=\"$(CACHEDIR)\" \ -DSTATEDIR=\"$(STATEDIR)\" \ -DNMBDSOCKETDIR=\"$(NMBDSOCKETDIR)\" \ - -DLOCALEDIR=\"$(LOCALEDIR)\" + -DLOCALEDIR=\"$(LOCALEDIR)\" \ + -DDATADIR=\"$(DATADIR)\" \ + -DSETUPDIR=\"$(SETUPDIR)\" # Note that all executable programs now provide for an optional executable suffix. @@ -485,7 +488,7 @@ READLINE_OBJ = ../libcli/smbreadline/smbreadline.o # Be sure to include them into your application POPT_LIB_OBJ = lib/popt_common.o -PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/loadparm_server_role.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o +PARAM_WITHOUT_REG_OBJ = ../dynconfig/dynconfig.o param/loadparm.o param/loadparm_server_role.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o PARAM_REG_ADD_OBJ = $(REG_SMBCONF_OBJ) $(LIBSMBCONF_OBJ) $(PRIVILEGES_BASIC_OBJ) PARAM_OBJ = $(PARAM_WITHOUT_REG_OBJ) $(PARAM_REG_ADD_OBJ) @@ -1697,7 +1700,7 @@ BINARY_PREREQS = bin/.dummy # but since we also require "make install prefix=/opt/samba" *not* to # rebuild it's a bit hard. -dynconfig.o: dynconfig.c Makefile +../dynconfig/dynconfig.o: ../dynconfig/dynconfig.c Makefile @echo Compiling $*.c @$(COMPILE_CC_PATH) && exit 0;\ echo "The following command failed:" 1>&2;\ @@ -3302,16 +3305,13 @@ uninstallpammodules:: rm -f "$(DESTDIR)/$(PAMMODULESDIR)/$${module}.@SHLIBEXT@"; \ done -# Toplevel clean files -TOPFILES=dynconfig.o localedir.o - cleanlibs:: -rm -f ../lib/*/*.o ../lib/*/*/*.o \ ../lib/*/*.ho \ ../libcli/*.o ../libcli/*/*.o ../libcli/*/*/*.o \ ../librpc/*/*.o \ ../libgpo/*.o ../libgpo/*/*.o \ - ../libds/*.o ../libds/*/*.o + ../libds/*.o ../libds/*/*.o ../dynconfig/*.o clean:: cleanlibs -rm -f include/build_env.h diff --git a/source3/build/wscript b/source3/build/wscript index d370daf8996..b9c6bd264c8 100644 --- a/source3/build/wscript +++ b/source3/build/wscript @@ -42,7 +42,7 @@ def configure(conf): def build(bld): cflags = dynconfig_cflags(bld) bld.SAMBA3_SUBSYSTEM('DYNCONFIG', - '../dynconfig.c', + '../../dynconfig/dynconfig.c', deps='replace talloc tdb popt', cflags=cflags) diff --git a/source3/dynconfig.c b/source3/dynconfig.c deleted file mode 100644 index 32f64a6e22c..00000000000 --- a/source3/dynconfig.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Copyright (C) 2001 by Martin Pool - Copyright (C) 2003 by Jim McDonough - Copyright (C) 2007 by Jeremy Allison - - 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 . -*/ - -#include "includes.h" - -/** - * @file dynconfig.c - * - * @brief Global configurations, initialized to configured defaults. - * - * This file should be the only file that depends on path - * configuration (--prefix, etc), so that if ./configure is re-run, - * all programs will be appropriately updated. Everything else in - * Samba should import extern variables from here, rather than relying - * on preprocessor macros. - * - * Eventually some of these may become even more variable, so that - * they can for example consistently be set across the whole of Samba - * by command-line parameters, config file entries, or environment - * variables. - * - * @todo Perhaps eventually these should be merged into the parameter - * table? There's kind of a chicken-and-egg situation there... - **/ - -#define DEFINE_DYN_CONFIG_PARAM(name) \ -static char *dyn_##name; \ -\ - const char *get_dyn_##name(void) \ -{\ - if (dyn_##name == NULL) {\ - return name;\ - }\ - return dyn_##name;\ -}\ -\ - const char *set_dyn_##name(const char *newpath) \ -{\ - if (dyn_##name) {\ - SAFE_FREE(dyn_##name);\ - }\ - dyn_##name = SMB_STRDUP(newpath);\ - return dyn_##name;\ -}\ -\ - bool is_default_dyn_##name(void) \ -{\ - return (dyn_##name == NULL);\ -} - -DEFINE_DYN_CONFIG_PARAM(SBINDIR) -DEFINE_DYN_CONFIG_PARAM(BINDIR) -DEFINE_DYN_CONFIG_PARAM(SWATDIR) -DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/ -DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/ -DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/ -DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR) -DEFINE_DYN_CONFIG_PARAM(LIBDIR) -DEFINE_DYN_CONFIG_PARAM(MODULESDIR) -DEFINE_DYN_CONFIG_PARAM(SHLIBEXT) -DEFINE_DYN_CONFIG_PARAM(LOCKDIR) -DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */ -DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */ -DEFINE_DYN_CONFIG_PARAM(PIDDIR) -DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR) -DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR) -DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) -DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) -DEFINE_DYN_CONFIG_PARAM(LOCALEDIR) diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h deleted file mode 100644 index d0e42dc9f51..00000000000 --- a/source3/include/dynconfig.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Copyright (C) 2001 by Martin Pool - Copyright (C) 2003 by Jim McDonough - - 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 . -*/ - -/** - * @file dynconfig.h - * - * @brief Exported global configurations. - **/ - -const char *get_dyn_SBINDIR(void); -const char *set_dyn_SBINDIR(const char *newpath); -bool is_default_dyn_SBINDIR(void); - -const char *get_dyn_BINDIR(void); -const char *set_dyn_BINDIR(const char *newpath); -bool is_default_dyn_BINDIR(void); - -const char *get_dyn_SWATDIR(void); -const char *set_dyn_SWATDIR(const char *newpath); -bool is_default_dyn_SWATDIR(void); - -const char *get_dyn_CONFIGFILE(void); -const char *set_dyn_CONFIGFILE(const char *newpath); -bool is_default_dyn_CONFIGFILE(void); - -const char *get_dyn_LOGFILEBASE(void); -const char *set_dyn_LOGFILEBASE(const char *newpath); -bool is_default_dyn_LOGFILEBASE(void); - -const char *get_dyn_LMHOSTSFILE(void); -const char *set_dyn_LMHOSTSFILE(const char *newpath); -bool is_default_dyn_LMHOSTSFILE(void); - -const char *get_dyn_CODEPAGEDIR(void); -const char *set_dyn_CODEPAGEDIR(const char *newpath); -bool is_default_dyn_CODEPAGEDIR(void); - -const char *get_dyn_LIBDIR(void); -const char *set_dyn_LIBDIR(const char *newpath); -bool is_default_dyn_LIBDIR(void); - -const char *get_dyn_MODULESDIR(void); -const char *set_dyn_MODULESDIR(const char *newpath); -bool is_default_dyn_MODULESDIR(void); - -const char *get_dyn_SHLIBEXT(void); -const char *set_dyn_SHLIBEXT(const char *newpath); -bool is_default_dyn_SHLIBEXT(void); - -const char *get_dyn_LOCKDIR(void); -const char *set_dyn_LOCKDIR(const char *newpath); -bool is_default_dyn_LOCKDIR(void); - -const char *get_dyn_STATEDIR(void); -const char *set_dyn_STATEDIR(const char *newpath); -bool is_default_dyn_STATEDIR(void); - -const char *get_dyn_CACHEDIR(void); -const char *set_dyn_CACHEDIR(const char *newpath); -bool is_default_dyn_CACHEDIR(void); - -const char *get_dyn_PIDDIR(void); -const char *set_dyn_PIDDIR(const char *newpath); -bool is_default_dyn_PIDDIR(void); - -const char *get_dyn_NMBDSOCKETDIR(void); -const char *set_dyn_NMBDSOCKETDIR(const char *newpath); -bool is_default_dyn_NMBDSOCKETDIR(void); - -const char *get_dyn_NCALRPCDIR(void); -const char *set_dyn_NCALRPCDIR(const char *newpath); -bool is_default_dyn_NCALRPCDIR(void); - -const char *get_dyn_SMB_PASSWD_FILE(void); -const char *set_dyn_SMB_PASSWD_FILE(const char *newpath); -bool is_default_dyn_SMB_PASSWD_FILE(void); - -const char *get_dyn_PRIVATE_DIR(void); -const char *set_dyn_PRIVATE_DIR(const char *newpath); -bool is_default_dyn_PRIVATE_DIR(void); - -const char *get_dyn_LOCALEDIR(void); -const char *set_dyn_LOCALEDIR(const char *newpath); -bool is_default_dyn_LOCALEDIR(void); diff --git a/source3/include/includes.h b/source3/include/includes.h index 8f220dfaec5..014d1d44bd2 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -532,7 +532,7 @@ typedef char fstring[FSTRING_LEN]; #include "libads/ads_status.h" #include "../libcli/util/error.h" #include "../lib/util/charset/charset.h" -#include "dynconfig.h" +#include "dynconfig/dynconfig.h" #include "locking.h" #include "smb_perfcount.h" #include "smb.h" diff --git a/source3/script/mkbuildoptions-waf.awk b/source3/script/mkbuildoptions-waf.awk index ddb3f6527a9..2d7063a79e6 100644 --- a/source3/script/mkbuildoptions-waf.awk +++ b/source3/script/mkbuildoptions-waf.awk @@ -21,7 +21,7 @@ BEGIN { print ""; print "#include \"includes.h\""; print "#include \"build_env.h\""; - print "#include \"dynconfig.h\""; + print "#include \"dynconfig/dynconfig.h\""; print ""; print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; print "void build_options(bool screen);"; diff --git a/source3/script/mkbuildoptions.awk b/source3/script/mkbuildoptions.awk index 1955a80b46c..3cd0dace213 100644 --- a/source3/script/mkbuildoptions.awk +++ b/source3/script/mkbuildoptions.awk @@ -21,7 +21,7 @@ BEGIN { print ""; print "#include \"includes.h\""; print "#include \"build_env.h\""; - print "#include \"dynconfig.h\""; + print "#include \"dynconfig/dynconfig.h\""; print ""; print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; print "void build_options(bool screen);"; diff --git a/source3/web/startstop.c b/source3/web/startstop.c index 81350e62f5c..e23acf89313 100644 --- a/source3/web/startstop.c +++ b/source3/web/startstop.c @@ -19,7 +19,7 @@ #include "includes.h" #include "web/swat_proto.h" -#include "dynconfig.h" +#include "dynconfig/dynconfig.h" /** Startup smbd from web interface. */ diff --git a/source4/dynconfig/wscript b/source4/dynconfig/wscript index f815e81a2d3..cc3ff45d35b 100755 --- a/source4/dynconfig/wscript +++ b/source4/dynconfig/wscript @@ -146,7 +146,7 @@ Build.BuildContext.dynconfig_cflags = dynconfig_cflags def build(bld): cflags = bld.dynconfig_cflags() bld.SAMBA_SUBSYSTEM('DYNCONFIG', - 'dynconfig.c', + '../../dynconfig/dynconfig.c', deps='replace talloc', public_headers=os_path_relpath(os.path.join(Options.launch_dir, 'version.h'), bld.curdir), header_path='samba', -- 2.34.1