rpms/autofs/devel autofs-4.1.4-no-unlink-upstream.patch,NONE,1.1
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Wed Oct 26 19:42:12 UTC 2005
Author: jmoyer
Update of /cvs/dist/rpms/autofs/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv26953
Added Files:
autofs-4.1.4-no-unlink-upstream.patch
Log Message:
Don't unlink files, only remove directories. This addresses a problem
whereby all files in a mounted volume could be removed by autofs! We still
haven't found the exact race that leads to this.
autofs-4.1.4-no-unlink-upstream.patch:
automount.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
--- NEW FILE autofs-4.1.4-no-unlink-upstream.patch ---
--- autofs-4.1.4/daemon/automount.c.no-unlink 2005-07-11 13:28:57.000000000 -0500
+++ autofs-4.1.4/daemon/automount.c 2005-07-11 13:50:46.000000000 -0500
@@ -216,16 +216,38 @@ static int walk_tree(const char *base, i
static int rm_unwanted_fn(const char *file, const struct stat *st, int when, void *arg)
{
int rmsymlink = *(int *) arg;
+ struct stat newst;
if (when == 0) {
if (st->st_dev != ap.dev)
return 0;
- } else {
- info("rm_unwanted: %s\n", file);
- if (S_ISDIR(st->st_mode))
- rmdir(file);
- else if (!S_ISLNK(st->st_mode) || rmsymlink)
- unlink(file);
+ return 1;
+ }
+
+ if (lstat(file, &newst)) {
+ crit ("rm_unwanted: unable to stat file, possible race "
+ "condition.");
+ return 0;
+ }
+
+ if (newst.st_dev != ap.dev) {
+ crit ("rm_unwanted: file %s has the wrong device, possible "
+ "race condition.",file);
+ return 0;
+ }
+
+ if (S_ISDIR(newst.st_mode)) {
+ if (rmdir(file)) {
+ info ("rm_unwanted: unable to remove directory"
+ " %s", file);
+ return 0;
+ }
+ } else if (S_ISREG(newst.st_mode)) {
+ crit ("rm_unwanted: attempting to remove files from a mounted "
+ "directory.");
+ return 0;
+ } else if (S_ISLNK(newst.st_mode) && rmsymlink) {
+ unlink(file);
}
return 1;
More information about the fedora-cvs-commits
mailing list