lp_load() could not be called multiple times to modify parameter settings based
on reading from multiple configuration settings. Each time, it initialized all
of the settings back to their defaults before reading the specified
configuration file.
This patch adds a parameter to lp_load() specifying whether the settings should
be initialized. It does, however, still force the settings to be initialized
the first time, even if the request was to not initialize them. (Not doing so
could wreak havoc due to uninitialized values.)
if ( override_logfile )
setup_logging( lp_logfile(), False );
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
argv[0], dyn_CONFIGFILE);
}
if ( override_logfile )
setup_logging( lp_logfile(), False );
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
argv[0], dyn_CONFIGFILE);
}
pstrcpy(username,getenv("LOGNAME"));
}
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
dyn_CONFIGFILE);
}
in_client = True; /* Make sure that we tell lp_load we are */
- if (!lp_load(dyn_CONFIGFILE, True, False, False))
+ if (!lp_load(dyn_CONFIGFILE, True, False, False, True))
{
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
return (1);
home = getenv("HOME");
if (home) {
slprintf(conf, sizeof(conf), "%s/.smb/smb.conf", home);
- if (lp_load(conf, True, False, False)) {
+ if (lp_load(conf, True, False, False, True)) {
conf_loaded = True;
} else {
DEBUG(5, ("Could not load config file: %s\n",
* defaults ...
*/
- if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
+ if (!lp_load(dyn_CONFIGFILE, True, False, False, False)) {
DEBUG(5, ("Could not load config file: %s\n",
dyn_CONFIGFILE));
} else if (home) {
*/
slprintf(conf, sizeof(conf),
"%s/.smb/smb.conf.append", home);
- if (!lp_load(conf, True, False, False)) {
+ if (!lp_load(conf, True, False, False, False)) {
DEBUG(10,
("Could not append config file: "
"%s\n",
if ( test && !lp_file_list_changed() )
return(True);
- ret = lp_load( dyn_CONFIGFILE, True , False, False);
+ ret = lp_load( dyn_CONFIGFILE, True , False, False, True);
/* perhaps the config filename is now set */
if ( !test ) {
/* Samba client initialisation */
load_case_tables();
- if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
+ if (!lp_load(dyn_CONFIGFILE, True, False, False, True)) {
d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
dyn_CONFIGFILE, strerror(errno));
exit(1);
}
reopen_logs();
- ret = lp_load(dyn_CONFIGFILE,False,False,True);
+ ret = lp_load(dyn_CONFIGFILE,False,False,True,True);
reopen_logs();
load_interfaces();
TimeInit();
setup_logging("nss_wins",False);
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
}
/* Read some options from the Samba config. Can be overridden by
the PAM config. */
- if(lp_load(service_file,True,False,False) == False) {
+ if(lp_load(service_file,True,False,False,True) == False) {
_log_err( LOG_ERR, "Error loading service file %s", service_file );
}
Initialise the global parameter structure.
***************************************************************************/
-static void init_globals(void)
+static void init_globals(BOOL first_time_only)
{
static BOOL done_init = False;
pstring s;
+ /* If requested to initialize only once and we've already done it... */
+ if (first_time_only && done_init) {
+ /* ... then we have nothing more to do */
+ return;
+ }
+
if (!done_init) {
int i;
False on failure.
***************************************************************************/
-BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
- BOOL add_ipc)
+BOOL lp_load(const char *pszFname,
+ BOOL global_only,
+ BOOL save_defaults,
+ BOOL add_ipc,
+ BOOL initialize_globals)
{
pstring n2;
BOOL bRetval;
bInGlobalSection = True;
bGlobalOnly = global_only;
- init_globals();
+ init_globals(! initialize_globals);
debug_init();
if (save_defaults) {
/* Load configuration file */
- if (!lp_load(dyn_CONFIGFILE, True, False, False))
+ if (!lp_load(dyn_CONFIGFILE, True, False, False, True))
fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
/* Misc other stuff */
/* Load smb.conf file */
- if (!lp_load(dyn_CONFIGFILE,True,False,False))
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True))
fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
/*
lp_killunused(conn_snum_used);
- ret = lp_load(dyn_CONFIGFILE, False, False, True);
+ ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
reload_printers();
pstrcpy(dyn_CONFIGFILE, p);
}
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
if (!init_names())
exit(1);
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {
argc -= 4;
argv += 4;
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {
argc -= 1;
argv += 1;
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {
setup_logging(argv[0],True);
- lp_load(dyn_CONFIGFILE,False,False,False);
+ lp_load(dyn_CONFIGFILE,False,False,False,True);
message_init();
*term_code = 0;
#endif /* KANJI */
- if (!lp_load(dyn_CONFIGFILE,True, False, False))
+ if (!lp_load(dyn_CONFIGFILE,True, False, False, True))
{
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
}
int count = 1;
/* Needed to initialize character set */
- lp_load("/dev/null", True, False, False);
+ lp_load("/dev/null", True, False, False, True);
if (argc < 2) {
fprintf(stderr, "usage: %s STRING1 [COUNT]\n"
int iters = 1;
/* Needed to initialize character set */
- lp_load("/dev/null", True, False, False);
+ lp_load("/dev/null", True, False, False, True);
if (argc < 3) {
fprintf(stderr, "usage: %s STRING1 STRING2 [ITERS]\n"
const char *ret = NULL;
/* Needed to initialize character set */
- lp_load("/dev/null", True, False, False);
+ lp_load("/dev/null", True, False, False, True);
if (argc < 3) {
fprintf(stderr, "usage: %s STRING1 STRING2 [ITERS]\n"
load_case_tables();
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (argc < 2) {
return NT_STATUS_OK;
}
- if (!lp_load(argv[1], False, True, False)) {
+ if (!lp_load(argv[1], False, True, False, True)) {
printf("Error loading \"%s\"\n", argv[1]);
return NT_STATUS_OK;
}
lp_killunused(conn_snum_used);
- ret = lp_load(dyn_CONFIGFILE, False, False, True);
+ ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
/* perhaps the config filename is now set */
if (!test)
opt_debug = 0; /* todo set this from getopts */
- lp_load( dyn_CONFIGFILE, True, False, False );
+ lp_load( dyn_CONFIGFILE, True, False, False, True);
exename = argv[0];
srcname = NULL;
* set by cmdline arg or remain default (0)
*/
AllowDebugChange = False;
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
argv_new = (const char **)poptGetArgs(pc);
exit(1);
}
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
}
/* Samba client initialisation */
- if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
+ if (!lp_load(dyn_CONFIGFILE, True, False, False, True)) {
d_fprintf(stderr, "ntlm_auth: error opening config file %s. Error was %s\n",
dyn_CONFIGFILE, strerror(errno));
exit(1);
if (user_name == NULL)
user_name = poptGetArg(pc);
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
exit(1);
}
setlinebuf(stdout);
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
if (argc == 1)
usage(&pc);
- lp_load(dyn_CONFIGFILE,False,False,False);
+ lp_load(dyn_CONFIGFILE,False,False,False,True);
/* Need to invert sense of return code -- samba
* routines mostly return True==1 for success, but
fault_setup(NULL);
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
pc = poptGetContext("smbcquotas", argc, argv, long_options, 0);
netbiosname = argv[2];
}
- if (!lp_load(configfile,True,False,False)) {
+ if (!lp_load(configfile,True,False,False,True)) {
d_printf("Unable to load config file\n");
}
usage();
}
- if (!lp_load(configfile,True,False,False)) {
+ if (!lp_load(configfile,True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
dyn_CONFIGFILE);
exit(1);
while(poptGetNextOpt(pc) != -1);
poptFreeContext(pc);
- lp_load(dyn_CONFIGFILE,True,False,False);
+ lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
/* Parse command line args */
extern int optind;
char *path;
- lp_load(dyn_CONFIGFILE,1,0,0);
+ lp_load(dyn_CONFIGFILE,1,0,0,1);
smbw_setup_shared();
while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
d_printf("using configfile = %s\n", dyn_CONFIGFILE);
}
- if (!lp_load(dyn_CONFIGFILE,False,False,False)) {
+ if (!lp_load(dyn_CONFIGFILE,False,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
return (-1);
}
fprintf(stderr,"Load smb config files from %s\n",config_file);
- if (!lp_load(config_file,False,True,False)) {
+ if (!lp_load(config_file,False,True,False,True)) {
fprintf(stderr,"Error loading services.\n");
return(1);
}
static BOOL load_config(BOOL save_def)
{
lp_resetnumservices();
- return lp_load(dyn_CONFIGFILE,False,save_def,False);
+ return lp_load(dyn_CONFIGFILE,False,save_def,False,True);
}
/****************************************************************************
if (test && !lp_file_list_changed())
return(True);
- ret = lp_load(dyn_CONFIGFILE,False,False,True);
+ ret = lp_load(dyn_CONFIGFILE,False,False,True,True);
/* perhaps the config filename is now set */