2 * Unix SMB/CIFS implementation.
3 * Group Policy Object Support
4 * Copyright (C) Guenther Deschner 2005-2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/filesys.h"
22 #include "librpc/gen_ndr/ndr_misc.h"
23 #include "../librpc/gen_ndr/ndr_security.h"
24 #include "../libgpo/gpo.h"
25 #include "../libcli/security/security.h"
27 #include "libgpo/gpo_proto.h"
30 #define DEFAULT_DOMAIN_POLICY "Default Domain Policy"
31 #define DEFAULT_DOMAIN_CONTROLLERS_POLICY "Default Domain Controllers Policy"
34 /* should we store a parsed guid ? */
37 const char *guid_string;
41 static struct gp_table gpo_default_policy[] = {
42 { DEFAULT_DOMAIN_POLICY,
43 "31B2F340-016D-11D2-945F-00C04FB984F9" },
44 { DEFAULT_DOMAIN_CONTROLLERS_POLICY,
45 "6AC1786C-016F-11D2-945F-00C04fB984F9" },
50 /* the following is seen in gPCMachineExtensionNames / gPCUserExtensionNames */
52 static struct gp_table gpo_cse_extensions[] = {
53 /* used to be "Administrative Templates Extension" */
54 /* "Registry Settings"
55 (http://support.microsoft.com/kb/216357/EN-US/) */
56 { "Registry Settings",
57 GP_EXT_GUID_REGISTRY },
58 { "Microsoft Disc Quota",
59 "3610EDA5-77EF-11D2-8DC5-00C04FA31A66" },
61 "B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A" },
62 { "Folder Redirection",
63 "25537BA6-77A8-11D2-9B6C-0000F8080861" },
65 "E437BC1C-AA7D-11D2-A382-00C04F991E27" },
66 { "Internet Explorer Branding",
67 "A2E30F80-D7DE-11d2-BBDE-00C04F86AE3B" },
68 { "QoS Packet Scheduler",
69 "426031c0-0b47-4852-b0ca-ac3d37bfcb39" },
71 GP_EXT_GUID_SCRIPTS },
73 GP_EXT_GUID_SECURITY },
74 { "Software Installation",
75 "C6DC5466-785A-11D2-84D0-00C04FB169F7" },
76 { "Wireless Group Policy",
77 "0ACDD40C-75AC-BAA0-BF6DE7E7FE63" },
78 { "Application Management",
79 "C6DC5466-785A-11D2-84D0-00C04FB169F7" },
81 "3060E8D0-7020-11D2-842D-00C04FA372D4" },
86 static struct gp_table gpo_cse_snapin_extensions[] = {
87 { "Administrative Templates",
88 "0F6B957D-509E-11D1-A7CC-0000F87571E3" },
90 "53D6AB1D-2488-11D1-A28C-00C04FB94F17" },
91 { "EFS recovery policy processing",
92 "B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A" },
93 { "Folder Redirection policy processing",
94 "25537BA6-77A8-11D2-9B6C-0000F8080861" },
95 { "Folder Redirection",
96 "88E729D6-BDC1-11D1-BD2A-00C04FB9603F" },
97 { "Registry policy processing",
98 "35378EAC-683F-11D2-A89A-00C04FBBCFA2" },
99 { "Remote Installation Services",
100 "3060E8CE-7020-11D2-842D-00C04FA372D4" },
101 { "Security Settings",
102 "803E14A0-B4FB-11D0-A0D0-00A0C90F574B" },
103 { "Security policy processing",
104 "827D319E-6EAC-11D2-A4EA-00C04F79F83A" },
106 "3060E8D0-7020-11D2-842D-00C04FA372D4" },
108 "53D6AB1B-2488-11D1-A28C-00C04FB94F17" },
112 /****************************************************************
113 ****************************************************************/
115 static const char *name_to_guid_string(const char *name,
116 struct gp_table *table)
120 for (i = 0; table[i].name; i++) {
121 if (strequal(name, table[i].name)) {
122 return table[i].guid_string;
129 /****************************************************************
130 ****************************************************************/
132 static const char *guid_string_to_name(const char *guid_string,
133 struct gp_table *table)
137 for (i = 0; table[i].guid_string; i++) {
138 if (strequal(guid_string, table[i].guid_string)) {
139 return table[i].name;
146 /****************************************************************
147 ****************************************************************/
149 static const char *snapin_guid_string_to_name(const char *guid_string,
150 struct gp_table *table)
153 for (i = 0; table[i].guid_string; i++) {
154 if (strequal(guid_string, table[i].guid_string)) {
155 return table[i].name;
162 static const char *default_gpo_name_to_guid_string(const char *name)
164 return name_to_guid_string(name, gpo_default_policy);
167 static const char *default_gpo_guid_string_to_name(const char *guid)
169 return guid_string_to_name(guid, gpo_default_policy);
173 /****************************************************************
174 ****************************************************************/
176 const char *cse_gpo_guid_string_to_name(const char *guid)
178 return guid_string_to_name(guid, gpo_cse_extensions);
181 /****************************************************************
182 ****************************************************************/
184 const char *cse_gpo_name_to_guid_string(const char *name)
186 return name_to_guid_string(name, gpo_cse_extensions);
189 /****************************************************************
190 ****************************************************************/
192 const char *cse_snapin_gpo_guid_string_to_name(const char *guid)
194 return snapin_guid_string_to_name(guid, gpo_cse_snapin_extensions);
197 /****************************************************************
198 ****************************************************************/
200 void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel)
202 int lvl = debuglevel;
205 if (gp_ext == NULL) {
209 DEBUG(lvl,("\t---------------------\n\n"));
210 DEBUGADD(lvl,("\tname:\t\t\t%s\n", gp_ext->gp_extension));
212 for (i=0; i< gp_ext->num_exts; i++) {
214 DEBUGADD(lvl,("\textension:\t\t\t%s\n",
215 gp_ext->extensions_guid[i]));
216 DEBUGADD(lvl,("\textension (name):\t\t\t%s\n",
217 gp_ext->extensions[i]));
219 DEBUGADD(lvl,("\tsnapin:\t\t\t%s\n",
220 gp_ext->snapins_guid[i]));
221 DEBUGADD(lvl,("\tsnapin (name):\t\t\t%s\n",
222 gp_ext->snapins[i]));
228 /****************************************************************
229 ****************************************************************/
231 void dump_gpo(const struct GROUP_POLICY_OBJECT *gpo,
234 int lvl = debuglevel;
235 TALLOC_CTX *frame = talloc_stackframe();
241 DEBUG(lvl,("---------------------\n\n"));
243 DEBUGADD(lvl,("name:\t\t\t%s\n", gpo->name));
244 DEBUGADD(lvl,("displayname:\t\t%s\n", gpo->display_name));
245 DEBUGADD(lvl,("version:\t\t%d (0x%08x)\n", gpo->version, gpo->version));
246 DEBUGADD(lvl,("version_user:\t\t%d (0x%04x)\n",
247 GPO_VERSION_USER(gpo->version),
248 GPO_VERSION_USER(gpo->version)));
249 DEBUGADD(lvl,("version_machine:\t%d (0x%04x)\n",
250 GPO_VERSION_MACHINE(gpo->version),
251 GPO_VERSION_MACHINE(gpo->version)));
252 DEBUGADD(lvl,("filesyspath:\t\t%s\n", gpo->file_sys_path));
253 DEBUGADD(lvl,("dspath:\t\t%s\n", gpo->ds_path));
255 DEBUGADD(lvl,("options:\t\t%d ", gpo->options));
256 switch (gpo->options) {
257 case GPFLAGS_ALL_ENABLED:
258 DEBUGADD(lvl,("GPFLAGS_ALL_ENABLED\n"));
260 case GPFLAGS_USER_SETTINGS_DISABLED:
261 DEBUGADD(lvl,("GPFLAGS_USER_SETTINGS_DISABLED\n"));
263 case GPFLAGS_MACHINE_SETTINGS_DISABLED:
264 DEBUGADD(lvl,("GPFLAGS_MACHINE_SETTINGS_DISABLED\n"));
266 case GPFLAGS_ALL_DISABLED:
267 DEBUGADD(lvl,("GPFLAGS_ALL_DISABLED\n"));
270 DEBUGADD(lvl,("unknown option: %d\n", gpo->options));
274 DEBUGADD(lvl,("link:\t\t\t%s\n", gpo->link));
275 DEBUGADD(lvl,("link_type:\t\t%d ", gpo->link_type));
276 switch (gpo->link_type) {
278 DEBUGADD(lvl,("GP_LINK_UNKOWN\n"));
281 DEBUGADD(lvl,("GP_LINK_OU\n"));
284 DEBUGADD(lvl,("GP_LINK_DOMAIN\n"));
287 DEBUGADD(lvl,("GP_LINK_SITE\n"));
289 case GP_LINK_MACHINE:
290 DEBUGADD(lvl,("GP_LINK_MACHINE\n"));
296 DEBUGADD(lvl,("machine_extensions:\t%s\n", gpo->machine_extensions));
298 if (gpo->machine_extensions) {
300 struct GP_EXT *gp_ext = NULL;
302 if (!ads_parse_gp_ext(frame, gpo->machine_extensions,
306 dump_gp_ext(gp_ext, lvl);
309 DEBUGADD(lvl,("user_extensions:\t%s\n", gpo->user_extensions));
311 if (gpo->user_extensions) {
313 struct GP_EXT *gp_ext = NULL;
315 if (!ads_parse_gp_ext(frame, gpo->user_extensions,
319 dump_gp_ext(gp_ext, lvl);
321 if (gpo->security_descriptor) {
322 DEBUGADD(lvl,("security descriptor:\n"));
324 NDR_PRINT_DEBUG(security_descriptor, gpo->security_descriptor);
330 /****************************************************************
331 ****************************************************************/
333 void dump_gpo_list(const struct GROUP_POLICY_OBJECT *gpo_list,
336 const struct GROUP_POLICY_OBJECT *gpo = NULL;
338 for (gpo = gpo_list; gpo; gpo = gpo->next) {
339 dump_gpo(gpo, debuglevel);
343 /****************************************************************
344 ****************************************************************/
346 void dump_gplink(const struct GP_LINK *gp_link)
351 if (gp_link == NULL) {
355 DEBUG(lvl,("---------------------\n\n"));
357 DEBUGADD(lvl,("gplink: %s\n", gp_link->gp_link));
358 DEBUGADD(lvl,("gpopts: %d ", gp_link->gp_opts));
359 switch (gp_link->gp_opts) {
360 case GPOPTIONS_INHERIT:
361 DEBUGADD(lvl,("GPOPTIONS_INHERIT\n"));
363 case GPOPTIONS_BLOCK_INHERITANCE:
364 DEBUGADD(lvl,("GPOPTIONS_BLOCK_INHERITANCE\n"));
370 DEBUGADD(lvl,("num links: %d\n", gp_link->num_links));
372 for (i = 0; i < gp_link->num_links; i++) {
374 DEBUGADD(lvl,("---------------------\n\n"));
376 DEBUGADD(lvl,("link: #%d\n", i + 1));
377 DEBUGADD(lvl,("name: %s\n", gp_link->link_names[i]));
379 DEBUGADD(lvl,("opt: %d ", gp_link->link_opts[i]));
380 if (gp_link->link_opts[i] & GPO_LINK_OPT_ENFORCED) {
381 DEBUGADD(lvl,("GPO_LINK_OPT_ENFORCED "));
383 if (gp_link->link_opts[i] & GPO_LINK_OPT_DISABLED) {
384 DEBUGADD(lvl,("GPO_LINK_OPT_DISABLED"));
386 DEBUGADD(lvl,("\n"));
390 #endif /* HAVE_LDAP */
392 /****************************************************************
393 ****************************************************************/
395 bool gpo_get_gp_ext_from_gpo(TALLOC_CTX *mem_ctx,
397 const struct GROUP_POLICY_OBJECT *gpo,
398 struct GP_EXT **gp_ext)
400 ZERO_STRUCTP(*gp_ext);
402 if (flags & GPO_INFO_FLAG_MACHINE) {
404 if (gpo->machine_extensions) {
406 if (!ads_parse_gp_ext(mem_ctx, gpo->machine_extensions,
413 if (gpo->user_extensions) {
415 if (!ads_parse_gp_ext(mem_ctx, gpo->user_extensions,
425 /****************************************************************
426 ****************************************************************/
428 static NTSTATUS gpo_process_a_gpo(TALLOC_CTX *mem_ctx,
429 const struct security_token *token,
430 struct registry_key *root_key,
431 struct GROUP_POLICY_OBJECT *gpo,
432 const char *extension_guid_filter,
435 struct GP_EXT *gp_ext = NULL;
438 DEBUG(10,("gpo_process_a_gpo: processing gpo %s (%s)\n",
439 gpo->name, gpo->display_name));
440 if (extension_guid_filter) {
441 DEBUGADD(10,("gpo_process_a_gpo: using filter %s (%s)\n",
442 extension_guid_filter,
443 cse_gpo_guid_string_to_name(extension_guid_filter)));
446 if (!gpo_get_gp_ext_from_gpo(mem_ctx, flags, gpo, &gp_ext)) {
447 return NT_STATUS_INVALID_PARAMETER;
450 if (!gp_ext || !gp_ext->num_exts) {
451 if (flags & GPO_INFO_FLAG_VERBOSE) {
452 DEBUG(0,("gpo_process_a_gpo: "
453 "no policies in %s (%s) for this extension\n",
454 gpo->name, gpo->display_name));
459 for (i=0; i<gp_ext->num_exts; i++) {
463 if (extension_guid_filter &&
464 !strequal(extension_guid_filter,
465 gp_ext->extensions_guid[i])) {
469 ntstatus = gpext_process_extension(mem_ctx,
470 flags, token, root_key,
472 gp_ext->extensions_guid[i],
473 gp_ext->snapins_guid[i]);
474 if (!NT_STATUS_IS_OK(ntstatus)) {
482 /****************************************************************
483 ****************************************************************/
485 static NTSTATUS gpo_process_gpo_list_by_ext(TALLOC_CTX *mem_ctx,
486 const struct security_token *token,
487 struct registry_key *root_key,
488 struct GROUP_POLICY_OBJECT *gpo_list,
489 const char *extensions_guid,
493 struct GROUP_POLICY_OBJECT *gpo;
495 for (gpo = gpo_list; gpo; gpo = gpo->next) {
497 if (gpo->link_type == GP_LINK_LOCAL) {
502 /* FIXME: we need to pass down the *list* down to the
503 * extension, otherwise we cannot store the e.g. the *list* of
504 * logon-scripts correctly (for more then one GPO) */
506 status = gpo_process_a_gpo(mem_ctx, token, root_key,
507 gpo, extensions_guid, flags);
509 if (!NT_STATUS_IS_OK(status)) {
510 DEBUG(0,("failed to process gpo by ext: %s\n",
519 /****************************************************************
520 ****************************************************************/
522 NTSTATUS gpo_process_gpo_list(TALLOC_CTX *mem_ctx,
523 const struct security_token *token,
524 struct GROUP_POLICY_OBJECT *gpo_list,
525 const char *extensions_guid_filter,
528 NTSTATUS status = NT_STATUS_OK;
529 struct gp_extension *gp_ext_list = NULL;
530 struct gp_extension *gp_ext = NULL;
531 struct registry_key *root_key = NULL;
532 struct gp_registry_context *reg_ctx = NULL;
535 status = gpext_init_gp_extensions(mem_ctx);
536 if (!NT_STATUS_IS_OK(status)) {
540 gp_ext_list = gpext_get_gp_extension_list();
542 return NT_STATUS_DLL_INIT_FAILED;
545 /* get the key here */
546 if (flags & GPO_LIST_FLAG_MACHINE) {
547 werr = gp_init_reg_ctx(mem_ctx, KEY_HKLM, REG_KEY_WRITE,
551 werr = gp_init_reg_ctx(mem_ctx, KEY_HKCU, REG_KEY_WRITE,
555 if (!W_ERROR_IS_OK(werr)) {
556 talloc_free(reg_ctx);
557 return werror_to_ntstatus(werr);
560 root_key = reg_ctx->curr_key;
562 for (gp_ext = gp_ext_list; gp_ext; gp_ext = gp_ext->next) {
564 const char *guid_str = NULL;
566 guid_str = GUID_string(mem_ctx, gp_ext->guid);
568 status = NT_STATUS_NO_MEMORY;
572 if (extensions_guid_filter &&
573 (!strequal(guid_str, extensions_guid_filter))) {
577 DEBUG(0,("-------------------------------------------------\n"));
578 DEBUG(0,("gpo_process_gpo_list: processing ext: %s {%s}\n",
579 gp_ext->name, guid_str));
582 status = gpo_process_gpo_list_by_ext(mem_ctx, token,
585 if (!NT_STATUS_IS_OK(status)) {
591 talloc_free(reg_ctx);
592 talloc_free(root_key);
593 gpext_free_gp_extensions();
599 /****************************************************************
600 check wether the version number in a GROUP_POLICY_OBJECT match those of the
601 locally stored version. If not, fetch the required policy via CIFS
602 ****************************************************************/
604 NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
606 const char *cache_dir,
608 struct GROUP_POLICY_OBJECT *gpo)
613 char *nt_path = NULL;
614 char *unix_path = NULL;
615 uint32_t sysvol_gpt_version = 0;
616 char *display_name = NULL;
618 result = gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
619 &server, &share, &nt_path, &unix_path);
621 if (!NT_STATUS_IS_OK(result)) {
625 result = gpo_get_sysvol_gpt_version(mem_ctx,
629 if (!NT_STATUS_IS_OK(result) &&
630 !NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_FILE)) {
631 DEBUG(10,("check_refresh_gpo: "
632 "failed to get local gpt version: %s\n",
637 DEBUG(10,("check_refresh_gpo: versions gpo %d sysvol %d\n",
638 gpo->version, sysvol_gpt_version));
640 /* FIXME: handle GPO_INFO_FLAG_FORCED_REFRESH from flags */
642 while (gpo->version > sysvol_gpt_version) {
644 DEBUG(1,("check_refresh_gpo: need to refresh GPO\n"));
646 result = gpo_fetch_files(mem_ctx, ads, cache_dir, gpo);
647 if (!NT_STATUS_IS_OK(result)) {
651 result = gpo_get_sysvol_gpt_version(mem_ctx,
655 if (!NT_STATUS_IS_OK(result)) {
656 DEBUG(10,("check_refresh_gpo: "
657 "failed to get local gpt version: %s\n",
662 if (gpo->version == sysvol_gpt_version) {
667 DEBUG(10,("Name:\t\t\t%s (%s)\n", gpo->display_name, gpo->name));
668 DEBUGADD(10,("sysvol GPT version:\t%d (user: %d, machine: %d)\n",
670 GPO_VERSION_USER(sysvol_gpt_version),
671 GPO_VERSION_MACHINE(sysvol_gpt_version)));
672 DEBUGADD(10,("LDAP GPO version:\t%d (user: %d, machine: %d)\n",
674 GPO_VERSION_USER(gpo->version),
675 GPO_VERSION_MACHINE(gpo->version)));
676 DEBUGADD(10,("LDAP GPO link:\t\t%s\n", gpo->link));
678 result = NT_STATUS_OK;
685 /****************************************************************
686 check wether the version numbers in the gpo_list match the locally stored, if
687 not, go and get each required GPO via CIFS
688 ****************************************************************/
690 NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
692 const char *cache_dir,
694 struct GROUP_POLICY_OBJECT *gpo_list)
696 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
697 struct GROUP_POLICY_OBJECT *gpo;
700 return NT_STATUS_INVALID_PARAMETER;
703 for (gpo = gpo_list; gpo; gpo = gpo->next) {
705 result = check_refresh_gpo(ads, mem_ctx, cache_dir, flags, gpo);
706 if (!NT_STATUS_IS_OK(result)) {
711 result = NT_STATUS_OK;
714 /* FIXME close cli connection */
719 /****************************************************************
720 ****************************************************************/
722 NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
723 const char *cache_dir,
724 struct GROUP_POLICY_OBJECT *gpo,
727 char *server, *share, *nt_path;
728 return gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
729 &server, &share, &nt_path, unix_path);
732 /****************************************************************
733 ****************************************************************/
735 char *gpo_flag_str(TALLOC_CTX *ctx, uint32_t flags)
743 str = talloc_strdup(ctx, "");
748 if (flags & GPO_INFO_FLAG_SLOWLINK)
749 str = talloc_strdup_append(str, "GPO_INFO_FLAG_SLOWLINK ");
750 if (flags & GPO_INFO_FLAG_VERBOSE)
751 str = talloc_strdup_append(str, "GPO_INFO_FLAG_VERBOSE ");
752 if (flags & GPO_INFO_FLAG_SAFEMODE_BOOT)
753 str = talloc_strdup_append(str, "GPO_INFO_FLAG_SAFEMODE_BOOT ");
754 if (flags & GPO_INFO_FLAG_NOCHANGES)
755 str = talloc_strdup_append(str, "GPO_INFO_FLAG_NOCHANGES ");
756 if (flags & GPO_INFO_FLAG_MACHINE)
757 str = talloc_strdup_append(str, "GPO_INFO_FLAG_MACHINE ");
758 if (flags & GPO_INFO_FLAG_LOGRSOP_TRANSITION)
759 str = talloc_strdup_append(str, "GPO_INFO_FLAG_LOGRSOP_TRANSITION ");
760 if (flags & GPO_INFO_FLAG_LINKTRANSITION)
761 str = talloc_strdup_append(str, "GPO_INFO_FLAG_LINKTRANSITION ");
762 if (flags & GPO_INFO_FLAG_FORCED_REFRESH)
763 str = talloc_strdup_append(str, "GPO_INFO_FLAG_FORCED_REFRESH ");
764 if (flags & GPO_INFO_FLAG_BACKGROUND)
765 str = talloc_strdup_append(str, "GPO_INFO_FLAG_BACKGROUND ");
770 /****************************************************************
771 ****************************************************************/
773 NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx,
775 const char *filename,
777 const char **filename_out)
779 const char *tmp = NULL;
781 const char *path = NULL;
783 if (flags & GPO_LIST_FLAG_MACHINE) {
789 tmp = talloc_asprintf(mem_ctx, "%s/%s/%s", filename,
791 NT_STATUS_HAVE_NO_MEMORY(tmp);
793 if (stat(tmp, &sbuf) == 0) {
798 path = talloc_strdup_upper(mem_ctx, path);
799 NT_STATUS_HAVE_NO_MEMORY(path);
801 tmp = talloc_asprintf(mem_ctx, "%s/%s/%s", filename,
803 NT_STATUS_HAVE_NO_MEMORY(tmp);
805 if (stat(tmp, &sbuf) == 0) {
810 return NT_STATUS_NO_SUCH_FILE;
813 /****************************************************************
814 ****************************************************************/
816 ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads,
819 struct security_token **token)
822 struct security_token *ad_token = NULL;
826 status = ads_get_sid_token(ads, mem_ctx, dn, &ad_token);
827 if (!ADS_ERR_OK(status)) {
830 ntstatus = merge_nt_token(mem_ctx, ad_token, get_system_token(),
832 if (!NT_STATUS_IS_OK(ntstatus)) {
833 return ADS_ERROR_NT(ntstatus);
837 return ADS_ERROR_NT(NT_STATUS_NOT_SUPPORTED);
841 /****************************************************************
842 ****************************************************************/
844 NTSTATUS gpo_copy(TALLOC_CTX *mem_ctx,
845 const struct GROUP_POLICY_OBJECT *gpo_src,
846 struct GROUP_POLICY_OBJECT **gpo_dst)
848 struct GROUP_POLICY_OBJECT *gpo;
850 gpo = talloc_zero(mem_ctx, struct GROUP_POLICY_OBJECT);
851 NT_STATUS_HAVE_NO_MEMORY(gpo);
853 gpo->options = gpo_src->options;
854 gpo->version = gpo_src->version;
856 gpo->ds_path = talloc_strdup(gpo, gpo_src->ds_path);
857 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->ds_path, gpo);
859 gpo->file_sys_path = talloc_strdup(gpo, gpo_src->file_sys_path);
860 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, gpo);
862 gpo->display_name = talloc_strdup(gpo, gpo_src->display_name);
863 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, gpo);
865 gpo->name = talloc_strdup(gpo, gpo_src->name);
866 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->name, gpo);
868 gpo->link = talloc_strdup(gpo, gpo_src->link);
869 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->link, gpo);
871 gpo->link_type = gpo_src->link_type;
873 if (gpo_src->user_extensions) {
874 gpo->user_extensions = talloc_strdup(gpo, gpo_src->user_extensions);
875 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->user_extensions, gpo);
878 if (gpo_src->machine_extensions) {
879 gpo->machine_extensions = talloc_strdup(gpo, gpo_src->machine_extensions);
880 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->machine_extensions, gpo);
883 gpo->security_descriptor = dup_sec_desc(gpo, gpo_src->security_descriptor);
884 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->security_descriptor, gpo);
886 gpo->next = gpo->prev = NULL;