From 09d0b152b7bd85aa01898af81bd166a7673ab886 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 29 Oct 2004 08:38:59 +0000 Subject: r3360: improved the deletion of tmp files. smbd now puts all tmp files in var/locks/smbd.tmp/ and deletes that dir on startup. (This used to be commit 7e942e7f1bd2c293a0e6648df43a96f8b8a2a295) --- source4/lib/util.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/lib/util.c') diff --git a/source4/lib/util.c b/source4/lib/util.c index 8b27bf070c..97d3d5dd1b 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -702,7 +702,6 @@ char *name_to_fqdn(TALLOC_CTX *mem_ctx, const char *name) /***************************************************************** A useful function for returning a path in the Samba lock directory. *****************************************************************/ - char *lock_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname, *dname; @@ -736,6 +735,30 @@ char *lib_path(TALLOC_CTX* mem_ctx, const char *name) return fname; } +/* + return a path in the smbd.tmp directory, where all temporary file + for smbd go. If NULL is passed for name then return the directory + path itself +*/ +char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) +{ + char *fname, *dname; + + dname = lock_path(mem_ctx, "smbd.tmp"); + if (!directory_exist(dname,NULL)) { + mkdir(dname,0755); + } + + if (name == NULL) { + return dname; + } + + fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name); + talloc_free(dname); + + return fname; +} + /** * @brief Returns the platform specific shared library extension. * -- cgit