Registry-tools : some problems ?

denis.bonnenfant denis.bonnenfant at diderot.org
Fri Mar 27 13:07:12 GMT 2009


Hi everybody,

I played and hacked a little bit with samba4 registry tools, and found 
some problems. As this part of samba4 seems to have not been modified 
during the last 2 years, I want to be sure that improving it will be 
worth the effort, as it mainly concerns not-AD samba3-x domains ( but 
this is still the very most of the production servers ). My goal is to 
allow server-side editing of user's hives for seamless XP/vista clients 
integration. I know that AD/GPO will do the same, but migrating all our  
management solution (www.sambaedu.org <http://www.sambaedu.org>) to AD 
is a really big task !

The problems :

- regpatch doesn't support patching a regf file : -F option is not 
implemented. I added it by mounting the hive to HKEY_CURRENT_USER, and 
it works quite well. My patch is somewhat hacky, as I harcoded 
predefined keys, but it works. I modified the same way regdiff, so regf 
hives can be dumped to .reg files. The result is quite good, but there 
are maybe some little string formatting problems remaining  with complex 
values.

- Duplicate key writes : I found a big issue : when adding a new key, 
there is no check to see if it already exists. So duplicates are created 
when recursing to  asubkey  for adding a value for example : 

with a regf file containing
[HKEY_CURRENT_USER/A]


REGEDIT4
[HKEY_CURRENT_USER/A/B]  

will result in :

[HKEY_CURRENT_USER/A]
[HKEY_CURRENT_USER/A/B]

so [HKEY_CURRENT_USER/A] is duplicated, and these keys are invalid with 
winXP regedit32

All my tests in windows shows that a key will never be duplicated using 
windows tools. So my question is : does the check has to be done by the 
fontends, or is the backend responsability to check key unicity ?

I decided doing it low-level in regf.c :

in regf_add_key function :

nk.clsname_length = 0;
nk.key_name = name;
+
+ /* Check if the key already exists */
+ if (W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk,
+ parent, name,
+ ret))) {
+ DEBUG(0, ("Key '%s' already exists\n", name));
+ return WERR_OK;
+ }
+
/* Get the security descriptor of the root key */
root = talloc_zero(ctx, struct nk_block);
W_ERROR_HAVE_NO_MEMORY(root);

And now the biggest issue : there are some other errors when creating 
keys  :
for ex:
[HKEY_CURRENT_USER/A/B]

adding key A
Found free block of size 3360 (needing 88) in middle of HBIN
Found free block of size 3272 (needing 32) in middle of HBIN
open_key A
adding key B
Can't find HBIN containing 0xffffffff
Unable to find subkey list
Found free block of size 3240 (needing 88) in middle of HBIN
Found free block of size 24 (needing 16) in middle of HBIN

keys are created, but the result is invalid in windows.

Looks like new keys are created with an invalid subkey offset (-1)

Does the original contributors can help me to solve this ?

Thanks,

Denis


More information about the samba-technical mailing list