1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +03:00

r26275: return loadparm context in lp_load.

(This used to be commit d01f0f4c20)
This commit is contained in:
Jelmer Vernooij
2007-12-04 00:12:13 +01:00
committed by Stefan Metzmacher
parent fc2f06d31b
commit b038240ac7
11 changed files with 51 additions and 34 deletions

View File

@ -323,7 +323,8 @@ static void smb_umount(const char *mount_point)
* not exit after open_sockets() or send_login() errors,
* as the smbfs mount would then have no way to recover.
*/
static void send_fs_socket(const char *the_service, const char *mount_point, struct smbcli_state *c)
static void send_fs_socket(struct loadparm_context *lp_ctx,
const char *the_service, const char *mount_point, struct smbcli_state *c)
{
int fd, closed = 0, res = 1;
pid_t parentpid = getppid();
@ -407,7 +408,7 @@ static void send_fs_socket(const char *the_service, const char *mount_point, str
pause();
DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", sys_getpid()));
c = do_connection(the_service,
lp_unicode(global_loadparm),
lp_unicode(lp_ctx),
lp_cli_maxprotocol(global_loadparm));
}
}
@ -529,7 +530,7 @@ static void init_mount(void)
for any reason, we will have to unmount the mount point. There
is no exit from the next call...
*/
send_fs_socket(service, mount_point, c);
send_fs_socket(global_loadparm, service, mount_point, c);
}
@ -852,6 +853,7 @@ static void parse_mount_smb(int argc, char **argv)
extern char *optarg;
extern int optind;
char *p;
struct loadparm_context *lp_ctx;
DEBUGLEVEL = 1;
@ -882,7 +884,7 @@ static void parse_mount_smb(int argc, char **argv)
}
if (getenv("PASSWD")) {
pstrcpy(password,getenv("PASSWD"));
pstrcpy(password, getenv("PASSWD"));
got_pass = true;
}
@ -895,7 +897,7 @@ static void parse_mount_smb(int argc, char **argv)
pstrcpy(username,getenv("LOGNAME"));
}
if (!lp_load(dyn_CONFIGFILE)) {
if (!lp_load(dyn_CONFIGFILE, &lp_ctx)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
lp_config_file());
}

View File

