From 3dceaacca69dcfb3a2b76df5d272bdb988331f38 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Sep 2015 18:54:31 +0200 Subject: [PATCH] lib/param: fix hiding of FLAG_SYNONYM values BUG: https://bugzilla.samba.org/show_bug.cgi?id=11526 Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 25dcdc92709a46d87125bc454faae7cad43d6b71) --- lib/param/loadparm.c | 89 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 06a9e59..c26442a 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -2014,22 +2014,28 @@ void lpcfg_dump_globals(struct loadparm_context *lp_ctx, FILE *f, fprintf(f, "# Global parameters\n[global]\n"); - for (i = 0; parm_table[i].label; i++) - if (parm_table[i].p_class == P_GLOBAL && - (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { - if (!show_defaults) { - if (lp_ctx->flags && (lp_ctx->flags[i] & FLAG_DEFAULT)) { - continue; - } + for (i = 0; parm_table[i].label; i++) { + if (parm_table[i].p_class != P_GLOBAL) { + continue; + } - if (is_default(lp_ctx->globals, i)) { - continue; - } + if (parm_table[i].flags & FLAG_SYNONYM) { + continue; + } + + if (!show_defaults) { + if (lp_ctx->flags && (lp_ctx->flags[i] & FLAG_DEFAULT)) { + continue; + } + + if (is_default(lp_ctx->globals, i)) { + continue; } + } - fprintf(f, "\t%s = ", parm_table[i].label); - lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f); - fprintf(f, "\n"); + fprintf(f, "\t%s = ", parm_table[i].label); + lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f); + fprintf(f, "\n"); } if (lp_ctx->globals->param_opt != NULL) { for (data = lp_ctx->globals->param_opt; data; @@ -2057,34 +2063,45 @@ void lpcfg_dump_a_service(struct loadparm_service * pService, struct loadparm_se fprintf(f, "\n[%s]\n", pService->szService); for (i = 0; parm_table[i].label; i++) { - if (parm_table[i].p_class == P_LOCAL && - (*parm_table[i].label != '-') && - (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) - { - if (pService == sDefault) { - if (!show_defaults) { - if (flags && (flags[i] & FLAG_DEFAULT)) { - continue; - } + if (parm_table[i].p_class != P_LOCAL) { + continue; + } - if (is_default(sDefault, i)) { - continue; - } + if (parm_table[i].flags & FLAG_SYNONYM) { + continue; + } + + if (*parm_table[i].label == '-') { + continue; + } + + if (pService == sDefault) { + if (!show_defaults) { + if (flags && (flags[i] & FLAG_DEFAULT)) { + continue; } - } else { - if (lpcfg_equal_parameter(parm_table[i].type, - ((char *)pService) + - parm_table[i].offset, - ((char *)sDefault) + - parm_table[i].offset)) + + if (is_default(sDefault, i)) { continue; + } + } + } else { + bool equal; + + equal = lpcfg_equal_parameter(parm_table[i].type, + ((char *)pService) + + parm_table[i].offset, + ((char *)sDefault) + + parm_table[i].offset); + if (equal) { + continue; } - - fprintf(f, "\t%s = ", parm_table[i].label); - lpcfg_print_parameter(&parm_table[i], - ((char *)pService) + parm_table[i].offset, f); - fprintf(f, "\n"); } + + fprintf(f, "\t%s = ", parm_table[i].label); + lpcfg_print_parameter(&parm_table[i], + ((char *)pService) + parm_table[i].offset, f); + fprintf(f, "\n"); } if (pService->param_opt != NULL) { for (data = pService->param_opt; data; data = data->next) { -- 1.9.1