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