1/* 2 * Unix SMB/CIFS implementation. 3 * Group Policy Object Support 4 * Copyright (C) Guenther Deschner 2005-2008 5 * 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. 10 * 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. 15 * 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/>. 18 */ 19 20#ifndef __GPO_H__ 21#define __GPO_H__ 22 23#if _SAMBA_BUILD_ == 4 24#include "source4/libgpo/ads_convenience.h" 25#else 26struct loadparm_context; 27#endif 28 29enum GPO_LINK_TYPE { 30 GP_LINK_UNKOWN = 0, 31 GP_LINK_MACHINE = 1, 32 GP_LINK_SITE = 2, 33 GP_LINK_DOMAIN = 3, 34 GP_LINK_OU = 4, 35 GP_LINK_LOCAL = 5 /* for convenience */ 36}; 37 38/* GPO_OPTIONS */ 39#define GPO_FLAG_DISABLE 0x00000001 40#define GPO_FLAG_FORCE 0x00000002 41 42/* GPO_LIST_FLAGS */ 43#define GPO_LIST_FLAG_MACHINE 0x00000001 44#define GPO_LIST_FLAG_SITEONLY 0x00000002 45 46/* following flags from http://support.microsoft.com/kb/312164/EN-US/ */ 47#define GPO_INFO_FLAG_MACHINE 0x00000001 48#define GPO_INFO_FLAG_BACKGROUND 0x00000010 49#define GPO_INFO_FLAG_SLOWLINK 0x00000020 50#define GPO_INFO_FLAG_VERBOSE 0x00000040 51#define GPO_INFO_FLAG_NOCHANGES 0x00000080 52#define GPO_INFO_FLAG_LINKTRANSITION 0x00000100 53#define GPO_INFO_FLAG_LOGRSOP_TRANSITION 0x00000200 54#define GPO_INFO_FLAG_FORCED_REFRESH 0x00000400 55#define GPO_INFO_FLAG_SAFEMODE_BOOT 0x00000800 56 57#define GPO_VERSION_USER(x) (x >> 16) 58#define GPO_VERSION_MACHINE(x) (x & 0xffff) 59 60struct GROUP_POLICY_OBJECT { 61 uint32_t options; /* GPFLAGS_* */ 62 uint32_t version; 63 const char *ds_path; 64 const char *file_sys_path; 65 const char *display_name; 66 const char *name; 67 const char *link; 68 enum GPO_LINK_TYPE link_type; 69 const char *user_extensions; 70 const char *machine_extensions; 71 struct security_descriptor *security_descriptor; 72 struct GROUP_POLICY_OBJECT *next, *prev; 73}; 74 75/* the following is seen on the DS (see adssearch.pl for details) */ 76 77/* the type field in a 'gPLink', the same as GPO_FLAG ? */ 78#define GPO_LINK_OPT_NONE 0x00000000 79#define GPO_LINK_OPT_DISABLED 0x00000001 80#define GPO_LINK_OPT_ENFORCED 0x00000002 81 82/* GPO_LINK_OPT_ENFORCED takes precedence over GPOPTIONS_BLOCK_INHERITANCE */ 83 84/* 'gPOptions', maybe a bitmask as well */ 85enum GPO_INHERIT { 86 GPOPTIONS_INHERIT = 0, 87 GPOPTIONS_BLOCK_INHERITANCE = 1 88}; 89 90/* 'flags' in a 'groupPolicyContainer' object */ 91#define GPFLAGS_ALL_ENABLED 0x00000000 92#define GPFLAGS_USER_SETTINGS_DISABLED 0x00000001 93#define GPFLAGS_MACHINE_SETTINGS_DISABLED 0x00000002 94#define GPFLAGS_ALL_DISABLED (GPFLAGS_USER_SETTINGS_DISABLED | \ 95 GPFLAGS_MACHINE_SETTINGS_DISABLED) 96 97struct GP_LINK { 98 const char *gp_link; /* raw link name */ 99 uint32_t gp_opts; /* inheritance options GPO_INHERIT */ 100 uint32_t num_links; /* number of links */ 101 char **link_names; /* array of parsed link names */ 102 uint32_t *link_opts; /* array of parsed link opts GPO_LINK_OPT_* */ 103}; 104 105struct GP_EXT { 106 const char *gp_extension; /* raw extension name */ 107 uint32_t num_exts; 108 char **extensions; 109 char **extensions_guid; 110 char **snapins; 111 char **snapins_guid; 112 struct GP_EXT *next, *prev; 113}; 114 115#define GPO_CACHE_DIR "gpo_cache" 116#define GPT_INI "GPT.INI" 117#define GPO_REFRESH_INTERVAL 60*90 118 119#define GPO_REG_STATE_MACHINE "State\\Machine" 120 121enum gp_reg_action { 122 GP_REG_ACTION_NONE = 0, 123 GP_REG_ACTION_ADD_VALUE = 1, 124 GP_REG_ACTION_ADD_KEY = 2, 125 GP_REG_ACTION_DEL_VALUES = 3, 126 GP_REG_ACTION_DEL_VALUE = 4, 127 GP_REG_ACTION_DEL_ALL_VALUES = 5, 128 GP_REG_ACTION_DEL_KEYS = 6, 129 GP_REG_ACTION_SEC_KEY_SET = 7, 130 GP_REG_ACTION_SEC_KEY_RESET = 8 131}; 132 133struct gp_registry_entry { 134 enum gp_reg_action action; 135 const char *key; 136 const char *value; 137 struct registry_value *data; 138}; 139 140struct gp_registry_value { 141 const char *value; 142 struct registry_value *data; 143}; 144 145struct gp_registry_entry2 { 146 enum gp_reg_action action; 147 const char *key; 148 size_t num_values; 149 struct gp_registry_value **values; 150}; 151 152struct gp_registry_entries { 153 size_t num_entries; 154 struct gp_registry_entry **entries; 155}; 156 157struct gp_registry_context { 158 const NT_USER_TOKEN *token; 159 const char *path; 160 struct registry_key *curr_key; 161}; 162 163#define GP_EXT_GUID_SECURITY "827D319E-6EAC-11D2-A4EA-00C04F79F83A" 164#define GP_EXT_GUID_REGISTRY "35378EAC-683F-11D2-A89A-00C04FBBCFA2" 165#define GP_EXT_GUID_SCRIPTS "42B5FAAE-6536-11D2-AE5A-0000F87571E3" 166#define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939" 167 168 169struct cli_state; 170 171/* The following definitions come from libgpo/gpo_fetch.c */ 172 173NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx, 174 const char *cache_dir, 175 const char *file_sys_path, 176 char **server, 177 char **service, 178 char **nt_path, 179 char **unix_path); 180NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx, 181 ADS_STRUCT *ads, 182 struct loadparm_context *lp_ctx, 183 const char *cache_dir, 184 struct GROUP_POLICY_OBJECT *gpo); 185NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx, 186 const char *unix_path, 187 uint32_t *sysvol_version, 188 char **display_name); 189 190/* The following definitions come from libgpo/gpo_ldap.c */ 191 192bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, 193 const char *extension_raw, 194 struct GP_EXT **gp_ext); 195ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads, 196 TALLOC_CTX *mem_ctx, 197 const char *link_dn, 198 struct GP_LINK *gp_link_struct); 199ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads, 200 TALLOC_CTX *mem_ctx, 201 const char *link_dn, 202 const char *gpo_dn, 203 uint32_t gpo_opt); 204ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads, 205 TALLOC_CTX *mem_ctx, 206 const char *link_dn, 207 const char *gpo_dn); 208ADS_STATUS ads_get_gpo(ADS_STRUCT *ads, 209 TALLOC_CTX *mem_ctx, 210 const char *gpo_dn, 211 const char *display_name, 212 const char *guid_name, 213 struct GROUP_POLICY_OBJECT *gpo); 214ADS_STATUS ads_get_sid_token(ADS_STRUCT *ads, 215 TALLOC_CTX *mem_ctx, 216 const char *dn, 217 NT_USER_TOKEN **token); 218ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads, 219 TALLOC_CTX *mem_ctx, 220 const char *dn, 221 uint32_t flags, 222 const NT_USER_TOKEN *token, 223 struct GROUP_POLICY_OBJECT **gpo_list); 224 225/* The following definitions come from libgpo/gpo_sec.c */ 226 227NTSTATUS gpo_apply_security_filtering(const struct GROUP_POLICY_OBJECT *gpo, 228 const NT_USER_TOKEN *token); 229 230/* The following definitions come from libgpo/gpo_util.c */ 231 232const char *cse_gpo_guid_string_to_name(const char *guid); 233const char *cse_gpo_name_to_guid_string(const char *name); 234const char *cse_snapin_gpo_guid_string_to_name(const char *guid); 235void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel); 236void dump_gpo(ADS_STRUCT *ads, 237 TALLOC_CTX *mem_ctx, 238 struct GROUP_POLICY_OBJECT *gpo, 239 int debuglevel); 240void dump_gpo_list(ADS_STRUCT *ads, 241 TALLOC_CTX *mem_ctx, 242 struct GROUP_POLICY_OBJECT *gpo_list, 243 int debuglevel); 244void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link); 245ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads, 246 TALLOC_CTX *mem_ctx, 247 const NT_USER_TOKEN *token, 248 struct registry_key *root_key, 249 struct GROUP_POLICY_OBJECT *gpo, 250 const char *extension_guid_filter, 251 uint32_t flags); 252ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads, 253 TALLOC_CTX *mem_ctx, 254 const NT_USER_TOKEN *token, 255 struct GROUP_POLICY_OBJECT *gpo_list, 256 const char *extensions_guid_filter, 257 uint32_t flags); 258NTSTATUS check_refresh_gpo(ADS_STRUCT *ads, 259 TALLOC_CTX *mem_ctx, 260 const char *cache_dir, 261 struct loadparm_context *lp_ctx, 262 uint32_t flags, 263 struct GROUP_POLICY_OBJECT *gpo); 264NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads, 265 TALLOC_CTX *mem_ctx, 266 const char *cache_dir, 267 struct loadparm_context *lp_ctx, 268 uint32_t flags, 269 struct GROUP_POLICY_OBJECT *gpo_list); 270NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx, 271 const char *cache_dir, 272 struct GROUP_POLICY_OBJECT *gpo, 273 char **unix_path); 274char *gpo_flag_str(TALLOC_CTX *mem_ctx, uint32_t flags); 275NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, 276 uint32_t flags, 277 const char *filename, 278 const char *suffix, 279 const char **filename_out); 280ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, 281 TALLOC_CTX *mem_ctx, 282 struct loadparm_context *lp_ctx, 283 const char *dn, 284 NT_USER_TOKEN **token); 285 286 287#include "../libgpo/gpext/gpext.h" 288 289#endif 290