diff options
author | Wilco Baan Hofman <wilco@baanhofman.nl> | 2009-03-01 16:25:57 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-04-20 23:16:16 +0200 |
commit | 248554370af30f485a4088d0d5de675e77b2aa7b (patch) | |
tree | dfae2c73ebff165845714a5566a29f257efcc9c4 /libgpo | |
parent | c441b7dda8507b22a94146be0df77e54e623645a (diff) | |
download | samba-248554370af30f485a4088d0d5de675e77b2aa7b.tar.gz samba-248554370af30f485a4088d0d5de675e77b2aa7b.tar.bz2 samba-248554370af30f485a4088d0d5de675e77b2aa7b.zip |
Make gpo_ldap.c compatible with samba 4. Add ads_get_ldap_server_name() function to samba 3. Move prototypes to root libgpo where appropriate.
gpo_ldap.c now compiles for both samba 3 and 4.
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'libgpo')
-rw-r--r-- | libgpo/config.mk | 4 | ||||
-rw-r--r-- | libgpo/gpext/gpext.h | 40 | ||||
-rw-r--r-- | libgpo/gpo.h | 114 | ||||
-rw-r--r-- | libgpo/gpo_ldap.c | 27 | ||||
-rw-r--r-- | libgpo/gpo_util.c | 10 |
5 files changed, 178 insertions, 17 deletions
diff --git a/libgpo/config.mk b/libgpo/config.mk index 20901bf28c..9feb2f8a6d 100644 --- a/libgpo/config.mk +++ b/libgpo/config.mk @@ -1,4 +1,6 @@ [SUBSYSTEM::LIBGPO] +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 \ + $(libgpodir)/ads_convenience.o diff --git a/libgpo/gpext/gpext.h b/libgpo/gpext/gpext.h index a3f9368f69..98519f102a 100644 --- a/libgpo/gpext/gpext.h +++ b/libgpo/gpext/gpext.h @@ -83,4 +83,44 @@ struct gp_extension_methods { NTSTATUS (*shutdown)(void); }; +/* The following definitions come from libgpo/gpext/gpext.c */ + +struct gp_extension *get_gp_extension_list(void); +NTSTATUS unregister_gp_extension(const char *name); +NTSTATUS register_gp_extension(TALLOC_CTX *gpext_ctx, + int version, + const char *name, + const char *guid, + struct gp_extension_methods *methods); +NTSTATUS gp_ext_info_add_entry(TALLOC_CTX *mem_ctx, + const char *module, + const char *ext_guid, + struct gp_extension_reg_table *table, + struct gp_extension_reg_info *info); +NTSTATUS shutdown_gp_extensions(void); +NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx); +NTSTATUS free_gp_extensions(void); +void debug_gpext_header(int lvl, + const char *name, + uint32_t flags, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid); +NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo_list, + const char *extension_guid, + const char *snapin_guid); +NTSTATUS gpext_process_extension(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + const struct nt_user_token *token, + struct registry_key *root_key, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid); + + #endif /* __GPEXT_H__ */ diff --git a/libgpo/gpo.h b/libgpo/gpo.h index c34dc4c750..7d89d04917 100644 --- a/libgpo/gpo.h +++ b/libgpo/gpo.h @@ -20,6 +20,10 @@ #ifndef __GPO_H__ #define __GPO_H__ +#if _SAMBA_BUILD_ == 4 +#include "source4/libgpo/ads_convenience.h" +#endif + enum GPO_LINK_TYPE { GP_LINK_UNKOWN = 0, GP_LINK_MACHINE = 1, @@ -160,6 +164,116 @@ struct gp_registry_context { #define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939" +struct cli_state; + +/* The following definitions come from libgpo/gpo_fetch.c */ + +NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx, + const char *file_sys_path, + char **server, + char **service, + char **nt_path, + char **unix_path); +NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + struct GROUP_POLICY_OBJECT *gpo); +NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx, + const char *unix_path, + uint32_t *sysvol_version, + char **display_name); + +/* The following definitions come from libgpo/gpo_ldap.c */ + +bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, + const char *extension_raw, + struct GP_EXT **gp_ext); +ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *link_dn, + struct GP_LINK *gp_link_struct); +ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *link_dn, + const char *gpo_dn, + uint32_t gpo_opt); +ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *link_dn, + const char *gpo_dn); +ADS_STATUS ads_get_gpo(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *gpo_dn, + const char *display_name, + const char *guid_name, + struct GROUP_POLICY_OBJECT *gpo); +ADS_STATUS ads_get_sid_token(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *dn, + struct nt_user_token **token); +ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *dn, + uint32_t flags, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT **gpo_list); + +/* The following definitions come from libgpo/gpo_sec.c */ + +NTSTATUS gpo_apply_security_filtering(const struct GROUP_POLICY_OBJECT *gpo, + const struct nt_user_token *token); + +/* The following definitions come from libgpo/gpo_util.c */ + +const char *cse_gpo_guid_string_to_name(const char *guid); +const char *cse_gpo_name_to_guid_string(const char *name); +const char *cse_snapin_gpo_guid_string_to_name(const char *guid); +void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel); +void dump_gpo(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + struct GROUP_POLICY_OBJECT *gpo, + int debuglevel); +void dump_gpo_list(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + struct GROUP_POLICY_OBJECT *gpo_list, + int debuglevel); +void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link); +ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const struct nt_user_token *token, + struct registry_key *root_key, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid_filter, + uint32_t flags); +ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo_list, + const char *extensions_guid_filter, + uint32_t flags); +NTSTATUS check_refresh_gpo(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + struct GROUP_POLICY_OBJECT *gpo, + struct cli_state **cli_out); +NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + struct GROUP_POLICY_OBJECT *gpo_list); +NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx, + struct GROUP_POLICY_OBJECT *gpo, + char **unix_path); +char *gpo_flag_str(uint32_t flags); +NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, + uint32_t flags, + const char *filename, + const char *suffix, + const char **filename_out); +ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *dn, + struct nt_user_token **token); + + #include "../libgpo/gpext/gpext.h" #endif diff --git a/libgpo/gpo_ldap.c b/libgpo/gpo_ldap.c index 788d6887a3..16c551ebab 100644 --- a/libgpo/gpo_ldap.c +++ b/libgpo/gpo_ldap.c @@ -19,6 +19,7 @@ #include "includes.h" #if _SAMBA_BUILD_ == 4 +#include "libgpo/gpo.h" #include "source4/libgpo/ads_convenience.h" #endif @@ -42,12 +43,12 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, DEBUG(20,("ads_parse_gp_ext: %s\n", extension_raw)); - ext = TALLOC_ZERO_P(mem_ctx, struct GP_EXT); + ext = talloc_zero(mem_ctx, struct GP_EXT); if (!ext) { goto parse_error; } - ext_list = str_list_make_v3(mem_ctx, extension_raw, "]"); + ext_list = str_list_make(mem_ctx, extension_raw, "]"); if (!ext_list) { goto parse_error; } @@ -59,13 +60,13 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, ext->num_exts = i; if (ext->num_exts) { - ext->extensions = TALLOC_ZERO_ARRAY(mem_ctx, char *, + ext->extensions = talloc_zero_array(mem_ctx, char *, ext->num_exts); - ext->extensions_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, + ext->extensions_guid = talloc_zero_array(mem_ctx, char *, ext->num_exts); - ext->snapins = TALLOC_ZERO_ARRAY(mem_ctx, char *, + ext->snapins = talloc_zero_array(mem_ctx, char *, ext->num_exts); - ext->snapins_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, + ext->snapins_guid = talloc_zero_array(mem_ctx, char *, ext->num_exts); } @@ -90,7 +91,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, p++; } - ext_strings = str_list_make_v3(mem_ctx, p, "}"); + ext_strings = str_list_make(mem_ctx, p, "}"); if (ext_strings == NULL) { goto parse_error; } @@ -140,8 +141,8 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, ret = true; parse_error: - TALLOC_FREE(ext_list); - TALLOC_FREE(ext_strings); + talloc_free(ext_list); + talloc_free(ext_strings); return ret; } @@ -178,9 +179,9 @@ static ADS_STATUS gpo_parse_gplink(TALLOC_CTX *mem_ctx, gp_link->num_links = i; if (gp_link->num_links) { - gp_link->link_names = TALLOC_ZERO_ARRAY(mem_ctx, char *, + gp_link->link_names = talloc_zero_array(mem_ctx, char *, gp_link->num_links); - gp_link->link_opts = TALLOC_ZERO_ARRAY(mem_ctx, uint32_t, + gp_link->link_opts = talloc_zero_array(mem_ctx, uint32_t, gp_link->num_links); } @@ -225,7 +226,7 @@ static ADS_STATUS gpo_parse_gplink(TALLOC_CTX *mem_ctx, status = ADS_SUCCESS; parse_error: - TALLOC_FREE(link_list); + talloc_free(link_list); return status; } @@ -595,7 +596,7 @@ static ADS_STATUS add_gplink_to_gpo_list(ADS_STRUCT *ads, DEBUG(10,("skipping GPO \"%s\" as object " "has no access to it\n", new_gpo->display_name)); - TALLOC_FREE(new_gpo); + talloc_free(new_gpo); continue; } diff --git a/libgpo/gpo_util.c b/libgpo/gpo_util.c index d5e3f24c8d..9bfb353dad 100644 --- a/libgpo/gpo_util.c +++ b/libgpo/gpo_util.c @@ -18,7 +18,11 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_misc.h" +#if _SAMBA_BUILD_ == 4 #include "../libgpo/gpo.h" +#include "source4/libgpo/ads_convenience.h" +#endif #undef strdup #define DEFAULT_DOMAIN_POLICY "Default Domain Policy" @@ -601,7 +605,7 @@ ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads, done: gp_free_reg_ctx(reg_ctx); - TALLOC_FREE(root_key); + talloc_free(root_key); free_gp_extensions(); return status; @@ -660,7 +664,7 @@ NTSTATUS check_refresh_gpo(ADS_STRUCT *ads, result = cli_full_connection(&cli, global_myname(), - ads->config.ldap_server_name, + ads_get_ldap_server_name(ads), /* server */ NULL, 0, share, "A:", @@ -834,7 +838,7 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, path, suffix); NT_STATUS_HAVE_NO_MEMORY(tmp); - if (sys_stat(tmp, &sbuf) == 0) { + if (stat(tmp, &sbuf) == 0) { *filename_out = tmp; return NT_STATUS_OK; } |