The branch, master has been updated
       via  e952191 selftest: remove printserver.enum_printers_servername from 
flapping
       via  dce2a28 selftest: remove 
samba3.rpc.spoolss.*printserver.openprinter_badnamelist from flapping
       via  ef8e228 selftest: mark the driver_info_winreg tests knownfail.
       via  e43d025 selftest: mark failing print_tests more specifically
       via  9db52c4 selftest: remove .*printer.*print_test_extended from 
flapping
       via  1837b90 selftest: remove the "rpc.spoolss.printer" test from 
flapping
       via  c333885 s3:registry: replace call to reg_openkey() in 
reg_createkey() by accesscheck.
       via  7f205bc s3:registry: remove a superfluous fill_subkey_cache() in 
reg_createkey()
       via  4b7817a s3:registry: use fill_subkey_cache to check exsistence in 
regkey_open_onelevel().
       via  be2cb08 s3:registry: let fill_subkey_cache return WERR_BADFILE when 
the subkey list could not be loaded
       via  1703e6f s3:registry: convert reg_openkey() to use talloc instead of 
SMB_STRDUP etc
       via  323ec9f s3:registry untangle an assignment from the check in 
regkey_open_onelevel()
       via  640ceca s3:registry: untangle assignment from check in 
regkey_open_onelevel()
       via  22451f7 s3:registry: fix seqnum race in regdb_fetch_keys_internal
       via  7ea8bd3 s3:registry: fix seqnum race in fetch_values_internal
       via  ab83005 s3:registry: update the seqnum in the subkey cache at the 
end of regval_store_keys
       via  4367071 s3:registry:db: update the value container seqnum after 
storing/deleting to prevent next read from going to disk if possible
       via  8c7047b s3:registry: wrap reg_deletekey() into a transaction
       via  32ac4f4 s3:registry: wrap reg_createkey() in a transaction
       via  1af68be s3:registry: untangle assignments from checks in 
reg_createkey()
       via  8d19ac7 s3:registry: wrap reg_deletevalue() in a transaction
       via  97bf058 s3:registry: untangle assignment from check in 
reg_deletevalue()
       via  8ddc2aa s3:registry: fix race in reg_setvalue that could lead to 
data corruption
       via  705ea5b s3:registry: untangle assignment from check and add a 
debugmessage in reg_setvalue()
       via  04aa303 s3:registry: don't leak the old contents when updating the 
value cache
       via  f474725 s3:registry: fix debug message in 
regdb_store_values_internal()
       via  4415933 s3:registry: improve log message in regdb_unpack_values()
       via  6f67f5d s3:registry: fix a debug message typo
       via  64a9ab4 s3:registry: add a new function regval_ctr_value_byname()
       via  2fc610c s3:registry: rename regval_ctr_key_exists() to 
regval_ctr_value_exists()
       via  421b398 s4:torture:rpc:spoolss: also initialize driverName before 
checking it in test_PrinterData_DsSpooler()
       via  6c01673 s3:registry:reg_api: fix reg_queryvalue to not fail when 
values are modified while it runs
       via  877af95 s3:registry: make regdb_values_need_update() static
       via  bc48100 s3:registry: make regdb_subkeys_need_update() static
       via  a3b1c13 s3:registry: make regdb_store_values() static
       via  6ab2eb8 s3:registry: make regdb_fetch_values() static
       via  5fdd602 s3:registry: make regdb_fetch_keys() static
       via  4cf4417 s3:registry: make regdb_store_keys() static
       via  3771593 s3:registry: printing backend: use regdb options via ops 
struct, not directly
       via  36cb40e s3:registry: remove usage of reg_objects from 
net_rpc_printer.c
       via  d14ca5d s3:registry: remove usage of reg_objects from cmd_spoolss.c
       via  4eb4f75 s3:eventlogadm make a transaction for addsource
       via  c6224e4 s3:eventlogadm reimplement addsource using reg_api
       via  5b636e5 s3-waf: Cleanup smbregistry.
       via  cd2616c s3:registry: remove usage of reg_objects from 
srv_spoolss_nt.c
       via  7ba1b13 s3:registry: remove usage of reg_objects from 
libads/ldap_printer.c
      from  b805513 s4-messaging: Use generate_random() to get a unique ID for 
messaging clients

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e952191fccf12e0b6959c0bef42935a9a0340bbe
Author: Michael Adam <ob...@samba.org>
Date:   Tue Apr 24 01:02:29 2012 +0200

    selftest: remove printserver.enum_printers_servername from flapping
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    
    Autobuild-User: Andreas Schneider <a...@cryptomilk.org>
    Autobuild-Date: Wed Apr 25 17:18:28 CEST 2012 on sn-devel-104

commit dce2a28574e4a2c4c31a441b3a89cb7566f506bb
Author: Michael Adam <ob...@samba.org>
Date:   Tue Apr 24 01:02:03 2012 +0200

    selftest: remove samba3.rpc.spoolss.*printserver.openprinter_badnamelist 
from flapping
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit ef8e228a5b4952b51d9db6b28017142759f40d10
Author: Michael Adam <ob...@samba.org>
Date:   Tue Apr 24 00:36:03 2012 +0200

    selftest: mark the driver_info_winreg tests knownfail.
    
    They only get executed when driver files are around.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit e43d025ae35879f77eca8a91681c151036fbb5bb
Author: Michael Adam <ob...@samba.org>
Date:   Tue Apr 24 00:28:48 2012 +0200

    selftest: mark failing print_tests more specifically
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 9db52c4ee074a6c96d3e62841e7ccff3ac834045
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 16 13:55:26 2012 +0200

    selftest: remove .*printer.*print_test_extended from flapping
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 1837b9008d6f9f0f09bcaea3b9198c760e8c1167
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 17:10:34 2012 +0200

    selftest: remove the "rpc.spoolss.printer" test from flapping
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit c333885fa11fcaca71fd6ddde9c3f09a06ececd0
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 16:44:15 2012 +0200

    s3:registry: replace call to reg_openkey() in reg_createkey() by 
accesscheck.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 7f205bcbf2f8501f2008a457a3749f4d93127837
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 16:13:29 2012 +0200

    s3:registry: remove a superfluous fill_subkey_cache() in reg_createkey()
    
    Pair-Programmed-With: Gregor Beck <gb...@sernet.de>
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 4b7817aa80c3ea4efe47da91cf71c25e1afc6a6b
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 16:07:21 2012 +0200

    s3:registry: use fill_subkey_cache to check exsistence in 
regkey_open_onelevel().
    
    Pair-Programmed-With: Gregor Beck <gb...@sernet.de>
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit be2cb08e405036532c97e3f7dc50607582c0daeb
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 16:05:33 2012 +0200

    s3:registry: let fill_subkey_cache return WERR_BADFILE when the subkey list 
could not be loaded
    
    WERR_NO_MORE_ITEMS seems inappropriate.
    
    Pair-Programmed-With: Gregor Beck <gb...@sernet.de>
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 1703e6fe096ea9e3e14c189522150321fee1a4c5
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 15:47:33 2012 +0200

    s3:registry: convert reg_openkey() to use talloc instead of SMB_STRDUP etc
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 323ec9f9b46edb5792bd0695955184e4111e9a34
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 15:30:38 2012 +0200

    s3:registry untangle an assignment from the check in regkey_open_onelevel()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 640cecab195e378da6d661d860477ffe531b76cd
Author: Michael Adam <ob...@samba.org>
Date:   Mon Apr 23 15:29:41 2012 +0200

    s3:registry: untangle assignment from check in regkey_open_onelevel()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 22451f7f45c1f692dc9d40af0e6ce82666359390
Author: Michael Adam <ob...@samba.org>
Date:   Wed Apr 11 15:51:40 2012 +0200

    s3:registry: fix seqnum race in regdb_fetch_keys_internal
    
    This prevents race between fetching seqnum and key content.
    
    Because there is currently no way to atomically fetch the
    record along with the seqnum, I use a loop.
    This is far from optimal and should should ideally be done
    differently. But for now it fixes the race.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 7ea8bd3605adb3a53ca44ebdabfdcdb9c1aeaa18
Author: Michael Adam <ob...@samba.org>
Date:   Wed Apr 11 15:48:02 2012 +0200

    s3:registry: fix seqnum race in fetch_values_internal
    
    This prevents race between fetching seqnum and key content.
    
    Because there is currently no way to atomically fetch the
    record along with the seqnum, I use a loop.
    This is far from optimal and should should ideally be done
    differently. But for now it fixes the race.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit ab83005b30c621230db674faa1d123f44c9122e7
