2007-12-10 22:30:37 +03:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-11-19 05:24:05 +03:00
Copyright ( C ) 2001 by Martin Pool < mbp @ samba . org >
2003-08-01 18:47:39 +04:00
Copyright ( C ) 2003 by Jim McDonough < jmcd @ us . ibm . com >
2007-12-10 22:30:37 +03:00
Copyright ( C ) 2007 by Jeremy Allison < jra @ samba . org >
2001-11-19 05:24:05 +03:00
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2001-11-19 05:24:05 +03:00
( at your option ) any later version .
2007-12-10 22:30:37 +03:00
2001-11-19 05:24:05 +03:00
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 .
2007-12-10 22:30:37 +03:00
2001-11-19 05:24:05 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2001-11-19 05:24:05 +03:00
*/
# include "includes.h"
/**
* @ file dynconfig . c
*
2001-11-19 05:49:53 +03:00
* @ brief Global configurations , initialized to configured defaults .
2001-11-19 05:24:05 +03:00
*
* 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 .
2001-11-19 06:35:27 +03:00
*
* @ todo Perhaps eventually these should be merged into the parameter
* table ? There ' s kind of a chicken - and - egg situation there . . .
2001-11-19 05:24:05 +03:00
* */
2007-12-10 22:30:37 +03:00
#if 0
static char const * dyn_SBINDIR = SBINDIR ;
static char const * dyn_BINDIR = BINDIR ;
static char const * dyn_SWATDIR = SWATDIR ;
# endif
# 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 ; \
}
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 ( SHLIBEXT )
DEFINE_DYN_CONFIG_PARAM ( LOCKDIR )
DEFINE_DYN_CONFIG_PARAM ( PIDDIR )
DEFINE_DYN_CONFIG_PARAM ( SMB_PASSWD_FILE )
DEFINE_DYN_CONFIG_PARAM ( PRIVATE_DIR )
#if 0
static char * dyn_CONFIGFILE ; /**< Location of smb.conf file. **/
const char * get_dyn_CONFIGFILE ( void )
{
if ( dyn_CONFIGFILE = = NULL ) {
return CONFIGFILE ;
}
return dyn_CONFIGFILE ;
}
2001-11-19 05:24:05 +03:00
2007-12-10 22:30:37 +03:00
const char * set_dyn_CONFIGFILE ( const char * newpath )
{
if ( dyn_CONFIGFILE ) {
SAFE_FREE ( dyn_CONFIGFILE ) ;
}
dyn_CONFIGFILE = SMB_STRDUP ( newpath ) ;
return dyn_CONFIGFILE ;
}
2001-11-19 05:24:05 +03:00
2001-11-19 08:49:20 +03:00
/** Log file directory. **/
2007-12-10 22:30:37 +03:00
static char * dyn_LOGFILEBASE ;
const char * get_dyn_LOGFILEBASE ( void )
{
if ( dyn_LOGFILEBASE = = NULL ) {
return LOGFILEBASE ;
}
return dyn_LOGFILEBASE ;
}
const char * set_dyn_LOGFILEBASE ( const char * newpath )
{
if ( dyn_LOGFILEBASE ) {
SAFE_FREE ( dyn_LOGFILEBASE ) ;
}
dyn_LOGFILEBASE = SMB_STRDUP ( newpath ) ;
return dyn_LOGFILEBASE ;
}
2001-11-19 06:12:10 +03:00
2001-11-19 08:49:20 +03:00
/** Statically configured LanMan hosts. **/
2007-12-10 22:30:37 +03:00
static char * dyn_LMHOSTSFILE ;
const char * get_dyn_LMHOSTSFILE ( void )
{
if ( dyn_LMHOSTSFILE = = NULL ) {
return LMHOSTSFILE ;
}
return dyn_LMHOSTSFILE ;
}
const char * set_dyn_LMHOSTSFILE ( const char * newpath )
{
if ( dyn_LMHOSTSFILE ) {
SAFE_FREE ( dyn_LMHOSTSFILE ) ;
}
dyn_LMHOSTSFILE = SMB_STRDUP ( newpath ) ;
return dyn_LMHOSTSFILE ;
}
2001-11-19 06:35:27 +03:00
2007-11-01 20:00:10 +03:00
/**
* @ brief Samba data directory .
*
* @ sa data_path ( ) to get the path to a file inside the CODEPAGEDIR .
* */
2007-12-10 22:30:37 +03:00
static char * dyn_CODEPAGEDIR ;
const char * get_dyn_CODEPAGEDIR ( void )
{
if ( dyn_CODEPAGEDIR = = NULL ) {
return CODEPAGEDIR ;
}
return dyn_CODEPAGEDIR ;
}
const char * set_dyn_CODEPAGEDIR ( const char * newpath )
{
if ( dyn_CODEPAGEDIR ) {
SAFE_FREE ( dyn_CODEPAGEDIR ) ;
}
dyn_CODEPAGEDIR = SMB_STRDUP ( newpath ) ;
return dyn_CODEPAGEDIR ;
}
2007-11-01 20:00:10 +03:00
2001-11-19 06:35:27 +03:00
/**
* @ brief Samba library directory .
*
* @ sa lib_path ( ) to get the path to a file inside the LIBDIR .
* */
2007-12-10 22:30:37 +03:00
static char * dyn_LIBDIR ;
const char * get_dyn_LIBDIR ( void )
{
if ( dyn_LIBDIR = = NULL ) {
return LIBDIR ;
}
return dyn_CODEPAGEDIR ;
}
const char * set_dyn_LIBDIR ( const char * newpath )
{
if ( dyn_LIBDIR ) {
SAFE_FREE ( dyn_LIBDIR ) ;
}
dyn_LIBDIR = SMB_STRDUP ( newpath ) ;
return dyn_LIBDIR ;
}
static char * dyn_SHLIBEXT ;
const char * get_dyn_SHLIBEXT ( void )
{
if ( dyn_SHLIBEXT = = NULL ) {
return SHLIBEXT ;
}
return dyn_SHLIBEXT ;
}
const char * set_dyn_SHLIBEXT ( const char * newpath )
{
if ( dyn_SHLIBEXT ) {
SAFE_FREE ( dyn_SHLIBEXT ) ;
}
dyn_SHLIBEXT = SMB_STRDUP ( newpath ) ;
return dyn_SHLIBEXT ;
}
2001-11-19 06:35:27 +03:00
/**
* @ brief Directory holding lock files .
*
* Not writable , but used to set a default in the parameter table .
* */
2001-11-19 08:49:20 +03:00
2007-12-10 22:30:37 +03:00
static char * dyn_LOCKDIR ;
const char * get_dyn_LOCKDIR ( void )
{
if ( dyn_LOCKDIR = = NULL ) {
return LOCKDIR ;
}
return dyn_LOCKDIR ;
}
const char * set_dyn_LOCKDIR ( const char * newpath )
{
if ( dyn_LOCKDIR ) {
SAFE_FREE ( dyn_LOCKDIR ) ;
}
dyn_LOCKDIR = SMB_STRDUP ( newpath ) ;
return dyn_LOCKDIR ;
}
static char * dyn_PIDDIR ;
const char * get_dyn_PIDDIR ( void )
{
if ( dyn_PIDDIR = = NULL ) {
return PIDDIR ;
}
return dyn_PIDDIR ;
}
2007-11-01 20:00:10 +03:00
2007-12-10 22:30:37 +03:00
const char * set_dyn_PIDDIR ( const char * newpath )
{
if ( dyn_PIDDIR ) {
SAFE_FREE ( dyn_PIDDIR ) ;
}
dyn_PIDDIR = SMB_STRDUP ( newpath ) ;
return dyn_PIDDIR ;
}
static char * dyn_SMB_PASSWD_FILE ;
const char * get_dyn_SMB_PASSWD_FILE ( void )
{
if ( dyn_SMB_PASSWD_FILE = = NULL ) {
return SMB_PASSWD_FILE ;
}
return dyn_SMB_PASSWD_FILE ;
}
const char * set_dyn_SMB_PASSWD_FILE ( const char * newpath )
{
if ( dyn_SMB_PASSWD_FILE ) {
SAFE_FREE ( dyn_SMB_PASSWD_FILE ) ;
}
dyn_SMB_PASSWD_FILE = SMB_STRDUP ( newpath ) ;
return dyn_SMB_PASSWD_FILE ;
}
static char * dyn_PRIVATE_DIR ;
const char * get_dyn_PRIVATE_DIR ( void )
{
if ( dyn_PRIVATE_DIR = = NULL ) {
return PRIVATE_DIR ;
}
return dyn_PRIVATE_DIR ;
}
const char * set_dyn_PRIVATE_DIR ( const char * newpath )
{
if ( dyn_PRIVATE_DIR ) {
SAFE_FREE ( dyn_PRIVATE_DIR ) ;
}
dyn_PRIVATE_DIR = SMB_STRDUP ( newpath ) ;
return dyn_PRIVATE_DIR ;
}
# endif
2007-11-01 20:00:10 +03:00
/* In non-FHS mode, these should be configurable using 'lock dir =';
but in FHS mode , they are their own directory . Implement as wrapper
functions so that everything can still be kept in dynconfig . c .
*/
2007-12-10 22:30:37 +03:00
const char * get_dyn_STATEDIR ( void )
2007-11-01 20:00:10 +03:00
{
# ifdef FHS_COMPATIBLE
return STATEDIR ;
# else
return lp_lockdir ( ) ;
# endif
}
2007-12-10 22:30:37 +03:00
const char * get_dyn_CACHEDIR ( void )
2007-11-01 20:00:10 +03:00
{
# ifdef FHS_COMPATIBLE
return CACHEDIR ;
# else
return lp_lockdir ( ) ;
# endif
}