Merge commit 'upstream/3.1.0'
[debian/amanda] / client-src / selfcheck.c
index 763ac323c535d8eb83c58d8a301122e5cc6b7b3e..bbfcd67daad6506cbd224ef7dfe32685421425dd 100644 (file)
@@ -32,7 +32,6 @@
 
 #include "amanda.h"
 #include "fsusage.h"
-#include "version.h"
 #include "getfsent.h"
 #include "amandates.h"
 #include "clock.h"
@@ -63,6 +62,7 @@ int need_runtar=0;
 int need_gnutar=0;
 int need_compress_path=0;
 int need_calcsize=0;
+int need_global_check=0;
 int program_is_application_api=0;
 
 static char *amandad_auth = NULL;
@@ -94,6 +94,7 @@ main(
     dle_t *dle;
     int level;
     GSList *errlist;
+    level_t *alevel;
 
     /* initialize */
 
@@ -107,6 +108,7 @@ main(
     textdomain("amanda"); 
 
     safe_fd(-1, 0);
+    openbsd_fd_inform();
     safe_cd();
 
     set_pname("selfcheck");
@@ -114,10 +116,11 @@ main(
     /* Don't die when child closes pipe */
     signal(SIGPIPE, SIG_IGN);
 
-    erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG);
+    add_amanda_log_handler(amanda_log_stderr);
+    add_amanda_log_handler(amanda_log_syslog);
     dbopen(DBG_SUBDIR_CLIENT);
     startclock();
-    dbprintf(_("version %s\n"), version());
+    dbprintf(_("version %s\n"), VERSION);
 
     if(argc > 2 && strcmp(argv[1], "amandad") == 0) {
        amandad_auth = stralloc(argv[2]);
@@ -211,10 +214,12 @@ main(
            dle->program = s - 1;
            skip_non_whitespace(s, ch);
            s[-1] = '\0';
-           dle->calcsize = 1;
+           dle->estimatelist = g_slist_append(dle->estimatelist,
+                                              GINT_TO_POINTER(ES_CALCSIZE));
        }
        else {
-           dle->calcsize = 0;
+           dle->estimatelist = g_slist_append(dle->estimatelist,
+                                              GINT_TO_POINTER(ES_CLIENT));
        }
 
        skip_whitespace(s, ch);                 /* find disk name */
@@ -247,7 +252,9 @@ main(
        if (ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
            goto err;                           /* bad level */
        }
-       dle->level = g_slist_append(dle->level, GINT_TO_POINTER(level));
+       alevel = g_new0(level_t, 1);
+       alevel->level = level;
+       dle->levellist = g_slist_append(dle->levellist, alevel);
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
@@ -282,6 +289,7 @@ main(
            need_gnutar=1;
            need_compress_path=1;
            need_calcsize=1;
+           need_global_check=1;
            /*@ignore@*/
            check_disk(dle);
            /*@end@*/
@@ -351,13 +359,13 @@ static void
 check_options(
     dle_t *dle)
 {
-    if (dle->calcsize == 1) {
+    if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE) {
        need_calcsize=1;
     }
 
     if (strcmp(dle->program,"GNUTAR") == 0) {
        need_gnutar=1;
-        if(dle->device[0] == '/' && dle->device[1] == '/') {
+        if(dle->device && dle->device[0] == '/' && dle->device[1] == '/') {
            if(dle->exclude_file && dle->exclude_file->nb_element > 1) {
                g_printf(_("ERROR [samba support only one exclude file]\n"));
            }
@@ -413,7 +421,7 @@ check_options(
 #ifndef AIX_BACKUP
 #ifdef VDUMP
 #ifdef DUMP
-       if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
+       if (dle->device && strcmp(amname_to_fstype(dle->device), "advfs") == 0)
 #else
        if (1)
 #endif
@@ -427,7 +435,7 @@ check_options(
 #endif /* VDUMP */
 #ifdef XFSDUMP
 #ifdef DUMP
-       if (strcmp(amname_to_fstype(dle->device), "xfs") == 0)
+       if (dle->device && strcmp(amname_to_fstype(dle->device), "xfs") == 0)
 #else
        if (1)
 #endif
@@ -441,7 +449,7 @@ check_options(
 #endif /* XFSDUMP */
 #ifdef VXDUMP
 #ifdef DUMP
-       if (strcmp(amname_to_fstype(dle->device), "vxfs") == 0)
+       if (dle->device && strcmp(amname_to_fstype(dle->device), "vxfs") == 0)
 #else
        if (1)
 #endif
@@ -489,196 +497,212 @@ static void
 check_disk(
     dle_t *dle)
 {
-    char *device = stralloc("nodevice");
+    char *device = NULL;
     char *err = NULL;
     char *user_and_password = NULL;
     char *domain = NULL;
     char *share = NULL, *subdir = NULL;
     size_t lpass = 0;
-    int amode;
+    int amode = R_OK;
     int access_result;
     char *access_type;
     char *extra_info = NULL;
-    char *qdisk = quote_string(dle->disk);
-    char *qamdevice = quote_string(dle->device);
+    char *qdisk = NULL;
+    char *qamdevice = NULL;
     char *qdevice = NULL;
 
-    dbprintf(_("checking disk %s\n"), qdisk);
-    if (dle->calcsize == 1) {
-       if (dle->device[0] == '/' && dle->device[1] == '/') {
-           err = vstrallocf(_("Can't use CALCSIZE for samba estimate, use CLIENT: %s"),
-                           dle->device);
-           goto common_exit;
-       }
-    }
-
-    if (strcmp(dle->program, "GNUTAR")==0) {
-        if(dle->device[0] == '/' && dle->device[1] == '/') {
-#ifdef SAMBA_CLIENT
-           int nullfd, checkerr;
-           int passwdfd;
-           char *pwtext;
-           size_t pwtext_len;
-           pid_t checkpid;
-           amwait_t retstat;
-           pid_t wpid;
-           int rc;
-           char *line;
-           char *sep;
-           FILE *ferr;
-           char *pw_fd_env;
-           int errdos;
-
-           parsesharename(dle->device, &share, &subdir);
-           if (!share) {
-               err = vstrallocf(_("cannot parse for share/subdir disk entry %s"), dle->device);
+    if (dle->disk) {
+       need_global_check=1;
+       qdisk = quote_string(dle->disk);
+       qamdevice = quote_string(dle->device);
+       device = stralloc("nodevice");
+       dbprintf(_("checking disk %s\n"), qdisk);
+       if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE) {
+           if (dle->device[0] == '/' && dle->device[1] == '/') {
+               err = vstrallocf(
+                   _("Can't use CALCSIZE for samba estimate, use CLIENT: %s"),
+                   dle->device);
                goto common_exit;
            }
-           if ((subdir) && (SAMBA_VERSION < 2)) {
-               err = vstrallocf(_("subdirectory specified for share '%s' but, samba is not v2 or better"),
+       }
+
+       if (strcmp(dle->program, "GNUTAR")==0) {
+            if(dle->device[0] == '/' && dle->device[1] == '/') {
+               #ifdef SAMBA_CLIENT
+               int nullfd, checkerr;
+               int passwdfd;
+               char *pwtext;
+               size_t pwtext_len;
+               pid_t checkpid;
+               amwait_t retstat;
+               pid_t wpid;
+               int rc;
+               char *line;
+               char *sep;
+               FILE *ferr;
+               char *pw_fd_env;
+               int errdos;
+
+               parsesharename(dle->device, &share, &subdir);
+               if (!share) {
+                   err = vstrallocf(
+                             _("cannot parse for share/subdir disk entry %s"),
+                             dle->device);
+                   goto common_exit;
+               }
+               if ((subdir) && (SAMBA_VERSION < 2)) {
+                   err = vstrallocf(_("subdirectory specified for share '%s' but, samba is not v2 or better"),
+                                    dle->device);
+                   goto common_exit;
+               }
+               if ((user_and_password = findpass(share, &domain)) == NULL) {
+                   err = vstrallocf(_("cannot find password for %s"),
+                                    dle->device);
+                   goto common_exit;
+               }
+               lpass = strlen(user_and_password);
+               if ((pwtext = strchr(user_and_password, '%')) == NULL) {
+                   err = vstrallocf(
+                               _("password field not \'user%%pass\' for %s"),
                                dle->device);
-               goto common_exit;
-           }
-           if ((user_and_password = findpass(share, &domain)) == NULL) {
-               err = vstrallocf(_("cannot find password for %s"), dle->device);
-               goto common_exit;
-           }
-           lpass = strlen(user_and_password);
-           if ((pwtext = strchr(user_and_password, '%')) == NULL) {
-               err = vstrallocf(_("password field not \'user%%pass\' for %s"), dle->device);
-               goto common_exit;
-           }
-           *pwtext++ = '\0';
-           pwtext_len = (size_t)strlen(pwtext);
-           amfree(device);
-           if ((device = makesharename(share, 0)) == NULL) {
-               err = vstrallocf(_("cannot make share name of %s"), share);
-               goto common_exit;
-           }
+                   goto common_exit;
+               }
+               *pwtext++ = '\0';
+               pwtext_len = (size_t)strlen(pwtext);
+               amfree(device);
+               if ((device = makesharename(share, 0)) == NULL) {
+                   err = vstrallocf(_("cannot make share name of %s"), share);
+                   goto common_exit;
+               }
 
-           if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
-               err = vstrallocf(_("Cannot access /dev/null : %s"), strerror(errno));
-               goto common_exit;
-           }
+               if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
+                   err = vstrallocf(_("Cannot access /dev/null : %s"),
+                                    strerror(errno));
+                   goto common_exit;
+               }
 
-           if (pwtext_len > 0) {
-               pw_fd_env = "PASSWD_FD";
-           } else {
-               pw_fd_env = "dummy_PASSWD_FD";
-           }
-           checkpid = pipespawn(SAMBA_CLIENT, STDERR_PIPE|PASSWD_PIPE, 0,
-                                &nullfd, &nullfd, &checkerr,
-                                pw_fd_env, &passwdfd,
-                                "smbclient",
-                                device,
-                                *user_and_password ? "-U" : skip_argument,
-                                *user_and_password ? user_and_password : skip_argument,
-                                "-E",
-                                domain ? "-W" : skip_argument,
-                                domain ? domain : skip_argument,
+               if (pwtext_len > 0) {
+                   pw_fd_env = "PASSWD_FD";
+               } else {
+                   pw_fd_env = "dummy_PASSWD_FD";
+               }
+               checkpid = pipespawn(SAMBA_CLIENT, STDERR_PIPE|PASSWD_PIPE, 0,
+                                    &nullfd, &nullfd, &checkerr,
+                                    pw_fd_env, &passwdfd,
+                                    "smbclient",
+                                    device,
+                                    *user_and_password ? "-U" : skip_argument,
+                                    *user_and_password ? user_and_password
+                                                       : skip_argument,
+                                    "-E",
+                                    domain ? "-W" : skip_argument,
+                                    domain ? domain : skip_argument,
 #if SAMBA_VERSION >= 2
-                                subdir ? "-D" : skip_argument,
-                                subdir ? subdir : skip_argument,
+                                    subdir ? "-D" : skip_argument,
+                                    subdir ? subdir : skip_argument,
 #endif
-                                "-c", "quit",
-                                NULL);
-           amfree(domain);
-           aclose(nullfd);
-           /*@ignore@*/
-           if ((pwtext_len > 0)
-             && full_write(passwdfd, pwtext, pwtext_len) < pwtext_len) {
-               err = vstrallocf(_("password write failed: %s: %s"),
-                               dle->device, strerror(errno));
+                                    "-c", "quit",
+                                    NULL);
+               amfree(domain);
+               aclose(nullfd);
+               /*@ignore@*/
+               if ((pwtext_len > 0) &&
+                   full_write(passwdfd, pwtext, pwtext_len) < pwtext_len) {
+                   err = vstrallocf(_("password write failed: %s: %s"),
+                                    dle->device, strerror(errno));
+                   aclose(passwdfd);
+                   goto common_exit;
+               }
+               /*@end@*/
+               memset(user_and_password, '\0', (size_t)lpass);
+               amfree(user_and_password);
                aclose(passwdfd);
-               goto common_exit;
-           }
-           /*@end@*/
-           memset(user_and_password, '\0', (size_t)lpass);
-           amfree(user_and_password);
-           aclose(passwdfd);
-           ferr = fdopen(checkerr, "r");
-           if (!ferr) {
-               g_printf(_("ERROR [Can't fdopen: %s]\n"), strerror(errno));
-               error(_("Can't fdopen: %s"), strerror(errno));
-               /*NOTREACHED*/
-           }
-           sep = "";
-           errdos = 0;
-           for(sep = ""; (line = agets(ferr)) != NULL; free(line)) {
-               if (line[0] == '\0')
-                   continue;
-               strappend(extra_info, sep);
-               strappend(extra_info, line);
-               sep = ": ";
-               if(strstr(line, "ERRDOS") != NULL) {
-                   errdos = 1;
+               ferr = fdopen(checkerr, "r");
+               if (!ferr) {
+                   g_printf(_("ERROR [Can't fdopen: %s]\n"), strerror(errno));
+                   error(_("Can't fdopen: %s"), strerror(errno));
+                   /*NOTREACHED*/
                }
-           }
-           afclose(ferr);
-           checkerr = -1;
-           rc = 0;
-           sep = "";
-           while ((wpid = wait(&retstat)) != -1) {
-               if (!WIFEXITED(retstat) || WEXITSTATUS(retstat) != 0) {
-                   char *exitstr = str_exit_status("smbclient", retstat);
-                   strappend(err, sep);
-                   strappend(err, exitstr);
-                   sep = "\n";
-                   amfree(exitstr);
-
-                   rc = 1;
+               sep = "";
+               errdos = 0;
+               for(sep = ""; (line = agets(ferr)) != NULL; free(line)) {
+                   if (line[0] == '\0')
+                       continue;
+                   strappend(extra_info, sep);
+                   strappend(extra_info, line);
+                   sep = ": ";
+                   if(strstr(line, "ERRDOS") != NULL) {
+                       errdos = 1;
+                   }
                }
-           }
-           if (errdos != 0 || rc != 0) {
-               if (extra_info) {
-                   err = newvstrallocf(err,
-                                  _("samba access error: %s: %s %s"),
-                                  dle->device, extra_info, err);
-                   amfree(extra_info);
-               } else {
-                   err = newvstrallocf(err, _("samba access error: %s: %s"),
-                                  dle->device, err);
+               afclose(ferr);
+               checkerr = -1;
+               rc = 0;
+               sep = "";
+               while ((wpid = wait(&retstat)) != -1) {
+                   if (!WIFEXITED(retstat) || WEXITSTATUS(retstat) != 0) {
+                       char *exitstr = str_exit_status("smbclient", retstat);
+                       strappend(err, sep);
+                       strappend(err, exitstr);
+                       sep = "\n";
+                       amfree(exitstr);
+
+                       rc = 1;
+                   }
+               }
+               if (errdos != 0 || rc != 0) {
+                   if (extra_info) {
+                       err = newvstrallocf(err,
+                                           _("samba access error: %s: %s %s"),
+                                           dle->device, extra_info, err);
+                       amfree(extra_info);
+                   } else {
+                       err = newvstrallocf(err,
+                                           _("samba access error: %s: %s"),
+                                          dle->device, err);
+                   }
                }
-           }
 #else
-           err = vstrallocf(_("This client is not configured for samba: %s"),
-                       qdisk);
+               err = vstrallocf(
+                             _("This client is not configured for samba: %s"),
+                             qdisk);
 #endif
-           goto common_exit;
-       }
-       amode = F_OK;
-       amfree(device);
-       device = amname_to_dirname(dle->device);
-    } else if (strcmp(dle->program, "DUMP") == 0) {
-       if(dle->device[0] == '/' && dle->device[1] == '/') {
-           err = vstrallocf(
+               goto common_exit;
+           }
+           amode = F_OK;
+           amfree(device);
+           device = amname_to_dirname(dle->device);
+       } else if (strcmp(dle->program, "DUMP") == 0) {
+           if(dle->device[0] == '/' && dle->device[1] == '/') {
+               err = vstrallocf(
                  _("The DUMP program cannot handle samba shares, use GNUTAR: %s"),
                  qdisk);
-           goto common_exit;
-       }
+               goto common_exit;
+           }
 #ifdef VDUMP                                                           /* { */
 #ifdef DUMP                                                            /* { */
-        if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
-#else                                                                  /* }{ */
-       if (1)
+            if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
+#else                                                                  /* }{*/
+           if (1)
 #endif                                                                 /* } */
-       {
-           amfree(device);
-           device = amname_to_dirname(dle->device);
-           amode = F_OK;
-       } else
+           {
+               amfree(device);
+               device = amname_to_dirname(dle->device);
+               amode = F_OK;
+           } else
 #endif                                                                 /* } */
-       {
-           amfree(device);
-           device = amname_to_devname(dle->device);
+           {
+               amfree(device);
+               device = amname_to_devname(dle->device);
 #ifdef USE_RUNDUMP
-           amode = F_OK;
+               amode = F_OK;
 #else
-           amode = R_OK;
+               amode = R_OK;
 #endif
+           }
        }
     }
-    else { /* program_is_application_api==1 */
+    if (dle->program_is_application_api) {
        pid_t                    application_api_pid;
        backup_support_option_t *bsu;
        int                      app_err[2];
@@ -701,7 +725,18 @@ check_disk(
            goto common_exit;
        }
 
-       if (dle->calcsize && !bsu->calcsize) {
+       if (dle->data_path == DATA_PATH_AMANDA &&
+           (bsu->data_path_set & DATA_PATH_AMANDA)==0) {
+           g_printf("ERROR application %s doesn't support amanda data-path\n",
+                    dle->program);
+       }
+       if (dle->data_path == DATA_PATH_DIRECTTCP &&
+           (bsu->data_path_set & DATA_PATH_DIRECTTCP)==0) {
+           g_printf("ERROR application %s doesn't support directtcp data-path\n",
+                    dle->program);
+       }
+       if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE &&
+                           !bsu->calcsize) {
            g_printf("ERROR application %s doesn't support calcsize estimate\n",
                     dle->program);
        }
@@ -748,72 +783,71 @@ check_disk(
 
        case 0: /* child */
            {
-               char **argvchild, **arg;
+               GPtrArray *argv_ptr = g_ptr_array_new();
+               guint i;
                char *cmd = vstralloc(APPLICATION_DIR, "/", dle->program, NULL);
                GSList   *scriptlist;
                script_t *script;
+               estimatelist_t el;
                char *cmdline;
-               int j=0;
-               int k;
 
                aclose(app_err[0]);
                dup2(app_err[1], 2);
 
-               k = application_property_argv_size(dle);
-               for (scriptlist = dle->scriptlist; scriptlist != NULL;
-                    scriptlist = scriptlist->next) {
-                   script = (script_t *)scriptlist->data;
-                   if (script->result && script->result->proplist) {
-                       k += property_argv_size(script->result->proplist);
-                   }
-               }
-               argvchild = g_new0(char *, 18 + k);
-               argvchild[j++] = dle->program;
-               argvchild[j++] = "selfcheck";
+               g_ptr_array_add(argv_ptr, stralloc(dle->program));
+               g_ptr_array_add(argv_ptr, stralloc("selfcheck"));
                if (bsu->message_line == 1) {
-                   argvchild[j++] = "--message";
-                   argvchild[j++] = "line";
+                   g_ptr_array_add(argv_ptr, stralloc("--message"));
+                   g_ptr_array_add(argv_ptr, stralloc("line"));
                }
                if (g_options->config != NULL && bsu->config == 1) {
-                   argvchild[j++] = "--config";
-                   argvchild[j++] = g_options->config;
+                   g_ptr_array_add(argv_ptr, stralloc("--config"));
+                   g_ptr_array_add(argv_ptr, stralloc(g_options->config));
                }
                if (g_options->hostname != NULL && bsu->host == 1) {
-                   argvchild[j++] = "--host";
-                   argvchild[j++] = g_options->hostname;
+                   g_ptr_array_add(argv_ptr, stralloc("--host"));
+                   g_ptr_array_add(argv_ptr, stralloc(g_options->hostname));
                }
                if (dle->disk != NULL && bsu->disk == 1) {
-                   argvchild[j++] = "--disk";
-                   argvchild[j++] = dle->disk;
+                   g_ptr_array_add(argv_ptr, stralloc("--disk"));
+                   g_ptr_array_add(argv_ptr, stralloc(dle->disk));
+               }
+               if (dle->device) {
+                   g_ptr_array_add(argv_ptr, stralloc("--device"));
+                   g_ptr_array_add(argv_ptr, stralloc(dle->device));
                }
-               argvchild[j++] = "--device";
-               argvchild[j++] = dle->device;
                if (dle->create_index && bsu->index_line == 1) {
-                   argvchild[j++] = "--index";
-                   argvchild[j++] = "line";
+                   g_ptr_array_add(argv_ptr, stralloc("--index"));
+                   g_ptr_array_add(argv_ptr, stralloc("line"));
                }
                if (dle->record && bsu->record == 1) {
-                   argvchild[j++] = "--record";
+                   g_ptr_array_add(argv_ptr, stralloc("--record"));
                }
-               if (dle->calcsize && bsu->calcsize == 1) {
-                   argvchild[j++] = "--calcsize";
+               
+               for (el = dle->estimatelist; el != NULL; el=el->next) {
+                   estimate_t estimate = (estimate_t)GPOINTER_TO_INT(el->data);
+                   if (estimate == ES_CALCSIZE && bsu->calcsize == 1) {
+                       g_ptr_array_add(argv_ptr, stralloc("--calcsize"));
+                   }
                }
-               j += application_property_add_to_argv(&argvchild[j], dle, bsu);
+               application_property_add_to_argv(argv_ptr, dle, bsu,
+                                                g_options->features);
 
                for (scriptlist = dle->scriptlist; scriptlist != NULL;
                     scriptlist = scriptlist->next) {
                    script = (script_t *)scriptlist->data;
                    if (script->result && script->result->proplist) {
-                       j += property_add_to_argv(&argvchild[j],
-                                                 script->result->proplist);
+                       property_add_to_argv(argv_ptr,
+                                            script->result->proplist);
                    }
                }
 
-               argvchild[j++] = NULL;
+               g_ptr_array_add(argv_ptr, NULL);
 
                cmdline = stralloc(cmd);
-               for(arg = argvchild; *arg != NULL; arg++) {
-                   char *quoted = quote_string(*arg);
+               for (i = 0; i < argv_ptr->len-1; i++) {
+                   char *quoted = quote_string(
+                                       (char *)g_ptr_array_index(argv_ptr,i));
                    cmdline = vstrextend(&cmdline, " ", quoted, NULL);
                    amfree(quoted);
                }
@@ -821,7 +855,7 @@ check_disk(
                amfree(cmdline);
 
                safe_fd(-1, 0);
-               execve(cmd, argvchild, safe_env());
+               execve(cmd, (char **)argv_ptr->pdata, safe_env());
                g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
                exit(127);
            }
@@ -865,25 +899,27 @@ check_disk(
        return;
     }
 
-    qdevice = quote_string(device);
-    dbprintf(_("device %s\n"), qdevice);
+    if (device) {
+       qdevice = quote_string(device);
+       dbprintf(_("device %s\n"), qdevice);
 
-    /* skip accessability test if this is an AFS entry */
-    if(strncmp_const(device, "afs:") != 0) {
+       /* skip accessability test if this is an AFS entry */
+       if(strncmp_const(device, "afs:") != 0) {
 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
-       access_result = open(device, O_RDONLY);
-       access_type = "open";
+           access_result = open(device, O_RDONLY);
+           access_type = "open";
 #else
-       access_result = access(device, amode);
-       access_type = "access";
+           access_result = access(device, amode);
+           access_type = "access";
 #endif
-       if(access_result == -1) {
-           err = vstrallocf(_("Could not access %s (%s): %s"),
-                       qdevice, qdisk, strerror(errno));
-       }
+           if(access_result == -1) {
+               err = vstrallocf(_("Could not access %s (%s): %s"),
+                                qdevice, qdisk, strerror(errno));
+           }
 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
-       aclose(access_result);
+           aclose(access_result);
 #endif
+       }
     }
 
 common_exit:
@@ -904,12 +940,18 @@ common_exit:
        dbprintf(_("%s\n"), err);
        amfree(err);
     } else {
-       g_printf("OK %s\n", qdisk);
-       dbprintf(_("disk %s OK\n"), qdisk);
-       g_printf("OK %s\n", qamdevice);
-       dbprintf(_("amdevice %s OK\n"), qamdevice);
-       g_printf("OK %s\n", qdevice);
-       dbprintf(_("device %s OK\n"), qdevice);
+       if (dle->disk) {
+           g_printf("OK %s\n", qdisk);
+           dbprintf(_("disk %s OK\n"), qdisk);
+       }
+       if (dle->device) {
+           g_printf("OK %s\n", qamdevice);
+           dbprintf(_("amdevice %s OK\n"), qamdevice);
+       }
+       if (device) {
+           g_printf("OK %s\n", qdevice);
+           dbprintf(_("device %s OK\n"), qdevice);
+       }
     }
     if(extra_info) {
        dbprintf(_("extra info: %s\n"), extra_info);
@@ -934,7 +976,7 @@ check_overall(void)
 
     if( need_runtar )
     {
-       cmd = vstralloc(amlibexecdir, "/", "runtar", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "runtar", NULL);
        check_file(cmd,X_OK);
        check_suid(cmd);
        amfree(cmd);
@@ -942,7 +984,7 @@ check_overall(void)
 
     if( need_rundump )
     {
-       cmd = vstralloc(amlibexecdir, "/", "rundump", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "rundump", NULL);
        check_file(cmd,X_OK);
        check_suid(cmd);
        amfree(cmd);
@@ -1033,7 +1075,7 @@ check_overall(void)
     if( need_calcsize ) {
        char *cmd;
 
-       cmd = vstralloc(amlibexecdir, "/", "calcsize", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "calcsize", NULL);
 
        check_file(cmd, X_OK);
 
@@ -1101,6 +1143,7 @@ check_overall(void)
        }
     }
 
+    if (need_global_check) {
     check_access("/dev/null", R_OK|W_OK);
     check_space(AMANDA_TMPDIR, (off_t)64);     /* for amandad i/o */
 
@@ -1109,6 +1152,8 @@ check_overall(void)
 #endif
 
     check_space("/var/lib", (off_t)64);                /* for /var/lib/dumpdates writing */
+    check_space("/etc", (off_t)64);            /* for /etc/dumpdates writing */
+    }
 }
 
 static void