2 * Unix SMB/CIFS implementation.
3 * Virtual Windows Registry Layer
4 * Copyright (C) Gerald Carter 2002-2005
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 /* Implementation of registry frontend view functions. */
26 #define DBGC_CLASS DBGC_RPC_SRV
28 struct reg_dyn_values
{
30 int (*fetch_values
) ( REGVAL_CTR
*val
);
33 /***********************************************************************
34 ***********************************************************************/
36 static int netlogon_params( REGVAL_CTR
*regvals
)
40 if ( !pdb_get_account_policy(AP_REFUSE_MACHINE_PW_CHANGE
, &dwValue
) )
43 regval_ctr_addvalue( regvals
, "RefusePasswordChange", REG_DWORD
,
44 (char*)&dwValue
, sizeof(dwValue
) );
46 return regval_ctr_numvals( regvals
);
49 /***********************************************************************
50 ***********************************************************************/
52 static int prod_options( REGVAL_CTR
*regvals
)
54 const char *value_ascii
= "";
58 switch (lp_server_role()) {
61 value_ascii
= "LanmanNT";
64 value_ascii
= "ServerNT";
66 case ROLE_DOMAIN_MEMBER
:
67 value_ascii
= "WinNT";
71 value_length
= push_ucs2( value
, value
, value_ascii
, sizeof(value
),
72 STR_TERMINATE
|STR_NOALIGN
);
73 regval_ctr_addvalue( regvals
, "ProductType", REG_SZ
, value
,
76 return regval_ctr_numvals( regvals
);
79 /***********************************************************************
80 ***********************************************************************/
82 static int tcpip_params( REGVAL_CTR
*regvals
)
91 value_length
= push_ucs2( value
, value
, hname
, sizeof(value
), STR_TERMINATE
|STR_NOALIGN
);
92 regval_ctr_addvalue( regvals
, "Hostname",REG_SZ
, value
, value_length
);
94 get_mydnsdomname( mydomainname
);
95 value_length
= push_ucs2( value
, value
, mydomainname
, sizeof(value
), STR_TERMINATE
|STR_NOALIGN
);
96 regval_ctr_addvalue( regvals
, "Domain", REG_SZ
, value
, value_length
);
98 return regval_ctr_numvals( regvals
);
101 /***********************************************************************
102 ***********************************************************************/
104 static int perflib_params( REGVAL_CTR
*regvals
)
107 int last_counter
= -1;
109 int version
= 0x00010001;
111 base_index
= reg_perfcount_get_base_index();
112 regval_ctr_addvalue(regvals
, "Base Index", REG_DWORD
, (char *)&base_index
, sizeof(base_index
));
113 last_counter
= reg_perfcount_get_last_counter(base_index
);
114 regval_ctr_addvalue(regvals
, "Last Counter", REG_DWORD
, (char *)&last_counter
, sizeof(last_counter
));
115 last_help
= reg_perfcount_get_last_help(last_counter
);
116 regval_ctr_addvalue(regvals
, "Last Help", REG_DWORD
, (char *)&last_help
, sizeof(last_help
));
117 regval_ctr_addvalue(regvals
, "Version", REG_DWORD
, (char *)&version
, sizeof(version
));
119 return regval_ctr_numvals( regvals
);
122 /***********************************************************************
123 ***********************************************************************/
125 static int perflib_009_params( REGVAL_CTR
*regvals
)
131 base_index
= reg_perfcount_get_base_index();
132 buffer_size
= reg_perfcount_get_counter_names(base_index
, &buffer
);
133 regval_ctr_addvalue(regvals
, "Counter", REG_MULTI_SZ
, buffer
, buffer_size
);
136 buffer_size
= reg_perfcount_get_counter_help(base_index
, &buffer
);
137 regval_ctr_addvalue(regvals
, "Help", REG_MULTI_SZ
, buffer
, buffer_size
);
141 return regval_ctr_numvals( regvals
);
144 /***********************************************************************
145 ***********************************************************************/
147 static int hkpt_params( REGVAL_CTR
*regvals
)
153 /* This is ALMOST the same as perflib_009_params, but HKPT has
154 a "Counters" entry instead of a "Counter" key. <Grrrr> */
156 base_index
= reg_perfcount_get_base_index();
157 buffer_size
= reg_perfcount_get_counter_names(base_index
, &buffer
);
158 regval_ctr_addvalue(regvals
, "Counters", REG_MULTI_SZ
, buffer
, buffer_size
);
163 buffer_size
= reg_perfcount_get_counter_help(base_index
, &buffer
);
164 regval_ctr_addvalue(regvals
, "Help", REG_MULTI_SZ
, buffer
, buffer_size
);
168 return regval_ctr_numvals( regvals
);
171 /***********************************************************************
172 ***********************************************************************/
174 static int current_version( REGVAL_CTR
*values
)
176 const char *sysroot_string
= "c:\\Windows";
181 value_length
= push_ucs2( value
, value
, sysroot_string
, sizeof(value
),
182 STR_TERMINATE
|STR_NOALIGN
);
183 regval_ctr_addvalue( values
, "SystemRoot", REG_SZ
, value
, value_length
);
185 fstr_sprintf( sysversion
, "%d.%d", lp_major_announce_version(), lp_minor_announce_version() );
186 value_length
= push_ucs2( value
, value
, sysversion
, sizeof(value
),
187 STR_TERMINATE
|STR_NOALIGN
);
188 regval_ctr_addvalue( values
, "CurrentVersion", REG_SZ
, value
, value_length
);
191 return regval_ctr_numvals( values
);
195 /***********************************************************************
196 Structure holding the registry paths and pointers to the value
197 enumeration functions
198 ***********************************************************************/
200 static struct reg_dyn_values dynamic_values
[] = {
201 { "HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/NETLOGON/PARAMETERS", &netlogon_params
},
202 { "HKLM/SYSTEM/CURRENTCONTROLSET/CONTROL/PRODUCTOPTIONS", &prod_options
},
203 { "HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/TCPIP/PARAMETERS", &tcpip_params
},
204 { "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION/PERFLIB", &perflib_params
},
205 { "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION/PERFLIB/009", &perflib_009_params
},
206 { "HKLM/SOFTWARE/MICROSOFT/WINDOWS NT/CURRENTVERSION", ¤t_version
},
207 { "HKPT", &hkpt_params
},
211 /***********************************************************************
212 ***********************************************************************/
214 int fetch_dynamic_reg_values( REGISTRY_KEY
*key
, REGVAL_CTR
*val
)
219 pstrcpy( path
, key
->name
);
220 normalize_reg_path( path
);
222 for ( i
=0; dynamic_values
[i
].path
; i
++ ) {
223 if ( strcmp( path
, dynamic_values
[i
].path
) == 0 )
224 return dynamic_values
[i
].fetch_values( val
);
230 /***********************************************************************
231 ***********************************************************************/
233 BOOL
check_dynamic_reg_values( REGISTRY_KEY
*key
)
238 pstrcpy( path
, key
->name
);
239 normalize_reg_path( path
);
241 for ( i
=0; dynamic_values
[i
].path
; i
++ ) {
242 /* can't write to dynamic keys */
243 if ( strcmp( path
, dynamic_values
[i
].path
) == 0 )