NTSTATUS dbwrap_trans_store_uint32_bystring(struct db_context *db, const char *keystr, uint32_t v) { uint32_t v_store; SIVAL(&v_store, 0, v); return dbwrap_trans_store(db, string_term_tdb_data(keystr), make_tdb_data((const uint8_t *)&v_store, sizeof(v_store)), TDB_REPLACE); }
static NTSTATUS fss_state_sc_store(TALLOC_CTX *mem_ctx, struct db_context *db, const char *sc_set_key_str, struct fss_sc *sc) { NTSTATUS status; TDB_DATA val; const char *sc_key_str; struct fsrvp_state_sc sc_state; struct fss_sc_smap *smap; enum ndr_err_code ndr_ret; DATA_BLOB sc_state_blob; /* becomes sc_set/@sc_set.id/sc/@sc_id */ sc_key_str = talloc_asprintf(mem_ctx, "%s/%s%s", sc_set_key_str, FSS_DB_KEY_PFX_SC, sc->id_str); if (sc_key_str == NULL) { return NT_STATUS_NO_MEMORY; } sc_state.id_str = sc->id_str; sc_state.volume_name = sc->volume_name; /* @sc->sc_path may be null if not committed, store empty str */ sc_state.sc_path = (sc->sc_path ? sc->sc_path : ""); sc_state.create_ts = sc->create_ts; sc_state.smaps_count = sc->smaps_count; ndr_ret = ndr_push_struct_blob(&sc_state_blob, mem_ctx, &sc_state, (ndr_push_flags_fn_t)ndr_push_fsrvp_state_sc); if (ndr_ret != NDR_ERR_SUCCESS) { return NT_STATUS_INTERNAL_ERROR; } val.dsize = sc_state_blob.length; val.dptr = sc_state_blob.data; status = dbwrap_store(db, string_term_tdb_data(sc_key_str), val, 0); if (!NT_STATUS_IS_OK(status)) { return status; } for (smap = sc->smaps; smap; smap = smap->next) { status = fss_state_smap_store(mem_ctx, db, sc_key_str, smap); if (!NT_STATUS_IS_OK(status)) { return status; } } return NT_STATUS_OK; }
static void cache_mangled_name( const char mangled_name[13], const char *raw_name ) { TDB_DATA data_val; char mangled_name_key[13]; char *s1 = NULL; char *s2 = NULL; /* If the cache isn't initialized, give up. */ if( !tdb_mangled_cache ) return; /* Init the string lengths. */ strlcpy(mangled_name_key, mangled_name, sizeof(mangled_name_key)); /* See if the extensions are unmangled. If so, store the entry * without the extension, thus creating a "group" reverse map. */ s1 = strrchr( mangled_name_key, '.' ); if( s1 && (s2 = strrchr( raw_name, '.' )) ) { size_t i = 1; while( s1[i] && (tolower_m( s1[i] ) == s2[i]) ) i++; if( !s1[i] && !s2[i] ) { /* Truncate at the '.' */ *s1 = '\0'; /* * DANGER WILL ROBINSON - this * is changing a const string via * an aliased pointer ! Remember to * put it back once we've used it. * JRA */ *s2 = '\0'; } } /* Allocate a new cache entry. If the allocation fails, just return. */ data_val = string_term_tdb_data(raw_name); if (tdb_store_bystring(tdb_mangled_cache, mangled_name_key, data_val, TDB_REPLACE) != 0) { DEBUG(0,("cache_mangled_name: Error storing entry %s -> %s\n", mangled_name_key, raw_name)); } else { DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name)); } /* Restore the change we made to the const string. */ if (s2) { *s2 = '.'; } }
static bool group_map_remove(const struct dom_sid *sid) { char *key; NTSTATUS status; key = group_mapping_key(talloc_tos(), sid); if (key == NULL) { return false; } status = dbwrap_trans_delete(db, string_term_tdb_data(key)); TALLOC_FREE(key); return NT_STATUS_IS_OK(status); }
NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, TDB_DATA data, int flags) { struct db_record *rec; NTSTATUS status; rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key)); if (rec == NULL) { return NT_STATUS_NO_MEMORY; } status = rec->store(rec, data, flags); TALLOC_FREE(rec); return status; }
static int regdb_normalize_keynames_fn(struct db_record *rec, void *private_data) { TALLOC_CTX *mem_ctx = talloc_tos(); const char *keyname; NTSTATUS status; if (rec->key.dptr == NULL || rec->key.dsize == 0) { return 0; } keyname = strchr((const char *) rec->key.dptr, '/'); if (keyname) { struct db_record new_rec; keyname = talloc_string_sub(mem_ctx, (const char *) rec->key.dptr, "/", "\\"); DEBUG(2, ("regdb_normalize_keynames_fn: Convert %s to %s\n", (const char *) rec->key.dptr, keyname)); new_rec.value = rec->value; new_rec.key = string_term_tdb_data(keyname); new_rec.private_data = rec->private_data; /* Delete the original record and store the normalized key */ status = rec->delete_rec(rec); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("regdb_normalize_keynames_fn: " "tdb_delete for [%s] failed!\n", rec->key.dptr)); return 1; } status = rec->store(&new_rec, new_rec.value, TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("regdb_normalize_keynames_fn: " "failed to store new record for [%s]!\n", keyname)); return 1; } } return 0; }
static NTSTATUS fss_state_sc_set_store(TALLOC_CTX *mem_ctx, struct db_context *db, struct fss_sc_set *sc_set) { NTSTATUS status; TDB_DATA val; const char *sc_set_key_str; struct fss_sc *sc; struct fsrvp_state_sc_set sc_set_state; DATA_BLOB sc_set_state_blob; enum ndr_err_code ndr_ret; sc_set_key_str = talloc_asprintf(mem_ctx, "%s%s", FSS_DB_KEY_PFX_SC_SET, sc_set->id_str); if (sc_set_key_str == NULL) { return NT_STATUS_NO_MEMORY; } sc_set_state.id_str = sc_set->id_str; sc_set_state.state = sc_set->state; sc_set_state.context = sc_set->context; sc_set_state.scs_count = sc_set->scs_count; ndr_ret = ndr_push_struct_blob(&sc_set_state_blob, mem_ctx, &sc_set_state, (ndr_push_flags_fn_t)ndr_push_fsrvp_state_sc_set); if (ndr_ret != NDR_ERR_SUCCESS) { return NT_STATUS_INTERNAL_ERROR; } val.dsize = sc_set_state_blob.length; val.dptr = sc_set_state_blob.data; status = dbwrap_store(db, string_term_tdb_data(sc_set_key_str), val, 0); if (!NT_STATUS_IS_OK(status)) { return status; } for (sc = sc_set->scs; sc; sc = sc->next) { status = fss_state_sc_store(mem_ctx, db, sc_set_key_str, sc); if (!NT_STATUS_IS_OK(status)) { return status; } } return NT_STATUS_OK; }
static int dbwrap_tool_exists(struct db_context *db, const char *keyname, const char *data) { bool result; result = dbwrap_exists(db, string_term_tdb_data(keyname)); if (result) { d_fprintf(stdout, "Key %s exists\n", keyname); } else { d_fprintf(stdout, "Key %s does not exist\n", keyname); } return (result)?0:1; }
NTSTATUS dbwrap_trans_change_int32_atomic_bystring(struct db_context *db, const char *keystr, int32_t *oldval, int32_t change_val) { NTSTATUS ret; struct dbwrap_change_int32_atomic_context state; state.key = string_term_tdb_data(keystr); state.oldval = oldval; state.change_val = change_val; ret = dbwrap_trans_do(db, dbwrap_change_int32_atomic_action, &state); return ret; }
static NTSTATUS fss_state_smap_store(TALLOC_CTX *mem_ctx, struct db_context *db, const char *sc_key_str, struct fss_sc_smap *smap) { NTSTATUS status; TDB_DATA val; const char *smap_key_str; struct fsrvp_state_smap smap_state; enum ndr_err_code ndr_ret; DATA_BLOB smap_state_blob; /* becomes sc_set/@sc_set_id/sc/@sc_id/smap/@sc_share_name */ smap_key_str = talloc_asprintf(mem_ctx, "%s/%s%s", sc_key_str, FSS_DB_KEY_PFX_SMAP, smap->sc_share_name); if (smap_key_str == NULL) { return NT_STATUS_NO_MEMORY; } smap_state.share_name = smap->share_name; smap_state.sc_share_name = smap->sc_share_name; /* @smap->sc_share_comment may be null if not exposed. */ if (smap->sc_share_comment != NULL) { smap_state.sc_share_comment = smap->sc_share_comment; } else { smap_state.sc_share_comment = ""; } smap_state.is_exposed = smap->is_exposed; ndr_ret = ndr_push_struct_blob(&smap_state_blob, mem_ctx, &smap_state, (ndr_push_flags_fn_t)ndr_push_fsrvp_state_smap); if (ndr_ret != NDR_ERR_SUCCESS) { return NT_STATUS_INTERNAL_ERROR; } val.dsize = smap_state_blob.length; val.dptr = smap_state_blob.data; status = dbwrap_store(db, string_term_tdb_data(smap_key_str), val, 0); if (!NT_STATUS_IS_OK(status)) { return status; } return NT_STATUS_OK; }
/* load a msg file into the tdb */ static bool load_msg(const char *msg_file) { char **lines; int num_lines, i; char *msgid, *msgstr; TDB_DATA data; lines = file_lines_load(msg_file, &num_lines, 0, NULL); if (!lines) { return False; } if (tdb_lockall(tdb) != 0) { TALLOC_FREE(lines); return False; } /* wipe the db */ tdb_wipe_all(tdb); msgid = NULL; for (i=0;i<num_lines;i++) { if (strncmp(lines[i], "msgid \"", 7) == 0) { msgid = lines[i] + 7; } if (msgid && strncmp(lines[i], "msgstr \"", 8) == 0) { msgstr = lines[i] + 8; trim_char(msgid, '\0', '\"'); trim_char(msgstr, '\0', '\"'); if (*msgstr == 0) { msgstr = msgid; } all_string_sub(msgid, "\\n", "\n", 0); all_string_sub(msgstr, "\\n", "\n", 0); data = string_term_tdb_data(msgstr); tdb_store_bystring(tdb, msgid, data, 0); msgid = NULL; } } TALLOC_FREE(lines); tdb_unlockall(tdb); return True; }
bool set_share_security(const char *share_name, struct security_descriptor *psd) { TALLOC_CTX *frame = talloc_stackframe(); char *key; bool ret = False; TDB_DATA blob; NTSTATUS status; char *c_share_name = canonicalize_servicename(frame, share_name); if (!c_share_name) { goto out; } if (!share_info_db_init()) { goto out; } status = marshall_sec_desc(frame, psd, &blob.dptr, &blob.dsize); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("marshall_sec_desc failed: %s\n", nt_errstr(status))); goto out; } if (!(key = talloc_asprintf(frame, SHARE_SECURITY_DB_KEY_PREFIX_STR "%s", c_share_name))) { DEBUG(0, ("talloc_asprintf failed\n")); goto out; } status = dbwrap_trans_store(share_db, string_term_tdb_data(key), blob, TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("set_share_security: Failed to store secdesc for " "%s: %s\n", share_name, nt_errstr(status))); goto out; } DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); ret = True; out: TALLOC_FREE(frame); return ret; }
static int dbwrap_tool_store_string(struct db_context *db, const char *keyname, const char *data) { NTSTATUS status; status = dbwrap_trans_store_bystring(db, keyname, string_term_tdb_data(data), TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "ERROR: could not store string key '%s': %s\n", keyname, nt_errstr(status)); return -1; } return 0; }
bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr, uint32_t *val) { TDB_DATA dbuf; if (db->fetch(db, NULL, string_term_tdb_data(keystr), &dbuf) != 0) { return false; } if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(uint32_t))) { TALLOC_FREE(dbuf.dptr); return false; } *val = IVAL(dbuf.dptr, 0); TALLOC_FREE(dbuf.dptr); return true; }
int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr) { TDB_DATA dbuf; int32 ret; if (db->fetch(db, NULL, string_term_tdb_data(keystr), &dbuf) != 0) { return -1; } if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(int32_t))) { TALLOC_FREE(dbuf.dptr); return -1; } ret = IVAL(dbuf.dptr, 0); TALLOC_FREE(dbuf.dptr); return ret; }
static NTSTATUS dbwrap_change_uint32_atomic_action(struct db_context *db, void *private_data) { struct db_record *rec; uint32_t val = (uint32_t)-1; uint32_t v_store; NTSTATUS ret; struct dbwrap_change_uint32_atomic_context *state; TDB_DATA value; state = (struct dbwrap_change_uint32_atomic_context *)private_data; rec = dbwrap_fetch_locked(db, talloc_tos(), string_term_tdb_data(state->keystr)); if (!rec) { return NT_STATUS_UNSUCCESSFUL; } value = dbwrap_record_get_value(rec); if (value.dptr == NULL) { val = *(state->oldval); } else if (value.dsize == sizeof(val)) { val = IVAL(value.dptr, 0); *(state->oldval) = val; } else { ret = NT_STATUS_UNSUCCESSFUL; goto done; } val += state->change_val; SIVAL(&v_store, 0, val); ret = dbwrap_record_store(rec, make_tdb_data((const uint8_t *)&v_store, sizeof(v_store)), TDB_REPLACE); done: TALLOC_FREE(rec); return ret; }
int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v) { struct db_record *rec; uint32 v_store; NTSTATUS status; rec = db->fetch_locked(db, NULL, string_term_tdb_data(keystr)); if (rec == NULL) { return -1; } SIVAL(&v_store, 0, v); status = rec->store(rec, make_tdb_data((const uint8 *)&v_store, sizeof(v_store)), TDB_REPLACE); TALLOC_FREE(rec); return NT_STATUS_IS_OK(status) ? 0 : -1; }
/* Open up the notify.tdb database. You should close it down using talloc_free(). We need the messaging_ctx to allow for notifications via internal messages */ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, struct messaging_context *messaging_ctx, struct event_context *ev, connection_struct *conn) { struct notify_context *notify; if (!lp_change_notify(conn->params)) { return NULL; } notify = talloc(mem_ctx, struct notify_context); if (notify == NULL) { return NULL; } notify->db = db_open(notify, lock_path("notify.tdb"), 0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0644); if (notify->db == NULL) { talloc_free(notify); return NULL; } notify->server = server; notify->messaging_ctx = messaging_ctx; notify->list = NULL; notify->array = NULL; notify->seqnum = notify->db->get_seqnum(notify->db); notify->key = string_term_tdb_data(NOTIFY_KEY); talloc_set_destructor(notify, notify_destructor); /* register with the messaging subsystem for the notify message type */ messaging_register(notify->messaging_ctx, notify, MSG_PVFS_NOTIFY, notify_handler); notify->sys_notify_ctx = sys_notify_context_create(conn, notify, ev); return notify; }
bool set_share_security(const char *share_name, SEC_DESC *psd) { TALLOC_CTX *frame; char *key; bool ret = False; TDB_DATA blob; NTSTATUS status; if (!share_info_db_init()) { return False; } frame = talloc_stackframe(); status = marshall_sec_desc(frame, psd, &blob.dptr, &blob.dsize); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("marshall_sec_desc failed: %s\n", nt_errstr(status))); goto out; } if (!(key = talloc_asprintf(frame, "SECDESC/%s", share_name))) { DEBUG(0, ("talloc_asprintf failed\n")); goto out; } status = dbwrap_trans_store(share_db, string_term_tdb_data(key), blob, TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("set_share_security: Failed to store secdesc for " "%s: %s\n", share_name, nt_errstr(status))); goto out; } DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); ret = True; out: TALLOC_FREE(frame); return ret; }
bool delete_share_security(const char *servicename) { TDB_DATA kbuf; char *key; NTSTATUS status; if (!(key = talloc_asprintf(talloc_tos(), "SECDESC/%s", servicename))) { return False; } kbuf = string_term_tdb_data(key); status = dbwrap_trans_delete(share_db, kbuf); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("delete_share_security: Failed to delete entry for " "share %s: %s\n", servicename, nt_errstr(status))); return False; } return True; }
bool run_dbwrap_watch1(int dummy) { struct tevent_context *ev = NULL; struct messaging_context *msg = NULL; struct db_context *backend = NULL; struct db_context *db = NULL; const char *keystr = "key"; TDB_DATA key = string_term_tdb_data(keystr); struct db_record *rec = NULL; struct tevent_req *req = NULL; NTSTATUS status; bool ret = false; ev = samba_tevent_context_init(talloc_tos()); if (ev == NULL) { fprintf(stderr, "tevent_context_init failed\n"); goto fail; } msg = messaging_init(ev, ev); if (msg == NULL) { fprintf(stderr, "messaging_init failed\n"); goto fail; } backend = db_open(msg, "test_watch.tdb", 0, TDB_DEFAULT, O_CREAT|O_RDWR, 0644, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); if (backend == NULL) { fprintf(stderr, "db_open failed: %s\n", strerror(errno)); goto fail; } db = db_open_watched(ev, backend, msg); rec = dbwrap_fetch_locked(db, db, key); if (rec == NULL) { fprintf(stderr, "dbwrap_fetch_locked failed\n"); goto fail; } req = dbwrap_watched_watch_send(talloc_tos(), ev, rec, (struct server_id){0});
NTSTATUS dbwrap_store_int32_bystring(struct db_context *db, const char *keystr, int32_t v) { struct db_record *rec; int32_t v_store; NTSTATUS status; rec = dbwrap_fetch_locked(db, talloc_tos(), string_term_tdb_data(keystr)); if (rec == NULL) { return NT_STATUS_UNSUCCESSFUL; } SIVAL(&v_store, 0, v); status = dbwrap_record_store(rec, make_tdb_data((const uint8_t *)&v_store, sizeof(v_store)), TDB_REPLACE); TALLOC_FREE(rec); return status; }
NTSTATUS dbwrap_fetch_uint32_bystring(struct db_context *db, const char *keystr, uint32_t *val) { struct dbwrap_fetch_uint32_state state; NTSTATUS status; if (val == NULL) { return NT_STATUS_INVALID_PARAMETER; } state.status = NT_STATUS_INTERNAL_ERROR; status = dbwrap_parse_record(db, string_term_tdb_data(keystr), dbwrap_fetch_uint32_parser, &state); if (!NT_STATUS_IS_OK(status)) { return status; } if (NT_STATUS_IS_OK(state.status)) { *val = state.result; } return state.status; }
static void cache_mangled_name( const char mangled_name[13], const char *raw_name ) { TDB_DATA data_val; char mangled_name_key[13]; char *s1; char *s2; /* If the cache isn't initialized, give up. */ if( !tdb_mangled_cache ) return; /* Init the string lengths. */ safe_strcpy(mangled_name_key, mangled_name, sizeof(mangled_name_key)-1); /* See if the extensions are unmangled. If so, store the entry * without the extension, thus creating a "group" reverse map. */ s1 = strrchr( mangled_name_key, '.' ); if( s1 && (s2 = strrchr( raw_name, '.' )) ) { size_t i = 1; while( s1[i] && (tolower_ascii( s1[i] ) == s2[i]) ) i++; if( !s1[i] && !s2[i] ) { /* Truncate at the '.' */ *s1 = '\0'; *s2 = '\0'; } } /* Allocate a new cache entry. If the allocation fails, just return. */ data_val = string_term_tdb_data(raw_name); if (tdb_store_bystring(tdb_mangled_cache, mangled_name_key, data_val, TDB_REPLACE) != 0) { DEBUG(0,("cache_mangled_name: Error storing entry %s -> %s\n", mangled_name_key, raw_name)); } else { DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name)); } }
static void test_store_records(struct db_context *db, struct tevent_context *ev) { TDB_DATA key; uint32_t *counters; TALLOC_CTX *tmp_ctx = talloc_stackframe(); struct timeval start; key = string_term_tdb_data("testkey"); start = timeval_current(); while ((timelimit == 0) || (timeval_elapsed(&start) < timelimit)) { struct db_record *rec; TDB_DATA data; TDB_DATA value; int ret; NTSTATUS status; if (!no_trans) { if (verbose) DEBUG(1, ("starting transaction\n")); ret = dbwrap_transaction_start(db); if (ret != 0) { DEBUG(0, ("Failed to start transaction on node " "%d\n", pnn)); goto fail; } if (verbose) DEBUG(1, ("transaction started\n")); do_sleep(torture_delay); } if (verbose) DEBUG(1, ("calling fetch_lock\n")); rec = dbwrap_fetch_locked(db, tmp_ctx, key); if (rec == NULL) { DEBUG(0, ("Failed to fetch record\n")); goto fail; } if (verbose) DEBUG(1, ("fetched record ok\n")); do_sleep(torture_delay); value = dbwrap_record_get_value(rec); data.dsize = MAX(value.dsize, sizeof(uint32_t) * (pnn+1)); data.dptr = (unsigned char *)talloc_zero_size(tmp_ctx, data.dsize); if (data.dptr == NULL) { DEBUG(0, ("Failed to allocate data\n")); goto fail; } memcpy(data.dptr, value.dptr, value.dsize); counters = (uint32_t *)data.dptr; /* bump our counter */ counters[pnn]++; if (verbose) DEBUG(1, ("storing data\n")); status = dbwrap_record_store(rec, data, TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("Failed to store record\n")); if (!no_trans) { ret = dbwrap_transaction_cancel(db); if (ret != 0) { DEBUG(0, ("Error cancelling transaction.\n")); } } goto fail; } talloc_free(rec); if (verbose) DEBUG(1, ("stored data ok\n")); do_sleep(torture_delay); if (!no_trans) { if (verbose) DEBUG(1, ("calling transaction_commit\n")); ret = dbwrap_transaction_commit(db); if (ret != 0) { DEBUG(0, ("Failed to commit transaction\n")); goto fail; } if (verbose) DEBUG(1, ("transaction committed\n")); } /* store the counters and verify that they are sane */ if (verbose || (pnn == 0)) { if (!check_counters(db, data)) { goto fail; } } talloc_free(data.dptr); do_sleep(torture_delay); } goto done; fail: success = false; done: talloc_free(tmp_ctx); return; }
bool run_dbwrap_watch1(int dummy) { struct tevent_context *ev = NULL; struct messaging_context *msg = NULL; struct db_context *db = NULL; const char *keystr = "key"; TDB_DATA key = string_term_tdb_data(keystr); struct db_record *rec = NULL; struct tevent_req *req = NULL; NTSTATUS status; bool ret = false; ev = tevent_context_init(talloc_tos()); if (ev == NULL) { fprintf(stderr, "tevent_context_init failed\n"); goto fail; } msg = messaging_init(ev, ev); if (msg == NULL) { fprintf(stderr, "messaging_init failed\n"); goto fail; } db = db_open(msg, "test_watch.tdb", 0, TDB_DEFAULT, O_CREAT|O_RDWR, 0644, DBWRAP_LOCK_ORDER_1); if (db == NULL) { fprintf(stderr, "db_open failed: %s\n", strerror(errno)); goto fail; } dbwrap_watch_db(db, msg); rec = dbwrap_fetch_locked(db, db, key); if (rec == NULL) { fprintf(stderr, "dbwrap_fetch_locked failed\n"); goto fail; } req = dbwrap_record_watch_send(talloc_tos(), ev, rec, msg); if (req == NULL) { fprintf(stderr, "dbwrap_record_watch_send failed\n"); goto fail; } TALLOC_FREE(rec); status = dbwrap_store_int32(db, keystr, 1); if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "dbwrap_store_int32 failed: %s\n", nt_errstr(status)); goto fail; } if (!tevent_req_poll(req, ev)) { fprintf(stderr, "tevent_req_poll failed\n"); goto fail; } status = dbwrap_record_watch_recv(req, talloc_tos(), &rec); if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "dbwrap_record_watch_recv failed: %s\n", nt_errstr(status)); goto fail; } ret = true; fail: TALLOC_FREE(req); TALLOC_FREE(rec); TALLOC_FREE(db); TALLOC_FREE(msg); TALLOC_FREE(ev); return ret; }
int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval) { TDB_DATA key = string_term_tdb_data(keyval); return tdb_chainlock(tdb, key); }
void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval) { TDB_DATA key = string_term_tdb_data(keyval); tdb_chainunlock_read(tdb, key); }
NTSTATUS dbwrap_trans_delete_bystring(struct db_context *db, const char *key) { return dbwrap_trans_delete(db, string_term_tdb_data(key)); }
NTSTATUS dbwrap_trans_store_bystring(struct db_context *db, const char *key, TDB_DATA data, int flags) { return dbwrap_trans_store(db, string_term_tdb_data(key), data, flags); }