diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-10-29 08:38:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:01 -0500 |
commit | 09d0b152b7bd85aa01898af81bd166a7673ab886 (patch) | |
tree | 6bebf9648412322c15b2b8a5777aa67c3a09d463 /source4/lib | |
parent | 98052096e3150c2b1a3d31fc6fcc1dbc0d7a3067 (diff) | |
download | samba-09d0b152b7bd85aa01898af81bd166a7673ab886.tar.gz samba-09d0b152b7bd85aa01898af81bd166a7673ab886.tar.bz2 samba-09d0b152b7bd85aa01898af81bd166a7673ab886.zip |
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)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/messaging/messaging.c | 4 | ||||
-rw-r--r-- | source4/lib/util.c | 25 |
2 files changed, 26 insertions, 3 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 7f90bd4e40..125089ac62 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -85,7 +85,7 @@ static char *messaging_path(TALLOC_CTX *mem_ctx, servid_t server_id) { char *name = talloc_asprintf(mem_ctx, "messaging/msg.%u", (unsigned)server_id); char *ret; - ret = lock_path(mem_ctx, name); + ret = smbd_tmp_path(mem_ctx, name); talloc_free(name); return ret; } @@ -449,7 +449,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, servid_t server_id } /* create the messaging directory if needed */ - msg->path = lock_path(msg, "messaging"); + msg->path = smbd_tmp_path(msg, "messaging"); mkdir(msg->path, 0700); talloc_free(msg->path); 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. * |