Author: Michael Adam <ob...@samba.org>
Date:   Wed Apr 11 16:02:44 2012 +0200

    s3:registry: update the seqnum in the subkey cache at the end of 
regval_store_keys
    
    The purpose is to prevent next reads from going to disk.
    
    Note that this will currently only be effective with local tdbs, not
    with ctdb: For tdb, store and delete bump the seqnum while transaction
    commit does not. For ctdb, transaction commit bumps the seqnum, while
    store and delete don't... This needs fixing (in ctdb).
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 4367071f62d2994f1d3d4f33d45fcd6b4c7bec26
Author: Michael Adam <ob...@samba.org>
Date:   Wed Apr 11 15:38:29 2012 +0200

    s3:registry:db: update the value container seqnum after storing/deleting to 
prevent next read from going to disk if possible
    
    Note that this will currently only be effective in the local TDB 
implementation.
    For CTDB, this wont work since seqnum currently works differently there 
(needs
    fixing): For tdb, store and delete operations bump the db seqnum, while
    transaction commits don't. For ctdb, the seqnum is bumped by the transaction
    commit but not by store and delete operations.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 8c7047b0e7b1ee25a6a5535cf495c9afded2d924
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 22:53:24 2012 +0200

    s3:registry: wrap reg_deletekey() into a transaction
    
    This is wrong layering but fixes a race condition.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 32ac4f4b34dd2788498f0c09c946532165d6af74
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 22:17:35 2012 +0200

    s3:registry: wrap reg_createkey() in a transaction
    
    This is wrong layering (calling into regdb_transaction* in the reg_api code)
    but fixes a potential race. It makes the multi-step create procedure atomic.
    
    This should completely be done in the backend.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 1af68be008a11bffdf78d70c8d1635003a3c4407
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 17:58:26 2012 +0200

    s3:registry: untangle assignments from checks in reg_createkey()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 8d19ac7474e67eb8ffccb717c177c952e10e88e3
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 17:52:43 2012 +0200

    s3:registry: wrap reg_deletevalue() in a transaction
    
    This is at the wrong layer, but if fixes a race potentially causing
    data corruption by concurrent access.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 97bf05871ad384fd53f04b92489934fef1e42d63
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 17:46:02 2012 +0200

    s3:registry: untangle assignment from check in reg_deletevalue()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 8ddc2aa0e1734f00f120c4ac7a0e2ebbaa888f11
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 13:38:32 2012 +0200

    s3:registry: fix race in reg_setvalue that could lead to data corruption
    
    (there was no lock around fetching the values and storing them)
    
    The layering is wrong in that it uses regdb transactions in reg_api
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 705ea5b8c29a7ea9d1e2865abeec3d31d4c18d93
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 15:19:47 2012 +0200

    s3:registry: untangle assignment from check and add a debugmessage in 
reg_setvalue()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 04aa303fb11ed7b275a1268f932bb79209f77787
Author: Michael Adam <ob...@samba.org>
Date:   Thu Apr 12 08:18:04 2012 +0200

    s3:registry: don't leak the old contents when updating the value cache
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit f4747250ea1d1090dda4c0a8a32aa2a4587ba4b4
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 15:39:58 2012 +0200

    s3:registry: fix debug message in regdb_store_values_internal()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 44159330db1317812bf581433f97d8792a86fb70
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 15:35:14 2012 +0200

    s3:registry: improve log message in regdb_unpack_values()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 6f67f5d5b73d1a857f20103bd7f69245a18155f1
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 15:14:01 2012 +0200

    s3:registry: fix a debug message typo
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 64a9ab4f82e54420caa26f92ef99b13084923282
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 14:39:50 2012 +0200

    s3:registry: add a new function regval_ctr_value_byname()
    
    This is like regval_ctr_key_exists() but does not return bool,
    but the regval_blob instead, if found, and NULL if not found.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 2fc610caf5c4a54556464623976d5f92871c49c9
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 14:33:39 2012 +0200

    s3:registry: rename regval_ctr_key_exists() to regval_ctr_value_exists()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 421b3984cdf16f4755d6e7113c03b49ff8ff4bfa
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 01:00:51 2012 +0200

    s4:torture:rpc:spoolss: also initialize driverName before checking it in 
test_PrinterData_DsSpooler()
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 6c016734aa98836f818a9549a0ac4917381abca2
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 30 00:10:14 2012 +0200

    s3:registry:reg_api: fix reg_queryvalue to not fail when values are 
