1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
/*
* Unix SMB/CIFS implementation.
* Group Policy Support
* Copyright (C) Guenther Deschner 2005-2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "libgpo/gpo_ini.h"
#define GP_EXT_NAME "security"
#define GPTTMPL_UNIX_PATH "Microsoft/Windows NT/SecEdit/GptTmpl.inf"
#define GPTTMPL_SECTION_UNICODE "Unicode"
#define GPTTMPL_SECTION_VERSION "Version"
#define GPTTMPL_SECTION_REGISTRY_VALUES "Registry Values"
#define GPTTMPL_SECTION_SYSTEM_ACCESS "System Access"
#define GPTTMPL_SECTION_KERBEROS_POLICY "Kerberos Policy"
#define GPTTMPL_SECTION_EVENT_AUDIT "Event Audit"
#define GPTTMPL_SECTION_PRIVILEGE_RIGHTS "Privilege Rights"
#define GPTTMPL_SECTION_APPLICATION_LOG "Application Log"
#define GPTTMPL_SECTION_SECURITY_LOG "Security Log"
#define GPTTMPL_SECTION_SYSTEM_LOG "System Log"
#define GPTTMPL_SECTION_GROUP_MEMBERSHIP "Group Membership"
#define GPTTMPL_SECTION_FILE_SECURITY "File Security"
#define GPTTMPL_SECTION_SERVICE_GENERAL_SETTING "Service General Setting"
static TALLOC_CTX *ctx = NULL;
struct gpttmpl_table {
const char *section;
const char *parameter;
enum winreg_Type type;
};
/****************************************************************
parse the Version section from gpttmpl file
****************************************************************/
#define GPTTMPL_PARAMETER_REVISION "Revision"
#define GPTTMPL_PARAMETER_SIGNATURE "signature"
#define GPTTMPL_VALUE_CHICAGO "$CHICAGO$" /* whatever this is good for... */
#define GPTTMPL_PARAMETER_UNICODE "Unicode"
static NTSTATUS gpttmpl_parse_header(dictionary *dict,
uint32_t *version_out)
{
const char *signature = NULL;
uint32_t version;
if (!dict) {
return NT_STATUS_INVALID_PARAMETER;
}
if ((signature = iniparser_getstring(dict, GPTTMPL_SECTION_VERSION
":"GPTTMPL_PARAMETER_SIGNATURE, NULL)) == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
if (!strequal(signature, GPTTMPL_VALUE_CHICAGO)) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
if ((version = iniparser_getint(dict, GPTTMPL_SECTION_VERSION
":"GPTTMPL_PARAMETER_REVISION, Undefined)) == Undefined) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
if (version_out) {
*version_out = version;
}
/* treat that as boolean */
if ((!iniparser_getboolean(dict, GPTTMPL_SECTION_UNICODE
":"GPTTMPL_PARAMETER_UNICODE, Undefined)) == Undefined) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static NTSTATUS gpttmpl_init_context(TALLOC_CTX *mem_ctx,
uint32_t flags,
const char *unix_path,
struct gp_inifile_context **ini_ctx)
{
NTSTATUS status;
uint32_t version;
struct gp_inifile_context *tmp_ctx = NULL;
status = gp_inifile_init_context(mem_ctx, flags, unix_path,
GPTTMPL_UNIX_PATH, &tmp_ctx);
NT_STATUS_NOT_OK_RETURN(status);
status = gpttmpl_parse_header(tmp_ctx->dict, &version);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1,("gpttmpl_init_context: failed: %s\n",
nt_errstr(status)));
TALLOC_FREE(tmp_ctx);
return status;
}
*ini_ctx = tmp_ctx;
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static NTSTATUS gpttmpl_process(struct gp_inifile_context *ini_ctx,
struct registry_key *root_key,
uint32_t flags)
{
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static NTSTATUS security_process_group_policy(ADS_STRUCT *ads,
TALLOC_CTX *mem_ctx,
uint32_t flags,
struct registry_key *root_key,
const struct nt_user_token *token,
struct GROUP_POLICY_OBJECT *gpo,
const char *extension_guid,
const char *snapin_guid)
{
NTSTATUS status;
char *unix_path = NULL;
struct gp_inifile_context *ini_ctx = NULL;
debug_gpext_header(0, "security_process_group_policy", flags, gpo,
extension_guid, snapin_guid);
/* this handler processes the gpttmpl files and merge output to the
* registry */
status = gpo_get_unix_path(mem_ctx, gpo, &unix_path);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
status = gpttmpl_init_context(mem_ctx, flags, unix_path, &ini_ctx);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
status = gpttmpl_process(ini_ctx, root_key, flags);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
out:
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("security_process_group_policy: %s\n",
nt_errstr(status)));
}
TALLOC_FREE(ini_ctx);
return status;
}
/****************************************************************
****************************************************************/
static NTSTATUS security_get_reg_config(TALLOC_CTX *mem_ctx,
struct gp_extension_reg_info **reg_info)
{
NTSTATUS status;
struct gp_extension_reg_info *info = NULL;
struct gp_extension_reg_table table[] = {
/* FIXME: how can we store the "(Default)" value ??? */
/* { "", REG_SZ, "Security" }, */
{ "ProcessGroupPolicy", REG_SZ, "security_process_group_policy" },
{ "NoUserPolicy", REG_DWORD, "1" },
{ "ExtensionDebugLevel", REG_DWORD, "1" },
{ NULL, REG_NONE, NULL }
};
info = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info);
NT_STATUS_HAVE_NO_MEMORY(info);
status = gp_ext_info_add_entry(mem_ctx, GP_EXT_NAME,
GP_EXT_GUID_SECURITY,
table, info);
NT_STATUS_NOT_OK_RETURN(status);
*reg_info = info;
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static NTSTATUS security_initialize(TALLOC_CTX *mem_ctx)
{
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static NTSTATUS security_shutdown(void)
{
NTSTATUS status;
status = unregister_gp_extension(GP_EXT_NAME);
if (NT_STATUS_IS_OK(status)) {
return status;
}
TALLOC_FREE(ctx);
return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
static struct gp_extension_methods security_methods = {
.initialize = security_initialize,
.process_group_policy = security_process_group_policy,
.get_reg_config = security_get_reg_config,
.shutdown = security_shutdown
};
/****************************************************************
****************************************************************/
NTSTATUS gpext_security_init(void)
{
NTSTATUS status;
ctx = talloc_init("gpext_security_init");
NT_STATUS_HAVE_NO_MEMORY(ctx);
status = register_gp_extension(ctx, SMB_GPEXT_INTERFACE_VERSION,
GP_EXT_NAME, GP_EXT_GUID_SECURITY,
&security_methods);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(ctx);
}
return status;
}
|