]> git.pld-linux.org Git - packages/autofs.git/blob - autofs-4.1.4-no-unlink-upstream.patch
- use functions
[packages/autofs.git] / autofs-4.1.4-no-unlink-upstream.patch
1 --- autofs-4.1.4/daemon/automount.c.no-unlink   2005-07-11 13:28:57.000000000 -0500
2 +++ autofs-4.1.4/daemon/automount.c     2005-07-11 13:50:46.000000000 -0500
3 @@ -216,16 +216,38 @@ static int walk_tree(const char *base, i
4  static int rm_unwanted_fn(const char *file, const struct stat *st, int when, void *arg)
5  {
6         int rmsymlink = *(int *) arg;
7 +       struct stat newst;
8  
9         if (when == 0) {
10                 if (st->st_dev != ap.dev)
11                         return 0;
12 -       } else {
13 -               info("rm_unwanted: %s\n", file);
14 -               if (S_ISDIR(st->st_mode))
15 -                       rmdir(file);
16 -               else if (!S_ISLNK(st->st_mode) || rmsymlink)
17 -                       unlink(file);
18 +               return 1;
19 +       }
20 +
21 +       if (lstat(file, &newst)) {
22 +               crit ("rm_unwanted: unable to stat file, possible race "
23 +                     "condition.");
24 +               return 0;
25 +       }
26 +
27 +       if (newst.st_dev != ap.dev) {
28 +               crit ("rm_unwanted: file %s has the wrong device, possible "
29 +                     "race condition.",file);
30 +               return 0;
31 +       }
32 +
33 +       if (S_ISDIR(newst.st_mode)) {
34 +               if (rmdir(file)) {
35 +                       info ("rm_unwanted: unable to remove directory"
36 +                             " %s", file);
37 +                       return 0;
38 +               }
39 +       } else if (S_ISREG(newst.st_mode)) {
40 +               crit ("rm_unwanted: attempting to remove files from a mounted "
41 +                     "directory.");
42 +               return 0;
43 +       } else if (S_ISLNK(newst.st_mode) && rmsymlink) {
44 +               unlink(file);
45         }
46  
47         return 1;
This page took 0.034943 seconds and 3 git commands to generate.