modified while it runs
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 877af95ed714452bc1ea58c0aad113f599fcc787
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:23:44 2012 +0200

    s3:registry: make regdb_values_need_update() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit bc48100530c7438bc2efc61e73afe31841c298c4
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:22:27 2012 +0200

    s3:registry: make regdb_subkeys_need_update() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit a3b1c13cd4ed2c801e6b98e04e5696a4d6013051
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:21:16 2012 +0200

    s3:registry: make regdb_store_values() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 6ab2eb829552f6bcf932c13ce31da509727e1779
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:19:56 2012 +0200

    s3:registry: make regdb_fetch_values() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 5fdd6026055cb9cc591976c3a84b1635a92bc2a0
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:18:39 2012 +0200

    s3:registry: make regdb_fetch_keys() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 4cf44177ac6a898547d4e713d20e38d8ebe37d3a
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:10:54 2012 +0200

    s3:registry: make regdb_store_keys() static
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 37715930c29acbbd6527e7737fd3114cda6c89d2
Author: Michael Adam <ob...@samba.org>
Date:   Fri Apr 20 14:07:30 2012 +0200

    s3:registry: printing backend: use regdb options via ops struct, not 
directly
    
    just like the other backends.
    
    This is in preparation of making the backend functions private
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 36cb40ef2bd04d7b09bea0400404fcd2bbd5face
Author: Gregor Beck <gb...@sernet.de>
Date:   Thu Apr 19 15:40:40 2012 +0200

    s3:registry: remove usage of reg_objects from net_rpc_printer.c
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit d14ca5d07abfc46c20bc87fc66314e9ede29b0ac
Author: Gregor Beck <gb...@sernet.de>
Date:   Thu Apr 19 14:00:36 2012 +0200

    s3:registry: remove usage of reg_objects from cmd_spoolss.c
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 4eb4f75371aa16bf19474090b1dbef042e9a0446
Author: Gregor Beck <gb...@sernet.de>
Date:   Thu Apr 19 13:32:26 2012 +0200

    s3:eventlogadm make a transaction for addsource
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit c6224e46aa0bd25f81b6f75b5cfc3d54d07261d9
Author: Gregor Beck <gb...@sernet.de>
Date:   Thu Apr 19 13:30:40 2012 +0200

    s3:eventlogadm reimplement addsource using reg_api
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 5b636e524920de98daef8e2ee6fb588e79a2bf6e
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Apr 25 14:15:42 2012 +0200

    s3-waf: Cleanup smbregistry.

commit cd2616cc16ae5d33d0ae26a3a75370e75c050c64
Author: Gregor Beck <gb...@sernet.de>
Date:   Wed Apr 18 16:16:05 2012 +0200

    s3:registry: remove usage of reg_objects from srv_spoolss_nt.c
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 7ba1b13e99997f7d2650b4951d217e3ca0f5a15e
Author: Gregor Beck <gb...@sernet.de>
Date:   Wed Apr 18 16:06:07 2012 +0200

    s3:registry: remove usage of reg_objects from libads/ldap_printer.c
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 selftest/flapping                           |    6 +-
 selftest/knownfail                          |    2 +
 source3/libads/ldap_printer.c               |  145 ++++++----------
 source3/registry/reg_api.c                  |  255 +++++++++++++++++++++------
 source3/registry/reg_backend_db.c           |  101 +++++++++--
 source3/registry/reg_backend_db.h           |    6 -
 source3/registry/reg_backend_printing.c     |   19 +-
 source3/registry/reg_objects.c              |   20 ++-
 source3/registry/reg_objects.h              |    4 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c |    1 -
 source3/rpcclient/cmd_spoolss.c             |   43 ++---
 source3/utils/eventlogadm.c                 |  199 +++++++++++----------
 source3/utils/net_rpc_printer.c             |  202 ++++++++--------------
 source3/wscript_build                       |   14 +-
 source4/torture/rpc/spoolss.c               |    1 +
 15 files changed, 564 insertions(+), 454 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/flapping b/selftest/flapping
index 91194df..fbd38af 100644
--- a/selftest/flapping
+++ b/selftest/flapping
@@ -12,12 +12,8 @@
 ^samba3.smbtorture_s3.*OPLOCK4 # fails sometimes on sn-devel
 ^samba4.nbt.winsreplication.owned # fails sometimes, timing related
 ^samba3.rpc.spoolss.*printserver.enum_printers_old # fails on some hosts due 
