1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

r13212: r12414@cabra: derrell | 2006-01-28 17:52:17 -0500

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.)
This commit is contained in:
Derrell Lipman
2006-01-28 22:53:04 +00:00
committed by Gerald (Jerry) Carter
parent 0e24c701ce
commit f2a24de769
41 changed files with 56 additions and 47 deletions

View File

@ -3449,7 +3449,7 @@ static int do_message_op(void)
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);
}

View File

@ -3654,7 +3654,7 @@ static int do_message_op(void)
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);
}

View File

@ -910,7 +910,7 @@ static void parse_mount_smb(int argc, char **argv)
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);
}

View File

@ -214,7 +214,7 @@ static int smb_print(struct cli_state *, char *, FILE *);
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);

View File

@ -6025,7 +6025,7 @@ smbc_init_context(SMBCCTX *context)
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",
@ -6041,7 +6041,7 @@ smbc_init_context(SMBCCTX *context)
* 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) {
@ -6052,7 +6052,7 @@ smbc_init_context(SMBCCTX *context)
*/
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",

View File

@ -291,7 +291,7 @@ static BOOL reload_nmbd_services(BOOL test)
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 ) {

View File

@ -1024,7 +1024,7 @@ int main(int argc, char **argv)
/* 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);

View File

@ -47,7 +47,7 @@ static BOOL reload_services_file(void)
}
reopen_logs();
ret = lp_load(dyn_CONFIGFILE,False,False,True);
ret = lp_load(dyn_CONFIGFILE,False,False,True,True);
reopen_logs();
load_interfaces();

View File

@ -80,7 +80,7 @@ static void nss_wins_init(void)
TimeInit();
setup_logging("nss_wins",False);
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
}

View File

@ -167,7 +167,7 @@ int set_ctrl( int flags, int argc, const char **argv )
/* 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 );
}

View File

@ -1354,11 +1354,17 @@ static void init_printer_values(service *pService)
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;
@ -4188,8 +4194,11 @@ static void set_allowed_client_auth(void)
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;
@ -4208,7 +4217,7 @@ BOOL lp_load(const char *pszFname, BOOL global_only, BOOL save_defaults,
bInGlobalSection = True;
bGlobalOnly = global_only;
init_globals();
init_globals(! initialize_globals);
debug_init();
if (save_defaults) {

View File

@ -47,7 +47,7 @@ void py_samba_init(void)
/* 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 */

View File

@ -757,7 +757,7 @@ out_free:
/* 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);
/*

View File

@ -529,7 +529,7 @@ BOOL reload_services(BOOL test)
lp_killunused(conn_snum_used);
ret = lp_load(dyn_CONFIGFILE, False, False, True);
ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
reload_printers();

View File

@ -76,7 +76,7 @@ void smbw_init(void)
pstrcpy(dyn_CONFIGFILE, p);
}
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
if (!init_names())
exit(1);

View File

@ -586,7 +586,7 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {

View File

@ -498,7 +498,7 @@ static void usage(void)
argc -= 4;
argv += 4;
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {

View File

@ -454,7 +454,7 @@ static void usage(void)
argc -= 1;
argv += 1;
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (getenv("USER")) {

View File

@ -41,7 +41,7 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len)
setup_logging(argv[0],True);
lp_load(dyn_CONFIGFILE,False,False,False);
lp_load(dyn_CONFIGFILE,False,False,False,True);
message_init();

View File

@ -242,7 +242,7 @@ enum client_action
*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);
}

View File

@ -33,7 +33,7 @@ int main(int argc, char *argv[])
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"

View File

@ -12,7 +12,7 @@ int main(int argc, char *argv[])
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"

View File

@ -14,7 +14,7 @@ int main(int argc, char *argv[])
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"

View File

@ -4916,7 +4916,7 @@ static void usage(void)
load_case_tables();
lp_load(dyn_CONFIGFILE,True,False,False);
lp_load(dyn_CONFIGFILE,True,False,False,True);
load_interfaces();
if (argc < 2) {

View File

@ -113,7 +113,7 @@ static NTSTATUS cmd_conf(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
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;
}
@ -448,7 +448,7 @@ BOOL reload_services(BOOL test)
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)

View File

@ -170,7 +170,7 @@ int main( int argc, char *argv[] )
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;

View File

@ -825,7 +825,7 @@ static struct functable net_func[] = {
* 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);

View File

@ -248,7 +248,7 @@ int main(int argc,char *argv[])
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);
}

View File

@ -1758,7 +1758,7 @@ enum {
/* 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);

View File

@ -795,7 +795,7 @@ int main (int argc, char **argv)
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);
}

View File

@ -830,7 +830,7 @@ static struct cli_state *connect_one(const char *share)
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);

View File

@ -827,7 +827,7 @@ int main(int argc, const char **argv)
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

View File

@ -435,7 +435,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
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);

View File

@ -236,7 +236,7 @@ int main(int argc, char *argv[])
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");
}

View File

@ -187,7 +187,7 @@ static int process_options(int argc, char **argv, int local_flags)
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);

View File

@ -216,7 +216,7 @@ static BOOL print_tree(struct user_auth_info *user_info)
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 */

View File

@ -33,7 +33,7 @@ int main(int argc, char *argv[])
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) {

View File

@ -648,7 +648,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
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);
}

View File

@ -266,7 +266,7 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
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);
}

View File

@ -422,7 +422,7 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte
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);
}
/****************************************************************************

View File

@ -64,7 +64,7 @@ BOOL reload_services(BOOL test)
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 */