Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/libgpo/gpext
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/libgpo/gpext/gpext.c

    r740 r988  
    2424#include "lib/util/dlinklist.h"
    2525#include "../libcli/registry/util_reg.h"
    26 #if _SAMBA_BUILD_ == 3
    2726#include "libgpo/gpo_proto.h"
    2827#include "registry.h"
    2928#include "registry/reg_api.h"
    30 #endif
    3129
    3230static struct gp_extension *extensions = NULL;
     
    3533****************************************************************/
    3634
    37 struct gp_extension *get_gp_extension_list(void)
     35struct gp_extension *gpext_get_gp_extension_list(void)
    3836{
    3937        return extensions;
     
    104102****************************************************************/
    105103
    106 NTSTATUS unregister_gp_extension(const char *name)
     104NTSTATUS gpext_unregister_gp_extension(const char *name)
    107105{
    108106        struct gp_extension *ext;
     
    124122****************************************************************/
    125123
    126 NTSTATUS register_gp_extension(TALLOC_CTX *gpext_ctx,
    127                                int version,
    128                                const char *name,
    129                                const char *guid,
    130                                struct gp_extension_methods *methods)
     124NTSTATUS gpext_register_gp_extension(TALLOC_CTX *gpext_ctx,
     125                                     int version,
     126                                     const char *name,
     127                                     const char *guid,
     128                                     struct gp_extension_methods *methods)
    131129{
    132130        struct gp_extension_methods *test;
     
    343341****************************************************************/
    344342
    345 NTSTATUS gp_ext_info_add_entry(TALLOC_CTX *mem_ctx,
    346                                const char *module,
    347                                const char *ext_guid,
    348                                struct gp_extension_reg_table *table,
    349                                struct gp_extension_reg_info *info)
     343NTSTATUS gpext_info_add_entry(TALLOC_CTX *mem_ctx,
     344                              const char *module,
     345                              const char *ext_guid,
     346                              struct gp_extension_reg_table *table,
     347                              struct gp_extension_reg_info *info)
    350348{
    351349        NTSTATUS status;
    352350        struct gp_extension_reg_info_entry *entry = NULL;
    353351
    354         entry = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info_entry);
     352        entry = talloc_zero(mem_ctx, struct gp_extension_reg_info_entry);
    355353        NT_STATUS_HAVE_NO_MEMORY(entry);
    356354
     
    443441        W_ERROR_HAVE_NO_MEMORY(subkeyname);
    444442
    445         strupper_m(CONST_DISCARD(char *,subkeyname));
     443        if (!strupper_m(discard_const_p(char, subkeyname))) {
     444                return WERR_INVALID_PARAM;
     445        }
    446446
    447447        werr = gp_store_reg_subkey(mem_ctx,
     
    490490                                 size_t *ext_list_len)
    491491{
    492         SMB_STRUCT_DIR *dir = NULL;
    493         SMB_STRUCT_DIRENT *dirent = NULL;
    494 
    495         dir = sys_opendir(modules_path(SAMBA_SUBSYSTEM_GPEXT));
     492        DIR *dir = NULL;
     493        struct dirent *dirent = NULL;
     494
     495        dir = opendir(modules_path(talloc_tos(),
     496                                       SAMBA_SUBSYSTEM_GPEXT));
    496497        if (!dir) {
    497                 return map_nt_error_from_unix(errno);
    498         }
    499 
    500         while ((dirent = sys_readdir(dir))) {
     498                return map_nt_error_from_unix_common(errno);
     499        }
     500
     501        while ((dirent = readdir(dir))) {
    501502
    502503                fstring name; /* forgive me... */
     
    510511                p = strrchr(dirent->d_name, '.');
    511512                if (!p) {
    512                         sys_closedir(dir);
     513                        closedir(dir);
    513514                        return NT_STATUS_NO_MEMORY;
    514515                }
     
    524525
    525526                if (!add_string_to_array(mem_ctx, name, ext_list,
    526                                          (int *)ext_list_len)) {
    527                         sys_closedir(dir);
     527                                         ext_list_len)) {
     528                        closedir(dir);
    528529                        return NT_STATUS_NO_MEMORY;
    529530                }
    530531        }
    531532
    532         sys_closedir(dir);
     533        closedir(dir);
    533534
    534535        return NT_STATUS_OK;
     
    538539****************************************************************/
    539540
    540 NTSTATUS shutdown_gp_extensions(void)
     541NTSTATUS gpext_shutdown_gp_extensions(void)
    541542{
    542543        struct gp_extension *ext = NULL;
     
    554555****************************************************************/
    555556
    556 NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx)
     557NTSTATUS gpext_init_gp_extensions(TALLOC_CTX *mem_ctx)
    557558{
    558559        NTSTATUS status;
     
    564565        struct gp_registry_context *reg_ctx = NULL;
    565566
    566         if (get_gp_extension_list()) {
     567        if (gpext_get_gp_extension_list()) {
    567568                return NT_STATUS_OK;
    568569        }
     
    637638****************************************************************/
    638639
    639 NTSTATUS free_gp_extensions(void)
     640NTSTATUS gpext_free_gp_extensions(void)
    640641{
    641642        struct gp_extension *ext, *ext_next = NULL;
     
    655656****************************************************************/
    656657
    657 void debug_gpext_header(int lvl,
     658void gpext_debug_header(int lvl,
    658659                        const char *name,
    659660                        uint32_t flags,
    660                         struct GROUP_POLICY_OBJECT *gpo,
     661                        const struct GROUP_POLICY_OBJECT *gpo,
    661662                        const char *extension_guid,
    662663                        const char *snapin_guid)
     
    678679}
    679680
    680 NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads,
    681                            TALLOC_CTX *mem_ctx,
    682                            uint32_t flags,
    683                            const struct security_token *token,
    684                            struct GROUP_POLICY_OBJECT *gpo_list,
    685                            const char *extension_guid,
    686                            const char *snapin_guid)
    687 {
     681/****************************************************************
     682****************************************************************/
     683
     684static NTSTATUS gpext_check_gpo_for_gpext_presence(TALLOC_CTX *mem_ctx,
     685                                                   uint32_t flags,
     686                                                   const struct GROUP_POLICY_OBJECT *gpo,
     687                                                   const struct GUID *guid,
     688                                                   bool *gpext_guid_present)
     689{
     690        struct GP_EXT *gp_ext = NULL;
     691        int i;
     692        bool ok;
     693
     694        *gpext_guid_present = false;
     695
     696
     697        if (gpo->link_type == GP_LINK_LOCAL) {
     698                return NT_STATUS_OK;
     699        }
     700
     701        ok = gpo_get_gp_ext_from_gpo(mem_ctx, flags, gpo, &gp_ext);
     702        if (!ok) {
     703                return NT_STATUS_INVALID_PARAMETER;
     704        }
     705
     706        if (gp_ext == NULL) {
     707                return NT_STATUS_OK;
     708        }
     709
     710        for (i = 0; i < gp_ext->num_exts; i++) {
     711                struct GUID guid2;
     712                NTSTATUS status;
     713
     714                status = GUID_from_string(gp_ext->extensions_guid[i], &guid2);
     715                if (!NT_STATUS_IS_OK(status)) {
     716                        return status;
     717                }
     718                if (GUID_equal(guid, &guid2)) {
     719                        *gpext_guid_present = true;
     720                        return NT_STATUS_OK;
     721                }
     722        }
     723
    688724        return NT_STATUS_OK;
    689725}
     
    692728****************************************************************/
    693729
    694 NTSTATUS gpext_process_extension(ADS_STRUCT *ads,
    695                                  TALLOC_CTX *mem_ctx,
     730NTSTATUS gpext_process_extension(TALLOC_CTX *mem_ctx,
    696731                                 uint32_t flags,
    697732                                 const struct security_token *token,
    698733                                 struct registry_key *root_key,
    699                                  struct GROUP_POLICY_OBJECT *gpo,
    700                                  const char *extension_guid,
    701                                  const char *snapin_guid)
     734                                 const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
     735                                 const struct GROUP_POLICY_OBJECT *changed_gpo_list,
     736                                 const char *extension_guid_filter)
    702737{
    703738        NTSTATUS status;
    704739        struct gp_extension *ext = NULL;
    705         struct GUID guid;
    706         bool cse_found = false;
    707 
    708         status = init_gp_extensions(mem_ctx);
     740        const struct GROUP_POLICY_OBJECT *gpo;
     741        struct GUID extension_guid_filter_guid;
     742
     743        status = gpext_init_gp_extensions(mem_ctx);
    709744        if (!NT_STATUS_IS_OK(status)) {
    710                 DEBUG(1,("init_gp_extensions failed: %s\n",
     745                DEBUG(1,("gpext_init_gp_extensions failed: %s\n",
    711746                        nt_errstr(status)));
    712747                return status;
    713748        }
    714749
    715         status = GUID_from_string(extension_guid, &guid);
    716         if (!NT_STATUS_IS_OK(status)) {
    717                 return status;
     750        if (extension_guid_filter) {
     751                status = GUID_from_string(extension_guid_filter,
     752                                          &extension_guid_filter_guid);
     753                if (!NT_STATUS_IS_OK(status)) {
     754                        return status;
     755                }
    718756        }
    719757
    720758        for (ext = extensions; ext; ext = ext->next) {
    721759
    722                 if (GUID_equal(ext->guid, &guid)) {
    723                         cse_found = true;
    724                         break;
    725                 }
    726         }
    727 
    728         if (!cse_found) {
    729                 goto no_ext;
    730         }
    731 
    732         status = ext->methods->initialize(mem_ctx);
    733         NT_STATUS_NOT_OK_RETURN(status);
    734 
    735         status = ext->methods->process_group_policy(ads,
    736                                                     mem_ctx,
    737                                                     flags,
    738                                                     root_key,
    739                                                     token,
    740                                                     gpo,
    741                                                     extension_guid,
    742                                                     snapin_guid);
    743         if (!NT_STATUS_IS_OK(status)) {
    744                 ext->methods->shutdown();
     760                struct GROUP_POLICY_OBJECT *deleted_gpo_list_filtered = NULL;
     761                struct GROUP_POLICY_OBJECT *changed_gpo_list_filtered = NULL;
     762
     763                if (extension_guid_filter) {
     764                        if (!GUID_equal(&extension_guid_filter_guid, ext->guid)) {
     765                                continue;
     766                        }
     767                }
     768
     769                for (gpo = deleted_gpo_list; gpo; gpo = gpo->next) {
     770
     771                        bool is_present = false;
     772
     773                        status = gpext_check_gpo_for_gpext_presence(mem_ctx,
     774                                                                    flags,
     775                                                                    gpo,
     776                                                                    ext->guid,
     777                                                                    &is_present);
     778                        if (!NT_STATUS_IS_OK(status)) {
     779                                return status;
     780                        }
     781
     782                        if (is_present) {
     783                                struct GROUP_POLICY_OBJECT *new_gpo;
     784
     785                                status = gpo_copy(mem_ctx, gpo, &new_gpo);
     786                                if (!NT_STATUS_IS_OK(status)) {
     787                                        return status;
     788                                }
     789
     790                                DLIST_ADD(deleted_gpo_list_filtered, new_gpo);
     791                        }
     792                }
     793
     794                for (gpo = changed_gpo_list; gpo; gpo = gpo->next) {
     795
     796                        bool is_present = false;
     797
     798                        status = gpext_check_gpo_for_gpext_presence(mem_ctx,
     799                                                                    flags,
     800                                                                    gpo,
     801                                                                    ext->guid,
     802                                                                    &is_present);
     803                        if (!NT_STATUS_IS_OK(status)) {
     804                                return status;
     805                        }
     806
     807                        if (is_present) {
     808                                struct GROUP_POLICY_OBJECT *new_gpo;
     809
     810                                status = gpo_copy(mem_ctx, gpo, &new_gpo);
     811                                if (!NT_STATUS_IS_OK(status)) {
     812                                        return status;
     813                                }
     814
     815                                DLIST_ADD(changed_gpo_list_filtered, new_gpo);
     816                        }
     817                }
     818
     819                status = ext->methods->initialize(mem_ctx);
     820                NT_STATUS_NOT_OK_RETURN(status);
     821
     822                status = ext->methods->process_group_policy(mem_ctx,
     823                                                            flags,
     824                                                            root_key,
     825                                                            token,
     826                                                            deleted_gpo_list_filtered,
     827                                                            changed_gpo_list_filtered);
     828                if (!NT_STATUS_IS_OK(status)) {
     829                        ext->methods->shutdown();
     830                }
    745831        }
    746832
    747833        return status;
    748 
    749  no_ext:
    750         if (flags & GPO_INFO_FLAG_VERBOSE) {
    751                 DEBUG(0,("process_extension: no extension available for:\n"));
    752                 DEBUGADD(0,("%s (%s) (snapin: %s)\n",
    753                         extension_guid,
    754                         cse_gpo_guid_string_to_name(extension_guid),
    755                         snapin_guid));
    756         }
    757 
    758         return NT_STATUS_OK;
    759 }
     834}
  • vendor/current/libgpo/gpext/gpext.h

    r740 r988  
    6262        NTSTATUS (*initialize)(TALLOC_CTX *mem_ctx);
    6363
    64         NTSTATUS (*process_group_policy)(ADS_STRUCT *ads,
    65                                          TALLOC_CTX *mem_ctx,
     64        NTSTATUS (*process_group_policy)(TALLOC_CTX *mem_ctx,
    6665                                         uint32_t flags,
    6766                                         struct registry_key *root_key,
    6867                                         const struct security_token *token,
    69                                          struct GROUP_POLICY_OBJECT *gpo,
    70                                          const char *extension_guid,
    71                                          const char *snapin_guid);
    72 
    73         NTSTATUS (*process_group_policy2)(ADS_STRUCT *ads,
    74                                          TALLOC_CTX *mem_ctx,
    75                                          uint32_t flags,
    76                                          const struct security_token *token,
    77                                          struct GROUP_POLICY_OBJECT *gpo_list,
    78                                          const char *extension_guid);
     68                                         const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
     69                                         const struct GROUP_POLICY_OBJECT *changed_gpo_list);
    7970
    8071        NTSTATUS (*get_reg_config)(TALLOC_CTX *mem_ctx,
     
    8677/* The following definitions come from libgpo/gpext/gpext.c  */
    8778
    88 struct gp_extension *get_gp_extension_list(void);
    89 NTSTATUS unregister_gp_extension(const char *name);
    90 NTSTATUS register_gp_extension(TALLOC_CTX *gpext_ctx,
    91                                int version,
    92                                const char *name,
    93                                const char *guid,
    94                                struct gp_extension_methods *methods);
    95 NTSTATUS gp_ext_info_add_entry(TALLOC_CTX *mem_ctx,
    96                                const char *module,
    97                                const char *ext_guid,
    98                                struct gp_extension_reg_table *table,
    99                                struct gp_extension_reg_info *info);
    100 NTSTATUS shutdown_gp_extensions(void);
    101 NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx);
    102 NTSTATUS free_gp_extensions(void);
    103 void debug_gpext_header(int lvl,
     79struct gp_extension *gpext_get_gp_extension_list(void);
     80NTSTATUS gpext_unregister_gp_extension(const char *name);
     81NTSTATUS gpext_register_gp_extension(TALLOC_CTX *gpext_ctx,
     82                                     int version,
     83                                     const char *name,
     84                                     const char *guid,
     85                                     struct gp_extension_methods *methods);
     86NTSTATUS gpext_info_add_entry(TALLOC_CTX *mem_ctx,
     87                              const char *module,
     88                              const char *ext_guid,
     89                              struct gp_extension_reg_table *table,
     90                              struct gp_extension_reg_info *info);
     91NTSTATUS gpext_shutdown_gp_extensions(void);
     92NTSTATUS gpext_init_gp_extensions(TALLOC_CTX *mem_ctx);
     93NTSTATUS gpext_free_gp_extensions(void);
     94void gpext_debug_header(int lvl,
    10495                        const char *name,
    10596                        uint32_t flags,
    106                         struct GROUP_POLICY_OBJECT *gpo,
     97                        const struct GROUP_POLICY_OBJECT *gpo,
    10798                        const char *extension_guid,
    10899                        const char *snapin_guid);
    109 NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads,
    110                            TALLOC_CTX *mem_ctx,
    111                            uint32_t flags,
    112                            const struct security_token *token,
    113                            struct GROUP_POLICY_OBJECT *gpo_list,
    114                            const char *extension_guid,
    115                            const char *snapin_guid);
    116 NTSTATUS gpext_process_extension(ADS_STRUCT *ads,
    117                                  TALLOC_CTX *mem_ctx,
     100NTSTATUS gpext_process_extension(TALLOC_CTX *mem_ctx,
    118101                                 uint32_t flags,
    119102                                 const struct security_token *token,
    120103                                 struct registry_key *root_key,
    121                                  struct GROUP_POLICY_OBJECT *gpo,
    122                                  const char *extension_guid,
    123                                  const char *snapin_guid);
     104                                 const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
     105                                 const struct GROUP_POLICY_OBJECT *changed_gpo_list,
     106                                 const char *extension_guid);
    124107
    125108
Note: See TracChangeset for help on using the changeset viewer.