lib: Pass mem_ctx to cache_path()
authorVolker Lendecke <vl@samba.org>
Thu, 16 Aug 2018 08:51:44 +0000 (10:51 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 17 Aug 2018 12:28:51 +0000 (14:28 +0200)
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

15 files changed:
libgpo/pygpo.c
source3/lib/gencache.c
source3/lib/util_path.c
source3/lib/util_path.h
source3/libgpo/gpext/registry.c
source3/libgpo/gpext/scripts.c
source3/libgpo/gpext/security.c
source3/libsmb/samlogon_cache.c
source3/nmbd/nmbd_serverlistdb.c
source3/passdb/login_cache.c
source3/printing/printing.c
source3/printing/printing_db.c
source3/profile/profile.c
source3/smbd/lanman.c
source3/utils/net_ads_gpo.c

index 88486424917f307961c4a4086434457ed2a8e8ce..cd107318860dc74b2c57f4dcbfdbf39c4427f58f 100644 (file)
@@ -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");
index 158554bd9a87b4620a0060eb7e15087fde2102a4..b4d374bf837c67b5bf8d4a7e5cc4c158a09e94a9 100644 (file)
@@ -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;
        }
index efe3e608d7da900de12653744a5d0f2f9df14d4d..d9fed29c2a519d4a12acc049f6fbe0f7ccc1ed2e 100644 (file)
@@ -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());
 }
 
 /**
index b189b3e33cb7f1e45dcfae1480886aed3cd5da94..3e7d04de5507d7324e94985f1630e6d02a50d500 100644 (file)
@@ -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
index 5d51bdff6e9af782b85257d7b644d1220758c516..525493fcb2cb385cf3a09ceb006840a3046ea63e 100644 (file)
@@ -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;
        }
index de664133b87dfb924195d439a0e10c64127a7bd7..dfa9958e326a702d0de9130f8167706ee31f188d 100644 (file)
@@ -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;
        }
index b6b7ca08e62657838bb680a7dd6b20bb8b3aaa9d..a915eec61e4f9dfb0a2e15a6babd9a24e4ae3d0a 100644 (file)
@@ -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;
        }
index ae77610ec99abf733a185c5c267c041c49100f5c..74e89d7c38bbd260ad42e65bf3caf6b808ab4876 100644 (file)
@@ -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;
        }
index 05dcb6c748270bee583218aac2ac0331da3d0422..ad251833ed549f1aaf7343772177e0d5d5b45bb3 100644 (file)
@@ -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;
        }
index eebb50a8b13f070c68a0083c42f5278a9e5eb858..6b636b3c8b7fdbf9b88b7f090489117f3f379520 100644 (file)
@@ -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;
index 0acbb7e28ced2f2edad28e30f3427d357aeadfa9..efdd68709997dd99ae81fd41156864a7679b6bd3 100644 (file)
@@ -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;
        }
index 7465195b771aab33bf56d1141bbfe7144cd1d752..3fa85579f20b6e0da3943ce3a83f97a07814e1c2 100644 (file)
@@ -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);
index 833c9c4425de4d1caf57f5b942a51b2002cf6ef5..5deef81b6df15dad6206511bfd0dda545e38aad8 100644 (file)
@@ -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;
        }
index 90906a204d4f5703ebd3739d45e318c55d07e519..dcc7f916d6e8901bd5e9a4dc139847edde00d2b8 100644 (file)
@@ -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;
        }
index f2f65c8790e9172e7ade9e99d37e7faae7765f3f..791e836bfd98130fa5619c89529f6bedbe3424bd 100644 (file)
@@ -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;