What is lp_load_ex() in source3/param/loadparm.c?

Michael Adam obnox at samba.org
Sun Aug 22 15:31:30 MDT 2010


Andrew Bartlett wrote:
> On Fri, 2010-08-20 at 11:22 +0200, Michael Adam wrote:
> > Hi Andrew,
> > 
> > Andrew Bartlett wrote:
> > > I've been looking over the source3/param code with a view to finishing a
> > > port of lp_set_cmdline() (by tridge).  In doing that I noticed that
> > > lp_load_ex() isn't called from outside loadparm.c, and could be made
> > > static. 
> > > 
> > > However, it looks like it was meant to be, or it's a public API that I
> > > can't find the public definition for.  Before I make any foolish
> > > mistakes, I wonder if someone might happen to be able to fill me in on
> > > the history here?
> > 
> > lp_load_ex() is the most flexible lp_load function.
> > The need for greater flexibility was born with the creation
> > of clustered samba and registry configuration.
> > We have wrappers to call it with special parameters:
> > 
> > lp_load() - standard
> > 
> > lp_load_initial_only()
> >    wrapper to only load the smb.conf file
> >    without including registry config (globals):
> >    This is called in daemon startup before messaging etc is set
> >    up: if "clustering = yes", we need to connect to the ctdb
> >    daemon before we can load the registry config...
> > 
> > lp_load_with_registry_shares()
> >    the registry shares are not usually loaded at lp_load() time,
> >    but on demand by the server smbd/services.c .
> >    But for testparm, e.g. we want to load everything, hence
> >    this wrapper.
> > 
> > Possibly lp_load_ex was called outside of loadparm.c once,
> > but now that we have these wrappers, it is not any more.
> > 
> > So I have just pushed a patch to master that makes it static.
> > Thanks for being that careful!
> 
> Thanks for checking that over, and for the explaination.  Now I'm just
> wondering what the first_time_only parameter of init_globals() is really
> for.  It seems to be an override, to say that despite the static, please
> do re-init the globals. 
> 
> In the second of the patches I attach I wondered if this would clarify
> things.  What do you think?

Yeah very much indeed. Lol, it was ridiculous with the inverse logic. ;)
I pushed this one directly.

> Also, as I have been reading over the code, I developed these patches to
> help me understand what each caller wanted.  Could you have a look at
> them for me?

Yes I started, and I really like these simple warppers to
lp_load very much, especially the default config wrappers.
I am not quite sure about the "_for_client()" naming scheme
though. You seem to refer to the false,true,true,false lp_load
call scheme, but this is also used in nmbd, for instance.

I'd like to go over all callers of lp_load myself and check
whether all the parameters to lp_load are correct at all
(there may still be regressions introduced by the introduction
of registry shares/registry global config), and verify the
correct wrappers.

I also think that there are some inaccuracies in the patches
changing callers of lp_load to the new wrappers. Some are simply
assigned to the wrong commit (not bad but irritating at first
sight), and in at least two places you changed a call to
"lp_load_initial_only" which does not load registry globals
to a full blown lp_load wrapper. I would like to check all
the instances. But I don't think I will make it tonight. :-)

I would like to hold off pushing the introduction of the
wrappers until I have gone over the callers in detail, if
that's ok for you.

> I've also included the start of an implementation of lp_set_cmdline()
> that I've been working on with tridge, in case it can get some comment. 

That looks very interesting and useful, indeed!
I guess the lp_set_cmdline() should be integrated in argv parsing
in the main functions? The cmdline_override() function in the
patch is not used (yet). So I guess the patch is not quite
finished yet?

Cheers - Michael

> Thanks,
> 
> Andrew Bartlett
> 
> -- 
> Andrew Bartlett                                http://samba.org/~abartlet/
> Authentication Developer, Samba Team           http://samba.org
> Samba Developer, Cisco Inc.

