From: Günther Deschner Date: Sun, 11 Sep 2016 10:48:14 +0000 (+0200) Subject: libgpo: add gp_inifile_init_context_direct() X-Git-Tag: talloc-2.1.9~462 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c16dfe32532e06c7fe9fad6524ebef7d7378b76;p=thirdparty%2Fsamba.git libgpo: add gp_inifile_init_context_direct() This varient ignores the group policy flags and does not try to find the right unix path. Guenther Signed-off-by: Guenther Deschner Reviewed-by: Andreas Schneider --- diff --git a/libgpo/gpo_ini.c b/libgpo/gpo_ini.c index c0276122922..3ea8006d1e1 100644 --- a/libgpo/gpo_ini.c +++ b/libgpo/gpo_ini.c @@ -272,6 +272,59 @@ NTSTATUS gp_inifile_init_context(TALLOC_CTX *mem_ctx, return status; } +/**************************************************************** +****************************************************************/ + +NTSTATUS gp_inifile_init_context_direct(TALLOC_CTX *mem_ctx, + const char *unix_path, + struct gp_inifile_context **pgp_ctx) +{ + struct gp_inifile_context *gp_ctx = NULL; + NTSTATUS status; + int rv; + char *tmp_filename = NULL; + + if (unix_path == NULL || pgp_ctx == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + gp_ctx = talloc_zero(mem_ctx, struct gp_inifile_context); + if (gp_ctx == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = convert_file_from_ucs2(mem_ctx, unix_path, + &tmp_filename); + if (!NT_STATUS_IS_OK(status)) { + goto failed; + } + + rv = pm_process(tmp_filename, + change_section, + store_keyval_pair, + gp_ctx); + if (rv != 0) { + return NT_STATUS_NO_SUCH_FILE; + } + + gp_ctx->generated_filename = tmp_filename; + gp_ctx->mem_ctx = mem_ctx; + + *pgp_ctx = gp_ctx; + + return NT_STATUS_OK; + + failed: + + DEBUG(1,("gp_inifile_init_context_direct failed: %s\n", + nt_errstr(status))); + + talloc_free(gp_ctx); + + return status; +} + + /**************************************************************** parse the local gpt.ini file ****************************************************************/ diff --git a/libgpo/gpo_ini.h b/libgpo/gpo_ini.h index c9afec09784..b948a7a32d0 100644 --- a/libgpo/gpo_ini.h +++ b/libgpo/gpo_ini.h @@ -35,7 +35,9 @@ struct gp_inifile_context { 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 gp_inifile_init_context_direct(TALLOC_CTX *mem_ctx, + const char *unix_path, + struct gp_inifile_context **ctx_ret); NTSTATUS parse_gpt_ini(TALLOC_CTX *ctx, const char *filename, uint32_t *version,