mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
lib: Use "mem_ctx" arg in gencache_get
Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Sep 5 20:09:21 CEST 2013 on sn-devel-104
This commit is contained in:
parent
32037e0533
commit
d3c689fc5c
@ -96,14 +96,13 @@ static bool fetch_map_from_gencache(TALLOC_CTX *ctx,
|
||||
if (key == NULL) {
|
||||
return false;
|
||||
}
|
||||
found = gencache_get(key, NULL, &value, NULL);
|
||||
found = gencache_get(key, ctx, &value, NULL);
|
||||
TALLOC_FREE(key);
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
TALLOC_FREE(*p_user_out);
|
||||
*p_user_out = talloc_strdup(ctx, value);
|
||||
SAFE_FREE(value);
|
||||
*p_user_out = value;
|
||||
if (!*p_user_out) {
|
||||
return false;
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
|
||||
DATA_BLOB blob;
|
||||
bool ret = False;
|
||||
|
||||
ret = gencache_get_data_blob(keystr, NULL, &blob, ptimeout, NULL);
|
||||
ret = gencache_get_data_blob(keystr, mem_ctx, &blob, ptimeout, NULL);
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
@ -725,11 +725,7 @@ bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
|
||||
return false;
|
||||
}
|
||||
if (value) {
|
||||
*value = SMB_STRDUP((char *)blob.data);
|
||||
data_blob_free(&blob);
|
||||
if (*value == NULL) {
|
||||
return false;
|
||||
}
|
||||
*value = talloc_move(mem_ctx, (char **)&blob.data);
|
||||
return true;
|
||||
}
|
||||
data_blob_free(&blob);
|
||||
@ -783,8 +779,11 @@ static int gencache_iterate_blobs_fn(struct tdb_context *tdb, TDB_DATA key,
|
||||
keystr = (char *)key.dptr;
|
||||
} else {
|
||||
/* ensure 0-termination */
|
||||
keystr = SMB_STRNDUP((char *)key.dptr, key.dsize);
|
||||
keystr = talloc_strndup(talloc_tos(), (char *)key.dptr, key.dsize);
|
||||
free_key = keystr;
|
||||
if (keystr == NULL) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gencache_pull_timeout((char *)data.dptr, &timeout, &endptr)) {
|
||||
@ -806,7 +805,7 @@ static int gencache_iterate_blobs_fn(struct tdb_context *tdb, TDB_DATA key,
|
||||
timeout, state->private_data);
|
||||
|
||||
done:
|
||||
SAFE_FREE(free_key);
|
||||
TALLOC_FREE(free_key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -862,8 +861,11 @@ static void gencache_iterate_fn(const char *key, DATA_BLOB value,
|
||||
valstr = (char *)value.data;
|
||||
} else {
|
||||
/* ensure 0-termination */
|
||||
valstr = SMB_STRNDUP((char *)value.data, value.length);
|
||||
valstr = talloc_strndup(talloc_tos(), (char *)value.data, value.length);
|
||||
free_val = valstr;
|
||||
if (valstr == NULL) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(10, ("Calling function with arguments "
|
||||
@ -872,7 +874,9 @@ static void gencache_iterate_fn(const char *key, DATA_BLOB value,
|
||||
|
||||
state->fn(key, valstr, timeout, state->private_data);
|
||||
|
||||
SAFE_FREE(free_val);
|
||||
done:
|
||||
|
||||
TALLOC_FREE(free_val);
|
||||
}
|
||||
|
||||
void gencache_iterate(void (*fn)(const char *key, const char *value,
|
||||
|
@ -48,7 +48,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
|
||||
if (key == NULL) {
|
||||
return false;
|
||||
}
|
||||
ret = gencache_get(key, NULL, &value, &timeout);
|
||||
ret = gencache_get(key, talloc_tos(), &value, &timeout);
|
||||
if (!ret) {
|
||||
goto done;
|
||||
}
|
||||
@ -128,7 +128,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
|
||||
|
||||
done:
|
||||
TALLOC_FREE(key);
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired)
|
||||
if (key == NULL) {
|
||||
return false;
|
||||
}
|
||||
ret = gencache_get(key, NULL, &value, &timeout);
|
||||
ret = gencache_get(key, talloc_tos(), &value, &timeout);
|
||||
TALLOC_FREE(key);
|
||||
if (!ret) {
|
||||
return false;
|
||||
@ -218,7 +218,7 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired)
|
||||
if (value[0] != '-') {
|
||||
ret = string_to_sid(sid, value);
|
||||
}
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
if (ret) {
|
||||
*expired = (timeout <= time(NULL));
|
||||
}
|
||||
@ -246,7 +246,7 @@ bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired)
|
||||
if (key == NULL) {
|
||||
return false;
|
||||
}
|
||||
ret = gencache_get(key, NULL, &value, &timeout);
|
||||
ret = gencache_get(key, talloc_tos(), &value, &timeout);
|
||||
TALLOC_FREE(key);
|
||||
if (!ret) {
|
||||
return false;
|
||||
@ -255,7 +255,7 @@ bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired)
|
||||
if (value[0] != '-') {
|
||||
ret = string_to_sid(sid, value);
|
||||
}
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
if (ret) {
|
||||
*expired = (timeout <= time(NULL));
|
||||
}
|
||||
@ -431,7 +431,7 @@ static bool idmap_cache_del_xid(char t, int xid)
|
||||
time_t timeout;
|
||||
bool ret = true;
|
||||
|
||||
if (!gencache_get(key, NULL, &sid_str, &timeout)) {
|
||||
if (!gencache_get(key, mem_ctx, &sid_str, &timeout)) {
|
||||
DEBUG(3, ("no entry: %s\n", key));
|
||||
ret = false;
|
||||
goto done;
|
||||
|
@ -143,13 +143,13 @@ NTSTATUS check_negative_conn_cache( const char *domain, const char *server)
|
||||
if (key == NULL)
|
||||
goto done;
|
||||
|
||||
if (gencache_get(key, NULL, &value, NULL))
|
||||
if (gencache_get(key, talloc_tos(), &value, NULL))
|
||||
result = negative_conn_cache_valuedecode(value);
|
||||
done:
|
||||
DEBUG(9,("check_negative_conn_cache returning result %d for domain %s "
|
||||
"server %s\n", NT_STATUS_V(result), domain, server));
|
||||
TALLOC_FREE(key);
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ bool namecache_fetch(const char *name,
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!gencache_get(key, NULL, &value, &timeout)) {
|
||||
if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
|
||||
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
|
||||
SAFE_FREE(key);
|
||||
return False;
|
||||
@ -170,7 +170,7 @@ bool namecache_fetch(const char *name,
|
||||
*num_names = ipstr_list_parse(value, ip_list);
|
||||
|
||||
SAFE_FREE(key);
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
|
||||
return *num_names > 0; /* true only if some ip has been fetched */
|
||||
}
|
||||
@ -294,7 +294,7 @@ bool namecache_status_fetch(const char *keyname,
|
||||
if (!key)
|
||||
return False;
|
||||
|
||||
if (!gencache_get(key, NULL, &value, &timeout)) {
|
||||
if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
|
||||
DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
|
||||
key));
|
||||
SAFE_FREE(key);
|
||||
@ -306,6 +306,6 @@ bool namecache_status_fetch(const char *keyname,
|
||||
|
||||
strlcpy(srvname_out, value, 16);
|
||||
SAFE_FREE(key);
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return True;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ bool trustdom_cache_fetch(const char* name, struct dom_sid* sid)
|
||||
if (!key)
|
||||
return False;
|
||||
|
||||
if (!gencache_get(key, NULL, &value, &timeout)) {
|
||||
if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
|
||||
DEBUG(5, ("no entry for trusted domain %s found.\n", name));
|
||||
SAFE_FREE(key);
|
||||
return False;
|
||||
@ -172,11 +172,11 @@ bool trustdom_cache_fetch(const char* name, struct dom_sid* sid)
|
||||
/* convert sid string representation into struct dom_sid structure */
|
||||
if(! string_to_sid(sid, value)) {
|
||||
sid = NULL;
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return False;
|
||||
}
|
||||
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ uint32 trustdom_cache_fetch_timestamp( void )
|
||||
time_t timeout;
|
||||
uint32 timestamp;
|
||||
|
||||
if (!gencache_get(TDOMTSKEY, NULL, &value, &timeout)) {
|
||||
if (!gencache_get(TDOMTSKEY, talloc_tos(), &value, &timeout)) {
|
||||
DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
|
||||
SAFE_FREE(value);
|
||||
return 0;
|
||||
@ -199,7 +199,7 @@ uint32 trustdom_cache_fetch_timestamp( void )
|
||||
|
||||
timestamp = atoi(value);
|
||||
|
||||
SAFE_FREE(value);
|
||||
TALLOC_FREE(value);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (gencache_get(cache_key, NULL, &cache_value, NULL)) {
|
||||
if (gencache_get(cache_key, talloc_tos(), &cache_value, NULL)) {
|
||||
uint32 tmp = strtoul(cache_value, NULL, 10);
|
||||
*value = tmp;
|
||||
ret = True;
|
||||
@ -454,7 +454,7 @@ bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value)
|
||||
|
||||
done:
|
||||
SAFE_FREE(cache_key);
|
||||
SAFE_FREE(cache_value);
|
||||
TALLOC_FREE(cache_value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -631,16 +631,16 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
|
||||
cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s",
|
||||
aprinter);
|
||||
if ((cache_key != NULL) &&
|
||||
gencache_get(cache_key, NULL, &tmp, NULL)) {
|
||||
gencache_get(cache_key, talloc_tos(), &tmp, NULL)) {
|
||||
|
||||
found = (strcmp(tmp, printer_not_found) != 0);
|
||||
if (!found) {
|
||||
DEBUG(4, ("Printer %s not found\n", aprinter));
|
||||
SAFE_FREE(tmp);
|
||||
TALLOC_FREE(tmp);
|
||||
return WERR_INVALID_PRINTER_NAME;
|
||||
}
|
||||
fstrcpy(sname, tmp);
|
||||
SAFE_FREE(tmp);
|
||||
TALLOC_FREE(tmp);
|
||||
}
|
||||
|
||||
/* Search all sharenames first as this is easier than pulling
|
||||
|
@ -8135,7 +8135,7 @@ static bool run_local_gencache(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!gencache_get("foo", NULL, &val, &tm)) {
|
||||
if (!gencache_get("foo", talloc_tos(), &val, &tm)) {
|
||||
d_printf("%s: gencache_get() failed\n", __location__);
|
||||
return False;
|
||||
}
|
||||
@ -8143,11 +8143,11 @@ static bool run_local_gencache(int dummy)
|
||||
if (strcmp(val, "bar") != 0) {
|
||||
d_printf("%s: gencache_get() returned %s, expected %s\n",
|
||||
__location__, val, "bar");
|
||||
SAFE_FREE(val);
|
||||
TALLOC_FREE(val);
|
||||
return False;
|
||||
}
|
||||
|
||||
SAFE_FREE(val);
|
||||
TALLOC_FREE(val);
|
||||
|
||||
if (!gencache_del("foo")) {
|
||||
d_printf("%s: gencache_del() failed\n", __location__);
|
||||
@ -8159,7 +8159,7 @@ static bool run_local_gencache(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (gencache_get("foo", NULL, &val, &tm)) {
|
||||
if (gencache_get("foo", talloc_tos(), &val, &tm)) {
|
||||
d_printf("%s: gencache_get() on deleted entry "
|
||||
"succeeded\n", __location__);
|
||||
return False;
|
||||
@ -8173,7 +8173,7 @@ static bool run_local_gencache(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
|
||||
if (!gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
|
||||
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
|
||||
return False;
|
||||
}
|
||||
@ -8197,7 +8197,7 @@ static bool run_local_gencache(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
|
||||
if (gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
|
||||
d_printf("%s: gencache_get_data_blob() on deleted entry "
|
||||
"succeeded\n", __location__);
|
||||
return False;
|
||||
@ -8212,7 +8212,7 @@ static bool run_local_gencache(int dummy)
|
||||
__location__);
|
||||
return false;
|
||||
}
|
||||
if (gencache_get("blob", NULL, &val, &tm)) {
|
||||
if (gencache_get("blob", talloc_tos(), &val, &tm)) {
|
||||
d_printf("%s: gencache_get succeeded\n", __location__);
|
||||
return false;
|
||||
}
|
||||
|
@ -1512,7 +1512,7 @@ bool fetch_current_dc_from_gencache(TALLOC_CTX *mem_ctx,
|
||||
if (key == NULL) {
|
||||
goto done;
|
||||
}
|
||||
if (!gencache_get(key, NULL, &value, NULL)) {
|
||||
if (!gencache_get(key, mem_ctx, &value, NULL)) {
|
||||
goto done;
|
||||
}
|
||||
p = strchr(value, ' ');
|
||||
@ -1541,6 +1541,7 @@ done:
|
||||
TALLOC_FREE(dc_name);
|
||||
TALLOC_FREE(dc_ip);
|
||||
TALLOC_FREE(key);
|
||||
TALLOC_FREE(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user