r25528: Only do transactions on registry.tdb if anything changes
[Samba.git] / source / registry / reg_db.c
blob489c094b1507d5281493f9c265836d0614453c31
1 /*
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. */
22 #include "includes.h"
24 #undef DBGC_CLASS
25 #define DBGC_CLASS DBGC_REGISTRY
27 static struct tdb_wrap *tdb_reg = NULL;
28 static int tdb_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[] = {
41 KEY_PRINTING_2K,
42 KEY_PRINTING_PORTS,
43 KEY_PRINTING,
44 KEY_SHARES,
45 KEY_EVENTLOG,
46 KEY_SMBCONF,
47 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib",
48 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009",
49 "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
50 "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
51 "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\DefaultUserConfiguration",
52 "HKLM\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
53 "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters",
54 "HKU",
55 "HKCR",
56 "HKPD",
57 "HKPT",
58 NULL };
60 struct builtin_regkey_value {
61 const char *path;
62 const char *valuename;
63 uint32 type;
64 union {
65 const char *string;
66 uint32 dw_value;
67 } data;
70 static struct builtin_regkey_value builtin_registry_values[] = {
71 { KEY_PRINTING_PORTS,
72 SAMBA_PRINTER_PORT_NAME, REG_SZ, { "" } },
73 { KEY_PRINTING_2K,
74 "DefaultSpoolDirectory", REG_SZ, { "C:\\Windows\\System32\\Spool\\Printers" } },
75 { KEY_EVENTLOG,
76 "DisplayName", REG_SZ, { "Event Log" } },
77 { KEY_EVENTLOG,
78 "ErrorControl", REG_DWORD, { (char*)0x00000001 } },
79 { NULL, NULL, 0, { NULL } }
82 /***********************************************************************
83 Open the registry data in the tdb
84 ***********************************************************************/
86 static BOOL init_registry_data( void )
88 pstring path, base, remaining;
89 fstring keyname, subkeyname;
90 REGSUBKEY_CTR *subkeys;
91 REGVAL_CTR *values;
92 int i;
93 const char *p, *p2;
94 UNISTR2 data;
97 * There are potentially quite a few store operations which are all
98 * indiviually wrapped in tdb transactions. Wrapping them in a single
99 * transaction gives just a single transaction_commit() to actually do
100 * its fsync()s. See tdb/common/transaction.c for info about nested
101 * transaction behaviour.
104 if ( tdb_transaction_start( tdb_reg->tdb ) == -1 ) {
105 DEBUG(0, ("init_registry_data: tdb_transaction_start "
106 "failed\n"));
107 return False;
110 /* loop over all of the predefined paths and add each component */
112 for ( i=0; builtin_registry_paths[i] != NULL; i++ ) {
114 DEBUG(6,("init_registry_data: Adding [%s]\n", builtin_registry_paths[i]));
116 pstrcpy( path, builtin_registry_paths[i] );
117 pstrcpy( base, "" );
118 p = path;
120 while ( next_token(&p, keyname, "\\", sizeof(keyname)) ) {
122 /* build up the registry path from the components */
124 if ( *base )
125 pstrcat( base, "\\" );
126 pstrcat( base, keyname );
128 /* get the immediate subkeyname (if we have one ) */
130 *subkeyname = '\0';
131 if ( *p ) {
132 pstrcpy( remaining, p );
133 p2 = remaining;
135 if ( !next_token(&p2, subkeyname, "\\", sizeof(subkeyname)) )
136 fstrcpy( subkeyname, p2 );
139 DEBUG(10,("init_registry_data: Storing key [%s] with subkey [%s]\n",
140 base, *subkeyname ? subkeyname : "NULL"));
142 /* we don't really care if the lookup succeeds or not since
143 we are about to update the record. We just want any
144 subkeys already present */
146 if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) {
147 DEBUG(0,("talloc() failure!\n"));
148 goto fail;
151 regdb_fetch_keys( base, subkeys );
152 if ( *subkeyname )
153 regsubkey_ctr_addkey( subkeys, subkeyname );
154 if ( !regdb_store_keys( base, subkeys ))
155 goto fail;
157 TALLOC_FREE( subkeys );
161 /* loop over all of the predefined values and add each component */
163 for ( i=0; builtin_registry_values[i].path != NULL; i++ ) {
164 if ( !(values = TALLOC_ZERO_P( NULL, REGVAL_CTR )) ) {
165 DEBUG(0,("talloc() failure!\n"));
166 goto fail;
169 regdb_fetch_values( builtin_registry_values[i].path, values );
171 /* preserve existing values across restarts. Only add new ones */
173 if ( !regval_ctr_key_exists( values, builtin_registry_values[i].valuename ) )
175 switch( builtin_registry_values[i].type ) {
176 case REG_DWORD:
177 regval_ctr_addvalue( values,
178 builtin_registry_values[i].valuename,
179 REG_DWORD,
180 (char*)&builtin_registry_values[i].data.dw_value,
181 sizeof(uint32) );
182 break;
184 case REG_SZ:
185 init_unistr2( &data, builtin_registry_values[i].data.string, UNI_STR_TERMINATE);
186 regval_ctr_addvalue( values,
187 builtin_registry_values[i].valuename,
188 REG_SZ,
189 (char*)data.buffer,
190 data.uni_str_len*sizeof(uint16) );
191 break;
193 default:
194 DEBUG(0,("init_registry_data: invalid value type in builtin_registry_values [%d]\n",
195 builtin_registry_values[i].type));
197 regdb_store_values( builtin_registry_values[i].path, values );
200 TALLOC_FREE( values );
203 if (tdb_transaction_commit( tdb_reg->tdb ) == -1) {
204 DEBUG(0, ("init_registry_data: Could not commit "
205 "transaction\n"));
206 return False;
209 return True;
211 fail:
213 if (tdb_transaction_cancel( tdb_reg->tdb ) == -1) {
214 smb_panic("init_registry_data: tdb_transaction_cancel "
215 "failed\n");
218 return False;
221 /***********************************************************************
222 Open the registry database
223 ***********************************************************************/
225 BOOL regdb_init( void )
227 const char *vstring = "INFO/version";
228 uint32 vers_id;
230 if ( tdb_reg )
231 return True;
233 if ( !(tdb_reg = tdb_wrap_open(NULL, lock_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) )
235 tdb_reg = tdb_wrap_open(NULL, lock_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
236 if ( !tdb_reg ) {
237 DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
238 lock_path("registry.tdb"), strerror(errno) ));
239 return False;
242 DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
245 tdb_refcount = 1;
247 vers_id = tdb_fetch_int32(tdb_reg->tdb, vstring);
249 if ( vers_id != REGVER_V1 ) {
250 /* any upgrade code here if needed */
251 DEBUG(10, ("regdb_init: got INFO/version = %d != %d\n",
252 vers_id, REGVER_V1));
255 /* always setup the necessary keys and values */
257 if ( !init_registry_data() ) {
258 DEBUG(0,("init_registry: Failed to initialize data in registry!\n"));
259 return False;
262 return True;
265 /***********************************************************************
266 Open the registry. Must already have been initialized by regdb_init()
267 ***********************************************************************/
269 WERROR regdb_open( void )
271 WERROR result = WERR_OK;
273 if ( tdb_reg ) {
274 DEBUG(10,("regdb_open: incrementing refcount (%d)\n", tdb_refcount));
275 tdb_refcount++;
276 return WERR_OK;
279 become_root();
281 tdb_reg = tdb_wrap_open(NULL, lock_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600);
282 if ( !tdb_reg ) {
283 result = ntstatus_to_werror( map_nt_error_from_unix( errno ) );
284 DEBUG(0,("regdb_open: Failed to open %s! (%s)\n",
285 lock_path("registry.tdb"), strerror(errno) ));
288 unbecome_root();
290 tdb_refcount = 1;
291 DEBUG(10,("regdb_open: refcount reset (%d)\n", tdb_refcount));
293 return result;
296 /***********************************************************************
297 ***********************************************************************/
299 int regdb_close( void )
301 tdb_refcount--;
303 DEBUG(10,("regdb_close: decrementing refcount (%d)\n", tdb_refcount));
305 if ( tdb_refcount > 0 )
306 return 0;
308 SMB_ASSERT( tdb_refcount >= 0 );
310 TALLOC_FREE(tdb_reg);
311 return 0;
314 /***********************************************************************
315 return the tdb sequence number of the registry tdb.
316 this is an indicator for the content of the registry
317 having changed. it will change upon regdb_init, too, though.
318 ***********************************************************************/
319 int regdb_get_seqnum(void)
321 return tdb_get_seqnum(tdb_reg->tdb);
324 /***********************************************************************
325 Add subkey strings to the registry tdb under a defined key
326 fmt is the same format as tdb_pack except this function only supports
327 fstrings
328 ***********************************************************************/
330 static BOOL regdb_store_keys_internal( const char *key, REGSUBKEY_CTR *ctr )
332 TDB_DATA dbuf;
333 uint8 *buffer;
334 int i = 0;
335 uint32 len, buflen;
336 BOOL ret = True;
337 uint32 num_subkeys = regsubkey_ctr_numkeys( ctr );
338 pstring keyname;
340 if ( !key )
341 return False;
343 pstrcpy( keyname, key );
344 normalize_reg_path( keyname );
346 /* allocate some initial memory */
348 if (!(buffer = (uint8 *)SMB_MALLOC(sizeof(pstring)))) {
349 return False;
351 buflen = sizeof(pstring);
352 len = 0;
354 /* store the number of subkeys */
356 len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys );
358 /* pack all the strings */
360 for (i=0; i<num_subkeys; i++) {
361 len += tdb_pack( buffer+len, buflen-len, "f", regsubkey_ctr_specific_key(ctr, i) );
362 if ( len > buflen ) {
363 /* allocate some extra space */
364 if ((buffer = (uint8 *)SMB_REALLOC( buffer, len*2 )) == NULL) {
365 DEBUG(0,("regdb_store_keys: Failed to realloc memory of size [%d]\n", len*2));
366 ret = False;
367 goto done;
369 buflen = len*2;
371 len = tdb_pack( buffer+len, buflen-len, "f", regsubkey_ctr_specific_key(ctr, i) );
375 /* finally write out the data */
377 dbuf.dptr = buffer;
378 dbuf.dsize = len;
379 if ( tdb_store_bystring( tdb_reg->tdb, keyname, dbuf, TDB_REPLACE ) == -1) {
380 ret = False;
381 goto done;
384 done:
385 SAFE_FREE( buffer );
387 return ret;
390 /***********************************************************************
391 Store the new subkey record and create any child key records that
392 do not currently exist
393 ***********************************************************************/
395 BOOL regdb_store_keys( const char *key, REGSUBKEY_CTR *ctr )
397 int num_subkeys, i;
398 pstring path;
399 REGSUBKEY_CTR *subkeys = NULL, *old_subkeys = NULL;
400 char *oldkeyname;
403 * fetch a list of the old subkeys so we can determine if anything has
404 * changed
407 if ( !(old_subkeys = TALLOC_ZERO_P( ctr, REGSUBKEY_CTR )) ) {
408 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
409 goto fail;
412 regdb_fetch_keys( key, old_subkeys );
414 if (ctr->num_subkeys == old_subkeys->num_subkeys) {
416 for (i = 0; i<ctr->num_subkeys; i++) {
417 if (strcmp(ctr->subkeys[i],
418 old_subkeys->subkeys[i]) != 0) {
419 break;
422 if (i == ctr->num_subkeys) {
424 * Nothing changed, no point to even start a tdb
425 * transaction
427 TALLOC_FREE(old_subkeys);
428 return True;
432 if ( tdb_transaction_start( tdb_reg->tdb ) == -1 ) {
433 DEBUG(0, ("regdb_store_keys: tdb_transaction_start failed\n"));
434 return False;
438 * Re-fetch the old keys inside the transaction
441 TALLOC_FREE(old_subkeys);
443 if ( !(old_subkeys = TALLOC_ZERO_P( ctr, REGSUBKEY_CTR )) ) {
444 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
445 goto fail;
448 regdb_fetch_keys( key, old_subkeys );
450 /* store the subkey list for the parent */
452 if ( !regdb_store_keys_internal( key, ctr ) ) {
453 DEBUG(0,("regdb_store_keys: Failed to store new subkey list "
454 "for parent [%s]\n", key ));
455 goto fail;
458 /* now delete removed keys */
460 num_subkeys = regsubkey_ctr_numkeys( old_subkeys );
461 for ( i=0; i<num_subkeys; i++ ) {
462 oldkeyname = regsubkey_ctr_specific_key( old_subkeys, i );
464 if ( regsubkey_ctr_key_exists( ctr, oldkeyname ) ) {
466 * It's still around, don't delete
469 continue;
472 pstr_sprintf( path, "%s/%s", key, oldkeyname );
473 normalize_reg_path( path );
474 if (tdb_delete_bystring( tdb_reg->tdb, path ) == -1) {
475 DEBUG(1, ("Deleting %s failed\n", path));
476 goto fail;
479 pstr_sprintf( path, "%s/%s/%s", REG_VALUE_PREFIX, key,
480 oldkeyname );
481 normalize_reg_path( path );
484 * Ignore errors here, we might have no values around
486 tdb_delete_bystring( tdb_reg->tdb, path );
489 TALLOC_FREE( old_subkeys );
491 /* now create records for any subkeys that don't already exist */
493 num_subkeys = regsubkey_ctr_numkeys( ctr );
494 for ( i=0; i<num_subkeys; i++ ) {
495 pstr_sprintf( path, "%s/%s", key,
496 regsubkey_ctr_specific_key( ctr, i ) );
498 if ( !(subkeys = TALLOC_ZERO_P( ctr, REGSUBKEY_CTR )) ) {
499 DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
500 goto fail;
503 if ( regdb_fetch_keys( path, subkeys ) == -1 ) {
504 /* create a record with 0 subkeys */
505 if ( !regdb_store_keys_internal( path, subkeys ) ) {
506 DEBUG(0,("regdb_store_keys: Failed to store "
507 "new record for key [%s]\n", path ));
508 goto fail;
512 TALLOC_FREE( subkeys );
515 if (tdb_transaction_commit( tdb_reg->tdb ) == -1) {
516 DEBUG(0, ("regdb_store_keys: Could not commit transaction\n"));
517 return False;
520 return True;
522 fail:
523 TALLOC_FREE( old_subkeys );
524 TALLOC_FREE( subkeys );
526 if (tdb_transaction_cancel( tdb_reg->tdb ) == -1) {
527 smb_panic("regdb_store_keys: tdb_transaction_cancel failed\n");
530 return False;
534 /***********************************************************************
535 Retrieve an array of strings containing subkeys. Memory should be
536 released by the caller.
537 ***********************************************************************/
539 int regdb_fetch_keys( const char* key, REGSUBKEY_CTR *ctr )
541 pstring path;
542 uint32 num_items;
543 TDB_DATA dbuf;
544 uint8 *buf;
545 uint32 buflen, len;
546 int i;
547 fstring subkeyname;
549 DEBUG(11,("regdb_fetch_keys: Enter key => [%s]\n", key ? key : "NULL"));
551 pstrcpy( path, key );
553 /* convert to key format */
554 pstring_sub( path, "\\", "/" );
555 strupper_m( path );
557 dbuf = tdb_fetch_bystring( tdb_reg->tdb, path );
559 buf = dbuf.dptr;
560 buflen = dbuf.dsize;
562 if ( !buf ) {
563 DEBUG(5,("regdb_fetch_keys: tdb lookup failed to locate key [%s]\n", key));
564 return -1;
567 len = tdb_unpack( buf, buflen, "d", &num_items);
569 for (i=0; i<num_items; i++) {
570 len += tdb_unpack( buf+len, buflen-len, "f", subkeyname );
571 regsubkey_ctr_addkey( ctr, subkeyname );
574 SAFE_FREE( dbuf.dptr );
576 DEBUG(11,("regdb_fetch_keys: Exit [%d] items\n", num_items));
578 return num_items;
581 /****************************************************************************
582 Unpack a list of registry values frem the TDB
583 ***************************************************************************/
585 static int regdb_unpack_values(REGVAL_CTR *values, uint8 *buf, int buflen)
587 int len = 0;
588 uint32 type;
589 pstring valuename;
590 uint32 size;
591 uint8 *data_p;
592 uint32 num_values = 0;
593 int i;
597 /* loop and unpack the rest of the registry values */
599 len += tdb_unpack(buf+len, buflen-len, "d", &num_values);
601 for ( i=0; i<num_values; i++ ) {
602 /* unpack the next regval */
604 type = REG_NONE;
605 size = 0;
606 data_p = NULL;
607 len += tdb_unpack(buf+len, buflen-len, "fdB",
608 valuename,
609 &type,
610 &size,
611 &data_p);
613 /* add the new value. Paranoid protective code -- make sure data_p is valid */
615 if ( size && data_p ) {
616 regval_ctr_addvalue( values, valuename, type, (const char *)data_p, size );
617 SAFE_FREE(data_p); /* 'B' option to tdb_unpack does a malloc() */
620 DEBUG(8,("specific: [%s], len: %d\n", valuename, size));
623 return len;
626 /****************************************************************************
627 Pack all values in all printer keys
628 ***************************************************************************/
630 static int regdb_pack_values(REGVAL_CTR *values, uint8 *buf, int buflen)
632 int len = 0;
633 int i;
634 REGISTRY_VALUE *val;
635 int num_values;
637 if ( !values )
638 return 0;
640 num_values = regval_ctr_numvals( values );
642 /* pack the number of values first */
644 len += tdb_pack( buf+len, buflen-len, "d", num_values );
646 /* loop over all values */
648 for ( i=0; i<num_values; i++ ) {
649 val = regval_ctr_specific_value( values, i );
650 len += tdb_pack(buf+len, buflen-len, "fdB",
651 regval_name(val),
652 regval_type(val),
653 regval_size(val),
654 regval_data_p(val) );
657 return len;
660 /***********************************************************************
661 Retrieve an array of strings containing subkeys. Memory should be
662 released by the caller.
663 ***********************************************************************/
665 int regdb_fetch_values( const char* key, REGVAL_CTR *values )
667 TDB_DATA data;
668 pstring keystr;
670 DEBUG(10,("regdb_fetch_values: Looking for value of key [%s] \n", key));
672 pstr_sprintf( keystr, "%s/%s", REG_VALUE_PREFIX, key );
673 normalize_reg_path( keystr );
675 data = tdb_fetch_bystring( tdb_reg->tdb, keystr );
677 if ( !data.dptr ) {
678 /* all keys have zero values by default */
679 return 0;
682 regdb_unpack_values( values, data.dptr, data.dsize );
684 SAFE_FREE( data.dptr );
686 return regval_ctr_numvals(values);
689 /***********************************************************************
690 Stub function since we do not currently support storing registry
691 values in the registry.tdb
692 ***********************************************************************/
694 BOOL regdb_store_values( const char *key, REGVAL_CTR *values )
696 TDB_DATA old_data, data;
697 pstring keystr;
698 int len, ret;
700 DEBUG(10,("regdb_store_values: Looking for value of key [%s] \n", key));
702 ZERO_STRUCT( data );
704 len = regdb_pack_values( values, data.dptr, data.dsize );
705 if ( len <= 0 ) {
706 DEBUG(0,("regdb_store_values: unable to pack values. len <= 0\n"));
707 return False;
710 data.dptr = SMB_MALLOC_ARRAY( uint8, len );
711 data.dsize = len;
713 len = regdb_pack_values( values, data.dptr, data.dsize );
715 SMB_ASSERT( len == data.dsize );
717 pstr_sprintf( keystr, "%s/%s", REG_VALUE_PREFIX, key );
718 normalize_reg_path( keystr );
720 old_data = tdb_fetch_bystring(tdb_reg->tdb, keystr);
722 if ((old_data.dptr != NULL)
723 && (old_data.dsize == data.dsize)
724 && (memcmp(old_data.dptr, data.dptr, data.dsize) == 0)) {
725 SAFE_FREE(old_data.dptr);
726 SAFE_FREE(data.dptr);
727 return True;
730 ret = tdb_trans_store_bystring(tdb_reg->tdb, keystr, data, TDB_REPLACE);
732 SAFE_FREE( old_data.dptr );
733 SAFE_FREE( data.dptr );
735 return ret != -1 ;
738 static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
739 struct security_descriptor **psecdesc)
741 char *tdbkey;
742 TDB_DATA data;
743 NTSTATUS status;
745 DEBUG(10, ("regdb_get_secdesc: Getting secdesc of key [%s]\n", key));
747 if (asprintf(&tdbkey, "%s/%s", REG_SECDESC_PREFIX, key) == -1) {
748 return WERR_NOMEM;
750 normalize_dbkey(tdbkey);
752 data = tdb_fetch_bystring(tdb_reg->tdb, tdbkey);
753 SAFE_FREE(tdbkey);
755 if (data.dptr == NULL) {
756 return WERR_BADFILE;
759 status = unmarshall_sec_desc(mem_ctx, (uint8 *)data.dptr, data.dsize,
760 psecdesc);
762 SAFE_FREE(data.dptr);
764 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
765 return WERR_NOMEM;
768 if (!NT_STATUS_IS_OK(status)) {
769 return WERR_REG_CORRUPT;
772 return WERR_OK;
775 static WERROR regdb_set_secdesc(const char *key,
776 struct security_descriptor *secdesc)
778 prs_struct ps;
779 TALLOC_CTX *mem_ctx;
780 char *tdbkey;
781 WERROR err = WERR_NOMEM;
782 TDB_DATA tdbdata;
784 if (!(mem_ctx = talloc_init("regdb_set_secdesc"))) {
785 return WERR_NOMEM;
788 ZERO_STRUCT(ps);
790 if (!(tdbkey = talloc_asprintf(mem_ctx, "%s/%s", REG_SECDESC_PREFIX,
791 key))) {
792 goto done;
794 normalize_dbkey(tdbkey);
796 err = ntstatus_to_werror(marshall_sec_desc(mem_ctx, secdesc,
797 &tdbdata.dptr,
798 &tdbdata.dsize));
799 if (!W_ERROR_IS_OK(err)) {
800 goto done;
803 if (tdb_trans_store_bystring(tdb_reg->tdb, tdbkey, tdbdata, 0) == -1) {
804 err = ntstatus_to_werror(map_nt_error_from_unix(errno));
805 goto done;
808 done:
809 prs_mem_free(&ps);
810 TALLOC_FREE(mem_ctx);
811 return err;
815 * Table of function pointers for default access
818 REGISTRY_OPS regdb_ops = {
819 regdb_fetch_keys,
820 regdb_fetch_values,
821 regdb_store_keys,
822 regdb_store_values,
823 NULL,
824 regdb_get_secdesc,
825 regdb_set_secdesc