to timing issues ?
-^samba3.rpc.spoolss.*printserver.openprinter_badnamelist # # fails sometimes 
on sn-devel, but should be fixed
-^samba3.rpc.spoolss.*printserver.enum_printers_servername # fails sometimes on 
sn-devel, but should be fixed
 ^samba3.rpc.spoolss.printer.*addprinterex.print_test # another intermittent 
failure
-.*printer.*print_test_extended # fails on some hosts due to timing issues ?
-.*printer.*print_test # fails on some hosts due to timing issues ?
-.*rpc.spoolss.printer # seems to be flakey currently, but should be fixed
 ^samba3.rap.printing # fails sometimes on sn-devel
+^samba3.rpc.spoolss.printer.*addprinter.print_test # fails on some hosts due 
to timing issues ?
 ^samba3.smb2.lock.*.rw-exclusive # another intermittent failure
 ^samba4.blackbox.gentest # is flakey due to timing
diff --git a/selftest/knownfail b/selftest/knownfail
index 82ff0d6..525fb4c 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -192,3 +192,5 @@
 ^samba3.smb2.setinfo .setinfo
 ^samba3.smb2.session .reconnect
 ^samba3.smb2.session .reauth
+^samba3.rpc.spoolss.printer.*addprinter.driver_info_winreg # knownfail or 
flapping?
+^samba3.rpc.spoolss.printer.*addprinterex.driver_info_winreg # knownfail or 
flapping?
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index 8ff9f9b..e9eb419 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -22,7 +22,8 @@
 #include "rpc_client/rpc_client.h"
 #include "../librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_client/cli_spoolss.h"
-#include "registry/reg_objects.h"
+#include "registry.h"
+#include "libcli/registry/util_reg.h"
 
 #ifdef HAVE_ADS
 
@@ -114,46 +115,45 @@ ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char 
*prt_dn,
 /*
   map a REG_SZ to an ldap mod
 */
-static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
-                  struct regval_blob *value)
+static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
+                  const char *name, struct registry_value *value)
 {
-       char *str_value = NULL;
-       size_t converted_size;
+       const char *str_value = NULL;
        ADS_STATUS status;
 
-       if (regval_type(value) != REG_SZ)
+       if (value->type != REG_SZ)
                return false;
 
-       if (regval_size(value) && *((smb_ucs2_t *) regval_data_p(value))) {
-               if (!pull_ucs2_talloc(ctx, &str_value,
-                                     (const smb_ucs2_t *) regval_data_p(value),
-                                     &converted_size))
-               {
+       if (value->data.length  && value->data.data) {
+               if (!pull_reg_sz(ctx, &value->data, &str_value)) {
                        return false;
                }
-               status = ads_mod_str(ctx, mods, regval_name(value), str_value);
+               status = ads_mod_str(ctx, mods, name, str_value);
                return ADS_ERR_OK(status);
        }
        return true;
-               
 }
 
 /*
   map a REG_DWORD to an ldap mod
 */
-static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
-                     struct regval_blob *value)
+static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods,
+                     const char *name, struct registry_value *value)
 {
        char *str_value = NULL;
        ADS_STATUS status;
 
-       if (regval_type(value) != REG_DWORD)
-               return False;
-       str_value = talloc_asprintf(ctx, "%d", *((uint32 *) 
regval_data_p(value)));
+       if (value->type != REG_DWORD) {
+               return false;
+       }
+       if (value->data.length != sizeof(uint32)) {
+               return false;
+       }
+       str_value = talloc_asprintf(ctx, "%d", IVAL(value->data.data, 0));
        if (!str_value) {
-               return False;
+               return false;
        }
-       status = ads_mod_str(ctx, mods, regval_name(value), str_value);
+       status = ads_mod_str(ctx, mods, name, str_value);
        return ADS_ERR_OK(status);
 }
 
