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

param: replace lp_set_cmdline in s3 helpers to store_cmdline

Change-Id: I9a6ac66eeb8e0dd9ba356f5201f7ac09784b476d
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Garming Sam
2014-02-28 12:53:32 +13:00
committed by Andrew Bartlett
parent 85f5f8648c
commit 39fb65e54c
5 changed files with 32 additions and 14 deletions

View File

@ -1701,16 +1701,19 @@ bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
while (isspace((unsigned char)*pszParmValue)) pszParmValue++; while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
if (lp_ctx->s3_fns) {
return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
}
parmnum = lpcfg_map_parameter(pszParmName); parmnum = lpcfg_map_parameter(pszParmName);
if (parmnum < 0 && strchr(pszParmName, ':')) { if (parmnum < 0 && strchr(pszParmName, ':')) {
/* set a parametric option */ /* set a parametric option */
return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, bool ok;
ok = lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
pszParmValue, FLAG_CMDLINE); pszParmValue, FLAG_CMDLINE);
if (lp_ctx->s3_fns != NULL) {
if (ok) {
lp_ctx->s3_fns->store_cmdline(pszParmName, pszParmValue);
}
}
return ok;
} }
if (parmnum < 0) { if (parmnum < 0) {
@ -1721,9 +1724,15 @@ bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
/* reset the CMDLINE flag in case this has been called before */ /* reset the CMDLINE flag in case this has been called before */
lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE; lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
if (lp_ctx->s3_fns != NULL) {
if (!lp_ctx->s3_fns->lp_do_parameter(-1, pszParmName, pszParmValue)) {
return false;
}
} else {
if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) { if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
return false; return false;
} }
}
lp_ctx->flags[parmnum] |= FLAG_CMDLINE; lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
@ -1742,6 +1751,10 @@ bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
lp_ctx->flags[i] |= FLAG_CMDLINE; lp_ctx->flags[i] |= FLAG_CMDLINE;
} }
if (lp_ctx->s3_fns != NULL) {
lp_ctx->s3_fns->store_cmdline(pszParmName, pszParmValue);
}
return true; return true;
} }

View File

@ -285,6 +285,7 @@ int getservicebyname(const char *, struct loadparm_service *);
bool lp_include(struct loadparm_context *, int, const char *, char **); bool lp_include(struct loadparm_context *, int, const char *, char **);
void init_printer_values(TALLOC_CTX *, struct loadparm_service *); void init_printer_values(TALLOC_CTX *, struct loadparm_service *);
bool lp_do_section(const char *pszSectionName, void *userdata); bool lp_do_section(const char *pszSectionName, void *userdata);
bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
int num_parameters(void); int num_parameters(void);

View File

@ -11,7 +11,7 @@ struct loadparm_s3_helpers
int (*getservicebyname)(const char *, struct loadparm_service *); int (*getservicebyname)(const char *, struct loadparm_service *);
int (*get_numservices)(void); int (*get_numservices)(void);
bool (*load)(const char *filename); bool (*load)(const char *filename);
bool (*set_cmdline)(const char *pszParmName, const char *pszParmValue); bool (*store_cmdline)(const char *pszParmName, const char *pszParmValue);
void (*dump)(FILE *f, bool show_defaults, int maxtoprint); void (*dump)(FILE *f, bool show_defaults, int maxtoprint);
char * (*lp_string)(TALLOC_CTX *ctx, const char *in); char * (*lp_string)(TALLOC_CTX *ctx, const char *in);
bool (*lp_string_set)(char **dest, const char *src); bool (*lp_string_set)(char **dest, const char *src);

View File

@ -579,7 +579,7 @@ static struct lp_stored_option *stored_options;
re-applied when we do a globals reset, so that cmdline set options re-applied when we do a globals reset, so that cmdline set options
are sticky across reloads of smb.conf are sticky across reloads of smb.conf
*/ */
static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue) bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
{ {
struct lp_stored_option *entry, *entry_next; struct lp_stored_option *entry, *entry_next;
for (entry = stored_options; entry != NULL; entry = entry_next) { for (entry = stored_options; entry != NULL; entry = entry_next) {
@ -2710,12 +2710,16 @@ bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
{ {
bool ret; bool ret;
TALLOC_CTX *frame = talloc_stackframe(); TALLOC_CTX *frame = talloc_stackframe();
struct loadparm_context *lp_ctx;
ret = lp_set_cmdline_helper(pszParmName, pszParmValue); lp_ctx = loadparm_init_s3(talloc_tos(), loadparm_s3_helpers());
if (ret) { if (lp_ctx == NULL) {
store_lp_set_cmdline(pszParmName, pszParmValue); DEBUG(0, ("loadparm_init_s3 failed\n"));
return false;
} }
ret = lpcfg_set_cmdline(lp_ctx, pszParmName, pszParmValue);
TALLOC_FREE(frame); TALLOC_FREE(frame);
return ret; return ret;
} }

View File

@ -66,7 +66,7 @@ static struct loadparm_s3_helpers s3_fns =
.get_default_loadparm_service = lp_default_loadparm_service, .get_default_loadparm_service = lp_default_loadparm_service,
.get_numservices = lp_numservices, .get_numservices = lp_numservices,
.load = lp_load_for_s4_ctx, .load = lp_load_for_s4_ctx,
.set_cmdline = lp_set_cmdline, .store_cmdline = store_lp_set_cmdline,
.dump = lp_dump, .dump = lp_dump,
.lp_string = lp_string, .lp_string = lp_string,
.lp_string_set = lp_string_set, .lp_string_set = lp_string_set,