Imported Upstream version 2.5.1p3
[debian/amanda] / client-src / selfcheck.c
index 8d8ae757edb5460c31a9e051917c95e475578345..2230bc5a54cfc3179aeab263e7c851289834ec45 100644 (file)
@@ -25,7 +25,7 @@
  *                        University of Maryland at College Park
  */
 /* 
- * $Id: selfcheck.c,v 1.95 2006/08/29 11:21:00 martinea Exp $
+ * $Id: selfcheck.c,v 1.95.2.2 2007/01/19 01:03:34 martinea Exp $
  *
  * do self-check and send back any error messages
  */
@@ -75,6 +75,7 @@ static void check_options(char *program, char *calcprog, char *disk, char *amdev
 static void check_disk(char *program, char *calcprog, char *disk, char *amdevice, int level, char *optstr);
 static void check_overall(void);
 static void check_access(char *filename, int mode);
+static int check_file_exist(char *filename);
 static void check_file(char *filename, int mode);
 static void check_dir(char *dirname, int mode);
 static void check_suid(char *filename);
@@ -681,7 +682,7 @@ check_disk(
        amode = F_OK;
        amfree(device);
        device = amname_to_dirname(amdevice);
-    } else if (strcmp(program, "DUMP") == 0) {
+    } else if (strcmp(myprogram, "DUMP") == 0) {
        if(amdevice[0] == '/' && amdevice[1] == '/') {
            err = vstralloc("The DUMP program cannot handle samba shares,",
                            " use GNUTAR: ",
@@ -945,20 +946,32 @@ check_overall(void)
        }
     }
 
-    ifneed_compress_path )
+    if (need_compress_path )
        check_file(COMPRESS_PATH, X_OK);
 
-    if( need_dump || need_xfsdump )
-       check_file("/etc/dumpdates",
+    if (need_dump || need_xfsdump ) {
+       if (check_file_exist("/etc/dumpdates")) {
+           check_file("/etc/dumpdates",
 #ifdef USE_RUNDUMP
-                  F_OK
+                      F_OK
 #else
-                  R_OK|W_OK
+                      R_OK|W_OK
 #endif
-                  );
+                     );
+       } else {
+#ifndef USE_RUNDUMP
+           if (access("/etc", R_OK|W_OK) == -1) {
+               printf("ERROR [dump will not be able to create the /etc/dumpdates file: %s]\n", strerror(errno));
+           }
+#endif
+       }
+    }
 
-    if (need_vdump)
-        check_file("/etc/vdumpdates", F_OK);
+    if (need_vdump) {
+       if (check_file_exist("/etc/vdumpdates")) {
+            check_file("/etc/vdumpdates", F_OK);
+       }
+    }
 
     check_access("/dev/null", R_OK|W_OK);
     check_space(AMANDA_TMPDIR, (off_t)64);     /* for amandad i/o */
@@ -1016,6 +1029,20 @@ check_access(
     amfree(quoted);
 }
 
+static int
+check_file_exist(
+    char *filename)
+{
+    struct stat stat_buf;
+
+    if (stat(filename, &stat_buf) != 0) {
+       if(errno == ENOENT) {
+           return 0;
+       }
+    }
+    return 1;
+}
+
 static void
 check_file(
     char *     filename,