Ejemplo n.º 1
0
static int dump_tdb(const char *fname, const char *keyname, bool emergency)
{
	TDB_CONTEXT *tdb;
	TDB_DATA key, value;
	struct tdb_logging_context logfn = { log_stderr };

	tdb = tdb_open_ex(fname, 0, 0, O_RDONLY, 0, &logfn, NULL);
	if (!tdb) {
		printf("Failed to open %s\n", fname);
		return 1;
	}

	if (emergency) {
		return tdb_rescue(tdb, emergency_walk, keyname) == 0;
	}
	if (!keyname) {
		return tdb_traverse(tdb, traverse_fn, NULL) == -1 ? 1 : 0;
	} else {
		key.dptr = discard_const_p(uint8_t, keyname);
		key.dsize = strlen(keyname);
		value = tdb_fetch(tdb, key);
		if (!value.dptr) {
			return 1;
		} else {
			print_data(value);
			free(value.dptr);
		}
	}

	return 0;
}
Ejemplo n.º 2
0
static int dump_tdb(const char *fname, struct ldb_dn *dn, bool emergency)
{
	TDB_CONTEXT *tdb;
	struct tdb_logging_context logfn = { log_stderr };

	tdb = tdb_open_ex(fname, 0, 0, O_RDONLY, 0, &logfn, NULL);
	if (!tdb) {
		fprintf(stderr, "Failed to open %s\n", fname);
		return 1;
	}

	if (emergency) {
		return tdb_rescue(tdb, emergency_walk, dn) == 0;
	}
	return tdb_traverse(tdb, traverse_fn, dn) == -1 ? 1 : 0;
}