> From b54293e658da92b4207af64f01785cb05863dc3b Mon Sep 17 00:00:00 2001
> From: Andrew Tridgell <tridge at samba.org>
> Date: Wed, 11 Aug 2010 13:35:14 +1000
> Subject: [PATCH 1/8] s3-param: added lp_set_cmdline()
> 
> ---
>  source3/include/proto.h  |    1 +
>  source3/include/smb.h    |    1 +
>  source3/param/loadparm.c |   65 +++++++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 63 insertions(+), 4 deletions(-)
> 
> diff --git a/source3/include/proto.h b/source3/include/proto.h
> index 09c34ed..d306d98 100644
> --- a/source3/include/proto.h
> +++ b/source3/include/proto.h
> @@ -3988,6 +3988,7 @@ const char *lp_ldap_group_suffix(void);
>  const char *lp_ldap_idmap_suffix(void);
>  void *lp_local_ptr_by_snum(int snum, void *ptr);
>  bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
> +bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
>  void init_locals(void);
>  bool lp_is_default(int snum, struct parm_struct *parm);
>  bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
> diff --git a/source3/include/smb.h b/source3/include/smb.h
> index ab1b4b2..96467c9 100644
> --- a/source3/include/smb.h
> +++ b/source3/include/smb.h
> @@ -910,6 +910,7 @@ struct parm_struct {
>  #define FLAG_HIDE  	0x2000 /* options that should be hidden in SWAT */
>  #define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
>  #define FLAG_META	0x8000 /* A meta directive - not a real parameter */
> +#define FLAG_CMDLINE	0x10000 /* option has been overridden */
>  
>  struct bitmap {
>  	uint32 *b;
> diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
> index 340031b..a76f487 100644
> --- a/source3/param/loadparm.c
> +++ b/source3/param/loadparm.c
> @@ -116,6 +116,7 @@ struct param_opt_struct {
>  	char *key;
>  	char *value;
>  	char **list;
> +	unsigned flags;
>  };
>  
>  /*
> @@ -4943,6 +4944,18 @@ static void free_global_parameters(void)
>  	free_parameters_by_snum(GLOBAL_SECTION_SNUM);
>  }
>  
> +static int map_parameter(const char *pszParmName);
> +
> +static bool cmdline_override(const char *pszParmName)
> +{
> +	int parmnum;
> +	parmnum = map_parameter(pszParmName);
> +	if (parmnum < 0) {
> +		return false;
> +	}
> +	return (parm_table[parmnum].flags & FLAG_CMDLINE);
> +}
> +
>  /***************************************************************************
>   Initialise the global parameter structure.
>  ***************************************************************************/
> @@ -5817,7 +5830,6 @@ FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrappi
>  
>  /* local prototypes */
>  
> -static int map_parameter(const char *pszParmName);
>  static int map_parameter_canonical(const char *pszParmName, bool *inverse);
>  static const char *get_boolean(bool bool_value);
>  static int getservicebyname(const char *pszServiceName,
> @@ -6820,7 +6832,8 @@ static int getservicebyname(const char *pszServiceName, struct service *pservice
>   */
>  static void set_param_opt(struct param_opt_struct **opt_list,
>  			  const char *opt_name,
> -			  const char *opt_value)
> +			  const char *opt_value,
> +			  unsigned flags)
>  {
>  	struct param_opt_struct *new_opt, *opt;
>  	bool not_added;
> @@ -6836,9 +6849,16 @@ static void set_param_opt(struct param_opt_struct **opt_list,
>  	while (opt) {
>  		/* If we already have same option, override it */
>  		if (strwicmp(opt->key, opt_name) == 0) {
> +			if ((opt->flags & FLAG_CMDLINE) && 
> +			    !(flags & FLAG_CMDLINE)) {
> +				/* it's been marked as not to be
> +				   overridden */
> +				return;
> +			}
>  			string_free(&opt->value);
>  			TALLOC_FREE(opt->list);
>  			opt->value = SMB_STRDUP(opt_value);
> +			opt->flags = flags;
>  			not_added = false;
>  			break;
>  		}
> @@ -6849,6 +6869,7 @@ static void set_param_opt(struct param_opt_struct **opt_list,
>  	    new_opt->key = SMB_STRDUP(opt_name);
>  	    new_opt->value = SMB_STRDUP(opt_value);
>  	    new_opt->list = NULL;
> +	    new_opt->flags = flags;
>  	    DLIST_ADD(*opt_list, new_opt);
>  	}
>  }
> @@ -6916,7 +6937,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS
>  
>  	data = pserviceSource->param_opt;
>  	while (data) {
> -		set_param_opt(&pserviceDest->param_opt, data->key, data->value);
> +		set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
>  		data = data->next;
>  	}
>  }
> @@ -7673,11 +7694,17 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
>  
>  		opt_list = (snum < 0)
>  			? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
> -		set_param_opt(opt_list, pszParmName, pszParmValue);
> +		set_param_opt(opt_list, pszParmName, pszParmValue, 0);
>  
>  		return (True);
>  	}
>  
> +	/* if it's already been set by the command line, then we don't
> +	   override here */
> +	if (parm_table[parmnum].flags & FLAG_CMDLINE) {
> +		return true;
> +	}
> +
>  	if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
>  		DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
>  			  pszParmName));
> @@ -7766,6 +7793,36 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
>  	return (True);
>  }
>  
> +
> +/***************************************************************************
> +set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
> +FLAG_CMDLINE won't be overridden by loads from smb.conf.
> +***************************************************************************/
> +
> +bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
> +{
> +	int parmnum;
> +	parmnum = map_parameter(pszParmName);
> +	if (parmnum >= 0) {
> +		parm_table[parmnum].flags &= ~FLAG_CMDLINE;
> +		if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
> +			return false;
> +		}
> +		parm_table[parmnum].flags |= FLAG_CMDLINE;
> +		return true;
> +	}
> +
> +	/* it might be parametric */
> +	if (strchr(pszParmName, ':') != NULL) {
> +		set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
> +		return true;
> +	}
> +
> +	DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",  pszParmName));
> +	return true;	
> +}
> +
> +
>  /***************************************************************************
>   Process a parameter.
>  ***************************************************************************/
> -- 
> 1.7.2.1
> 

