Fix ini parsing in the s3 gpext modules. Fix ini parser API. Make the build work
authorWilco Baan Hofman <wilco@baanhofman.nl>
Mon, 20 Apr 2009 14:51:33 +0000 (16:51 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 20 Apr 2009 21:16:17 +0000 (23:16 +0200)
Signed-off-by: Günther Deschner <gd@samba.org>
libgpo/config.mk
libgpo/gpo_fetch.c
libgpo/gpo_ini.c
libgpo/gpo_ini.h
source3/Makefile.in
source3/libgpo/gpext/scripts.c
source3/libgpo/gpext/security.c

index a9ad76c..6472d16 100644 (file)
@@ -2,5 +2,6 @@
 PRIVATE_DEPENDENCIES = LIBLDB LIBSAMBA-NET
 
 LIBGPO_OBJ_FILES = ../libgpo/gpo_util.o ../libgpo/gpo_sec.o \
-                                  ../libgpo/gpext/gpext.o ../libgpo/gpo_fetch.o \
+                                  ../libgpo/gpext/gpext.o \
+                                  ../libgpo/gpo_fetch.o ../libgpo/gpo_ini.o \
                        $(libgpodir)/ads_convenience.o $(libgpodir)/gpo_filesync.o
index a5714f7..beedfc2 100644 (file)
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "../libgpo/gpo.h"
+#include "../libgpo/gpo_ini.h"
 
 #if _SAMBA_BUILD_ == 4
 #include "param/param.h"
index 79bf5fd..af2b88c 100644 (file)
@@ -169,6 +169,7 @@ NTSTATUS gp_inifile_init_context(TALLOC_CTX *mem_ctx,
 {
        struct gp_inifile_context *ctx = NULL;
        NTSTATUS status;
+       int rv;
        char *tmp_filename = NULL;
        const char *ini_filename = NULL;
 
@@ -192,6 +193,12 @@ NTSTATUS gp_inifile_init_context(TALLOC_CTX *mem_ctx,
                goto failed;
        }
 
+       rv = pm_process(tmp_filename, change_section, store_keyval_pair, ctx);
+       if (!rv) {
+               return NT_STATUS_NO_SUCH_FILE;
+       }
+
+
        ctx->generated_filename = tmp_filename;
        ctx->mem_ctx = mem_ctx;
 
@@ -217,7 +224,7 @@ NTSTATUS gp_inifile_init_context(TALLOC_CTX *mem_ctx,
 #define GPT_INI_PARAMETER_VERSION "Version"
 #define GPT_INI_PARAMETER_DISPLAYNAME "displayName"
 
-NTSTATUS parse_gpt_ini(struct gp_inifile_context *ctx,
+NTSTATUS parse_gpt_ini(TALLOC_CTX *mem_ctx,
                       const char *filename,
                       uint32_t *version,
                       char **display_name)
@@ -226,12 +233,16 @@ NTSTATUS parse_gpt_ini(struct gp_inifile_context *ctx,
        int rv;
        int v = 0;
        char *name = NULL;
+       struct gp_inifile_context *ctx;
 
        if (!filename) {
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       rv = pm_process(filename, change_section, store_keyval_pair, NULL);
+       ctx = talloc_zero(mem_ctx, struct gp_inifile_context);
+       NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+       rv = pm_process(filename, change_section, store_keyval_pair, ctx);
        if (!rv) {
                return NT_STATUS_NO_SUCH_FILE;
        }
@@ -263,7 +274,7 @@ NTSTATUS parse_gpt_ini(struct gp_inifile_context *ctx,
                *version = v;
        }
 
-       result = NT_STATUS_OK;
+       talloc_free(ctx);
 
-       return result;
+       return NT_STATUS_OK;
 }
index 20588b6..02ca0ff 100644 (file)
@@ -36,7 +36,7 @@ NTSTATUS gp_inifile_init_context(TALLOC_CTX *mem_ctx, uint32_t flags,
                                 const char *unix_path, const char *suffix,
                                 struct gp_inifile_context **ctx_ret);
 
-NTSTATUS parse_gpt_ini(struct gp_inifile_context *ctx,
+NTSTATUS parse_gpt_ini(TALLOC_CTX *ctx,
                       const char *filename,
                       uint32_t *version,
                       char **display_name);
index ccb5a6e..51a469b 100644 (file)
@@ -411,7 +411,7 @@ LIBADDNS_OBJ = $(LIBADDNS_OBJ0) $(SOCKET_WRAPPER_OBJ)
 
 GPEXT_OBJ = ../libgpo/gpext/gpext.o @GPEXT_STATIC@
 
-LIBGPO_OBJ0 = ../libgpo/gpo_ldap.o libgpo/gpo_ini.o ../libgpo/gpo_util.o \
+LIBGPO_OBJ0 = ../libgpo/gpo_ldap.o ../libgpo/gpo_ini.o ../libgpo/gpo_util.o \
              ../libgpo/gpo_fetch.o libgpo/gpo_filesync.o ../libgpo/gpo_sec.o \
              libgpo/gpo_reg.o \
              $(GPEXT_OBJ)
index ddea35c..4ced3ab 100644 (file)
@@ -124,6 +124,7 @@ static NTSTATUS scripts_parse_ini_section(struct gp_inifile_context *ini_ctx,
                                          size_t *num_entries)
 {
        NTSTATUS status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       NTSTATUS result;
        int i = 0;
 
        while (1) {
@@ -141,8 +142,8 @@ static NTSTATUS scripts_parse_ini_section(struct gp_inifile_context *ini_ctx,
                                      GP_SCRIPTS_SECTION_CMDLINE);
                NT_STATUS_HAVE_NO_MEMORY(key);
 
-               script = iniparser_getstring(ini_ctx->dict, key, NULL);
-               if (!script) {
+               result = gp_inifile_getstring(ini_ctx, key, &script);
+               if (!NT_STATUS_IS_OK(result)) {
                        break;
                }
 
@@ -151,7 +152,10 @@ static NTSTATUS scripts_parse_ini_section(struct gp_inifile_context *ini_ctx,
                                      GP_SCRIPTS_SECTION_PARAMETERS);
                NT_STATUS_HAVE_NO_MEMORY(key);
 
-               parameters = iniparser_getstring(ini_ctx->dict, key, NULL);
+               result = gp_inifile_getstring(ini_ctx, key, &parameters);
+               if (!NT_STATUS_IS_OK(result)) {
+                       break;
+               }
 
                {
                        struct gp_registry_entry *entry = NULL;
index 6aeb354..8adeb59 100644 (file)
@@ -56,27 +56,30 @@ struct gpttmpl_table {
 #define GPTTMPL_VALUE_CHICAGO "$CHICAGO$" /* whatever this is good for... */
 #define GPTTMPL_PARAMETER_UNICODE "Unicode"
 
-static NTSTATUS gpttmpl_parse_header(dictionary *dict,
+static NTSTATUS gpttmpl_parse_header(struct gp_inifile_context *ini_ctx,
                                     uint32_t *version_out)
 {
        const char *signature = NULL;
+       NTSTATUS result;
        uint32_t version;
+       int is_unicode;
 
-       if (!dict) {
+       if (!ini_ctx) {
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if ((signature = iniparser_getstring(dict, GPTTMPL_SECTION_VERSION
-                       ":"GPTTMPL_PARAMETER_SIGNATURE, NULL)) == NULL) {
+       result = gp_inifile_getstring(ini_ctx, GPTTMPL_SECTION_VERSION
+                       ":"GPTTMPL_PARAMETER_SIGNATURE, &signature);
+       if (!NT_STATUS_IS_OK(result)) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
        if (!strequal(signature, GPTTMPL_VALUE_CHICAGO)) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
-
-       if ((version = iniparser_getint(dict, GPTTMPL_SECTION_VERSION
-                       ":"GPTTMPL_PARAMETER_REVISION, Undefined)) == Undefined) {
+       result = gp_inifile_getint(ini_ctx, GPTTMPL_SECTION_VERSION
+                       ":"GPTTMPL_PARAMETER_REVISION, &version);
+       if (!NT_STATUS_IS_OK(result))
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
@@ -84,9 +87,9 @@ static NTSTATUS gpttmpl_parse_header(dictionary *dict,
                *version_out = version;
        }
 
-       /* treat that as boolean */
-       if ((!iniparser_getboolean(dict, GPTTMPL_SECTION_UNICODE
-                       ":"GPTTMPL_PARAMETER_UNICODE, Undefined)) == Undefined) {
+       result = gp_inifile_getint(ini_ctx, GPTTMPL_SECTION_UNICODE
+                       ":"GPTTMPL_PARAMETER_UNICODE, is_unicode);
+       if (!NT_STATUS_IS_OK(result) || !is_unicode) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
@@ -109,7 +112,7 @@ static NTSTATUS gpttmpl_init_context(TALLOC_CTX *mem_ctx,
                                         GPTTMPL_UNIX_PATH, &tmp_ctx);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       status = gpttmpl_parse_header(tmp_ctx->dict, &version);
+       status = gpttmpl_parse_header(tmp_ctx, &version);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1,("gpttmpl_init_context: failed: %s\n",
                        nt_errstr(status)));