s3-libsmb: move protos to libsmb/proto.h
[kai/samba.git] / libgpo / gpo_fetch.c
index b6d50ad852ca9fd5e96182da0bee033cd2d6322a..8c4c50803188008c428a98a660be4452d74645d9 100644 (file)
 #include "includes.h"
 #include "system/filesys.h"
 #include "../libgpo/gpo.h"
+#include "../libgpo/gpo_ini.h"
 
 #if _SAMBA_BUILD_ == 4
 #include "param/param.h"
 #include "libcli/resolve/resolve.h"
-#include "../lib/tevent/tevent.h"
+#include <tevent.h>
 #include "libcli/libcli.h"
 #include "libcli/raw/libcliraw.h"
 #include "libcli/libcli_proto.h"
 #include "libgpo/ads_convenience.h"
-#include "libgpo/gpo.h"
+#include "libgpo/gpo_s4.h"
+#include "lib/util/util.h"
+#else
+#include "libgpo/gpo_proto.h"
+#include "libsmb/libsmb.h"
 #endif
 
 /****************************************************************
@@ -37,7 +42,7 @@
 ****************************************************************/
 
 NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
-                                 const char *cache_path,
+                                 const char *cache_dir,
                                 const char *file_sys_path,
                                 char **server,
                                 char **service,
@@ -73,7 +78,7 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
 
        if ((path = talloc_asprintf(mem_ctx,
                                        "%s/%s",
-                                       cache_path,
+                                       cache_dir,
                                        file_sys_path)) == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -98,16 +103,16 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
 ****************************************************************/
 
 static NTSTATUS gpo_prepare_local_store(TALLOC_CTX *mem_ctx,
-                                        const char *cache_path,
+                                        const char *cache_dir,
                                        const char *unix_path)
 {
        char *current_dir;
        char *tok;
 
-       current_dir = talloc_strdup(mem_ctx, cache_path);
+       current_dir = talloc_strdup(mem_ctx, cache_dir);
        NT_STATUS_HAVE_NO_MEMORY(current_dir);
 
-       if ((mkdir(cache_path, 0644)) < 0 && errno != EEXIST) {
+       if ((mkdir(cache_dir, 0644)) < 0 && errno != EEXIST) {
                return NT_STATUS_ACCESS_DENIED;
        }
 
@@ -146,13 +151,12 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads, struct loadparm_context *lp_
                        ads->auth.password,
                        CLI_FULL_CONNECTION_USE_KERBEROS |
                        CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
-                       Undefined, NULL);
+                       Undefined);
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(10,("check_refresh_gpo: "
                                "failed to connect: %s\n",
                                nt_errstr(result)));
-                       return result;
-               }
+               return result;
        }
        *(struct cli_state **) ret_cli = cli;
 #else
@@ -172,7 +176,7 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads, struct loadparm_context *lp_
                        tevent_context_init(ads),
                        &options,
                        &session_options,
-                       lp_iconv_convenience(lp_ctx),
+                       lp_iconv_handle(lp_ctx),
                        lp_gensec_settings(ads, lp_ctx));
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(10,("failed to connect: %s\n",
@@ -191,7 +195,7 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads, struct loadparm_context *lp_
 NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
                          ADS_STRUCT *ads,
                          struct loadparm_context *lp_ctx,
-                         const char *cache_path,
+                         const char *cache_dir,
                         struct GROUP_POLICY_OBJECT *gpo)
 {
        NTSTATUS result;
@@ -204,16 +208,17 @@ NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
 #endif
 
 
-       result = gpo_explode_filesyspath(mem_ctx, cache_path, gpo->file_sys_path,
+       result = gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
                                         &server, &service, &nt_path,
                                         &unix_path);
        NT_STATUS_NOT_OK_RETURN(result);
 
 
        result = gpo_connect_server(ads, lp_ctx, server, service, &cli);
+       NT_STATUS_NOT_OK_RETURN(result);
 
 
-       result = gpo_prepare_local_store(mem_ctx, cache_path, unix_path);
+       result = gpo_prepare_local_store(mem_ctx, cache_dir, unix_path);
        NT_STATUS_NOT_OK_RETURN(result);
 
        unix_ini_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);