]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2707 Check the NODUMP flag only on files and directories
authorEric Bollengier <eric@baculasystems.com>
Fri, 16 Feb 2024 17:14:20 +0000 (18:14 +0100)
committerEric Bollengier <eric@baculasystems.com>
Fri, 16 Feb 2024 17:17:28 +0000 (18:17 +0100)
The current code was trying to get the flag from fifo, ending to block the
backup procedure. Thanks to Martin.

bacula/src/findlib/find_one.c

index 7c5089b1fec67cf44a2de478fdf525008c7f2a0c..a9b019b204aa4ded42e4c0ef336fadb0f329058d 100644 (file)
@@ -230,29 +230,33 @@ static bool no_dump(JCR *jcr, FF_PKT *ff_pkt)
    bool ret = false; /* do backup */
    int attr;
    int fd = -1;
+   
    if (ff_pkt->flags & FO_HONOR_NODUMP) {
-      fd = open(ff_pkt->fname, O_RDONLY|O_CLOEXEC);
-      if (fd < 0) {
-         Dmsg2(50, "Failed to open file: %s err: %d\n",
-               ff_pkt->fname, errno);
-         goto bail_out;
+      if (S_ISDIR(ff_pkt->statp.st_mode) || S_ISREG(ff_pkt->statp.st_mode)) {
+        /* lsattr and chattr in the e2fsprogs package only works for files and dirs */
+        fd = open(ff_pkt->fname, O_RDONLY|O_CLOEXEC);
+        if (fd < 0) {
+           Dmsg2(50, "Failed to open file: %s err: %d\n",
+                 ff_pkt->fname, errno);
+           goto bail_out;
+        }
+
+        int ioctl_ret = ioctl(fd, FS_IOC_GETFLAGS, &attr);
+        if (ioctl_ret < 0) {
+           if (errno == ENOTTY) {
+              Dmsg2(50, "Failed to check for NODUMP flag for file: %s errno: %d, "
+                    "probably because of wrong filesystem used.\n",
+                    ff_pkt->fname, errno);
+           } else {
+              Dmsg2(50, "Failed to send Getflags IOCTL for: %s err: %d\n",
+                    ff_pkt->fname, errno);
+           }
+           goto bail_out;
+        }
+
+        /* Check if file has NODUMP flag set */
+        ret = attr & FS_NODUMP_FL;
       }
-
-      int ioctl_ret = ioctl(fd, FS_IOC_GETFLAGS, &attr);
-      if (ioctl_ret < 0) {
-         if (errno == ENOTTY) {
-            Dmsg2(50, "Failed to check for NODUMP flag for file: %s errno: %d, "
-                      "probably because of wrong filesystem used.\n",
-                  ff_pkt->fname, errno);
-         } else {
-            Dmsg2(50, "Failed to send Getflags IOCTL for: %s err: %d\n",
-                  ff_pkt->fname, errno);
-         }
-         goto bail_out;
-      }
-
-      /* Check if file has NODUMP flag set */
-      ret = attr & FS_NODUMP_FL;
    }
 
 bail_out: