1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

lib: Pass mem_ctx to state_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>
This commit is contained in:
Volker Lendecke 2018-08-16 10:51:44 +02:00 committed by Andreas Schneider
parent f986a73b24
commit c2ea100777
22 changed files with 38 additions and 38 deletions

View File

@ -53,7 +53,7 @@ static bool init_group_mapping(void)
return true;
}
tdb_path = state_path("group_mapping.tdb");
tdb_path = state_path(talloc_tos(), "group_mapping.tdb");
if (tdb_path == NULL) {
return false;
}
@ -67,7 +67,7 @@ static bool init_group_mapping(void)
return false;
}
ldb_path = state_path("group_mapping.ldb");
ldb_path = state_path(talloc_tos(), "group_mapping.ldb");
if (ldb_path == NULL) {
talloc_free(tdb_path);
return false;
@ -1084,7 +1084,7 @@ static bool mapping_switch(const char *ldb_path)
}
/* now rename the old db out of the way */
new_path = state_path("group_mapping.ldb.replaced");
new_path = state_path(talloc_tos(), "group_mapping.ldb.replaced");
if (!new_path) {
goto failed;
}

View File

@ -73,7 +73,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name )
char *file;
char *tdbname;
path = state_path("eventlog");
path = state_path(talloc_tos(), "eventlog");
if (!path) {
return NULL;
}
@ -373,7 +373,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only )
/* make sure that the eventlog dir exists */
eventlogdir = state_path("eventlog");
eventlogdir = state_path(talloc_tos(), "eventlog");
if (eventlogdir == NULL) {
return NULL;
}

View File

@ -148,7 +148,7 @@ bool share_info_db_init(void)
return True;
}
db_path = state_path("share_info.tdb");
db_path = state_path(talloc_tos(), "share_info.tdb");
if (db_path == NULL) {
return false;
}

View File

@ -78,9 +78,9 @@ char *lock_path(TALLOC_CTX *mem_ctx, const char *name)
* @retval Pointer to a talloc'ed string containing the full path.
**/
char *state_path(const char *name)
char *state_path(TALLOC_CTX *mem_ctx, const char *name)
{
return xx_path(talloc_tos(), name, lp_state_directory());
return xx_path(mem_ctx, name, lp_state_directory());
}
/**

View File

@ -28,7 +28,7 @@
#include <talloc.h>
char *lock_path(TALLOC_CTX *mem_ctx, const char *name);
char *state_path(const char *name);
char *state_path(TALLOC_CTX *mem_ctx, const char *name);
char *cache_path(const char *name);
char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *abs_path);

View File

@ -50,7 +50,7 @@ static bool acl_tdb_init(void)
return true;
}
dbname = state_path("file_ntacls.tdb");
dbname = state_path(talloc_tos(), "file_ntacls.tdb");
if (dbname == NULL) {
errno = ENOSYS;

View File

@ -458,7 +458,7 @@ static bool xattr_tdb_init(int snum, TALLOC_CTX *mem_ctx, struct db_context **p_
const char *dbname;
char *def_dbname;
def_dbname = state_path("xattr.tdb");
def_dbname = state_path(talloc_tos(), "xattr.tdb");
if (def_dbname == NULL) {
errno = ENOSYS;
return false;

View File

@ -601,7 +601,7 @@ bool initialise_wins(void)
return True;
}
db_path = state_path("wins.tdb");
db_path = state_path(talloc_tos(), "wins.tdb");
if (db_path == NULL) {
return false;
}
@ -620,7 +620,7 @@ bool initialise_wins(void)
add_samba_names_to_subnet(wins_server_subnet);
list_path = state_path(WINS_LIST);
list_path = state_path(talloc_tos(), WINS_LIST);
if (list_path == NULL) {
tdb_close(wins_tdb);
return false;
@ -2493,7 +2493,7 @@ void wins_write_database(time_t t, bool background)
}
}
if (!(fname = state_path(WINS_LIST))) {
if (!(fname = state_path(talloc_tos(), WINS_LIST))) {
goto err_exit;
}
/* This is safe as the 0 length means "don't expand". */

View File

@ -220,7 +220,7 @@ bool init_account_policy(void)
return True;
}
db_path = state_path("account_policy.tdb");
db_path = state_path(talloc_tos(), "account_policy.tdb");
if (db_path == NULL) {
return false;
}

View File

@ -336,7 +336,7 @@ static bool tdbsam_upgrade_next_rid(struct db_context *db)
return true;
}
db_path = state_path("winbindd_idmap.tdb");
db_path = state_path(talloc_tos(), "winbindd_idmap.tdb");
if (db_path == NULL) {
return false;
}

View File

