/* * Unix SMB/CIFS implementation. * Virtual Windows Registry Layer * Copyright (C) Gerald Carter 2002-2005 * Copyright (C) Jelmer Vernooij 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Implementation of internal registry database functions. */ #include "includes.h" #define VALUE_PREFIX "SAMBA_REGVAL" #define REGVER_V1 1 /* first db version with write support */ /*********************************************************************** Open the registry database ***********************************************************************/ static TDB_CONTEXT *samba3_open_registry ( const char *fn ) { uint32_t vers_id; /* placeholder tdb; reinit upon startup */ if ( !(tdb = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0600)) ) { return NULL; } vers_id = tdb_fetch_int32(tdb, "INFO/version"); if (vers_id > REGVER_V1) return NULL; return True; } /*********************************************************************** Retrieve an array of strings containing subkeys. Memory should be released by the caller. ***********************************************************************/ int regdb_fetch_keys( TDB_CONTEXT *tdb, const char* key, REGSUBKEY_CTR *ctr ) { char *path; uint32_t num_items; TDB_DATA dbuf; char *buf; uint32_t buflen, len; int i; fstring subkeyname; DEBUG(11,("regdb_fetch_keys: Enter key => [%s]\n", key ? key : "NULL")); path = talloc_strdup(key); /* convert to key format */ for ( i = 0; path[i]; i++) { if ( path[i] == '\\' ) path[i] = '/'; } strupper_m( path ); dbuf = tdb_fetch_bystring( tdb, path ); buf = dbuf.dptr; buflen = dbuf.dsize; if ( !buf ) { DEBUG(5,("regdb_fetch_keys: tdb lookup failed to locate key [%s]\n", key)); return -1; } len = tdb_unpack( buf, buflen, "d", &num_items); for (i=0; i