@ -50,6 +50,7 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
FILE *fp; /* File to print */
int status=0; /* Status of LPD job */
struct smbcli_state *cli; /* SMB interface */
struct loadparm_context *lp_ctx;
/* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */
if (argc > 2 && strncmp(argv[0],"smb://", 6) && !strncmp(argv[1],"smb://", 6)) {
@ -176,13 +177,13 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
setup_logging(argv[0], DEBUG_STDOUT);
if (!lp_load(dyn_CONFIGFILE)) {
if (!lp_load(dyn_CONFIGFILE, &lp_ctx)) {
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
return (1);
}
if (workgroup == NULL)
workgroup = lp_workgroup();
workgroup = lp_workgroup(lp_ctx);
do
{

View File

@ -52,9 +52,9 @@ static void popt_common_callback(poptContext con,
if (reason == POPT_CALLBACK_REASON_POST) {
if (!lp_loaded()) {
if (getenv("SMB_CONF_PATH"))
lp_load(getenv("SMB_CONF_PATH"));
lp_load(getenv("SMB_CONF_PATH"), NULL);
else
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, NULL);
}
/* Hook any 'every Samba program must do this, after
* the smb.conf is setup' functions here */
@ -101,7 +101,7 @@ static void popt_common_callback(poptContext con,
case 's':
if (arg) {
lp_load(arg);
lp_load(arg, NULL);
}
break;

View File

@ -2407,7 +2407,7 @@ bool loadparm_init(struct loadparm_context *lp_ctx)
_PUBLIC_ _DEPRECATED_ bool lp_load_default(void)
{
return lp_load(dyn_CONFIGFILE);
return lp_load(dyn_CONFIGFILE, NULL);
}
/***************************************************************************
@ -2415,13 +2415,16 @@ _PUBLIC_ _DEPRECATED_ bool lp_load_default(void)
False on failure.
***************************************************************************/
bool lp_load(const char *filename)
bool lp_load(const char *filename, struct loadparm_context **ret_lp)
{
char *n2;
bool bRetval;
struct param_opt *data;
struct loadparm_context *lp_ctx = &loadparm;
if (ret_lp != NULL)
*ret_lp = NULL;
filename = talloc_strdup(talloc_autofree_context(), filename);
global_loadparm = lp_ctx;
@ -2470,6 +2473,9 @@ bool lp_load(const char *filename)
close_iconv();
if (ret_lp != NULL)
*ret_lp = lp_ctx;
return bRetval;
}

View File

@ -187,7 +187,9 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
*/
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
bool ret = lp_load(lp_configfile(global_loadparm));
bool ret;
ret = lp_load(lp_configfile(global_loadparm), NULL);
if (ret) {
unload_interfaces();
}

View File

@ -49,18 +49,19 @@ int main(int argc, const char **argv)
const char *fname;
struct MprVar *return_var;
int exit_status, i;
struct loadparm_context *lp_ctx;
fault_setup(argv[0]);
if (getenv("SMB_CONF_PATH")) {
lp_load(getenv("SMB_CONF_PATH"));
lp_load(getenv("SMB_CONF_PATH"), &lp_ctx);
} else {
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, &lp_ctx);
}
ldb_global_init();
gensec_init(global_loadparm);
gensec_init(lp_ctx);
mprSetCtx(mem_ctx);

View File

@ -2172,6 +2172,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int opt;
int i, username_count=0;
bool ret;
struct loadparm_context *lp_ctx;
setlinebuf(stdout);
@ -2196,12 +2197,12 @@ static bool split_unc_name(const char *unc, char **server, char **share)
argc -= NSERVERS;
argv += NSERVERS;
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, &lp_ctx);
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
servers[1].credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0].credentials, global_loadparm);
cli_credentials_guess(servers[1].credentials, global_loadparm);
cli_credentials_guess(servers[0].credentials, lp_ctx);
cli_credentials_guess(servers[1].credentials, lp_ctx);
options.seed = time(NULL);
options.numops = 1000;
@ -2265,7 +2266,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
}
}
gensec_init(global_loadparm);
gensec_init(lp_ctx);
if (username_count == 0) {
usage();

View File

@ -543,6 +543,7 @@ static void usage(void)
int opt;
int seed, server;
int username_count=0;
struct loadparm_context *lp_ctx;
setlinebuf(stdout);
@ -563,12 +564,12 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, &lp_ctx);
servers[0] = cli_credentials_init(talloc_autofree_context());
servers[1] = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0], global_loadparm);
cli_credentials_guess(servers[1], global_loadparm);
cli_credentials_guess(servers[0], lp_ctx);
cli_credentials_guess(servers[1], lp_ctx);
seed = time(NULL);
@ -617,10 +618,10 @@ static void usage(void)
exact_error_codes = true;
break;
case 'l':
lp_set_cmdline(global_loadparm, "torture:unclist", optarg);
lp_set_cmdline(lp_ctx, "torture:unclist", optarg);
break;
case 'W':
lp_set_cmdline(global_loadparm, "workgroup", optarg);
lp_set_cmdline(lp_ctx, "workgroup", optarg);
break;
case 'h':
usage();
@ -639,7 +640,7 @@ static void usage(void)
servers[1] = servers[0];
}
gensec_init(global_loadparm);
gensec_init(lp_ctx);
argc -= optind;
argv += optind;

View File

@ -460,6 +460,7 @@ static void usage(void)
int opt;
char *p;
int seed;
struct loadparm_context *lp_ctx;
setlinebuf(stdout);
@ -483,7 +484,7 @@ static void usage(void)
argc -= 4;
argv += 4;
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, &lp_ctx);
if (getenv("USER")) {
fstrcpy(username,getenv("USER"));

View File

@ -281,6 +281,7 @@ static void usage(void)
struct smbcli_state *cli;
int opt;
int seed;
struct loadparm_context *lp_ctx;
setlinebuf(stdout);
@ -302,10 +303,10 @@ static void usage(void)
argc -= 1;
argv += 1;
lp_load(dyn_CONFIGFILE);
lp_load(dyn_CONFIGFILE, &lp_ctx);
credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(credentials, global_loadparm);
cli_credentials_guess(credentials, lp_ctx);
seed = time(NULL);
@ -326,7 +327,7 @@ static void usage(void)
verbose++;
break;
case 'M':
lp_set_cmdline(global_loadparm, "max protocol", optarg);
lp_set_cmdline(lp_ctx, "max protocol", optarg);
break;
case 'U':
cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED);
@ -358,7 +359,7 @@ static void usage(void)
}
}
gensec_init(global_loadparm);
gensec_init(lp_ctx);
argc -= optind;
argv += optind;

View File

@ -184,6 +184,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c
static const char *cname;
static const char *caddr;
static bool show_defaults = false;
struct loadparm_context *lp_ctx;
struct poptOption long_options[] = {
POPT_AUTOHELP
@ -238,15 +239,15 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c
fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm));
if (!lp_load(lp_configfile(global_loadparm))) {
if (!lp_load(lp_configfile(global_loadparm), &lp_ctx)) {
fprintf(stderr,"Error loading services.\n");
return(1);
}
fprintf(stderr,"Loaded services file OK.\n");
ret = do_global_checks(global_loadparm);
ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name);
ret = do_global_checks(lp_ctx);
ret |= do_share_checks(lp_ctx, cname, caddr, silent_mode, show_defaults, section_name, parameter_name);
return(ret);
}