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