2 * Unix SMB/CIFS implementation.
3 * Group Policy Object Support
4 * Copyright (C) Guenther Deschner 2005-2006
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.
22 #include "iniparser/src/iniparser.h"
24 /****************************************************************
25 parse the local gpt.ini file
26 ****************************************************************/
28 #define GPT_INI_SECTION_GENERAL "General"
29 #define GPT_INI_PARAMETER_VERSION "Version"
30 #define GPT_INI_PARAMETER_DISPLAYNAME "displayName"
32 NTSTATUS
parse_gpt_ini(TALLOC_CTX
*mem_ctx
, const char *filename
, uint32
*version
, char **display_name
)
39 d
= iniparser_load(filename
);
41 return NT_STATUS_NO_SUCH_FILE
;
44 if ((name
= iniparser_getstring(d
, GPT_INI_SECTION_GENERAL
45 ":"GPT_INI_PARAMETER_DISPLAYNAME
, NULL
)) == NULL
) {
46 /* the default domain policy and the default domain controller
47 * policy never have a displayname in their gpt.ini file */
48 DEBUG(10,("parse_gpt_ini: no name in %s\n", filename
));
51 if (name
&& display_name
) {
52 *display_name
= talloc_strdup(mem_ctx
, name
);
53 if (*display_name
== NULL
) {
54 result
= NT_STATUS_NO_MEMORY
;
59 if ((v
= iniparser_getint(d
, GPT_INI_SECTION_GENERAL
60 ":"GPT_INI_PARAMETER_VERSION
, Undefined
)) == Undefined
) {
61 DEBUG(10,("parse_gpt_ini: no version\n"));
62 result
= NT_STATUS_INTERNAL_DB_CORRUPTION
;
70 result
= NT_STATUS_OK
;
73 iniparser_freedict(d
);
81 /****************************************************************
82 parse the Version section from gpttmpl file
83 ****************************************************************/
85 #define GPTTMPL_SECTION_VERSION "Version"
86 #define GPTTMPL_PARAMETER_REVISION "Revision"
87 #define GPTTMPL_PARAMETER_SIGNATURE "signature"
88 #define GPTTMPL_CHICAGO "$CHICAGO$" /* whatever this is good for... */
89 #define GPTTMPL_SECTION_UNICODE "Unicode"
90 #define GPTTMPL_PARAMETER_UNICODE "Unicode"
92 static NTSTATUS
parse_gpttmpl(dictionary
*d
, uint32
*version_out
)
94 const char *signature
= NULL
;
97 if ((signature
= iniparser_getstring(d
, GPTTMPL_SECTION_VERSION
98 ":"GPTTMPL_PARAMETER_SIGNATURE
, NULL
)) == NULL
) {
99 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
102 if (!strequal(signature
, GPTTMPL_CHICAGO
)) {
103 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
106 if ((version
= iniparser_getint(d
, GPTTMPL_SECTION_VERSION
107 ":"GPTTMPL_PARAMETER_REVISION
, Undefined
)) == Undefined
) {
108 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
112 *version_out
= version
;
115 /* treat that as boolean */
116 if ((!iniparser_getboolean(d
, GPTTMPL_SECTION_UNICODE
117 ":"GPTTMPL_PARAMETER_UNICODE
, Undefined
)) == Undefined
) {
118 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
124 /****************************************************************
125 parse the "System Access" section from gpttmpl file
126 ****************************************************************/
128 #define GPTTMPL_SECTION_SYSTEM_ACCESS "System Access"
129 #define GPTTMPL_PARAMETER_MINPWDAGE "MinimumPasswordAge"
130 #define GPTTMPL_PARAMETER_MAXPWDAGE "MaximumPasswordAge"
131 #define GPTTMPL_PARAMETER_MINPWDLEN "MinimumPasswordLength"
132 #define GPTTMPL_PARAMETER_PWDCOMPLEX "PasswordComplexity"
133 #define GPTTMPL_PARAMETER_PWDHISTORY "PasswordHistorySize"
134 #define GPTTMPL_PARAMETER_LOCKOUTCOUNT "LockoutBadCount"
136 static NTSTATUS
parse_gpttmpl_system_access(const char *filename
)
139 dictionary
*d
= NULL
;
140 uint32 pwd_min_age
, pwd_max_age
, pwd_min_len
, pwd_history
;
141 uint32 lockout_count
;
145 d
= iniparser_load(filename
);
147 return NT_STATUS_NO_SUCH_FILE
;
150 status
= parse_gpttmpl(d
, &version
);
151 if (!NT_STATUS_IS_OK(status
)) {
155 status
= NT_STATUS_INVALID_PARAMETER
;
157 if ((pwd_min_age
= iniparser_getint(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
158 ":"GPTTMPL_PARAMETER_MINPWDAGE
, Undefined
)) == Undefined
) {
162 if ((pwd_max_age
= iniparser_getint(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
163 ":"GPTTMPL_PARAMETER_MINPWDAGE
, Undefined
)) == Undefined
) {
167 if ((pwd_min_len
= iniparser_getint(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
168 ":"GPTTMPL_PARAMETER_MINPWDLEN
, Undefined
)) == Undefined
) {
172 if ((pwd_complex
= iniparser_getboolean(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
173 ":"GPTTMPL_PARAMETER_PWDCOMPLEX
, Undefined
)) == Undefined
) {
177 if ((pwd_history
= iniparser_getint(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
178 ":"GPTTMPL_PARAMETER_PWDHISTORY
, Undefined
)) == Undefined
) {
182 if ((lockout_count
= iniparser_getint(d
, GPTTMPL_SECTION_SYSTEM_ACCESS
183 ":"GPTTMPL_PARAMETER_LOCKOUTCOUNT
, Undefined
)) == Undefined
) {
188 RequireLogonToChangePassword = 0
189 ForceLogoffWhenHourExpire = 0
190 ClearTextPassword = 0
193 status
= NT_STATUS_OK
;
197 iniparser_freedict(d
);
203 /****************************************************************
204 parse the "Kerberos Policy" section from gpttmpl file
205 ****************************************************************/
207 #define GPTTMPL_SECTION_KERBEROS_POLICY "Kerberos Policy"
208 #define GPTTMPL_PARAMETER_MAXTKTAGE "MaxTicketAge"
209 #define GPTTMPL_PARAMETER_MAXRENEWAGE "MaxRenewAge"
210 #define GPTTMPL_PARAMETER_MAXTGSAGE "MaxServiceAge"
211 #define GPTTMPL_PARAMETER_MAXCLOCKSKEW "MaxClockSkew"
212 #define GPTTMPL_PARAMETER_TKTVALIDATECLIENT "TicketValidateClient"
214 static NTSTATUS
parse_gpttmpl_kerberos_policy(const char *filename
)
217 dictionary
*d
= NULL
;
218 uint32 tkt_max_age
, tkt_max_renew
, tgs_max_age
, max_clock_skew
;
222 d
= iniparser_load(filename
);
224 return NT_STATUS_NO_SUCH_FILE
;
227 status
= parse_gpttmpl(d
, &version
);
228 if (!NT_STATUS_IS_OK(status
)) {
232 status
= NT_STATUS_INVALID_PARAMETER
;
234 if ((tkt_max_age
= iniparser_getint(d
, GPTTMPL_SECTION_KERBEROS_POLICY
235 ":"GPTTMPL_PARAMETER_MAXTKTAGE
, Undefined
)) != Undefined
) {
239 if ((tkt_max_renew
= iniparser_getint(d
, GPTTMPL_SECTION_KERBEROS_POLICY
240 ":"GPTTMPL_PARAMETER_MAXRENEWAGE
, Undefined
)) != Undefined
) {
244 if ((tgs_max_age
= iniparser_getint(d
, GPTTMPL_SECTION_KERBEROS_POLICY
245 ":"GPTTMPL_PARAMETER_MAXTGSAGE
, Undefined
)) != Undefined
) {
249 if ((max_clock_skew
= iniparser_getint(d
, GPTTMPL_SECTION_KERBEROS_POLICY
250 ":"GPTTMPL_PARAMETER_MAXCLOCKSKEW
, Undefined
)) != Undefined
) {
254 if ((tkt_validate
= iniparser_getboolean(d
, GPTTMPL_SECTION_KERBEROS_POLICY
255 ":"GPTTMPL_PARAMETER_TKTVALIDATECLIENT
, Undefined
)) != Undefined
) {
259 status
= NT_STATUS_OK
;
263 iniparser_freedict(d
);
273 perfectly parseable with iniparser:
275 {GUID}/Machine/Microsoft/Windows NT/SecEdit/GptTmpl.inf
281 MinimumPasswordAge = 1
282 MaximumPasswordAge = 42
283 MinimumPasswordLength = 7
284 PasswordComplexity = 1
285 PasswordHistorySize = 24
287 RequireLogonToChangePassword = 0
288 ForceLogoffWhenHourExpire = 0
289 ClearTextPassword = 0
295 TicketValidateClient = 1
297 signature="$CHICAGO$"