smbd: fix the handling of create_options to pass RAW-OPEN
[Samba.git] / source / dynconfig.c
blob57008ece44825a25b8f96c148749cf15aadbc4a5
1 /*
2 Unix SMB/CIFS implementation.
3 Copyright (C) 2001 by Martin Pool <mbp@samba.org>
4 Copyright (C) 2003 by Jim McDonough <jmcd@us.ibm.com>
5 Copyright (C) 2007 by Jeremy Allison <jra@samba.org>
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"
23 /**
24 * @file dynconfig.c
26 * @brief Global configurations, initialized to configured defaults.
28 * This file should be the only file that depends on path
29 * configuration (--prefix, etc), so that if ./configure is re-run,
30 * all programs will be appropriately updated. Everything else in
31 * Samba should import extern variables from here, rather than relying
32 * on preprocessor macros.
34 * Eventually some of these may become even more variable, so that
35 * they can for example consistently be set across the whole of Samba
36 * by command-line parameters, config file entries, or environment
37 * variables.
39 * @todo Perhaps eventually these should be merged into the parameter
40 * table? There's kind of a chicken-and-egg situation there...
41 **/
43 #if 0
44 static char const *dyn_SBINDIR = SBINDIR;
45 static char const *dyn_BINDIR = BINDIR;
46 static char const *dyn_SWATDIR = SWATDIR;
47 #endif
49 #define DEFINE_DYN_CONFIG_PARAM(name) \
50 static char *dyn_##name; \
52 const char *get_dyn_##name(void) \
54 if (dyn_##name == NULL) {\
55 return name;\
57 return dyn_##name;\
60 const char *set_dyn_##name(const char *newpath) \
62 if (dyn_##name) {\
63 SAFE_FREE(dyn_##name);\
65 dyn_##name = SMB_STRDUP(newpath);\
66 return dyn_##name;\
69 bool is_default_dyn_##name(void) \
71 return (dyn_##name == NULL);\
74 DEFINE_DYN_CONFIG_PARAM(SBINDIR)
75 DEFINE_DYN_CONFIG_PARAM(BINDIR)
76 DEFINE_DYN_CONFIG_PARAM(SWATDIR)
77 DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
78 DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
79 DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
80 DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
81 DEFINE_DYN_CONFIG_PARAM(LIBDIR)
82 DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
83 DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
84 DEFINE_DYN_CONFIG_PARAM(PIDDIR)
85 DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
86 DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
88 #if 0
89 static char *dyn_CONFIGFILE; /**< Location of smb.conf file. **/
91 const char *get_dyn_CONFIGFILE(void)
93 if (dyn_CONFIGFILE == NULL) {
94 return CONFIGFILE;
96 return dyn_CONFIGFILE;
99 const char *set_dyn_CONFIGFILE(const char *newpath)
101 if (dyn_CONFIGFILE) {
102 SAFE_FREE(dyn_CONFIGFILE);
104 dyn_CONFIGFILE = SMB_STRDUP(newpath);
105 return dyn_CONFIGFILE;
108 /** Log file directory. **/
109 static char *dyn_LOGFILEBASE;
111 const char *get_dyn_LOGFILEBASE(void)
113 if (dyn_LOGFILEBASE == NULL) {
114 return LOGFILEBASE;
116 return dyn_LOGFILEBASE;
119 const char *set_dyn_LOGFILEBASE(const char *newpath)
121 if (dyn_LOGFILEBASE) {
122 SAFE_FREE(dyn_LOGFILEBASE);
124 dyn_LOGFILEBASE = SMB_STRDUP(newpath);
125 return dyn_LOGFILEBASE;
128 /** Statically configured LanMan hosts. **/
129 static char *dyn_LMHOSTSFILE;
131 const char *get_dyn_LMHOSTSFILE(void)
133 if (dyn_LMHOSTSFILE == NULL) {
134 return LMHOSTSFILE;
136 return dyn_LMHOSTSFILE;
139 const char *set_dyn_LMHOSTSFILE(const char *newpath)
141 if (dyn_LMHOSTSFILE) {
142 SAFE_FREE(dyn_LMHOSTSFILE);
144 dyn_LMHOSTSFILE = SMB_STRDUP(newpath);
145 return dyn_LMHOSTSFILE;
149 * @brief Samba data directory.
151 * @sa data_path() to get the path to a file inside the CODEPAGEDIR.
153 static char *dyn_CODEPAGEDIR;
155 const char *get_dyn_CODEPAGEDIR(void)
157 if (dyn_CODEPAGEDIR == NULL) {
158 return CODEPAGEDIR;
160 return dyn_CODEPAGEDIR;
163 const char *set_dyn_CODEPAGEDIR(const char *newpath)
165 if (dyn_CODEPAGEDIR) {
166 SAFE_FREE(dyn_CODEPAGEDIR);
168 dyn_CODEPAGEDIR = SMB_STRDUP(newpath);
169 return dyn_CODEPAGEDIR;
173 * @brief Samba library directory.
175 * @sa lib_path() to get the path to a file inside the LIBDIR.
177 static char *dyn_LIBDIR;
179 const char *get_dyn_LIBDIR(void)
181 if (dyn_LIBDIR == NULL) {
182 return LIBDIR;
184 return dyn_CODEPAGEDIR;
187 const char *set_dyn_LIBDIR(const char *newpath)
189 if (dyn_LIBDIR) {
190 SAFE_FREE(dyn_LIBDIR);
192 dyn_LIBDIR = SMB_STRDUP(newpath);
193 return dyn_LIBDIR;
196 static char *dyn_SHLIBEXT;
198 const char *get_dyn_SHLIBEXT(void)
200 if (dyn_SHLIBEXT == NULL) {
201 return SHLIBEXT;
203 return dyn_SHLIBEXT;
206 const char *set_dyn_SHLIBEXT(const char *newpath)
208 if (dyn_SHLIBEXT) {
209 SAFE_FREE(dyn_SHLIBEXT);
211 dyn_SHLIBEXT = SMB_STRDUP(newpath);
212 return dyn_SHLIBEXT;
216 * @brief Directory holding lock files.
218 * Not writable, but used to set a default in the parameter table.
221 static char *dyn_LOCKDIR;
223 const char *get_dyn_LOCKDIR(void)
225 if (dyn_LOCKDIR == NULL) {
226 return LOCKDIR;
228 return dyn_LOCKDIR;
231 const char *set_dyn_LOCKDIR(const char *newpath)
233 if (dyn_LOCKDIR) {
234 SAFE_FREE(dyn_LOCKDIR);
236 dyn_LOCKDIR = SMB_STRDUP(newpath);
237 return dyn_LOCKDIR;
240 static char *dyn_PIDDIR;
242 const char *get_dyn_PIDDIR(void)
244 if (dyn_PIDDIR == NULL) {
245 return PIDDIR;
247 return dyn_PIDDIR;
250 const char *set_dyn_PIDDIR(const char *newpath)
252 if (dyn_PIDDIR) {
253 SAFE_FREE(dyn_PIDDIR);
255 dyn_PIDDIR = SMB_STRDUP(newpath);
256 return dyn_PIDDIR;
259 static char *dyn_SMB_PASSWD_FILE;
261 const char *get_dyn_SMB_PASSWD_FILE(void)
263 if (dyn_SMB_PASSWD_FILE == NULL) {
264 return SMB_PASSWD_FILE;
266 return dyn_SMB_PASSWD_FILE;
269 const char *set_dyn_SMB_PASSWD_FILE(const char *newpath)
271 if (dyn_SMB_PASSWD_FILE) {
272 SAFE_FREE(dyn_SMB_PASSWD_FILE);
274 dyn_SMB_PASSWD_FILE = SMB_STRDUP(newpath);
275 return dyn_SMB_PASSWD_FILE;
278 static char *dyn_PRIVATE_DIR;
280 const char *get_dyn_PRIVATE_DIR(void)
282 if (dyn_PRIVATE_DIR == NULL) {
283 return PRIVATE_DIR;
285 return dyn_PRIVATE_DIR;
288 const char *set_dyn_PRIVATE_DIR(const char *newpath)
290 if (dyn_PRIVATE_DIR) {
291 SAFE_FREE(dyn_PRIVATE_DIR);
293 dyn_PRIVATE_DIR = SMB_STRDUP(newpath);
294 return dyn_PRIVATE_DIR;
296 #endif
298 /* In non-FHS mode, these should be configurable using 'lock dir =';
299 but in FHS mode, they are their own directory. Implement as wrapper
300 functions so that everything can still be kept in dynconfig.c.
303 const char *get_dyn_STATEDIR(void)
305 #ifdef FHS_COMPATIBLE
306 return STATEDIR;
307 #else
308 return lp_lockdir();
309 #endif
312 const char *get_dyn_CACHEDIR(void)
314 #ifdef FHS_COMPATIBLE
315 return CACHEDIR;
316 #else
317 return lp_lockdir();
318 #endif