diff options
author | Garming Sam <garming@catalyst.net.nz> | 2014-02-20 10:24:00 +1300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-05-07 19:49:15 +0200 |
commit | ef3d445d8836a7f02ba4fc8f4b5381763583894b (patch) | |
tree | d1461dc8957dba3114ded58ae6288fec3d9f3751 /lib/param/loadparm.c | |
parent | c3c8f4fe9cf6411d8a14f54ef0d273f07ed42bbf (diff) | |
download | samba-ef3d445d8836a7f02ba4fc8f4b5381763583894b.tar.gz samba-ef3d445d8836a7f02ba4fc8f4b5381763583894b.tar.xz samba-ef3d445d8836a7f02ba4fc8f4b5381763583894b.zip |
param: consolidate handle_copy method between the two loadparms
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/param/loadparm.c')
-rw-r--r-- | lib/param/loadparm.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index fc5829379ee..aaf905d8f46 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -98,8 +98,6 @@ static bool defaults_saved = false; /* prototypes for the special type handlers */ static bool handle_include(struct loadparm_context *lp_ctx, int unused, const char *pszParmValue, char **ptr); -static bool handle_copy(struct loadparm_context *lp_ctx, int unused, - const char *pszParmValue, char **ptr); #include "lib/param/param_table.c" @@ -1133,27 +1131,38 @@ static bool handle_include(struct loadparm_context *lp_ctx, int unused, Handle the interpretation of the copy parameter. ***************************************************************************/ -static bool handle_copy(struct loadparm_context *lp_ctx, int unused, +bool handle_copy(struct loadparm_context *lp_ctx, int snum, const char *pszParmValue, char **ptr) { bool bRetval; - struct loadparm_service *serviceTemp; - - lpcfg_string_set(lp_ctx, ptr, pszParmValue); + struct loadparm_service *serviceTemp = NULL; + struct loadparm_service *current = NULL; bRetval = false; DEBUG(3, ("Copying service from service %s\n", pszParmValue)); serviceTemp = lpcfg_getservicebyname(lp_ctx, pszParmValue); + if (lp_ctx->s3_fns != NULL) { + current = lp_ctx->s3_fns->get_servicebynum(snum); + } else { + current = lp_ctx->currentService; + } + + if (current == NULL) { + DEBUG(0, ("Unable to copy service - invalid service destination")); + return false; + } if (serviceTemp != NULL) { - if (serviceTemp == lp_ctx->currentService) { + if (serviceTemp == current) { DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue)); } else { - copy_service(lp_ctx->currentService, + copy_service(current, serviceTemp, - lp_ctx->currentService->copymap); + current->copymap); + lpcfg_string_set(current, ptr, pszParmValue); + bRetval = true; } } else { |