svn commit: samba r6187 - in branches/SAMBA_4_0/source/smbd: .
sharpe at samba.org
sharpe at samba.org
Sun Apr 3 21:37:13 GMT 2005
Author: sharpe
Date: 2005-04-03 21:37:13 +0000 (Sun, 03 Apr 2005)
New Revision: 6187
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6187
Log:
1. Make sure that we don't try to delete . and .. in a more portable way.
2. Also, don't try to delete directories.
I am not entirely happy with this patch, and the fact that there is a
define for HAVE_SYS_STAT_H suggests that there are some systems for which
stat will not be defined, which means that the patch is not entirely
portable.
Modified:
branches/SAMBA_4_0/source/smbd/server.c
Changeset:
Modified: branches/SAMBA_4_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/server.c 2005-04-03 16:08:18 UTC (rev 6186)
+++ branches/SAMBA_4_0/source/smbd/server.c 2005-04-03 21:37:13 UTC (rev 6187)
@@ -55,17 +55,41 @@
}
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 != EISDIR &&
- errno != EISDIR) {
- DEBUG(0,("Unabled to delete '%s' - %s\n",
- fname, strerror(errno)));
- smb_panic("unable to cleanup tmp files");
+ /*
+ * Don't try to delete . and ..
+ */
+ if (strcmp(de->d_name, ".") != 0 &&
+ strcmp(de->d_name, "..")) {
+ char *fname = talloc_asprintf(mem_ctx, "%s/%s", path, de->d_name);
+ int ret = unlink(fname);
+ if (ret == -1 &&
+ errno != ENOENT &&
+ errno != EPERM &&
+ errno != EISDIR) {
+ DEBUG(0,("Unabled to delete '%s' - %s\n",
+ fname, strerror(errno)));
+ smb_panic("unable to cleanup tmp files");
+ }
+ if (ret == -1 &&
+ errno == EPERM) {
+ /*
+ * If it is a dir, don't complain
+ * NOTE! The test will only happen if we have
+ * sys/stat.h, otherwise we will always error out
+ */
+#ifdef HAVE_SYS_STAT_H
+ struct stat sb;
+ if (stat(fname, &sb) != -1 &&
+ !S_ISDIR(sb.st_mode))
+#endif
+ {
+ DEBUG(0,("Unable to delete '%s' - %s\n",
+ fname, strerror(errno)));
+ smb_panic("unable to cleanup tmp files");
+ }
+ }
+ talloc_free(fname);
}
- talloc_free(fname);
}
closedir(dir);
More information about the samba-cvs
mailing list