mirror of
https://github.com/samba-team/samba.git
synced 2025-03-09 08:58:35 +03:00
While we're all making incompatible tdb changes, I changed the implementation
of tdb_{store,get}_int() to store the length of the string key + 1 so the stored key contains the trailing NULL character. This allows normal string library routines to manipulate keys. Also renamed tdb_get_int() to tdb_fetch_int() to keep the set of verbs consistent.
This commit is contained in:
parent
0189af5442
commit
a423c7c5f2
@ -101,7 +101,7 @@ static uint32 get_cache_sequence_number(char *domain_name, char *cache_type, cha
|
||||
uint32 seq_num;
|
||||
slprintf(keystr,sizeof(keystr),"CACHESEQ %s/%s/%s",
|
||||
domain_name, cache_type, subkey?subkey:"");
|
||||
seq_num = (uint32)tdb_get_int(cache_tdb, keystr);
|
||||
seq_num = (uint32)tdb_fetch_int(cache_tdb, keystr);
|
||||
DEBUG(4,("%s is %u\n", keystr, (unsigned)seq_num));
|
||||
return seq_num;
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ static BOOL allocate_id(int *id, BOOL isgroup)
|
||||
|
||||
/* Get current high water mark */
|
||||
|
||||
if ((hwm = tdb_get_int(idmap_tdb, isgroup ? HWM_GROUP : HWM_USER)) == -1) {
|
||||
if ((hwm = tdb_fetch_int(idmap_tdb,
|
||||
isgroup ? HWM_GROUP : HWM_USER)) == -1) {
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -217,14 +218,14 @@ BOOL winbindd_idmap_init(void)
|
||||
|
||||
/* Create high water marks for group and user id */
|
||||
|
||||
if (tdb_get_int(idmap_tdb, HWM_USER) == -1) {
|
||||
if (tdb_fetch_int(idmap_tdb, HWM_USER) == -1) {
|
||||
if (tdb_store_int(idmap_tdb, HWM_USER, server_state.uid_low) == -1) {
|
||||
DEBUG(0, ("Unable to initialise user hwm in idmap database\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
if (tdb_get_int(idmap_tdb, HWM_GROUP) == -1) {
|
||||
if (tdb_fetch_int(idmap_tdb, HWM_GROUP) == -1) {
|
||||
if (tdb_store_int(idmap_tdb, HWM_GROUP, server_state.gid_low) == -1) {
|
||||
DEBUG(0, ("Unable to initialise group hwm in idmap database\n"));
|
||||
return False;
|
||||
|
@ -76,7 +76,7 @@ BOOL print_backend_init(void)
|
||||
|
||||
/* handle a Samba upgrade */
|
||||
tdb_writelock(tdb);
|
||||
if (tdb_get_int(tdb, "INFO/version") != PRINT_DATABASE_VERSION) {
|
||||
if (tdb_fetch_int(tdb, "INFO/version") != PRINT_DATABASE_VERSION) {
|
||||
tdb_traverse(tdb, (tdb_traverse_func)tdb_delete, NULL);
|
||||
tdb_store_int(tdb, "INFO/version", PRINT_DATABASE_VERSION);
|
||||
}
|
||||
@ -602,7 +602,7 @@ int print_job_start(int snum, char *jobname)
|
||||
/* lock the database */
|
||||
tdb_writelock(tdb);
|
||||
|
||||
next_jobid = tdb_get_int(tdb, "INFO/nextjob");
|
||||
next_jobid = tdb_fetch_int(tdb, "INFO/nextjob");
|
||||
if (next_jobid == -1) next_jobid = 1;
|
||||
|
||||
for (jobid = next_jobid+1; jobid != next_jobid; ) {
|
||||
@ -723,7 +723,7 @@ static BOOL print_cache_expired(int snum)
|
||||
fstring key;
|
||||
time_t t2, t = time(NULL);
|
||||
slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
|
||||
t2 = tdb_get_int(tdb, key);
|
||||
t2 = tdb_fetch_int(tdb, key);
|
||||
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
|
||||
return True;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
/* fetch a value by a arbitrary blob key, return -1 if not found */
|
||||
int tdb_get_int_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len)
|
||||
int tdb_fetch_int_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len)
|
||||
{
|
||||
TDB_DATA key, data;
|
||||
int ret;
|
||||
@ -42,9 +42,9 @@ int tdb_get_int_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len)
|
||||
}
|
||||
|
||||
/* fetch a value by string key, return -1 if not found */
|
||||
int tdb_get_int(TDB_CONTEXT *tdb, char *keystr)
|
||||
int tdb_fetch_int(TDB_CONTEXT *tdb, char *keystr)
|
||||
{
|
||||
return tdb_get_int_byblob(tdb, keystr, strlen(keystr));
|
||||
return tdb_fetch_int_byblob(tdb, keystr, strlen(keystr) + 1);
|
||||
}
|
||||
|
||||
/* store a value by an arbitary blob key, return 0 on success, -1 on failure */
|
||||
@ -63,7 +63,7 @@ int tdb_store_int_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, int v)
|
||||
/* store a value by string key, return 0 on success, -1 on failure */
|
||||
int tdb_store_int(TDB_CONTEXT *tdb, char *keystr, int v)
|
||||
{
|
||||
return tdb_store_int_byblob(tdb, keystr, strlen(keystr), v);
|
||||
return tdb_store_int_byblob(tdb, keystr, strlen(keystr) + 1, v);
|
||||
}
|
||||
|
||||
/* Store a buffer by a null terminated string key. Return 0 on success, -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user