@@ -161,19 +161,21 @@ static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods,
   map a boolean REG_BINARY to an ldap mod
 */
 static bool map_bool(TALLOC_CTX *ctx, ADS_MODLIST *mods,
-                    struct regval_blob *value)
+                    const char *name, struct registry_value *value)
 {
-       char *str_value;
+       const char *str_value;
        ADS_STATUS status;
 
-       if ((regval_type(value) != REG_BINARY) || (regval_size(value) != 1))
-               return False;
-       str_value =  talloc_asprintf(ctx, "%s", 
-                                    *(regval_data_p(value)) ? "TRUE" : 
"FALSE");
-       if (!str_value) {
-               return False;
+       if (value->type != REG_BINARY) {
+               return false;
+       }
+       if (value->data.length != 1) {
+               return false;
        }
-       status = ads_mod_str(ctx, mods, regval_name(value), str_value);
+
+       str_value =  *value->data.data ? "TRUE" : "FALSE";
+
+       status = ads_mod_str(ctx, mods, name, str_value);
        return ADS_ERR_OK(status);
 }
 
@@ -181,55 +183,35 @@ static bool map_bool(TALLOC_CTX *ctx, ADS_MODLIST *mods,
   map a REG_MULTI_SZ to an ldap mod
 */
 static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
-                        struct regval_blob *value)
+                        const char *name, struct registry_value *value)
 {
-       char **str_values = NULL;
-       size_t converted_size;
-       smb_ucs2_t *cur_str = (smb_ucs2_t *) regval_data_p(value);
-        uint32 size = 0, num_vals = 0, i=0;
+       const char **str_values = NULL;
        ADS_STATUS status;
 
-       if (regval_type(value) != REG_MULTI_SZ)
-               return False;
-
-       while(cur_str && *cur_str && (size < regval_size(value))) {
-               size += 2 * (strlen_w(cur_str) + 1);
-               cur_str += strlen_w(cur_str) + 1;
-               num_vals++;
-       };
+       if (value->type != REG_MULTI_SZ) {
+               return false;
+       }
 
-       if (num_vals) {
-               str_values = talloc_array(ctx, char *, num_vals + 1);
-               if (!str_values) {
-                       return False;
-               }
-               memset(str_values, '\0', 
-                      (num_vals + 1) * sizeof(char *));
-
-               cur_str = (smb_ucs2_t *) regval_data_p(value);
-               for (i=0; i < num_vals; i++) {
-                       cur_str += pull_ucs2_talloc(ctx, &str_values[i],
-                                                   cur_str, &converted_size) ?
-                           converted_size : (size_t)-1;
+       if (value->data.length  && value->data.data) {
+               if (!pull_reg_multi_sz(ctx, &value->data, &str_values)) {
+                       return false;
                }
-
-               status = ads_mod_strlist(ctx, mods, regval_name(value),
-                                        (const char **) str_values);
+               status = ads_mod_strlist(ctx, mods, name, str_values);
                return ADS_ERR_OK(status);
-       } 
-       return True;
+       }
+       return true;
 }
 
 struct valmap_to_ads {
        const char *valname;
-       bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, struct regval_blob *);
+       bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, const char *, struct 
registry_value *);
 };
 
 /*
   map a REG_SZ to an ldap mod
 */
 static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
