Changeset 988 for vendor/current/libgpo/gpext
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/libgpo/gpext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/libgpo/gpext/gpext.c
r740 r988 24 24 #include "lib/util/dlinklist.h" 25 25 #include "../libcli/registry/util_reg.h" 26 #if _SAMBA_BUILD_ == 327 26 #include "libgpo/gpo_proto.h" 28 27 #include "registry.h" 29 28 #include "registry/reg_api.h" 30 #endif31 29 32 30 static struct gp_extension *extensions = NULL; … … 35 33 ****************************************************************/ 36 34 37 struct gp_extension *g et_gp_extension_list(void)35 struct gp_extension *gpext_get_gp_extension_list(void) 38 36 { 39 37 return extensions; … … 104 102 ****************************************************************/ 105 103 106 NTSTATUS unregister_gp_extension(const char *name)104 NTSTATUS gpext_unregister_gp_extension(const char *name) 107 105 { 108 106 struct gp_extension *ext; … … 124 122 ****************************************************************/ 125 123 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)124 NTSTATUS 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) 131 129 { 132 130 struct gp_extension_methods *test; … … 343 341 ****************************************************************/ 344 342 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)343 NTSTATUS 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) 350 348 { 351 349 NTSTATUS status; 352 350 struct gp_extension_reg_info_entry *entry = NULL; 353 351 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); 355 353 NT_STATUS_HAVE_NO_MEMORY(entry); 356 354 … … 443 441 W_ERROR_HAVE_NO_MEMORY(subkeyname); 444 442 445 strupper_m(CONST_DISCARD(char *,subkeyname)); 443 if (!strupper_m(discard_const_p(char, subkeyname))) { 444 return WERR_INVALID_PARAM; 445 } 446 446 447 447 werr = gp_store_reg_subkey(mem_ctx, … … 490 490 size_t *ext_list_len) 491 491 { 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)); 496 497 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))) { 501 502 502 503 fstring name; /* forgive me... */ … … 510 511 p = strrchr(dirent->d_name, '.'); 511 512 if (!p) { 512 sys_closedir(dir);513 closedir(dir); 513 514 return NT_STATUS_NO_MEMORY; 514 515 } … … 524 525 525 526 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); 528 529 return NT_STATUS_NO_MEMORY; 529 530 } 530 531 } 531 532 532 sys_closedir(dir);533 closedir(dir); 533 534 534 535 return NT_STATUS_OK; … … 538 539 ****************************************************************/ 539 540 540 NTSTATUS shutdown_gp_extensions(void)541 NTSTATUS gpext_shutdown_gp_extensions(void) 541 542 { 542 543 struct gp_extension *ext = NULL; … … 554 555 ****************************************************************/ 555 556 556 NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx)557 NTSTATUS gpext_init_gp_extensions(TALLOC_CTX *mem_ctx) 557 558 { 558 559 NTSTATUS status; … … 564 565 struct gp_registry_context *reg_ctx = NULL; 565 566 566 if (g et_gp_extension_list()) {567 if (gpext_get_gp_extension_list()) { 567 568 return NT_STATUS_OK; 568 569 } … … 637 638 ****************************************************************/ 638 639 639 NTSTATUS free_gp_extensions(void)640 NTSTATUS gpext_free_gp_extensions(void) 640 641 { 641 642 struct gp_extension *ext, *ext_next = NULL; … … 655 656 ****************************************************************/ 656 657 657 void debug_gpext_header(int lvl,658 void gpext_debug_header(int lvl, 658 659 const char *name, 659 660 uint32_t flags, 660 struct GROUP_POLICY_OBJECT *gpo,661 const struct GROUP_POLICY_OBJECT *gpo, 661 662 const char *extension_guid, 662 663 const char *snapin_guid) … … 678 679 } 679 680 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 684 static 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 688 724 return NT_STATUS_OK; 689 725 } … … 692 728 ****************************************************************/ 693 729 694 NTSTATUS gpext_process_extension(ADS_STRUCT *ads, 695 TALLOC_CTX *mem_ctx, 730 NTSTATUS gpext_process_extension(TALLOC_CTX *mem_ctx, 696 731 uint32_t flags, 697 732 const struct security_token *token, 698 733 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) 702 737 { 703 738 NTSTATUS status; 704 739 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); 709 744 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", 711 746 nt_errstr(status))); 712 747 return status; 713 748 } 714 749 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 } 718 756 } 719 757 720 758 for (ext = extensions; ext; ext = ext->next) { 721 759 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 } 745 831 } 746 832 747 833 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 62 62 NTSTATUS (*initialize)(TALLOC_CTX *mem_ctx); 63 63 64 NTSTATUS (*process_group_policy)(ADS_STRUCT *ads, 65 TALLOC_CTX *mem_ctx, 64 NTSTATUS (*process_group_policy)(TALLOC_CTX *mem_ctx, 66 65 uint32_t flags, 67 66 struct registry_key *root_key, 68 67 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); 79 70 80 71 NTSTATUS (*get_reg_config)(TALLOC_CTX *mem_ctx, … … 86 77 /* The following definitions come from libgpo/gpext/gpext.c */ 87 78 88 struct gp_extension *g et_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,79 struct gp_extension *gpext_get_gp_extension_list(void); 80 NTSTATUS gpext_unregister_gp_extension(const char *name); 81 NTSTATUS 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); 86 NTSTATUS 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); 91 NTSTATUS gpext_shutdown_gp_extensions(void); 92 NTSTATUS gpext_init_gp_extensions(TALLOC_CTX *mem_ctx); 93 NTSTATUS gpext_free_gp_extensions(void); 94 void gpext_debug_header(int lvl, 104 95 const char *name, 105 96 uint32_t flags, 106 struct GROUP_POLICY_OBJECT *gpo,97 const struct GROUP_POLICY_OBJECT *gpo, 107 98 const char *extension_guid, 108 99 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, 100 NTSTATUS gpext_process_extension(TALLOC_CTX *mem_ctx, 118 101 uint32_t flags, 119 102 const struct security_token *token, 120 103 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); 124 107 125 108
Note:
See TracChangeset
for help on using the changeset viewer.
