Samba 3: added Samba 3.0.24 sources
[tomato.git] / release / src / router / samba3 / source / libsmb / gpo.c
blob0257138ece2944aa26ac7d0ce5f0d61082c1440a
1 /*
2 * Unix SMB/CIFS implementation.
3 * Group Policy Object Support
4 * Copyright (C) Guenther Deschner 2005
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 2 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, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 #define GPT_INI_SECTION_GENERAL "General"
24 #define GPT_INI_PARAMETER_VERSION "Version"
25 #define GPT_INI_PARAMETER_DISPLAYNAME "displayName"
27 struct gpt_ini {
28 uint32 version;
29 const char *display_name;
32 static uint32 version;
34 static BOOL do_section(const char *section)
36 DEBUG(10,("do_section: %s\n", section));
38 return True;
41 static BOOL do_parameter(const char *parameter, const char *value)
43 DEBUG(10,("do_parameter: %s, %s\n", parameter, value));
45 if (strequal(parameter, GPT_INI_PARAMETER_VERSION)) {
46 version = atoi(value);
48 return True;
51 NTSTATUS ads_gpo_get_sysvol_gpt_version(ADS_STRUCT *ads,
52 TALLOC_CTX *mem_ctx,
53 const char *filesyspath,
54 uint32 *sysvol_version)
56 NTSTATUS status;
57 const char *path;
58 struct cli_state *cli;
59 int fnum;
60 fstring tok;
61 static int io_bufsize = 64512;
62 int read_size = io_bufsize;
63 char *data = NULL;
64 off_t start = 0;
65 off_t nread = 0;
66 int handle = 0;
67 const char *local_file;
69 *sysvol_version = 0;
71 next_token(&filesyspath, tok, "\\", sizeof(tok));
72 next_token(&filesyspath, tok, "\\", sizeof(tok));
74 path = talloc_asprintf(mem_ctx, "\\%s\\gpt.ini", filesyspath);
75 if (path == NULL) {
76 return NT_STATUS_NO_MEMORY;
79 local_file = talloc_asprintf(mem_ctx, "%s/%s", lock_path("gpo_cache"), "gpt.ini");
80 if (local_file == NULL) {
81 return NT_STATUS_NO_MEMORY;
84 /* FIXME: walk down the dfs tree instead */
85 status = cli_full_connection(&cli, global_myname(),
86 ads->config.ldap_server_name,
87 NULL, 0,
88 "SYSVOL", "A:",
89 ads->auth.user_name, NULL, ads->auth.password,
90 CLI_FULL_CONNECTION_USE_KERBEROS,
91 Undefined, NULL);
92 if (!NT_STATUS_IS_OK(status)) {
93 return status;
96 fnum = cli_open(cli, path, O_RDONLY, DENY_NONE);
97 if (fnum == -1) {
98 return NT_STATUS_NO_SUCH_FILE;
102 data = (char *)SMB_MALLOC(read_size);
103 if (data == NULL) {
104 return NT_STATUS_NO_MEMORY;
107 handle = sys_open(local_file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
109 if (handle == -1) {
110 return NT_STATUS_NO_SUCH_FILE;
113 while (1) {
115 int n = cli_read(cli, fnum, data, nread + start, read_size);
117 if (n <= 0)
118 break;
120 if (write(handle, data, n) != n) {
121 break;
124 nread += n;
127 cli_close(cli, fnum);
129 if (!pm_process(local_file, do_section, do_parameter)) {
130 return NT_STATUS_INVALID_PARAMETER;
133 *sysvol_version = version;
135 SAFE_FREE(data);
137 cli_shutdown(cli);
139 return NT_STATUS_OK;
144 perfectly parseable with pm_process() :))
146 [Unicode]
147 Unicode=yes
148 [System Access]
149 MinimumPasswordAge = 1
150 MaximumPasswordAge = 42
151 MinimumPasswordLength = 7
152 PasswordComplexity = 1
153 PasswordHistorySize = 24
154 LockoutBadCount = 0
155 RequireLogonToChangePassword = 0
156 ForceLogoffWhenHourExpire = 0
157 ClearTextPassword = 0
158 [Kerberos Policy]
159 MaxTicketAge = 10
160 MaxRenewAge = 7
161 MaxServiceAge = 600
162 MaxClockSkew = 5
163 TicketValidateClient = 1
164 [Version]
165 signature="$CHICAGO$"
166 Revision=1