]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Mark Volume read-only only if no access rights or read-only partition
authorKern Sibbald <kern@sibbald.com>
Sat, 28 Oct 2017 16:39:12 +0000 (18:39 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:59 +0000 (09:02 +0100)
bacula/src/stored/mount.c

index d3bab5ee48d810017b74a00e6e49a6ae79458226..f3c82a5e861dbb996b123f2d15c2c8e4ce9b2a98 100644 (file)
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
 
+/* Make sure some EROFS is defined */
+#ifndef EROFS                         /* read-only file system */
+#define EROFS -1                      /* make impossible errno */
+#endif
+
 static pthread_mutex_t mount_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 enum {
@@ -212,13 +217,20 @@ mount_next_vol:
             dev->print_type(), dev->print_name(), dcr->VolumeName, dev->bstrerror());
 
       /* If not removable, Volume is broken. This is a serious issue here. */
-      if(dev->is_file() && !dev->is_removable()) {
+      if (dev->is_file() && !dev->is_removable()) {
          Dmsg3(40, "Volume \"%s\" not loaded on %s device %s.\n",
                dcr->VolumeName, dev->print_type(), dev->print_name());
-         mark_volume_in_error();
+         if (dev->dev_errno == EACCES || dev->dev_errno == EROFS) {
+            mark_volume_read_only();
+         } else {
+            mark_volume_in_error();
+         }
 
       } else {
          Dmsg0(100, "set_unload\n");
+         if (dev->dev_errno == EACCES || dev->dev_errno == EROFS) {
+            mark_volume_read_only();
+         }
          dev->set_unload();              /* force ask sysop */
          ask = true;
       }