mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib: Pass mem_ctx to cache_path()
Fix a confusing API: Many places TALLOC_FREE the path where it's not clear you have to do it. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Aug 17 14:28:51 CEST 2018 on sn-devel-144
This commit is contained in:
parent
c2ea100777
commit
6ca5ba5272
@ -93,7 +93,7 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
|
||||
}
|
||||
|
||||
if (!cache_dir) {
|
||||
cache_dir = cache_path(GPO_CACHE_DIR);
|
||||
cache_dir = cache_path(talloc_tos(), GPO_CACHE_DIR);
|
||||
if (!cache_dir) {
|
||||
PyErr_SetString(PyExc_MemoryError,
|
||||
"Failed to determine gpo cache dir");
|
||||
|
@ -64,7 +64,7 @@ static bool gencache_init(void)
|
||||
|
||||
hash_size = lp_parm_int(-1, "gencache", "hash_size", 10000);
|
||||
|
||||
cache_fname = cache_path("gencache.tdb");
|
||||
cache_fname = cache_path(talloc_tos(), "gencache.tdb");
|
||||
if (cache_fname == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ char *state_path(TALLOC_CTX *mem_ctx, const char *name)
|
||||
* @retval Pointer to a talloc'ed string containing the full path.
|
||||
**/
|
||||
|
||||
char *cache_path(const char *name)
|
||||
char *cache_path(TALLOC_CTX *mem_ctx, const char *name)
|
||||
{
|
||||
return xx_path(talloc_tos(), name, lp_cache_directory());
|
||||
return xx_path(mem_ctx, name, lp_cache_directory());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
char *lock_path(TALLOC_CTX *mem_ctx, const char *name);
|
||||
char *state_path(TALLOC_CTX *mem_ctx, const char *name);
|
||||
char *cache_path(const char *name);
|
||||
char *cache_path(TALLOC_CTX *mem_ctx, const char *name);
|
||||
char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *abs_path);
|
||||
|
||||
#endif
|
||||
|
@ -291,7 +291,7 @@ static NTSTATUS registry_process_group_policy(TALLOC_CTX *mem_ctx,
|
||||
size_t num_entries = 0;
|
||||
char *unix_path = NULL;
|
||||
const struct GROUP_POLICY_OBJECT *gpo;
|
||||
char *gpo_cache_path = cache_path(GPO_CACHE_DIR);
|
||||
char *gpo_cache_path = cache_path(talloc_tos(), GPO_CACHE_DIR);
|
||||
if (gpo_cache_path == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ static NTSTATUS scripts_process_group_policy(TALLOC_CTX *mem_ctx,
|
||||
GP_SCRIPTS_INI_LOGOFF
|
||||
};
|
||||
const struct GROUP_POLICY_OBJECT *gpo;
|
||||
char *gpo_cache_path = cache_path(GPO_CACHE_DIR);
|
||||
char *gpo_cache_path = cache_path(talloc_tos(), GPO_CACHE_DIR);
|
||||
if (gpo_cache_path == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ static NTSTATUS security_process_group_policy(TALLOC_CTX *mem_ctx,
|
||||
char *unix_path = NULL;
|
||||
struct gp_inifile_context *ini_ctx = NULL;
|
||||
const struct GROUP_POLICY_OBJECT *gpo;
|
||||
char *gpo_cache_path = cache_path(GPO_CACHE_DIR);
|
||||
char *gpo_cache_path = cache_path(talloc_tos(), GPO_CACHE_DIR);
|
||||
if (gpo_cache_path == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ bool netsamlogon_cache_init(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
path = cache_path(NETSAMLOGON_TDB);
|
||||
path = cache_path(talloc_tos(), NETSAMLOGON_TDB);
|
||||
if (path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ void write_browse_list(time_t t, bool force_write)
|
||||
|
||||
updatecount++;
|
||||
|
||||
fname = cache_path(SERVER_LIST);
|
||||
fname = cache_path(talloc_tos(), SERVER_LIST);
|
||||
if (!fname) {
|
||||
return;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ bool login_cache_init(void)
|
||||
/* skip file open if it's already opened */
|
||||
if (cache) return True;
|
||||
|
||||
cache_fname = cache_path(LOGIN_CACHE_FILE);
|
||||
cache_fname = cache_path(talloc_tos(), LOGIN_CACHE_FILE);
|
||||
if (cache_fname == NULL) {
|
||||
DEBUG(0, ("Filename allocation failed.\n"));
|
||||
return False;
|
||||
|
@ -204,7 +204,7 @@ bool print_backend_init(struct messaging_context *msg_ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
print_cache_path = cache_path("printing");
|
||||
print_cache_path = cache_path(talloc_tos(), "printing");
|
||||
if (print_cache_path == NULL) {
|
||||
return false;
|
||||
}
|
||||
@ -214,7 +214,7 @@ bool print_backend_init(struct messaging_context *msg_ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
print_cache_path = cache_path("printing.tdb");
|
||||
print_cache_path = cache_path(talloc_tos(), "printing.tdb");
|
||||
if (print_cache_path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ struct tdb_print_db *get_print_db_byname(const char *printername)
|
||||
DLIST_ADD(print_db_head, p);
|
||||
}
|
||||
|
||||
print_cache_path = cache_path("printing/");
|
||||
print_cache_path = cache_path(talloc_tos(), "printing/");
|
||||
if (print_cache_path == NULL) {
|
||||
DLIST_REMOVE(print_db_head, p);
|
||||
SAFE_FREE(p);
|
||||
|
@ -129,7 +129,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
|
||||
return true;
|
||||
}
|
||||
|
||||
db_name = cache_path("smbprofile.tdb");
|
||||
db_name = cache_path(talloc_tos(), "smbprofile.tdb");
|
||||
if (db_name == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1228,7 +1228,7 @@ static int get_session_info(uint32_t servertype,
|
||||
char **lines;
|
||||
bool local_list_only;
|
||||
int i;
|
||||
char *slist_cache_path = cache_path(SERVER_LIST);
|
||||
char *slist_cache_path = cache_path(talloc_tos(), SERVER_LIST);
|
||||
if (slist_cache_path == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ static int net_ads_gpo_refresh(struct net_context *c, int argc, const char **arg
|
||||
d_printf(_("finished\n"));
|
||||
|
||||
d_printf(_("* Refreshing Group Policy Data "));
|
||||
gpo_cache_path = cache_path(GPO_CACHE_DIR);
|
||||
gpo_cache_path = cache_path(talloc_tos(), GPO_CACHE_DIR);
|
||||
if (gpo_cache_path == NULL) {
|
||||
d_printf(_("failed: %s\n"), nt_errstr(NT_STATUS_NO_MEMORY));
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user