summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-08-16 10:51:44 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-17 11:30:11 +0200
commitc2ea10077715fb2a554a9f39b2ff49338bd8a124 (patch)
tree854522aa679e6396c94bace54639025232aaf084
parentf986a73b240ea61df1d4664b9c3c6d0858b17111 (diff)
downloadsamba-c2ea10077715fb2a554a9f39b2ff49338bd8a124.tar.gz
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>
-rw-r--r--source3/groupdb/mapping_tdb.c6
-rw-r--r--source3/lib/eventlog/eventlog.c4
-rw-r--r--source3/lib/sharesec.c2
-rw-r--r--source3/lib/util_path.c4
-rw-r--r--source3/lib/util_path.h2
-rw-r--r--source3/modules/vfs_acl_tdb.c2
-rw-r--r--source3/modules/vfs_xattr_tdb.c2
-rw-r--r--source3/nmbd/nmbd_winsserver.c6
-rw-r--r--source3/passdb/account_pol.c2
-rw-r--r--source3/passdb/pdb_tdb.c2
-rw-r--r--source3/printing/nt_printing.c6
-rw-r--r--source3/printing/nt_printing_migrate_internal.c6
-rw-r--r--source3/printing/nt_printing_tdb.c6
-rw-r--r--source3/registry/reg_backend_db.c4
-rw-r--r--source3/registry/reg_perfcount.c4
-rw-r--r--source3/utils/net_idmap.c4
-rw-r--r--source3/utils/net_registry.c2
-rw-r--r--source3/utils/smbcontrol.c4
-rw-r--r--source3/winbindd/idmap_autorid.c2
-rw-r--r--source3/winbindd/idmap_tdb.c2
-rw-r--r--source3/winbindd/winbindd.c2
-rw-r--r--source3/winbindd/winbindd_cache.c2
22 files changed, 38 insertions, 38 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index adc7d0b9d47..3561057214c 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -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;
}
diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index 9053fdd9a24..4b631180816 100644
--- a/source3/lib/eventlog/eventlog.c
+++ b/source3/lib/eventlog/eventlog.c
@@ -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;
}
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index d790b083218..58a2dee3bcf 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -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;
}
diff --git a/source3/lib/util_path.c b/source3/lib/util_path.c
index b8ce304c213..efe3e608d7d 100644
--- a/source3/lib/util_path.c
+++ b/source3/lib/util_path.c
@@ -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());
}
/**
diff --git a/source3/lib/util_path.h b/source3/lib/util_path.h
index 6df67fb6feb..b189b3e33cb 100644
--- a/source3/lib/util_path.h
+++ b/source3/lib/util_path.h
@@ -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);
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index bb69170c910..7506e4e34fa 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -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;
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index f67a86f8027..32968ae083f 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -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;
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index cd7d3b7fc75..c34bfaea3be 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -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". */
diff --git a/source3/passdb/account_pol.c b/source3/passdb/account_pol.c
index 421a054f83b..4d94dfe817c 100644
--- a/source3/passdb/account_pol.c
+++ b/source3/passdb/account_pol.c
@@ -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;
}
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 6f3dda6e229..91735ff7084 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -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;
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 633e350ff35..9c4c488040f 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -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;
diff --git a/source3/printing/nt_printing_migrate_internal.c b/source3/printing/nt_printing_migrate_internal.c
index dd78e69989e..8bcc2d45a11 100644
--- a/source3/printing/nt_printing_migrate_internal.c
+++ b/source3/printing/nt_printing_migrate_internal.c
@@ -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);
diff --git a/source3/printing/nt_printing_tdb.c b/source3/printing/nt_printing_tdb.c
index ea1e87e4a12..0193b177aec 100644
--- a/source3/printing/nt_printing_tdb.c
+++ b/source3/printing/nt_printing_tdb.c
@@ -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;
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 928572e8a5a..aa97d60abec 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -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;
}
diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c
index e31f8991642..6fa96f314fb 100644
--- a/source3/registry/reg_perfcount.c
+++ b/source3/registry/reg_perfcount.c
@@ -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;
}
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 4f365662a71..b49d5f43381 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -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"));
}
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index c67a148ddd0..01a36b20e7c 100644
--- a/source3/utils/net_registry.c
+++ b/source3/utils/net_registry.c
@@ -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;
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index bd89b9ebf0a..6e612e9dd8f 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -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;
}
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 65b3d5af222..cb7dcba1a5f 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -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;
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index 24ef11836e1..b1f908e2d62 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -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;
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 5e273762ff1..b63db381540 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -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)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index af67aa3b0cf..2f3bac7587b 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -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)