> From 64fb1be6151ff668eab7e50b4ee9ebf663a27602 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 17:51:48 +1000
> Subject: [PATCH 2/8] s3:param Clarify parameter name on init_globals()
> 
> This parameter is used with the registry backend to
> cause the globals table to be re-initialised.
> 
> Andrew Bartlett
> ---
>  source3/param/loadparm.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
> index a76f487..2bf287d 100644
> --- a/source3/param/loadparm.c
> +++ b/source3/param/loadparm.c
> @@ -4960,14 +4960,14 @@ static bool cmdline_override(const char *pszParmName)
>   Initialise the global parameter structure.
>  ***************************************************************************/
>  
> -static void init_globals(bool first_time_only)
> +static void init_globals(bool reinit_globals)
>  {
>  	static bool done_init = False;
>  	char *s = NULL;
>  	int i;
>  
>          /* If requested to initialize only once and we've already done it... */
> -        if (first_time_only && done_init) {
> +        if (!reinit_globals && done_init) {
>                  /* ... then we have nothing more to do */
>                  return;
>          }
> @@ -9238,7 +9238,7 @@ static bool lp_load_ex(const char *pszFname,
>  	bGlobalOnly = global_only;
>  	bAllowIncludeRegistry = allow_include_registry;
>  
> -	init_globals(! initialize_globals);
> +	init_globals(initialize_globals);
>  	debug_init();
>  
>  	free_file_list();
> @@ -9286,7 +9286,7 @@ static bool lp_load_ex(const char *pszFname,
>  			/* start over */
>  			DEBUG(1, ("lp_load_ex: changing to config backend "
>  				  "registry\n"));
> -			init_globals(false);
> +			init_globals(true);
>  			lp_kill_all_services();
>  			return lp_load_ex(pszFname, global_only, save_defaults,
>  					  add_ipc, initialize_globals,
> -- 
> 1.7.2.1
> 

> From e993ba5abebbbc6ba98992348063129b932ef926 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 20:15:45 +1000
> Subject: [PATCH 3/8] s3:param Simplify lp_load_with_registry_shares()
> 
> All the callers specified the same parameters anyway.
> 
> Andrew Bartlett
> ---
>  source3/include/proto.h      |    6 +-----
>  source3/param/loadparm.c     |   18 +++++++-----------
>  source3/param/test_lp_load.c |    6 +-----
>  source3/utils/testparm.c     |    2 +-
>  4 files changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/source3/include/proto.h b/source3/include/proto.h
> index d306d98..63998fc 100644
> --- a/source3/include/proto.h
> +++ b/source3/include/proto.h
> @@ -4023,11 +4023,7 @@ bool lp_load(const char *pszFname,
>  	     bool add_ipc,
>  	     bool initialize_globals);
>  bool lp_load_initial_only(const char *pszFname);
> -bool lp_load_with_registry_shares(const char *pszFname,
> -				  bool global_only,
> -				  bool save_defaults,
> -				  bool add_ipc,
> -				  bool initialize_globals);
> +bool lp_load_with_registry_shares(const char *pszFname);
>  int lp_numservices(void);
>  void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
>  void lp_dump_one(FILE * f, bool show_defaults, int snum);
> diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
> index 2bf287d..6bc1b02 100644
> --- a/source3/param/loadparm.c
> +++ b/source3/param/loadparm.c
> @@ -9361,19 +9361,15 @@ bool lp_load_initial_only(const char *pszFname)
>  			  false); /* allow_registry_shares*/
>  }
>  
> -bool lp_load_with_registry_shares(const char *pszFname,
> -				  bool global_only,
> -				  bool save_defaults,
> -				  bool add_ipc,
> -				  bool initialize_globals)
> +bool lp_load_with_registry_shares(const char *pszFname)
>  {
>  	return lp_load_ex(pszFname,
> -			  global_only,
> -			  save_defaults,
> -			  add_ipc,
> -			  initialize_globals,
> -			  true,  /* allow_include_registry */
> -			  true); /* allow_registry_shares*/
> +			  false, /* globals_only */
> +			  true, /* save_defaults */
> +			  false, /* add_ipc */
> +			  true, /* initialize_globals */
> +			  true, /* allow_include_registry */
> +			  true /* allow_registry_shares */);
>  }
>  
>  /***************************************************************************
> diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c
> index 1ec123e..224c2a7 100644
> --- a/source3/param/test_lp_load.c
> +++ b/source3/param/test_lp_load.c
> @@ -66,11 +66,7 @@ int main(int argc, const char **argv)
>  
>  	for (i=0; i < count; i++) {
>  		printf("call lp_load() #%d: ", i+1);
> -		if (!lp_load_with_registry_shares(config_file,
> -						  False, /* global only */
> -						  True,  /* save defaults */
> -						  False, /*add_ipc */
> -						  True)) /*init globals */
> +		if (!lp_load_with_registry_shares(config_file)
>  		{
>  			printf("ERROR.\n");
>  			ret = 1;
> diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
> index 6d606bb..2653942 100644
> --- a/source3/utils/testparm.c
> +++ b/source3/utils/testparm.c
> @@ -387,7 +387,7 @@ rameter is ignored when using CUPS libraries.\n",
>  
>  	fprintf(stderr,"Load smb config files from %s\n",config_file);
>  
> -	if (!lp_load_with_registry_shares(config_file,False,True,False,True)) {
> +	if (!lp_load_with_registry_shares(config_file)) {
>  		fprintf(stderr,"Error loading services.\n");
>  		ret = 1;
>  		goto done;
> -- 
> 1.7.2.1
> 

> From d36ef1210f70e3400d21fb12103bd8c46df81444 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 20:43:06 +1000
> Subject: [PATCH 4/8] s3:param Add lp_load_{default,}_config_for_client()
> 
> This simplifies a lot of callers all over the Samba codebase
> 
> Andrew Bartlett
> ---
>  source3/include/proto.h  |    2 ++
>  source3/param/loadparm.c |   16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/source3/include/proto.h b/source3/include/proto.h
> index 63998fc..93b486c 100644
> --- a/source3/include/proto.h
> +++ b/source3/include/proto.h
> @@ -4023,6 +4023,8 @@ bool lp_load(const char *pszFname,
>  	     bool add_ipc,
>  	     bool initialize_globals);
>  bool lp_load_initial_only(const char *pszFname);
> +bool lp_load_config_for_client(const char *pszFname);
> +bool lp_load_default_config_for_client(void);
>  bool lp_load_with_registry_shares(const char *pszFname);
>  int lp_numservices(void);
>  void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
> diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
> index 6bc1b02..3fe3abb 100644
> --- a/source3/param/loadparm.c
> +++ b/source3/param/loadparm.c
> @@ -9361,6 +9361,22 @@ bool lp_load_initial_only(const char *pszFname)
>  			  false); /* allow_registry_shares*/
>  }
>  
> +bool lp_load_config_for_client(const char *pszFname)
> +{
> +	return lp_load_ex(pszFname,
> +			  true,   /* global only */
> +			  false,  /* save_defaults */
> +			  false,  /* add_ipc */
> +			  true,   /* initialize_globals */
> +			  true,  /* allow_include_registry */
> +			  false); /* allow_registry_shares*/
> +}
> +
> +bool lp_load_default_config_for_client(void)
> +{
> +	return lp_load_config_for_client(get_dyn_CONFIGFILE());
> +}
> +
>  bool lp_load_with_registry_shares(const char *pszFname)
>  {
>  	return lp_load_ex(pszFname,
> -- 
> 1.7.2.1
> 

> From b0d0c71ee42ba14302749ec22e659c7446291802 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 20:45:25 +1000
> Subject: [PATCH 5/8] s3:param Change lp_load() -> lp_load_default_config_for_client()
> 
> This makes it much easier to figure out what the callers
> are trying to do with tools like grep.
> 
> Andrew Bartlett
> ---
>  source3/client/client.c         |    2 +-
>  source3/client/smbspool.c       |    2 +-
>  source3/lib/smbconf/testsuite.c |    6 +-----
>  source3/libnet/libnet_join.c    |    4 ++--
>  source3/libsmb/libsmb_context.c |    2 +-
>  source3/nmbd/nmbd.c             |    2 +-
>  source3/rpcclient/rpcclient.c   |    2 +-
>  source3/torture/locktest.c      |    2 +-
>  source3/torture/locktest2.c     |    2 +-
>  source3/torture/masktest.c      |    2 +-
>  source3/torture/torture.c       |    3 ++-
>  source3/utils/dbwrap_tool.c     |    2 +-
>  source3/utils/dbwrap_torture.c  |    2 +-
>  source3/utils/net.c             |    2 +-
>  source3/utils/nmblookup.c       |    2 +-
>  source3/utils/ntlm_auth.c       |    2 +-
>  source3/utils/pdbedit.c         |    2 +-
>  source3/utils/smbcacls.c        |    2 +-
>  source3/utils/smbcquotas.c      |    2 +-
>  source3/utils/smbfilter.c       |    2 +-
>  source3/utils/smbpasswd.c       |    2 +-
>  source3/utils/smbtree.c         |    2 +-
>  source3/utils/smbw_sample.c     |    2 +-
>  23 files changed, 25 insertions(+), 28 deletions(-)
> 
> diff --git a/source3/client/client.c b/source3/client/client.c
> index ce5b4e6..cae743b 100644
> --- a/source3/client/client.c
> +++ b/source3/client/client.c
> @@ -5038,7 +5038,7 @@ static int do_message_op(struct user_auth_info *a_info)
>  	if ( override_logfile )
>  		setup_logging( lp_logfile(), false );
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) {
> +	if (!lp_load_default_config_for_client()) {
>  		fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
>  			argv[0], get_dyn_CONFIGFILE());
>  	}
> diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
> index 07de579..5bd0077 100644
> --- a/source3/client/smbspool.c
> +++ b/source3/client/smbspool.c
> @@ -246,7 +246,7 @@ main(int argc,			/* I - Number of command-line arguments */
>  
>  	load_case_tables();
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True)) {
> +	if (!lp_load_default_config_for_client()) {
>  		fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
>  		goto done;
>  	}
> diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
> index 2c6fedc..b0d454e 100644
> --- a/source3/lib/smbconf/testsuite.c
> +++ b/source3/lib/smbconf/testsuite.c
> @@ -304,11 +304,7 @@ int main(int argc, const char **argv)
>  
>  	poptFreeContext(pc);
>  
> -	ret = lp_load(get_dyn_CONFIGFILE(),
> -		      true,  /* globals_only */
> -		      false, /* save_defaults */
> -		      false, /* add_ipc */
> -		      true   /* initialize globals */);
> +	ret = lp_load_default_config_for_client();
>  
>  	if (!ret) {
>  		printf("failure: error loading the configuration\n");
> diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
> index 7d83dc3..36f2f86 100644
> --- a/source3/libnet/libnet_join.c
> +++ b/source3/libnet/libnet_join.c
> @@ -1434,7 +1434,7 @@ static WERROR do_JoinConfig(struct libnet_JoinCtx *r)
>  		return werr;
>  	}
>  
> -	lp_load(get_dyn_CONFIGFILE(),true,false,false,true);
> +	lp_load_default_config_for_client();
>  
>  	r->out.modified_config = true;
>  	r->out.result = werr;
> @@ -1462,7 +1462,7 @@ static WERROR libnet_unjoin_config(struct libnet_UnjoinCtx *r)
>  		return werr;
>  	}
>  
> -	lp_load(get_dyn_CONFIGFILE(),true,false,false,true);
> +	lp_load_default_config_for_client();
>  
>  	r->out.modified_config = true;
>  	r->out.result = werr;
> diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
> index 7f4ede4..5e7463d 100644
> --- a/source3/libsmb/libsmb_context.c
> +++ b/source3/libsmb/libsmb_context.c
> @@ -57,7 +57,7 @@ SMBC_module_init(void * punused)
>      if (home) {
>          char *conf = NULL;
>          if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) {
> -            if (lp_load(conf, True, False, False, True)) {
> +            if (lp_load_initial_only(conf)) {
>                  conf_loaded = True;
>              } else {
>                  DEBUG(5, ("Could not load config file: %s\n",
> diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
> index 16a4d7d..d6ed7f9 100644
> --- a/source3/nmbd/nmbd.c
> +++ b/source3/nmbd/nmbd.c
> @@ -382,7 +382,7 @@ static bool reload_nmbd_services(bool test)
>  	if ( test && !lp_file_list_changed() )
>  		return(True);
>  
> -	ret = lp_load(get_dyn_CONFIGFILE(), True , False, False, True);
> +	ret = 	lp_load_default_config_for_client();
>  
>  	/* perhaps the config filename is now set */
>  	if ( !test ) {
> diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
> index 4ea2b74..ea016c8 100644
> --- a/source3/rpcclient/rpcclient.c
> +++ b/source3/rpcclient/rpcclient.c
> @@ -954,7 +954,7 @@ out_free:
>  
>  	/* Load smb.conf file */
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True))
> +	if (!lp_load_default_config_for_client())
>  		fprintf(stderr, "Can't load %s\n", get_dyn_CONFIGFILE());
>  
>  	if ( strlen(new_workgroup) != 0 )
> diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
> index a90c2e2..f9257a1 100644
> --- a/source3/torture/locktest.c
> +++ b/source3/torture/locktest.c
> @@ -621,7 +621,7 @@ static void usage(void)
>  	argc -= NSERVERS;
>  	argv += NSERVERS;
>  
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	if (getenv("USER")) {
> diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
> index 5c8a2d8..0cb04fb 100644
> --- a/source3/torture/locktest2.c
> +++ b/source3/torture/locktest2.c
> @@ -511,7 +511,7 @@ static void usage(void)
>  	argc -= 4;
>  	argv += 4;
>  
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	if (getenv("USER")) {
> diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
> index 51de6d9..27b3aa6 100644
> --- a/source3/torture/masktest.c
> +++ b/source3/torture/masktest.c
> @@ -499,7 +499,7 @@ static void usage(void)
>  	argv += 1;
>  
>  	load_case_tables();
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	if (getenv("USER")) {
> diff --git a/source3/torture/torture.c b/source3/torture/torture.c
> index 0e3ee18..a1eda74 100644
> --- a/source3/torture/torture.c
> +++ b/source3/torture/torture.c
> @@ -7699,7 +7699,8 @@ static void usage(void)
>  			set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH"));
>  		}
>  	}
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
> +
>  	load_interfaces();
>  
>  	if (argc < 2) {
> diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c
> index 6fbef5f..7f93484 100644
> --- a/source3/utils/dbwrap_tool.c
> +++ b/source3/utils/dbwrap_tool.c
> @@ -216,7 +216,7 @@ int main(int argc, const char **argv)
>  	DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
>  	dbf = x_stderr;
>  	AllowDebugChange = false;
> -	lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
> +	lp_load_default_config_for_client();
>  
>  	if ((argc < 3) || (argc > 6)) {
>  		d_fprintf(stderr,
> diff --git a/source3/utils/dbwrap_torture.c b/source3/utils/dbwrap_torture.c
> index 1430161..f157693 100644
> --- a/source3/utils/dbwrap_torture.c
> +++ b/source3/utils/dbwrap_torture.c
> @@ -280,7 +280,7 @@ int main(int argc, const char *argv[])
>  	load_case_tables();
>  	dbf = x_stderr;
>  	AllowDebugChange = false;
> -	lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
> +	lp_load_default_config_for_client();
>  
>  	ev_ctx = tevent_context_init(mem_ctx);
>  	if (ev_ctx == NULL) {
> diff --git a/source3/utils/net.c b/source3/utils/net.c
> index eea13ea..ca23702 100644
> --- a/source3/utils/net.c
> +++ b/source3/utils/net.c
> @@ -877,7 +877,7 @@ static struct functable net_func[] = {
>  	 * set by cmdline arg or remain default (0)
>  	 */
>  	AllowDebugChange = false;
> -	lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
> +	lp_load_default_config_for_client();
>  
>   	argv_new = (const char **)poptGetArgs(pc);
>  
> diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
> index 1187c96..a46ab05 100644
> --- a/source3/utils/nmblookup.c
> +++ b/source3/utils/nmblookup.c
> @@ -315,7 +315,7 @@ int main(int argc,char *argv[])
>  		exit(1);
>  	}
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
> +	if (!lp_load_default_config_for_client()) {
>  		fprintf(stderr, "Can't load %s - run testparm to debug it\n",
>  				get_dyn_CONFIGFILE());
>  	}
> diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
> index d234a3c..d49b872 100644
> --- a/source3/utils/ntlm_auth.c
> +++ b/source3/utils/ntlm_auth.c
> @@ -2470,7 +2470,7 @@ enum {
>  
>  	poptFreeContext(pc);
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True)) {
> +	if (!lp_load_default_config_for_client()) {
>  		d_fprintf(stderr, "ntlm_auth: error opening config file %s. Error was %s\n",
>  			get_dyn_CONFIGFILE(), strerror(errno));
>  		exit(1);
> diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
> index 9dff45b..556a981 100644
> --- a/source3/utils/pdbedit.c
> +++ b/source3/utils/pdbedit.c
> @@ -1075,7 +1075,7 @@ int main (int argc, char **argv)
>  	if (user_name == NULL)
>  		user_name = poptGetArg(pc);
>  
> -	if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
> +	if (!lp_load_default_config_for_client()) {
>  		fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
>  		exit(1);
>  	}
> diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
> index 65fec10..7618fce 100644
> --- a/source3/utils/smbcacls.c
> +++ b/source3/utils/smbcacls.c
> @@ -1209,7 +1209,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info,
>  
>  	setlinebuf(stdout);
>  
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	auth_info = user_auth_info_init(frame);
> diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
> index f575872..4c373e4 100644
> --- a/source3/utils/smbcquotas.c
> +++ b/source3/utils/smbcquotas.c
> @@ -471,7 +471,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
>  
>  	fault_setup(NULL);
>  
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	smbcquotas_auth_info = user_auth_info_init(frame);
> diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
> index 83de0c4..b20ca17 100644
> --- a/source3/utils/smbfilter.c
> +++ b/source3/utils/smbfilter.c
> @@ -285,7 +285,7 @@ int main(int argc, char *argv[])
>  		netbiosname = argv[2];
>  	}
>  
> -	if (!lp_load(configfile,True,False,False,True)) {
> +	if (!lp_load_default_config_for_client()) {
>  		d_printf("Unable to load config file\n");
>  	}
>  
> diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
> index 1b68136..5e762ff 100644
> --- a/source3/utils/smbpasswd.c
> +++ b/source3/utils/smbpasswd.c
> @@ -194,7 +194,7 @@ static int process_options(int argc, char **argv, int local_flags)
>  		usage();
>  	}
>  
> -	if (!lp_load(configfile,True,False,False,True)) {
> +	if (!lp_load_initial_only(configfile)) {
>  		fprintf(stderr, "Can't load %s - run testparm to debug it\n", 
>  			configfile);
>  		exit(1);
> diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
> index f27011c..c219fc3 100644
> --- a/source3/utils/smbtree.c
> +++ b/source3/utils/smbtree.c
> @@ -306,7 +306,7 @@ static bool print_tree(struct user_auth_info *user_info)
>  	while(poptGetNextOpt(pc) != -1);
>  	poptFreeContext(pc);
>  
> -	lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
> +	lp_load_default_config_for_client();
>  	load_interfaces();
>  
>  	/* Parse command line args */
> diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c
> index eface2f..0e87fd5 100644
> --- a/source3/utils/smbw_sample.c
> +++ b/source3/utils/smbw_sample.c
> @@ -34,7 +34,7 @@ int main(int argc, char *argv[])
>  	char *path;
>  	TALLOC_CTX *frame = talloc_stackframe();
>  
> -	lp_load(get_dyn_CONFIGFILE(),1,0,0,1);
> +	lp_load_default_config_for_client();
>  	smbw_setup_shared();
>  
>  	while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
> -- 
> 1.7.2.1
> 

> From f928aac243c19b3e108e99727583d731732c6eda Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 20:46:55 +1000
> Subject: [PATCH 6/8] s3:param Convert lp_load() to lp_load_config_for_client()
> 
> This call takes a smb.conf file name, but otherwise uses
> the same parameters as all these callers internally.
> 
> Andrew Bartlett
> ---
>  source3/libsmb/libsmb_context.c |    2 +-
>  source3/pam_smbpass/support.c   |    2 +-
>  source3/torture/t_push_ucs2.c   |    2 +-
>  source3/torture/t_strcmp.c      |    2 +-
>  source3/torture/t_strstr.c      |    2 +-
>  source3/utils/eventlogadm.c     |    4 ++--
>  source3/utils/smbfilter.c       |    2 +-
>  source3/utils/smbpasswd.c       |    2 +-
>  8 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
> index 5e7463d..3950f57 100644
> --- a/source3/libsmb/libsmb_context.c
> +++ b/source3/libsmb/libsmb_context.c
> @@ -57,7 +57,7 @@ SMBC_module_init(void * punused)
>      if (home) {
>          char *conf = NULL;
>          if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) {
> -            if (lp_load_initial_only(conf)) {
> +            if (lp_load_config_for_client(conf)) {
>                  conf_loaded = True;
>              } else {
>                  DEBUG(5, ("Could not load config file: %s\n",
> diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c
> index 715a0f4..7d8eb8d 100644
> --- a/source3/pam_smbpass/support.c
> +++ b/source3/pam_smbpass/support.c
> @@ -205,7 +205,7 @@ int set_ctrl( pam_handle_t *pamh, 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,True) == False) {
> +    if(lp_load_config_for_client(service_file) == False) {
>  	_log_err(pamh, LOG_ERR, "Error loading service file %s", service_file);
>      }
>  
> diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c
> index 2bd91da..628f4a5 100644
> --- a/source3/torture/t_push_ucs2.c
> +++ b/source3/torture/t_push_ucs2.c
> @@ -34,7 +34,7 @@ int main(int argc, char *argv[])
>  	int count = 1;
>  
>  	/* Needed to initialize character set */
> -	lp_load("/dev/null", True, False, False, True);
> +	lp_load_config_for_client("/dev/null");
>  
>  	if (argc < 2) {
>  		fprintf(stderr, "usage: %s STRING1 [COUNT]\n"
> diff --git a/source3/torture/t_strcmp.c b/source3/torture/t_strcmp.c
> index 318423b..7f01d79 100644
> --- a/source3/torture/t_strcmp.c
> +++ b/source3/torture/t_strcmp.c
> @@ -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, True);
> +	lp_load_config_for_client("/dev/null")
>  
>  	if (argc < 3) {
>  		fprintf(stderr, "usage: %s STRING1 STRING2 [ITERS]\n"
> diff --git a/source3/torture/t_strstr.c b/source3/torture/t_strstr.c
> index 49180b2..ad52e62 100644
> --- a/source3/torture/t_strstr.c
> +++ b/source3/torture/t_strstr.c
> @@ -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, True);
> +	lp_load_config_for_client("/dev/null");
>  
>  	if (argc < 3) {
>  		fprintf(stderr, "usage: %s STRING1 STRING2 [ITERS]\n"
> diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c
> index 15b8d20..91cad65 100644
> --- a/source3/utils/eventlogadm.c
> +++ b/source3/utils/eventlogadm.c
> @@ -277,8 +277,8 @@ int main( int argc, char *argv[] )
>  	}
>  
>  	if ( configfile == NULL ) {
> -		lp_load(get_dyn_CONFIGFILE(), True, False, False, True);
> -	} else if (!lp_load(configfile, True, False, False, True)) {
> +		lp_load_default_config_for_client();
> +	} else if (!lp_load_config_for_client(configfile)) {
>  		printf("Unable to parse configfile '%s'\n",configfile);
>  		exit( 1 );
>  	}
> diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
> index b20ca17..e90b230 100644
> --- a/source3/utils/smbfilter.c
> +++ b/source3/utils/smbfilter.c
> @@ -285,7 +285,7 @@ int main(int argc, char *argv[])
>  		netbiosname = argv[2];
>  	}
>  
> -	if (!lp_load_default_config_for_client()) {
> +	if (!lp_load_config_for_client(configfile)) {
>  		d_printf("Unable to load config file\n");
>  	}
>  
> diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
> index 5e762ff..1457126 100644
> --- a/source3/utils/smbpasswd.c
> +++ b/source3/utils/smbpasswd.c
> @@ -194,7 +194,7 @@ static int process_options(int argc, char **argv, int local_flags)
>  		usage();
>  	}
>  
> -	if (!lp_load_initial_only(configfile)) {
> +	if (!lp_load_config_for_client(configfile)) {
>  		fprintf(stderr, "Can't load %s - run testparm to debug it\n", 
>  			configfile);
>  		exit(1);
> -- 
> 1.7.2.1
> 

> From 83eae9f542d945f6da0751d639ca7f69e938d150 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 22:29:19 +1000
> Subject: [PATCH 7/8] s3:param Two more conversions to lp_load_default_for_client()
> 
> These two do NOT match the same behaviour, but neither invokes
> per-share smb.conf options, and seems to be a simple copy & paste
> from vfstest.
> 
> Andrew Bartlett
> ---
>  source3/torture/msgtest.c |    2 +-
>  source3/torture/pdbtest.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c
> index 6d1a689..bb7601e 100644
> --- a/source3/torture/msgtest.c
> +++ b/source3/torture/msgtest.c
> @@ -51,7 +51,7 @@ static void pong_message(struct messaging_context *msg_ctx,
>  
>  	setup_logging(argv[0],True);
>  
> -	lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
> +	lp_load_default_config_for_client();
>  
>  	if (!(evt_ctx = tevent_context_init(NULL)) ||
>  	    !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) {
> diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
> index a775791..4553554 100644
> --- a/source3/torture/pdbtest.c
> +++ b/source3/torture/pdbtest.c
> @@ -258,7 +258,7 @@ int main(int argc, char **argv)
>  	poptFreeContext(pc);
>  
>  	/* Load configuration */
> -	lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
> +	lp_load_default_config_for_client();
>  	setup_logging("pdbtest", True);
>  
>  	if (backend == NULL) {
> -- 
> 1.7.2.1
> 

> From 760d08baf256cc38ca560a40241cab302c160fc7 Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 20 Aug 2010 22:30:46 +1000
> Subject: [PATCH 8/8] s3:pdbtest Fix command name of pdbtest
> 
> ---
>  source3/torture/pdbtest.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
> index 4553554..b105ddc 100644
> --- a/source3/torture/pdbtest.c
> +++ b/source3/torture/pdbtest.c
> @@ -248,7 +248,7 @@ int main(int argc, char **argv)
>  
>  	load_case_tables();
>  
> -	pc = poptGetContext("vfstest", argc, (const char **) argv,
> +	pc = poptGetContext("pdbtest", argc, (const char **) argv,
>  			    long_options, 0);
>  
>  	poptSetOtherOptionHelp(pc, "backend[:settings] username");
> -- 
> 1.7.2.1
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 206 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20100822/3d7d1806/attachment.pgp>


More information about the samba-technical mailing list