s3:winbindd: make use of samba_tevent_context_init()
[Samba/gebeck_regimport.git] / dynconfig / dynconfig.c
blob79332a226d6677e2076e8afdda8b7507da0644ee
1 /*
2 Unix SMB/CIFS implementation.
3 Copyright (C) 2001 by Martin Pool <mbp@samba.org>
4 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
5 Copyright (C) Stefan Metzmacher 2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "nsswitch/winbind_struct_protocol.h"
24 /**
25 * @file dynconfig.c
27 * @brief Global configurations, initialized to configured defaults.
29 * This file should be the only file that depends on path
30 * configuration (--prefix, etc), so that if ./configure is re-run,
31 * all programs will be appropriately updated. Everything else in
32 * Samba should import extern variables from here, rather than relying
33 * on preprocessor macros.
35 * Eventually some of these may become even more variable, so that
36 * they can for example consistently be set across the whole of Samba
37 * by command-line parameters, config file entries, or environment
38 * variables.
40 * @todo Perhaps eventually these should be merged into the parameter
41 * table? There's kind of a chicken-and-egg situation there...
42 **/
44 #include "dynconfig.h"
45 #ifdef strdup
46 #undef strdup
47 #endif
49 #define DEFINE_DYN_CONFIG_PARAM(name) \
50 const char *dyn_##name = name; \
52 bool is_default_dyn_##name(void) \
54 if (strcmp(name, dyn_##name) == 0) { \
55 return true; \
56 } \
57 return false; \
60 const char *get_dyn_##name(void) \
62 return dyn_##name;\
65 const char *set_dyn_##name(const char *newpath) \
67 if (newpath == NULL) { \
68 return NULL; \
69 } \
70 if (strcmp(name, newpath) == 0) { \
71 return dyn_##name; \
72 } \
73 newpath = strdup(newpath);\
74 if (newpath == NULL) { \
75 return NULL; \
76 } \
77 if (is_default_dyn_##name()) { \
78 /* do not free a static string */ \
79 } else if (dyn_##name) {\
80 free(discard_const(dyn_##name)); \
82 dyn_##name = newpath; \
83 return dyn_##name;\
86 /* these are in common with s3 */
87 DEFINE_DYN_CONFIG_PARAM(SBINDIR)
88 DEFINE_DYN_CONFIG_PARAM(BINDIR)
89 DEFINE_DYN_CONFIG_PARAM(SWATDIR)
90 DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
91 DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
92 DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
93 DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
94 DEFINE_DYN_CONFIG_PARAM(LIBDIR)
95 DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
96 DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
97 DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
98 DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
99 DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
100 DEFINE_DYN_CONFIG_PARAM(PIDDIR)
101 DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
102 DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
103 DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
104 DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
105 DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
106 DEFINE_DYN_CONFIG_PARAM(DATADIR)
107 DEFINE_DYN_CONFIG_PARAM(SETUPDIR)
108 DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */
110 /* these are not used in s3 */
111 #ifdef WINBINDD_PRIVILEGED_SOCKET_DIR
112 DEFINE_DYN_CONFIG_PARAM(WINBINDD_PRIVILEGED_SOCKET_DIR)
113 #endif
114 #ifdef NTP_SIGND_SOCKET_DIR
115 DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR)
116 #endif
117 #ifdef PYTHONDIR
118 DEFINE_DYN_CONFIG_PARAM(PYTHONDIR)
119 #endif
120 #ifdef PYTHONARCHDIR
121 DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR)
122 #endif
123 #ifdef SCRIPTSBINDIR
124 DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR)
125 #endif