/* 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 2 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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... **/ #ifdef __OS2__ /* Directory the binary was called from, same as getbindir() */ const char * getsbindir() { static pstring buffer = ""; if (!*buffer) { pstring exedir = ""; if (os2_GetExePath(exedir) != 0) { snprintf(buffer, 260, "%s", SBINDIR); } else { snprintf(buffer, 260, "%s", exedir); } } return buffer; } /* Directory the binary was called from, same as getsbindir() */ const char * getbindir() { static pstring buffer = ""; if (!*buffer) { pstring exedir = ""; if (os2_GetExePath(exedir) != 0) { snprintf(buffer, 260, "%s", BINDIR); } else { snprintf(buffer, 260, "%s", exedir); } } return buffer; } /* Directory holding the SWAT files */ const char * getswatdir() { static pstring buffer = ""; if (!*buffer) { pstring exedir = ""; if (os2_GetExePath(exedir) != 0) { snprintf(buffer, 260, "%s", SWATDIR); } else { snprintf(buffer, 260, "%s/%s", exedir,"swat"); } } return buffer; } /* Location of smb.conf file. */ const char * getconfigfile() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/smb.conf", getenv("ETC")); /* Set UNIXROOT to x:\MPTN if UNIXROOT is undefined */ if (getenv("UNIXROOT") == NULL) { static pstring unixroot = ""; strncpy(unixroot,getenv("ETC"),strlen(getenv("ETC"))-4); setenv("UNIXROOT",unixroot,0); } /* Make sure TMPIR points to a proper value */ static pstring tmpdir = ""; if (getenv("TMPDIR") == NULL && getenv("TEMP") != NULL) { strncpy(tmpdir,getenv("TEMP"),strlen(getenv("TEMP"))); setenv("TMPDIR",tmpdir,0); } if (getenv("TMPDIR") == NULL) { strncpy(tmpdir,getenv("ETC"),2); stpcpy(tmpdir,"/OS2/SYSTEM"); setenv("TMPDIR",tmpdir,0); } } return buffer; } /* Log file directory */ const char * getlogbase() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/log", getenv("ETC")); } return buffer; } /* Directory holding lock files */ const char * getlockdir() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/lock", getenv("ETC")); } return buffer; } /* Directory holding the pid files */ const char * getpiddir() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/pid", getenv("ETC")); } return buffer; } /* Directory holding the private files */ const char * getprivatedir() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/private", getenv("ETC")); } return buffer; } /* Location of smbpasswd */ const char * getsmbpasswd() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/private/smbpasswd", getenv("ETC")); } return buffer; } /* Statically configured LanMan hosts */ const char * getlmhosts() { static pstring buffer = ""; if (!*buffer) { snprintf(buffer, 260, "%s/samba/lmhosts", getenv("ETC")); } return buffer; } /** * @brief Samba library directory. * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ // SCS we try to set the libdir based on the current running process const char * getlibdir() { static pstring buffer = ""; if (!*buffer) { pstring exedir = ""; if (os2_GetExePath(exedir) != 0) { snprintf(buffer, 260, "%s", LIBDIR); } else { snprintf(buffer, 260, "%s/%s", exedir, "lib"); } } return buffer; } fstring dyn_SHLIBEXT = SHLIBEXT; #else char const *dyn_SBINDIR = SBINDIR, *dyn_BINDIR = BINDIR, *dyn_SWATDIR = SWATDIR; /**< Location of smb.conf file. **/ pstring dyn_CONFIGFILE = CONFIGFILE; /** Log file directory. **/ pstring dyn_LOGFILEBASE = LOGFILEBASE; /** Statically configured LanMan hosts. **/ pstring dyn_LMHOSTSFILE = LMHOSTSFILE; /** * @brief Samba library directory. * * @sa lib_path() to get the path to a file inside the LIBDIR. **/ pstring dyn_LIBDIR = LIBDIR; fstring dyn_SHLIBEXT = SHLIBEXT; /** * @brief Directory holding lock files. * * Not writable, but used to set a default in the parameter table. **/ pstring dyn_LOCKDIR = LOCKDIR; pstring dyn_PIDDIR = PIDDIR; pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; pstring dyn_PRIVATE_DIR = PRIVATE_DIR; #endif /* __OS2__ */