@ -152,7 +152,7 @@ static bool print_driver_directories_init(void)
}
}
driver_path = state_path("DriverStore");
driver_path = state_path(talloc_tos(), "DriverStore");
if (driver_path == NULL) {
talloc_free(mem_ctx);
return false;
@ -165,7 +165,7 @@ static bool print_driver_directories_init(void)
return false;
}
driver_path = state_path("DriverStore/FileRepository");
driver_path = state_path(talloc_tos(), "DriverStore/FileRepository");
if (driver_path == NULL) {
talloc_free(mem_ctx);
return false;
@ -178,7 +178,7 @@ static bool print_driver_directories_init(void)
return false;
}
driver_path = state_path("DriverStore/Temp");
driver_path = state_path(talloc_tos(), "DriverStore/Temp");
if (driver_path == NULL) {
talloc_free(mem_ctx);
return false;

View File

@ -198,9 +198,9 @@ bool nt_printing_tdb_migrate(struct messaging_context *msg_ctx)
NTSTATUS status;
/* paths talloced on new stackframe */
drivers_path = state_path("ntdrivers.tdb");
printers_path = state_path("ntprinters.tdb");
forms_path = state_path("ntforms.tdb");
drivers_path = state_path(talloc_tos(), "ntdrivers.tdb");
printers_path = state_path(talloc_tos(), "ntprinters.tdb");
forms_path = state_path(talloc_tos(), "ntforms.tdb");
if ((drivers_path == NULL) || (printers_path == NULL)
|| (forms_path == NULL)) {
talloc_free(tmp_ctx);

View File

@ -349,17 +349,17 @@ bool nt_printing_tdb_upgrade(void)
int32_t vers_id;
bool ret;
drivers_path = state_path("ntdrivers.tdb");
drivers_path = state_path(talloc_tos(), "ntdrivers.tdb");
if (drivers_path == NULL) {
ret = false;
goto err_out;
}
printers_path = state_path("ntprinters.tdb");
printers_path = state_path(talloc_tos(), "ntprinters.tdb");
if (printers_path == NULL) {
ret = false;
goto err_drvdb_free;
}
forms_path = state_path("ntforms.tdb");
forms_path = state_path(talloc_tos(), "ntforms.tdb");
if (forms_path == NULL) {
ret = false;
goto err_prdb_free;

View File

@ -733,7 +733,7 @@ WERROR regdb_init(void)
return WERR_OK;
}
db_path = state_path("registry.tdb");
db_path = state_path(talloc_tos(), "registry.tdb");
if (db_path == NULL) {
return WERR_NOT_ENOUGH_MEMORY;
}
@ -861,7 +861,7 @@ WERROR regdb_open( void )
return WERR_OK;
}
db_path = state_path("registry.tdb");
db_path = state_path(talloc_tos(), "registry.tdb");
if (db_path == NULL) {
return WERR_NOT_ENOUGH_MEMORY;
}

View File

@ -48,7 +48,7 @@ static char *counters_directory(const char *dbname)
char *db_subpath = NULL;
char *ret = NULL;
dir_path = state_path(PERFCOUNTDIR);
dir_path = state_path(talloc_tos(), PERFCOUNTDIR);
if (dir_path == NULL) {
return NULL;
}
@ -64,7 +64,7 @@ static char *counters_directory(const char *dbname)
return NULL;
}
ret = state_path(db_subpath);
ret = state_path(talloc_tos(), db_subpath);
TALLOC_FREE(dir_path);
return ret;
}

View File

@ -148,7 +148,7 @@ static char *net_idmap_dbfile(struct net_context *c,
d_fprintf(stderr, _("Out of memory!\n"));
}
} else if (strequal(backend, "tdb")) {
dbfile = state_path("winbindd_idmap.tdb");
dbfile = state_path(talloc_tos(), "winbindd_idmap.tdb");
if (dbfile == NULL) {
d_fprintf(stderr, _("Out of memory!\n"));
}
@ -161,7 +161,7 @@ static char *net_idmap_dbfile(struct net_context *c,
}
ctx->backend = TDB;
} else if (strequal(backend, "autorid")) {
dbfile = state_path("autorid.tdb");
dbfile = state_path(talloc_tos(), "autorid.tdb");
if (dbfile == NULL) {
d_fprintf(stderr, _("Out of memory!\n"));
}

View File

@ -1512,7 +1512,7 @@ static int net_registry_check(struct net_context *c, int argc,
} else if (argc > 0) {
dbfile = talloc_strdup(talloc_tos(), argv[0]);
} else {
dbfile = state_path("registry.tdb");
dbfile = state_path(talloc_tos(), "registry.tdb");
}
if (dbfile == NULL) {
return -1;

View File

@ -1061,7 +1061,7 @@ static bool do_winbind_online(struct tevent_context *ev_ctx,
return False;
}
db_path = state_path("winbindd_cache.tdb");
db_path = state_path(talloc_tos(), "winbindd_cache.tdb");
if (db_path == NULL) {
return false;
}
@ -1099,7 +1099,7 @@ static bool do_winbind_offline(struct tevent_context *ev_ctx,
return False;
}
db_path = state_path("winbindd_cache.tdb");
db_path = state_path(talloc_tos(), "winbindd_cache.tdb");
if (db_path == NULL) {
return false;
}

View File

@ -879,7 +879,7 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
commonconfig->rw_ops->get_new_id = idmap_autorid_allocate_id;
commonconfig->rw_ops->set_mapping = idmap_tdb_common_set_mapping;
db_path = state_path("autorid.tdb");
db_path = state_path(talloc_tos(), "autorid.tdb");
if (db_path == NULL) {
status = NT_STATUS_NO_MEMORY;
goto error;

View File

@ -310,7 +310,7 @@ static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
mem_ctx = talloc_stackframe();
/* use the old database if present */
tdbfile = state_path("winbindd_idmap.tdb");
tdbfile = state_path(talloc_tos(), "winbindd_idmap.tdb");
if (!tdbfile) {
DEBUG(0, ("Out of memory!\n"));
ret = NT_STATUS_NO_MEMORY;

View File

@ -1256,7 +1256,7 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
char *get_winbind_priv_pipe_dir(void)
{
return state_path(WINBINDD_PRIV_SOCKET_SUBDIR);
return state_path(talloc_tos(), WINBINDD_PRIV_SOCKET_SUBDIR);
}
static void winbindd_setup_max_fds(void)

View File

@ -119,7 +119,7 @@ static char *wcache_path(void)
* Data needs to be kept persistent in state directory for
* running with "winbindd offline logon".
*/
return state_path("winbindd_cache.tdb");
return state_path(talloc_tos(), "winbindd_cache.tdb");
}
static void winbindd_domain_init_backend(struct winbindd_domain *domain)