-                             struct regval_blob *value)
+                             const char *name, struct registry_value *value)
 {
        const struct valmap_to_ads map[] = {
                {SPOOL_REG_ASSETNUMBER, map_sz},
@@ -289,13 +271,12 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, 
ADS_MODLIST *mods,
        int i;
 
        for (i=0; map[i].valname; i++) {
-               if (strcasecmp_m(map[i].valname, regval_name(value)) == 0) {
-                       if (!map[i].fn(ctx, mods, value)) {
-                               DEBUG(5, ("Add of value %s to modlist 
failed\n", regval_name(value)));
+               if (strcasecmp_m(map[i].valname, name) == 0) {
+                       if (!map[i].fn(ctx, mods, name, value)) {
+                               DEBUG(5, ("Add of value %s to modlist 
failed\n", name));
                        } else {
-                               DEBUG(7, ("Mapped value %s\n", 
regval_name(value)));
+                               DEBUG(7, ("Mapped value %s\n", name));
                        }
-                       
                }
        }
 }
@@ -343,18 +324,11 @@ WERROR get_remote_printer_publishing_data(struct 
rpc_pipe_client *cli,
        } else {
                /* Have the data we need now, so start building */
                for (i=0; i < count; i++) {
-                       struct regval_blob *v;
-
-                       v = regval_compose(mem_ctx, info[i].value_name,
-                                          info[i].type,
-                                          info[i].data->data,
-                                          info[i].data->length);
-                       if (v == NULL) {
-                               return WERR_NOMEM;
-                       }
+                       struct registry_value v;
+                       v.type = info[i].type;
+                       v.data = *info[i].data;
 
-                       map_regval_to_ads(mem_ctx, mods, v);
-                       talloc_free(v);
+                       map_regval_to_ads(mem_ctx, mods, info[i].value_name, 
&v);
                }
        }
 
@@ -368,18 +342,11 @@ WERROR get_remote_printer_publishing_data(struct 
rpc_pipe_client *cli,
                          printername, win_errstr(result)));
        } else {
                for (i=0; i < count; i++) {
-                       struct regval_blob *v;
-
-                       v = regval_compose(mem_ctx, info[i].value_name,
-                                          info[i].type,
-                                          info[i].data->data,
-                                          info[i].data->length);
-                       if (v == NULL) {
-                               return WERR_NOMEM;
-                       }
+                       struct registry_value v;
+                       v.type = info[i].type;
+                       v.data = *info[i].data;
 
-                       map_regval_to_ads(mem_ctx, mods, v);
-                       talloc_free(v);
+                       map_regval_to_ads(mem_ctx, mods, info[i].value_name, 
&v);
                }
        }
 
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index 372f2d3..a32ad8d 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -89,6 +89,7 @@ static WERROR fill_value_cache(struct registry_key *key)
                }
        }
 
+       TALLOC_FREE(key->values);
        werr = regval_ctr_init(key, &(key->values));
        W_ERROR_NOT_OK_RETURN(werr);
 
@@ -116,7 +117,7 @@ static WERROR fill_subkey_cache(struct registry_key *key)
 
        if (fetch_reg_keys(key->key, key->subkeys) == -1) {
                TALLOC_FREE(key->subkeys);
-               return WERR_NO_MORE_ITEMS;
+               return WERR_BADFILE;
        }
 
        return WERR_OK;
@@ -137,7 +138,6 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
        WERROR          result = WERR_OK;
        struct registry_key *regkey;
        struct registry_key_handle *key;
-       struct regsubkey_ctr    *subkeys = NULL;
 
        DEBUG(7,("regkey_open_onelevel: name = [%s]\n", name));
 
@@ -151,7 +151,8 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       if ( !(W_ERROR_IS_OK(result = regdb_open())) ) {
+       result = regdb_open();
+       if (!(W_ERROR_IS_OK(result))) {
                goto done;
        }
 
@@ -194,28 +195,21 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
 
        /* Look up the table of registry I/O operations */
 
-       if ( !(key->ops = reghook_cache_find( key->name )) ) {
+       key->ops = reghook_cache_find( key->name );
+       if (key->ops == NULL) {
                DEBUG(0,("reg_open_onelevel: Failed to assign "
                         "registry_ops to [%s]\n", key->name ));
                result = WERR_BADFILE;
                goto done;
        }
 
-       /* check if the path really exists; failed is indicated by -1 */
-       /* if the subkey count failed, bail out */
+       /* FIXME: Existence is currently checked by fetching the subkeys */
 
-       result = regsubkey_ctr_init(key, &subkeys);
+       result = fill_subkey_cache(regkey);
        if (!W_ERROR_IS_OK(result)) {
                goto done;
        }
 
-       if ( fetch_reg_keys( key, subkeys ) == -1 )  {
-               result = WERR_BADFILE;
-               goto done;
-       }
-
-       TALLOC_FREE( subkeys );
-
        if ( !regkey_access_check( key, access_desired, &key->access_granted,
                                   token ) ) {
                result = WERR_ACCESS_DENIED;
@@ -257,13 +251,15 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct 
registry_key *parent,
 {
        struct registry_key *direct_parent = parent;
        WERROR err;
-       char *p, *path, *to_free;
+       char *p, *path;
        size_t len;
+       TALLOC_CTX *frame = talloc_stackframe();
 
-       if (!(path = SMB_STRDUP(name))) {
-               return WERR_NOMEM;
+       path = talloc_strdup(frame, name);
+       if (path == NULL) {
+               err = WERR_NOMEM;
+               goto error;
        }
-       to_free = path;
 
        len = strlen(path);
 
@@ -275,22 +271,19 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct 
registry_key *parent,
                char *name_component;
                struct registry_key *tmp;
 
-               if (!(name_component = SMB_STRNDUP(path, (p - path)))) {
+               name_component = talloc_strndup(frame, path, (p - path));
+               if (name_component == NULL) {
                        err = WERR_NOMEM;
                        goto error;
                }
 
-               err = regkey_open_onelevel(mem_ctx, direct_parent,
+               err = regkey_open_onelevel(frame, direct_parent,
                                           name_component, parent->token,
                                           KEY_ENUMERATE_SUB_KEYS, &tmp);
-               SAFE_FREE(name_component);
 
                if (!W_ERROR_IS_OK(err)) {
                        goto error;
                }
-               if (direct_parent != parent) {
-                       TALLOC_FREE(direct_parent);
-               }
 
                direct_parent = tmp;
                path = p+1;
@@ -298,11 +291,9 @@ WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct 
registry_key *parent,
 
        err = regkey_open_onelevel(mem_ctx, direct_parent, path, parent->token,
                                   desired_access, pkey);
- error:
-       if (direct_parent != parent) {
-               TALLOC_FREE(direct_parent);
-       }
-       SAFE_FREE(to_free);
+
+error:
+       talloc_free(frame);
        return err;
 }
 
@@ -376,6 +367,43 @@ WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct 
registry_key *key,
        return WERR_OK;
 }
 
+static WERROR reg_enumvalue_nocachefill(TALLOC_CTX *mem_ctx,
+                                       struct registry_key *key,
+                                       uint32 idx, char **pname,
+                                       struct registry_value **pval)
+{
+       struct registry_value *val;
+       struct regval_blob *blob;
+
+       if (!(key->key->access_granted & KEY_QUERY_VALUE)) {
+               return WERR_ACCESS_DENIED;
+       }
+
+       if (idx >= regval_ctr_numvals(key->values)) {
+               return WERR_NO_MORE_ITEMS;
+       }
+
+       blob = regval_ctr_specific_value(key->values, idx);
+
+       val = talloc_zero(mem_ctx, struct registry_value);
+       if (val == NULL) {
+               return WERR_NOMEM;
+       }
+
+       val->type = regval_type(blob);
+       val->data = data_blob_talloc(mem_ctx, regval_data_p(blob), 
regval_size(blob));
+
+       if (pname
+           && !(*pname = talloc_strdup(
+                        mem_ctx, regval_name(blob)))) {
+               TALLOC_FREE(val);
+               return WERR_NOMEM;
+       }
+
+       *pval = val;
+       return WERR_OK;
+}
+
 WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
                      const char *name, struct registry_value **pval)
 {
@@ -394,7 +422,14 @@ WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct 
registry_key *key,
                struct regval_blob *blob;
                blob = regval_ctr_specific_value(key->values, i);
                if (strequal(regval_name(blob), name)) {
-                       return reg_enumvalue(mem_ctx, key, i, NULL, pval);
+                       /*
+                        * don't use reg_enumvalue here:
+                        * re-reading the values from the disk
+                        * would change the indexing and break
+                        * this function.
+                        */
+                       return reg_enumvalue_nocachefill(mem_ctx, key, i,
+                                                        NULL, pval);
                }
        }
 
@@ -523,14 +558,26 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key 
*parent,
        TALLOC_CTX *mem_ctx;
        char *path, *end;
        WERROR err;
+       uint32_t access_granted;
 
-       if (!(mem_ctx = talloc_new(ctx))) return WERR_NOMEM;
+       mem_ctx = talloc_new(ctx);
+       if (mem_ctx == NULL) {
+               return WERR_NOMEM;
+       }
 
-       if (!(path = talloc_strdup(mem_ctx, subkeypath))) {
+       path = talloc_strdup(mem_ctx, subkeypath);
+       if (path == NULL) {
                err = WERR_NOMEM;
                goto done;
        }
 
+       err = regdb_transaction_start();
+       if (!W_ERROR_IS_OK(err)) {
+               DEBUG(0, ("reg_createkey: failed to start transaction: %s\n",
+                         win_errstr(err)));
+               goto done;
+       }
+
        while ((end = strchr(path, '\\')) != NULL) {
                struct registry_key *tmp;
                enum winreg_CreateAction action;
@@ -540,7 +587,7 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key 
*parent,
                err = reg_createkey(mem_ctx, key, path,
                                    KEY_ENUMERATE_SUB_KEYS, &tmp, &action);
                if (!W_ERROR_IS_OK(err)) {
-                       goto done;
+                       goto trans_done;
                }


-- 
Samba Shared Repository

Reply via email to