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/smbd | |
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/smbd')
-rw-r--r-- | source4/smbd/service.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/source4/smbd/service.c b/source4/smbd/service.c index 33c0d5fcbd..d9841b63b2 100644 --- a/source4/smbd/service.c +++ b/source4/smbd/service.c @@ -356,26 +356,37 @@ void service_close_listening_sockets(struct server_context *srv_ctx) TDB_CLEAR_IF_FIRST. Unfortunately TDB_CLEAR_IF_FIRST is not efficient on unix systems due to the lack of scaling of the byte range locking system. So instead of putting the burden on tdb to - cleanup tmp files, this function deletes them. You need to expand - the list here as appropriate. + cleanup tmp files, this function deletes them. */ void service_cleanup_tmp_files(void) { - const char *list[] = { - "openfiles.tdb", - "brlock.tdb", - "unexpected.tdb"}; - int i; - for (i=0;i<ARRAY_SIZE(list);i++) { - char *path = lock_path(NULL, list[i]); - int ret; - ret = unlink(path); - if (ret == -1 && + char *path; + DIR *dir; + struct dirent *de; + TALLOC_CTX *mem_ctx = talloc_init("service_cleanup_tmp_files"); + + path = smbd_tmp_path(mem_ctx, NULL); + + dir = opendir(path); + if (!dir) { + talloc_free(mem_ctx); + return; + } + + for (de=readdir(dir);de;de=readdir(dir)) { + char *fname = talloc_asprintf(mem_ctx, "%s/%s", path, de->d_name); + int ret = unlink(fname); + if (ret == -1 && errno != ENOENT && - errno != ENOTDIR) { - DEBUG(0,("Failed to cleanup '%s'\n", path)); - smb_panic("unable to cleanup temporary files\n"); + errno != EISDIR && + errno != EISDIR) { + DEBUG(0,("Unabled to delete '%s' - %s\n", + fname, strerror(errno))); + smb_panic("unable to cleanup tmp files"); } - talloc_free(path); + talloc_free(fname); } + closedir(dir); + + talloc_free(mem_ctx); } |