*
* 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/* Implementation of internal registry database functions. */
#include "includes.h"
#include "lib/samba3/samba3.h"
#include "librpc/gen_ndr/winreg.h"
-#include "lib/tdb/include/tdbutil.h"
+#include "lib/tdb/include/tdb.h"
+#include "lib/util/util_tdb.h"
#include "system/filesys.h"
#include "pstring.h"
int len = 0;
uint32_t type;
uint32_t size;
- uint8_t *data_p;
+ uint8_t *data_p;
uint32_t num_values = 0;
int i;
fstring valuename;
/* loop and unpack the rest of the registry values */
- len += tdb_unpack(tdb, data.dptr+len, data.dsize-len, "d", &num_values);
+ len += tdb_unpack(tdb, (char *)data.dptr+len, data.dsize-len, "d", &num_values);
for ( i=0; i<num_values; i++ ) {
struct samba3_regval val;
type = REG_NONE;
size = 0;
data_p = NULL;
- len += tdb_unpack(tdb, data.dptr+len, data.dsize-len, "fdB",
+ len += tdb_unpack(tdb, (char *)data.dptr+len, data.dsize-len, "fdB",
valuename,
&val.type,
&size,
if ( !(tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600)) )
{
+ DEBUG(0, ("Unable to open registry database %s\n", fn));
return NT_STATUS_UNSUCCESSFUL;
}
db->key_count = 0;
db->keys = NULL;
- if (vers_id > REGVER_V1)
+ if (vers_id != -1 && vers_id >= REGVER_V1) {
+ DEBUG(0, ("Registry version mismatch: %d\n", vers_id));
return NT_STATUS_UNSUCCESSFUL;
+ }
for (kbuf = tdb_firstkey(tdb); kbuf.dptr; kbuf = tdb_nextkey(tdb, kbuf))
{
struct samba3_regkey key;
char *skey;
- if (strncmp(kbuf.dptr, VALUE_PREFIX, strlen(VALUE_PREFIX)))
+ if (strncmp((char *)kbuf.dptr, VALUE_PREFIX, strlen(VALUE_PREFIX)) == 0)
continue;
vbuf = tdb_fetch(tdb, kbuf);
- key.name = talloc_strdup(ctx, kbuf.dptr);
+ key.name = talloc_strdup(ctx, (char *)kbuf.dptr);
- len = tdb_unpack(tdb, vbuf.dptr, vbuf.dsize, "d", &key.subkey_count);
+ len = tdb_unpack(tdb, (char *)vbuf.dptr, vbuf.dsize, "d", &key.subkey_count);
key.value_count = 0;
key.values = NULL;
for (i = 0; i < key.subkey_count; i++) {
fstring tmp;
- len += tdb_unpack( tdb, vbuf.dptr+len, vbuf.dsize-len, "f", tmp );
+ len += tdb_unpack( tdb, (char *)vbuf.dptr+len, vbuf.dsize-len, "f", tmp );
key.subkeys[i] = talloc_strdup(ctx, tmp);
}
}
db->keys = talloc_realloc(ctx, db->keys, struct samba3_regkey, db->key_count+1);
- db->keys[i] = key;
+ db->keys[db->key_count] = key;
db->key_count++;
}