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 3 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, see <http://www.gnu.org/licenses/>.
20 /* Implementation of internal registry database functions. */
25 #define DBGC_CLASS DBGC_REGISTRY
27 static struct db_context
*regdb
= NULL
;
28 static int regdb_refcount
;
30 /* List the deepest path into the registry. All part components will be created.*/
32 /* If you want to have a part of the path controlled by the tdb and part by
33 a virtual registry db (e.g. printing), then you have to list the deepest path.
34 For example,"HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Print"
35 allows the reg_db backend to handle everything up to
36 "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" and then we'll hook
37 the reg_printing backend onto the last component of the path (see
38 KEY_PRINTING_2K in include/rpc_reg.h) --jerry */
40 static const char *builtin_registry_paths
[] = {
49 "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
51 "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\DefaultUserConfiguration",
60 struct builtin_regkey_value
{
62 const char *valuename
;
70 static struct builtin_regkey_value builtin_registry_values
[] = {
72 SAMBA_PRINTER_PORT_NAME
, REG_SZ
, { "" } },
74 "DefaultSpoolDirectory", REG_SZ
, { "C:\\Windows\\System32\\Spool\\Printers" } },
76 "DisplayName", REG_SZ
, { "Event Log" } },
78 "ErrorControl", REG_DWORD
, { (char*)0x00000001 } },
79 { NULL
, NULL
, 0, { NULL
} }
83 * Initialize a key in the registry:
84 * create each component key of the specified path.
86 static WERROR
init_registry_key_internal(const char *add_path
)
89 TALLOC_CTX
*frame
= talloc_stackframe();
92 char *remaining
= NULL
;
95 REGSUBKEY_CTR
*subkeys
;
98 DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path
));
100 path
= talloc_strdup(frame
, add_path
);
101 base
= talloc_strdup(frame
, "");
102 if (!path
|| !base
) {
108 while (next_token_talloc(frame
, &p
, &keyname
, "\\")) {
110 /* build up the registry path from the components */
113 base
= talloc_asprintf(frame
, "%s\\", base
);
119 base
= talloc_asprintf_append(base
, "%s", keyname
);
125 /* get the immediate subkeyname (if we have one ) */
127 subkeyname
= talloc_strdup(frame
, "");
133 remaining
= talloc_strdup(frame
, p
);
140 if (!next_token_talloc(frame
, &p2
,
143 subkeyname
= talloc_strdup(frame
,p2
);
151 DEBUG(10,("init_registry_key: Storing key [%s] with "
152 "subkey [%s]\n", base
,
153 *subkeyname
? subkeyname
: "NULL"));
155 /* we don't really care if the lookup succeeds or not
156 * since we are about to update the record.
157 * We just want any subkeys already present */
159 if (!(subkeys
= TALLOC_ZERO_P(frame
, REGSUBKEY_CTR
))) {
160 DEBUG(0,("talloc() failure!\n"));
165 regdb_fetch_keys(base
, subkeys
);
167 werr
= regsubkey_ctr_addkey(subkeys
, subkeyname
);
168 if (!W_ERROR_IS_OK(werr
)) {
172 if (!regdb_store_keys( base
, subkeys
)) {
173 werr
= WERR_CAN_NOT_COMPLETE
;
186 * Initialize a key in the registry:
187 * create each component key of the specified path,
188 * wrapped in one db transaction.
190 WERROR
init_registry_key(const char *add_path
)
194 if (regdb
->transaction_start(regdb
) != 0) {
195 DEBUG(0, ("init_registry_key: transaction_start failed\n"));
196 return WERR_REG_IO_FAILURE
;
199 werr
= init_registry_key_internal(add_path
);
200 if (!W_ERROR_IS_OK(werr
)) {
204 if (regdb
->transaction_commit(regdb
) != 0) {
205 DEBUG(0, ("init_registry_key: Could not commit transaction\n"));
206 return WERR_REG_IO_FAILURE
;
212 if (regdb
->transaction_cancel(regdb
) != 0) {
213 smb_panic("init_registry_key: transaction_cancel failed\n");
219 /***********************************************************************
220 Open the registry data in the tdb
221 ***********************************************************************/
223 WERROR
init_registry_data(void)
226 TALLOC_CTX
*frame
= NULL
;
232 * There are potentially quite a few store operations which are all
233 * indiviually wrapped in tdb transactions. Wrapping them in a single
234 * transaction gives just a single transaction_commit() to actually do
235 * its fsync()s. See tdb/common/transaction.c for info about nested
236 * transaction behaviour.
239 if (regdb
->transaction_start(regdb
) != 0) {
240 DEBUG(0, ("init_registry_data: tdb_transaction_start "
242 return WERR_REG_IO_FAILURE
;
245 /* loop over all of the predefined paths and add each component */
247 for (i
=0; builtin_registry_paths
[i
] != NULL
; i
++) {
248 werr
= init_registry_key_internal(builtin_registry_paths
[i
]);
249 if (!W_ERROR_IS_OK(werr
)) {
254 /* loop over all of the predefined values and add each component */
256 frame
= talloc_stackframe();
258 for (i
=0; builtin_registry_values
[i
].path
!= NULL
; i
++) {
260 values
= TALLOC_ZERO_P(frame
, REGVAL_CTR
);
261 if (values
== NULL
) {
266 regdb_fetch_values(builtin_registry_values
[i
].path
, values
);
268 /* preserve existing values across restarts. Only add new ones */
270 if (!regval_ctr_key_exists(values
,
271 builtin_registry_values
[i
].valuename
))
273 switch(builtin_registry_values
[i
].type
) {
275 regval_ctr_addvalue(values
,
276 builtin_registry_values
[i
].valuename
,
278 (char*)&builtin_registry_values
[i
].data
.dw_value
,
284 builtin_registry_values
[i
].data
.string
,
286 regval_ctr_addvalue(values
,
287 builtin_registry_values
[i
].valuename
,
290 data
.uni_str_len
*sizeof(uint16
));
294 DEBUG(0, ("init_registry_data: invalid value "
295 "type in builtin_registry_values "
297 builtin_registry_values
[i
].type
));
299 regdb_store_values(builtin_registry_values
[i
].path
,
307 if (regdb
->transaction_commit(regdb
) != 0) {
308 DEBUG(0, ("init_registry_data: Could not commit "
310 return WERR_REG_IO_FAILURE
;
319 if (regdb
->transaction_cancel(regdb
) != 0) {
320 smb_panic("init_registry_data: tdb_transaction_cancel "
327 /***********************************************************************
328 Open the registry database
329 ***********************************************************************/
331 WERROR
regdb_init(void)
333 const char *vstring
= "INFO/version";
338 DEBUG(10, ("regdb_init: incrementing refcount (%d)\n",
344 regdb
= db_open_trans(NULL
, state_path("registry.tdb"), 0,
345 REG_TDB_FLAGS
, O_RDWR
, 0600);
347 regdb
= db_open_trans(NULL
, state_path("registry.tdb"), 0,
348 REG_TDB_FLAGS
, O_RDWR
|O_CREAT
, 0600);
350 werr
= ntstatus_to_werror(map_nt_error_from_unix(errno
));
351 DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
352 state_path("registry.tdb"), strerror(errno
) ));
356 DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
361 vers_id
= dbwrap_fetch_int32(regdb
, vstring
);
363 if ( vers_id
!= REGVER_V1
) {
365 /* any upgrade code here if needed */
366 DEBUG(10, ("regdb_init: got %s = %d != %d\n", vstring
,
367 vers_id
, REGVER_V1
));
368 status
= dbwrap_trans_store_int32(regdb
, vstring
, REGVER_V1
);
369 if (!NT_STATUS_IS_OK(status
)) {
370 DEBUG(0, ("regdb_init: error storing %s = %d: %s\n",
371 vstring
, REGVER_V1
, nt_errstr(status
)));
372 return ntstatus_to_werror(status
);
374 DEBUG(10, ("regdb_init: stored %s = %d\n",
375 vstring
, REGVER_V1
));
382 /***********************************************************************
383 Open the registry. Must already have been initialized by regdb_init()
384 ***********************************************************************/
386 WERROR
regdb_open( void )
388 WERROR result
= WERR_OK
;
391 DEBUG(10,("regdb_open: incrementing refcount (%d)\n", regdb_refcount
));
398 regdb
= db_open_trans(NULL
, state_path("registry.tdb"), 0,
399 REG_TDB_FLAGS
, O_RDWR
, 0600);
401 result
= ntstatus_to_werror( map_nt_error_from_unix( errno
) );
402 DEBUG(0,("regdb_open: Failed to open %s! (%s)\n",
403 state_path("registry.tdb"), strerror(errno
) ));
409 DEBUG(10,("regdb_open: refcount reset (%d)\n", regdb_refcount
));
414 /***********************************************************************
415 ***********************************************************************/
417 int regdb_close( void )
419 if (regdb_refcount
== 0) {
425 DEBUG(10,("regdb_close: decrementing refcount (%d)\n", regdb_refcount
));
427 if ( regdb_refcount
> 0 )
430 SMB_ASSERT( regdb_refcount
>= 0 );
436 /***********************************************************************
437 return the tdb sequence number of the registry tdb.
438 this is an indicator for the content of the registry
439 having changed. it will change upon regdb_init, too, though.
440 ***********************************************************************/
441 int regdb_get_seqnum(void)
443 return regdb
->get_seqnum(regdb
);
446 /***********************************************************************
447 Add subkey strings to the registry tdb under a defined key
448 fmt is the same format as tdb_pack except this function only supports
450 ***********************************************************************/
452 static bool regdb_store_keys_internal(const char *key
, REGSUBKEY_CTR
*ctr
)
455 uint8
*buffer
= NULL
;
459 uint32 num_subkeys
= regsubkey_ctr_numkeys(ctr
);
460 char *keyname
= NULL
;
461 TALLOC_CTX
*ctx
= talloc_stackframe();
468 keyname
= talloc_strdup(ctx
, key
);
472 keyname
= normalize_reg_path(ctx
, keyname
);
474 /* allocate some initial memory */
476 buffer
= (uint8
*)SMB_MALLOC(1024);
477 if (buffer
== NULL
) {
483 /* store the number of subkeys */
485 len
+= tdb_pack(buffer
+len
, buflen
-len
, "d", num_subkeys
);
487 /* pack all the strings */
489 for (i
=0; i
<num_subkeys
; i
++) {
492 thistime
= tdb_pack(buffer
+len
, buflen
-len
, "f",
493 regsubkey_ctr_specific_key(ctr
, i
));
494 if (len
+thistime
> buflen
) {
497 * tdb_pack hasn't done anything because of the short
498 * buffer, allocate extra space.
500 buffer
= SMB_REALLOC_ARRAY(buffer
, uint8_t,
503 DEBUG(0, ("regdb_store_keys: Failed to realloc "
504 "memory of size [%d]\n",
509 buflen
= (len
+thistime
)*2;
510 thistime2
= tdb_pack(
511 buffer
+len
, buflen
-len
, "f",
512 regsubkey_ctr_specific_key(ctr
, i
));
513 if (thistime2
!= thistime
) {
514 DEBUG(0, ("tdb_pack failed\n"));
522 /* finally write out the data */
526 status
= dbwrap_store_bystring(regdb
, keyname
, dbuf
, TDB_REPLACE
);
527 if (!NT_STATUS_IS_OK(status
)) {
538 /***********************************************************************
539 Store the new subkey record and create any child key records that
540 do not currently exist
541 ***********************************************************************/
543 bool regdb_store_keys(const char *key
, REGSUBKEY_CTR
*ctr
)
547 REGSUBKEY_CTR
*subkeys
= NULL
, *old_subkeys
= NULL
;
548 char *oldkeyname
= NULL
;
549 TALLOC_CTX
*ctx
= talloc_stackframe();
553 * fetch a list of the old subkeys so we can determine if anything has
557 if (!(old_subkeys
= TALLOC_ZERO_P(ctx
, REGSUBKEY_CTR
))) {
558 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
562 regdb_fetch_keys(key
, old_subkeys
);
564 if ((ctr
->num_subkeys
&& old_subkeys
->num_subkeys
) &&
565 (ctr
->num_subkeys
== old_subkeys
->num_subkeys
)) {
567 for (i
= 0; i
<ctr
->num_subkeys
; i
++) {
568 if (strcmp(ctr
->subkeys
[i
],
569 old_subkeys
->subkeys
[i
]) != 0) {
573 if (i
== ctr
->num_subkeys
) {
575 * Nothing changed, no point to even start a tdb
578 TALLOC_FREE(old_subkeys
);
583 TALLOC_FREE(old_subkeys
);
585 if (regdb
->transaction_start(regdb
) != 0) {
586 DEBUG(0, ("regdb_store_keys: transaction_start failed\n"));
591 * Re-fetch the old keys inside the transaction
594 if (!(old_subkeys
= TALLOC_ZERO_P(ctx
, REGSUBKEY_CTR
))) {
595 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
599 regdb_fetch_keys(key
, old_subkeys
);
601 /* store the subkey list for the parent */
603 if (!regdb_store_keys_internal(key
, ctr
) ) {
604 DEBUG(0,("regdb_store_keys: Failed to store new subkey list "
605 "for parent [%s]\n", key
));
609 /* now delete removed keys */
611 num_subkeys
= regsubkey_ctr_numkeys(old_subkeys
);
612 for (i
=0; i
<num_subkeys
; i
++) {
613 oldkeyname
= regsubkey_ctr_specific_key(old_subkeys
, i
);
615 if (regsubkey_ctr_key_exists(ctr
, oldkeyname
)) {
617 * It's still around, don't delete
623 path
= talloc_asprintf(ctx
, "%s/%s", key
, oldkeyname
);
627 path
= normalize_reg_path(ctx
, path
);
631 status
= dbwrap_delete_bystring(regdb
, path
);
632 if (!NT_STATUS_IS_OK(status
)) {
633 DEBUG(1, ("Deleting %s failed\n", path
));
638 path
= talloc_asprintf(ctx
, "%s/%s/%s",
645 path
= normalize_reg_path(ctx
, path
);
651 * Ignore errors here, we might have no values around
653 dbwrap_delete_bystring(regdb
, path
);
657 TALLOC_FREE(old_subkeys
);
659 /* now create records for any subkeys that don't already exist */
661 num_subkeys
= regsubkey_ctr_numkeys(ctr
);
663 if (num_subkeys
== 0) {
664 if (!(subkeys
= TALLOC_ZERO_P(ctx
, REGSUBKEY_CTR
)) ) {
665 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
669 if (!regdb_store_keys_internal(key
, subkeys
)) {
670 DEBUG(0,("regdb_store_keys: Failed to store "
671 "new record for key [%s]\n", key
));
674 TALLOC_FREE(subkeys
);
678 for (i
=0; i
<num_subkeys
; i
++) {
679 path
= talloc_asprintf(ctx
, "%s/%s",
681 regsubkey_ctr_specific_key(ctr
, i
));
685 if (!(subkeys
= TALLOC_ZERO_P(ctx
, REGSUBKEY_CTR
)) ) {
686 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
690 if (regdb_fetch_keys( path
, subkeys
) == -1) {
691 /* create a record with 0 subkeys */
692 if (!regdb_store_keys_internal(path
, subkeys
)) {
693 DEBUG(0,("regdb_store_keys: Failed to store "
694 "new record for key [%s]\n", path
));
699 TALLOC_FREE(subkeys
);
703 if (regdb
->transaction_commit(regdb
) != 0) {
704 DEBUG(0, ("regdb_store_keys: Could not commit transaction\n"));
712 if (regdb
->transaction_cancel(regdb
) != 0) {
713 smb_panic("regdb_store_keys: transaction_cancel failed\n");
723 /***********************************************************************
724 Retrieve an array of strings containing subkeys. Memory should be
725 released by the caller.
726 ***********************************************************************/
728 int regdb_fetch_keys(const char *key
, REGSUBKEY_CTR
*ctr
)
738 TALLOC_CTX
*frame
= talloc_stackframe();
741 DEBUG(11,("regdb_fetch_keys: Enter key => [%s]\n", key
? key
: "NULL"));
743 path
= talloc_strdup(frame
, key
);
748 /* convert to key format */
749 path
= talloc_string_sub(frame
, path
, "\\", "/");
755 ctr
->seqnum
= regdb_get_seqnum();
757 dbret
= regdb
->fetch(regdb
, frame
, string_term_tdb_data(path
), &value
);
763 buflen
= value
.dsize
;
766 DEBUG(5,("regdb_fetch_keys: tdb lookup failed to locate key [%s]\n", key
));
770 len
= tdb_unpack( buf
, buflen
, "d", &num_items
);
773 * The following code breaks the abstraction that reg_objects.c sets
774 * up with regsubkey_ctr_addkey(). But if we use that with the current
775 * data structure of ctr->subkeys being an unsorted array, we end up
776 * with an O(n^2) algorithm for retrieving keys from the tdb
777 * file. This is pretty pointless, as we have to trust the data
778 * structure on disk not to have duplicates anyway. The alternative to
779 * breaking this abstraction would be to set up a more sophisticated
780 * data structure in REGSUBKEY_CTR.
782 * This makes "net conf list" for a registry with >1000 shares
783 * actually usable :-)
786 ctr
->subkeys
= talloc_array(ctr
, char *, num_items
);
787 if (ctr
->subkeys
== NULL
) {
788 DEBUG(5, ("regdb_fetch_keys: could not allocate subkeys\n"));
791 ctr
->num_subkeys
= num_items
;
793 for (i
=0; i
<num_items
; i
++) {
794 len
+= tdb_unpack(buf
+len
, buflen
-len
, "f", subkeyname
);
795 ctr
->subkeys
[i
] = talloc_strdup(ctr
->subkeys
, subkeyname
);
796 if (ctr
->subkeys
[i
] == NULL
) {
797 DEBUG(5, ("regdb_fetch_keys: could not allocate "
799 TALLOC_FREE(ctr
->subkeys
);
800 ctr
->num_subkeys
= 0;
805 DEBUG(11,("regdb_fetch_keys: Exit [%d] items\n", num_items
));
813 /****************************************************************************
814 Unpack a list of registry values frem the TDB
815 ***************************************************************************/
817 static int regdb_unpack_values(REGVAL_CTR
*values
, uint8
*buf
, int buflen
)
824 uint32 num_values
= 0;
827 /* loop and unpack the rest of the registry values */
829 len
+= tdb_unpack(buf
+len
, buflen
-len
, "d", &num_values
);
831 for ( i
=0; i
<num_values
; i
++ ) {
832 /* unpack the next regval */
838 len
+= tdb_unpack(buf
+len
, buflen
-len
, "fdB",
844 /* add the new value. Paranoid protective code -- make sure data_p is valid */
846 if (*valuename
&& size
&& data_p
) {
847 regval_ctr_addvalue(values
, valuename
, type
,
848 (const char *)data_p
, size
);
850 SAFE_FREE(data_p
); /* 'B' option to tdb_unpack does a malloc() */
852 DEBUG(8,("specific: [%s], len: %d\n", valuename
, size
));
858 /****************************************************************************
859 Pack all values in all printer keys
860 ***************************************************************************/
862 static int regdb_pack_values(REGVAL_CTR
*values
, uint8
*buf
, int buflen
)
872 num_values
= regval_ctr_numvals( values
);
874 /* pack the number of values first */
876 len
+= tdb_pack( buf
+len
, buflen
-len
, "d", num_values
);
878 /* loop over all values */
880 for ( i
=0; i
<num_values
; i
++ ) {
881 val
= regval_ctr_specific_value( values
, i
);
882 len
+= tdb_pack(buf
+len
, buflen
-len
, "fdB",
886 regval_data_p(val
) );
892 /***********************************************************************
893 Retrieve an array of strings containing subkeys. Memory should be
894 released by the caller.
895 ***********************************************************************/
897 int regdb_fetch_values( const char* key
, REGVAL_CTR
*values
)
900 TALLOC_CTX
*ctx
= talloc_stackframe();
905 DEBUG(10,("regdb_fetch_values: Looking for value of key [%s] \n", key
));
907 keystr
= talloc_asprintf(ctx
, "%s/%s", REG_VALUE_PREFIX
, key
);
911 keystr
= normalize_reg_path(ctx
, keystr
);
916 values
->seqnum
= regdb_get_seqnum();
918 dbret
= regdb
->fetch(regdb
, ctx
, string_term_tdb_data(keystr
), &value
);
924 /* all keys have zero values by default */
928 regdb_unpack_values(values
, value
.dptr
, value
.dsize
);
929 ret
= regval_ctr_numvals(values
);
936 bool regdb_store_values( const char *key
, REGVAL_CTR
*values
)
938 TDB_DATA old_data
, data
;
940 TALLOC_CTX
*ctx
= talloc_stackframe();
945 DEBUG(10,("regdb_store_values: Looking for value of key [%s] \n", key
));
949 len
= regdb_pack_values(values
, data
.dptr
, data
.dsize
);
951 DEBUG(0,("regdb_store_values: unable to pack values. len <= 0\n"));
955 data
.dptr
= TALLOC_ARRAY(ctx
, uint8
, len
);
958 len
= regdb_pack_values(values
, data
.dptr
, data
.dsize
);
960 SMB_ASSERT( len
== data
.dsize
);
962 keystr
= talloc_asprintf(ctx
, "%s/%s", REG_VALUE_PREFIX
, key
);
966 keystr
= normalize_reg_path(ctx
, keystr
);
971 old_data
= dbwrap_fetch_bystring(regdb
, ctx
, keystr
);
973 if ((old_data
.dptr
!= NULL
)
974 && (old_data
.dsize
== data
.dsize
)
975 && (memcmp(old_data
.dptr
, data
.dptr
, data
.dsize
) == 0))
981 status
= dbwrap_trans_store(regdb
, string_term_tdb_data(keystr
), data
,
984 result
= NT_STATUS_IS_OK(status
);
991 static WERROR
regdb_get_secdesc(TALLOC_CTX
*mem_ctx
, const char *key
,
992 struct security_descriptor
**psecdesc
)
997 TALLOC_CTX
*tmp_ctx
= talloc_stackframe();
998 WERROR err
= WERR_OK
;
1000 DEBUG(10, ("regdb_get_secdesc: Getting secdesc of key [%s]\n", key
));
1002 tdbkey
= talloc_asprintf(tmp_ctx
, "%s/%s", REG_SECDESC_PREFIX
, key
);
1003 if (tdbkey
== NULL
) {
1007 normalize_dbkey(tdbkey
);
1009 data
= dbwrap_fetch_bystring(regdb
, tmp_ctx
, tdbkey
);
1010 if (data
.dptr
== NULL
) {
1015 status
= unmarshall_sec_desc(mem_ctx
, (uint8
*)data
.dptr
, data
.dsize
,
1018 if (NT_STATUS_EQUAL(status
, NT_STATUS_NO_MEMORY
)) {
1020 } else if (!NT_STATUS_IS_OK(status
)) {
1021 err
= WERR_REG_CORRUPT
;
1025 TALLOC_FREE(tmp_ctx
);
1029 static WERROR
regdb_set_secdesc(const char *key
,
1030 struct security_descriptor
*secdesc
)
1032 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
1035 WERROR err
= WERR_NOMEM
;
1038 tdbkey
= talloc_asprintf(mem_ctx
, "%s/%s", REG_SECDESC_PREFIX
, key
);
1039 if (tdbkey
== NULL
) {
1042 normalize_dbkey(tdbkey
);
1044 if (secdesc
== NULL
) {
1045 /* assuming a delete */
1046 status
= dbwrap_trans_delete(regdb
,
1047 string_term_tdb_data(tdbkey
));
1048 if (NT_STATUS_IS_OK(status
)) {
1051 err
= ntstatus_to_werror(status
);
1056 err
= ntstatus_to_werror(marshall_sec_desc(mem_ctx
, secdesc
,
1059 if (!W_ERROR_IS_OK(err
)) {
1063 status
= dbwrap_trans_store(regdb
, string_term_tdb_data(tdbkey
),
1065 if (!NT_STATUS_IS_OK(status
)) {
1066 err
= ntstatus_to_werror(status
);
1071 TALLOC_FREE(mem_ctx
);
1075 bool regdb_subkeys_need_update(REGSUBKEY_CTR
*subkeys
)
1077 return (regdb_get_seqnum() != subkeys
->seqnum
);
1080 bool regdb_values_need_update(REGVAL_CTR
*values
)
1082 return (regdb_get_seqnum() != values
->seqnum
);
1086 * Table of function pointers for default access
1089 REGISTRY_OPS regdb_ops
= {
1090 .fetch_subkeys
= regdb_fetch_keys
,
1091 .fetch_values
= regdb_fetch_values
,
1092 .store_subkeys
= regdb_store_keys
,
1093 .store_values
= regdb_store_values
,
1094 .get_secdesc
= regdb_get_secdesc
,
1095 .set_secdesc
= regdb_set_secdesc
,
1096 .subkeys_need_update
= regdb_subkeys_need_update
,
1097 .values_need_update
= regdb_values_need_update