]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
net conf: fix import to correctly add includes (at the end)
authorMichael Adam <obnox@samba.org>
Tue, 8 Apr 2008 23:20:36 +0000 (01:20 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 9 Apr 2008 23:29:02 +0000 (01:29 +0200)
Michael

source/utils/net_conf.c

index e2d88c019d3e375497897c8d6497dc6db8f36841..c01a326c640026ea65128ed10314c813f2842700 100644 (file)
@@ -127,6 +127,9 @@ static WERROR import_process_service(struct smbconf_ctx *conf_ctx,
 {
        uint32_t idx;
        WERROR werr = WERR_OK;
+       uint32_t num_includes = 0;
+       char **includes = NULL;
+       TALLOC_CTX *mem_ctx = talloc_stackframe();
 
        if (opt_testmode) {
                d_printf("[%s]\n", servicename);
@@ -148,17 +151,42 @@ static WERROR import_process_service(struct smbconf_ctx *conf_ctx,
                        d_printf("\t%s = %s\n", param_names[idx],
                                 param_values[idx]);
                } else {
-                       werr = smbconf_set_parameter(conf_ctx,
-                                                    servicename,
-                                                    param_names[idx],
-                                                    param_values[idx]);
-                       if (!W_ERROR_IS_OK(werr)) {
-                               goto done;
+                       if (strequal(param_names[idx], "include")) {
+                               includes = TALLOC_REALLOC_ARRAY(mem_ctx,
+                                                               includes,
+                                                               char *,
+                                                               num_includes+1);
+                               if (includes == NULL) {
+                                       werr = WERR_NOMEM;
+                                       goto done;
+                               }
+                               includes[num_includes] =
+                                       talloc_strdup(includes,
+                                                     param_values[idx]);
+                               if (includes[num_includes] == NULL) {
+                                       werr = WERR_NOMEM;
+                                       goto done;
+                               }
+                               num_includes++;
+                       } else {
+                               werr = smbconf_set_parameter(conf_ctx,
+                                                            servicename,
+                                                            param_names[idx],
+                                                            param_values[idx]);
+                               if (!W_ERROR_IS_OK(werr)) {
+                                       goto done;
+                               }
                        }
                }
        }
 
+       if (!opt_testmode) {
+               werr = smbconf_set_includes(conf_ctx, servicename, num_includes,
+                                           (const char **)includes);
+       }
+
 done:
+       TALLOC_FREE(mem_ctx);
        return werr;
 }