Imported Upstream version 2.6.0
[debian/amanda] / client-src / selfcheck.c
index 2230bc5a54cfc3179aeab263e7c851289834ec45..8787a8245f40c0a055d6e7f8197662d10e4e8ad5 100644 (file)
  *                        University of Maryland at College Park
  */
 /* 
- * $Id: selfcheck.c,v 1.95.2.2 2007/01/19 01:03:34 martinea Exp $
+ * $Id: selfcheck.c,v 1.95 2006/08/29 11:21:00 martinea Exp $
  *
  * do self-check and send back any error messages
  */
 
 #include "amanda.h"
-#include "statfs.h"
+#include "fsusage.h"
 #include "version.h"
 #include "getfsent.h"
 #include "amandates.h"
@@ -40,7 +40,7 @@
 #include "pipespawn.h"
 #include "amfeatures.h"
 #include "client_util.h"
-#include "clientconf.h"
+#include "conffile.h"
 #include "amandad.h"
 
 #ifdef SAMBA_CLIENT
@@ -61,7 +61,7 @@ int need_runtar=0;
 int need_gnutar=0;
 int need_compress_path=0;
 int need_calcsize=0;
-int program_is_wrapper=0;
+int program_is_backup_api=0;
 
 static char *amandad_auth = NULL;
 static am_feature_t *our_features = NULL;
@@ -72,7 +72,7 @@ static g_option_t *g_options = NULL;
 int main(int argc, char **argv);
 
 static void check_options(char *program, char *calcprog, char *disk, char *amdevice, option_t *options);
-static void check_disk(char *program, char *calcprog, char *disk, char *amdevice, int level, char *optstr);
+static void check_disk(char *program, char *calcprog, char *disk, char *amdevice, int level, option_t *options);
 static void check_overall(void);
 static void check_access(char *filename, int mode);
 static int check_file_exist(char *filename);
@@ -97,16 +97,20 @@ main(
     char *optstr = NULL;
     char *err_extra = NULL;
     char *s, *fp;
-    char *conffile;
     option_t *options;
     int ch;
-#if defined(USE_DBMALLOC)
-    unsigned long malloc_hist_1, malloc_size_1;
-    unsigned long malloc_hist_2, malloc_size_2;
-#endif
 
     /* initialize */
 
+    /*
+     * Configure program for internationalization:
+     *   1) Only set the message locale for now.
+     *   2) Set textdomain for all amanda related programs to "amanda"
+     *      We don't want to be forced to support dozens of message catalogs.
+     */  
+    setlocale(LC_MESSAGES, "C");
+    textdomain("amanda"); 
+
     safe_fd(-1, 0);
     safe_cd();
 
@@ -115,26 +119,18 @@ main(
     /* Don't die when child closes pipe */
     signal(SIGPIPE, SIG_IGN);
 
-#if defined(USE_DBMALLOC)
-    malloc_size_1 = malloc_inuse(&malloc_hist_1);
-#endif
-
     erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG);
     dbopen(DBG_SUBDIR_CLIENT);
     startclock();
-    dbprintf(("%s: version %s\n", get_pname(), version()));
+    dbprintf(_("version %s\n"), version());
 
     if(argc > 2 && strcmp(argv[1], "amandad") == 0) {
        amandad_auth = stralloc(argv[2]);
     }
 
-    conffile = vstralloc(CONFIG_DIR, "/", "amanda-client.conf", NULL);
-    if (read_clientconf(conffile) > 0) {
-       printf("ERROR [reading conffile: %s]\n", conffile);
-       error("error reading conffile: %s", conffile);
-       /*NOTREACHED*/
-    }
-    amfree(conffile);
+    config_init(CONFIG_INIT_CLIENT, NULL);
+
+    check_running_as(RUNNING_AS_CLIENT_LOGIN);
 
     our_features = am_init_feature_set();
     our_feature_string = am_feature_to_string(our_features);
@@ -147,9 +143,7 @@ main(
        if (line[0] == '\0')
            continue;
 
-#define sc "OPTIONS "
-       if(strncmp(line, sc, SIZEOF(sc)-1) == 0) {
-#undef sc
+       if(strncmp_const(line, "OPTIONS ") == 0) {
            g_options = parse_g_options(line+8, 1);
            if(!g_options->hostname) {
                g_options->hostname = alloc(MAX_HOSTNAME_LENGTH+1);
@@ -157,27 +151,22 @@ main(
                g_options->hostname[MAX_HOSTNAME_LENGTH] = '\0';
            }
 
-           printf("OPTIONS ");
+           g_printf("OPTIONS ");
            if(am_has_feature(g_options->features, fe_rep_options_features)) {
-               printf("features=%s;", our_feature_string);
+               g_printf("features=%s;", our_feature_string);
            }
            if(am_has_feature(g_options->features, fe_rep_options_hostname)) {
-               printf("hostname=%s;", g_options->hostname);
+               g_printf("hostname=%s;", g_options->hostname);
            }
-           printf("\n");
+           g_printf("\n");
            fflush(stdout);
 
            if (g_options->config) {
-               conffile = vstralloc(CONFIG_DIR, "/", g_options->config, "/",
-                                    "amanda-client.conf", NULL);
-               if (read_clientconf(conffile) > 0) {
-                   printf("ERROR [reading conffile: %s]\n", conffile);
-                   error("error reading conffile: %s", conffile);
-                   /*NOTREACHED*/
-               }
-               amfree(conffile);
+               /* overlay this configuration on the existing (nameless) configuration */
+               config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY,
+                           g_options->config);
 
-               dbrename(g_options->config, DBG_SUBDIR_CLIENT);
+               dbrename(config_name, DBG_SUBDIR_CLIENT);
            }
 
            continue;
@@ -194,9 +183,9 @@ main(
        skip_non_whitespace(s, ch);
        s[-1] = '\0';                           /* terminate the program name */
 
-       program_is_wrapper = 0;
-       if(strcmp(program,"DUMPER")==0) {
-           program_is_wrapper = 1;
+       program_is_backup_api = 0;
+       if(strcmp(program,"BACKUP")==0) {
+           program_is_backup_api = 1;
            skip_whitespace(s, ch);             /* find dumper name */
            if (ch == '\0') {
                goto err;                       /* no program */
@@ -206,7 +195,7 @@ main(
            s[-1] = '\0';                       /* terminate the program name */
        }
 
-       if(strncmp(program, "CALCSIZE", 8) == 0) {
+       if(strncmp_const(program, "CALCSIZE") == 0) {
            skip_whitespace(s, ch);             /* find program name */
            if (ch == '\0') {
                goto err;                       /* no program */
@@ -251,11 +240,7 @@ main(
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
-#define sc "OPTIONS "
-       if (ch && strncmp (s - 1, sc, SIZEOF(sc)-1) == 0) {
-           s += SIZEOF(sc)-1;
-           ch = s[-1];
-#undef sc
+       if (ch && strncmp_const_skip(s - 1, "OPTIONS ", s, ch) == 0) {
            skip_whitespace(s, ch);             /* find the option string */
            if(ch == '\0') {
                goto err;                       /* bad options string */
@@ -266,7 +251,7 @@ main(
            options = parse_options(optstr, disk, amdevice, g_options->features, 1);
            /*@ignore@*/
            check_options(program, calcprog, disk, amdevice, options);
-           check_disk(program, calcprog, disk, amdevice, level, &optstr[2]);
+           check_disk(program, calcprog, disk, amdevice, level, options);
            /*@end@*/
            free_sl(options->exclude_file);
            free_sl(options->exclude_list);
@@ -292,14 +277,20 @@ main(
            need_compress_path=1;
            need_calcsize=1;
            /*@ignore@*/
-           check_disk(program, calcprog, disk, amdevice, level, "");
+           check_disk(program, calcprog, disk, amdevice, level, NULL);
            /*@end@*/
        } else {
            goto err;                           /* bad syntax */
        }
        amfree(disk);
+       amfree(qamdevice);
        amfree(amdevice);
     }
+    if (g_options == NULL) {
+       printf(_("ERROR [Missing OPTIONS line in selfcheck input]\n"));
+       error(_("Missing OPTIONS line in selfcheck input\n"));
+       /*NOTREACHED*/
+    }
 
     check_overall();
 
@@ -307,31 +298,16 @@ main(
     amfree(our_feature_string);
     am_release_feature_set(our_features);
     our_features = NULL;
-    am_release_feature_set(g_options->features);
-    g_options->features = NULL;
-    amfree(g_options->str);
-    amfree(g_options->hostname);
-    amfree(g_options);
-
-#if defined(USE_DBMALLOC)
-    malloc_size_2 = malloc_inuse(&malloc_hist_2);
-
-    if(malloc_size_1 != malloc_size_2) {
-       extern int dbfd;
-
-       malloc_list(dbfd(), malloc_hist_1, malloc_hist_2);
-    }
-#endif
+    free_g_options(g_options);
 
     dbclose();
     return 0;
 
  err:
-    printf("ERROR [BOGUS REQUEST PACKET]\n");
-    dbprintf(("%s: REQ packet is bogus%s%s\n",
-             debug_prefix_time(NULL),
+    g_printf(_("ERROR [BOGUS REQUEST PACKET]\n"));
+    dbprintf(_("REQ packet is bogus%s%s\n"),
              err_extra ? ": " : "",
-             err_extra ? err_extra : ""));
+             err_extra ? err_extra : "");
     dbclose();
     return 1;
 }
@@ -366,7 +342,7 @@ check_options(
 
        need_calcsize=1;
        if (calcprog == NULL) {
-           printf("ERROR [no program name for calcsize]\n");
+           g_printf(_("ERROR [no program name for calcsize]\n"));
        } else {
            myprogram = calcprog;
        }
@@ -376,18 +352,18 @@ check_options(
        need_gnutar=1;
         if(amdevice[0] == '/' && amdevice[1] == '/') {
            if(options->exclude_file && options->exclude_file->nb_element > 1) {
-               printf("ERROR [samba support only one exclude file]\n");
+               g_printf(_("ERROR [samba support only one exclude file]\n"));
            }
            if(options->exclude_list && options->exclude_list->nb_element > 0 &&
               options->exclude_optional==0) {
-               printf("ERROR [samba does not support exclude list]\n");
+               g_printf(_("ERROR [samba does not support exclude list]\n"));
            }
            if(options->include_file && options->include_file->nb_element > 0) {
-               printf("ERROR [samba does not support include file]\n");
+               g_printf(_("ERROR [samba does not support include file]\n"));
            }
            if(options->include_list && options->include_list->nb_element > 0 &&
               options->include_optional==0) {
-               printf("ERROR [samba does not support include list]\n");
+               g_printf(_("ERROR [samba does not support include list]\n"));
            }
            need_samba=1;
        }
@@ -414,16 +390,16 @@ check_options(
 
     if(strcmp(myprogram,"DUMP") == 0) {
        if(options->exclude_file && options->exclude_file->nb_element > 0) {
-           printf("ERROR [DUMP does not support exclude file]\n");
+           g_printf(_("ERROR [DUMP does not support exclude file]\n"));
        }
        if(options->exclude_list && options->exclude_list->nb_element > 0) {
-           printf("ERROR [DUMP does not support exclude list]\n");
+           g_printf(_("ERROR [DUMP does not support exclude list]\n"));
        }
        if(options->include_file && options->include_file->nb_element > 0) {
-           printf("ERROR [DUMP does not support include file]\n");
+           g_printf(_("ERROR [DUMP does not support include file]\n"));
        }
        if(options->include_list && options->include_list->nb_element > 0) {
-           printf("ERROR [DUMP does not support include list]\n");
+           g_printf(_("ERROR [DUMP does not support include list]\n"));
        }
 #ifdef USE_RUNDUMP
        need_rundump=1;
@@ -482,14 +458,23 @@ check_options(
            need_restore=1;
 #endif
     }
-    if ((options->compress == COMPR_BEST) || (options->compress == COMPR_FAST) 
-               || (options->compress == COMPR_CUST)) {
+    if ((options->compress == COMP_BEST) || (options->compress == COMP_FAST) 
+               || (options->compress == COMP_CUST)) {
        need_compress_path=1;
     }
     if(options->auth && amandad_auth) {
        if(strcasecmp(options->auth, amandad_auth) != 0) {
-           fprintf(stdout,"ERROR [client configured for auth=%s while server requested '%s']\n",
+           g_fprintf(stdout,_("ERROR [client configured for auth=%s while server requested '%s']\n"),
                    amandad_auth, options->auth);
+           if(strcmp(options->auth, "ssh") == 0)  {    
+               g_fprintf(stderr, _("ERROR [The auth in ~/.ssh/authorized_keys "
+                                 "should be \"--auth=ssh\", or use another auth "
+                                 " for the DLE]\n"));
+           }
+           else {
+               g_fprintf(stderr, _("ERROR [The auth in the inetd/xinetd configuration "
+                                 " must be the same as the DLE]\n"));
+           }           
        }
     }
 }
@@ -501,7 +486,7 @@ check_disk(
     char *     disk,
     char *     amdevice,
     int                level,
-    char *     optstr)
+    option_t    *options)
 {
     char *device = stralloc("nodevice");
     char *err = NULL;
@@ -517,17 +502,20 @@ check_disk(
     char *qdisk = quote_string(disk);
     char *qamdevice = quote_string(amdevice);
     char *qdevice = NULL;
+    FILE *toolin;
 
     (void)level;       /* Quiet unused parameter warning */
 
-    dbprintf(("%s: checking disk %s\n", debug_prefix_time(NULL), qdisk));
+    dbprintf(_("checking disk %s\n"), qdisk);
 
     if(strcmp(myprogram,"CALCSIZE") == 0) {
        if(amdevice[0] == '/' && amdevice[1] == '/') {
-           err = vstralloc("Can't use CALCSIZE for samba estimate,",
-                           " use CLIENT: ",
-                           amdevice,
-                           NULL);
+           err = vstrallocf(_("Can't use CALCSIZE for samba estimate, use CLIENT: %s"),
+                           amdevice);
+           goto common_exit;
+       }
+       if (calcprog == NULL) {
+           err = _("no program for calcsize");
            goto common_exit;
        }
        myprogram = calcprog;
@@ -542,9 +530,8 @@ check_disk(
            size_t pwtext_len;
            pid_t checkpid;
            amwait_t retstat;
-           char number[NUM_STR_SIZE];
            pid_t wpid;
-           int ret, sig, rc;
+           int rc;
            char *line;
            char *sep;
            FILE *ferr;
@@ -553,35 +540,33 @@ check_disk(
 
            parsesharename(amdevice, &share, &subdir);
            if (!share) {
-               err = stralloc2("cannot parse for share/subdir disk entry ", amdevice);
+               err = vstrallocf(_("cannot parse for share/subdir disk entry %s"), amdevice);
                goto common_exit;
            }
            if ((subdir) && (SAMBA_VERSION < 2)) {
-               err = vstralloc("subdirectory specified for share '",
-                               amdevice,
-                               "' but samba not v2 or better",
-                               NULL);
+               err = vstrallocf(_("subdirectory specified for share '%s' but, samba is not v2 or better"),
+                               amdevice);
                goto common_exit;
            }
            if ((user_and_password = findpass(share, &domain)) == NULL) {
-               err = stralloc2("cannot find password for ", amdevice);
+               err = vstrallocf(_("cannot find password for %s"), amdevice);
                goto common_exit;
            }
            lpass = strlen(user_and_password);
            if ((pwtext = strchr(user_and_password, '%')) == NULL) {
-               err = stralloc2("password field not \'user%pass\' for ", amdevice);
+               err = vstrallocf(_("password field not \'user%%pass\' for %s"), amdevice);
                goto common_exit;
            }
            *pwtext++ = '\0';
            pwtext_len = (size_t)strlen(pwtext);
            amfree(device);
            if ((device = makesharename(share, 0)) == NULL) {
-               err = stralloc2("cannot make share name of ", share);
+               err = vstrallocf(_("cannot make share name of %s"), share);
                goto common_exit;
            }
 
            if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
-               err = stralloc2("Cannot access /dev/null : ", strerror(errno));
+               err = vstrallocf(_("Cannot access /dev/null : %s"), strerror(errno));
                goto common_exit;
            }
 
@@ -611,11 +596,8 @@ check_disk(
            /*@ignore@*/
            if ((pwtext_len > 0)
              && fullwrite(passwdfd, pwtext, (size_t)pwtext_len) < 0) {
-               err = vstralloc("password write failed: ",
-                               amdevice,
-                               ": ",
-                               strerror(errno),
-                               NULL);
+               err = vstrallocf(_("password write failed: %s: %s"),
+                               amdevice, strerror(errno));
                aclose(passwdfd);
                goto common_exit;
            }
@@ -625,8 +607,8 @@ check_disk(
            aclose(passwdfd);
            ferr = fdopen(checkerr, "r");
            if (!ferr) {
-               printf("ERROR [Can't fdopen: %s]\n", strerror(errno));
-               error("Can't fdopen: %s", strerror(errno));
+               g_printf(_("ERROR [Can't fdopen: %s]\n"), strerror(errno));
+               error(_("Can't fdopen: %s"), strerror(errno));
                /*NOTREACHED*/
            }
            sep = "";
@@ -644,38 +626,31 @@ check_disk(
            afclose(ferr);
            checkerr = -1;
            rc = 0;
+           sep = "";
            while ((wpid = wait(&retstat)) != -1) {
-               if (WIFSIGNALED(retstat)) {
-                   ret = 0;
-                   rc = sig = WTERMSIG(retstat);
-               } else {
-                   sig = 0;
-                   rc = ret = WEXITSTATUS(retstat);
-               }
-               if (rc != 0) {
-                   strappend(err, sep);
-                   if (ret == 0) {
-                       strappend(err, "got signal ");
-                       ret = sig;
-                   } else {
-                       strappend(err, "returned ");
-                   }
-                   snprintf(number, (size_t)sizeof(number), "%d", ret);
-                   strappend(err, number);
+               if (!WIFEXITED(retstat) || WEXITSTATUS(retstat) != 0) {
+                   char *exitstr = str_exit_status("smbclient", retstat);
+                   err = newvstralloc(err, err, sep, exitstr);
+                   sep = "\n";
+                   amfree(exitstr);
+
+                   rc = 1;
                }
            }
            if (errdos != 0 || rc != 0) {
-               err = newvstralloc(err,
-                                  "samba access error: ",
-                                  amdevice,
-                                  ": ",
-                                  extra_info ? extra_info : "",
-                                  err,
-                                  NULL);
-               amfree(extra_info);
+               if (extra_info) {
+                   err = newvstrallocf(err,
+                                  _("samba access error: %s: %s %s"),
+                                  amdevice, extra_info, err);
+                   amfree(extra_info);
+               } else {
+                   err = newvstrallocf(err, _("samba access error: %s: %s"),
+                                  amdevice, err);
+               }
            }
 #else
-           err = stralloc2("This client is not configured for samba: ", qdisk);
+           err = vstrallocf(_("This client is not configured for samba: %s"),
+                       qdisk);
 #endif
            goto common_exit;
        }
@@ -684,10 +659,9 @@ check_disk(
        device = amname_to_dirname(amdevice);
     } else if (strcmp(myprogram, "DUMP") == 0) {
        if(amdevice[0] == '/' && amdevice[1] == '/') {
-           err = vstralloc("The DUMP program cannot handle samba shares,",
-                           " use GNUTAR: ",
-                           qdisk,
-                           NULL);
+           err = vstrallocf(
+                 _("The DUMP program cannot handle samba shares, use GNUTAR: %s"),
+                 qdisk);
            goto common_exit;
        }
 #ifdef VDUMP                                                           /* { */
@@ -712,35 +686,92 @@ check_disk(
 #endif
        }
     }
-    else { /* program_is_wrapper==1 */
-       pid_t pid_wrapper;
-       fflush(stdout);fflush(stdin);
-       switch (pid_wrapper = fork()) {
+    else { /* program_is_backup_api==1 */
+       pid_t  backup_api_pid;
+       int    property_pipe[2];
+       backup_support_option_t *bsu;
+
+       bsu = backup_support_option(program, g_options, disk, amdevice);
+
+       if (pipe(property_pipe) < 0) {
+           err = vstrallocf(_("pipe failed: %s"), strerror(errno));
+           goto common_exit;
+       }
+       fflush(stdout);fflush(stderr);
+       
+       switch (backup_api_pid = fork()) {
        case -1:
-           printf("ERROR [fork: %s]\n", strerror(errno));
-           error("fork: %s", strerror(errno));
-           /*NOTREACHED*/
+           err = vstrallocf(_("fork failed: %s"), strerror(errno));
+           goto common_exit;
 
        case 0: /* child */
            {
-               char *argvchild[6];
+               char *argvchild[14];
                char *cmd = vstralloc(DUMPER_DIR, "/", program, NULL);
-               argvchild[0] = program;
-               argvchild[1] = "selfcheck";
-               argvchild[2] = disk;
-               argvchild[3] = amdevice;
-               argvchild[4] = optstr;
-               argvchild[5] = NULL;
+               int j=0;
+               argvchild[j++] = program;
+               argvchild[j++] = "selfcheck";
+               if (bsu->message_line == 1) {
+                   argvchild[j++] = "--message";
+                   argvchild[j++] = "line";
+               }
+               if (g_options->config != NULL && bsu->config == 1) {
+                   argvchild[j++] = "--config";
+                   argvchild[j++] = g_options->config;
+               }
+               if (g_options->hostname != NULL && bsu->host == 1) {
+                   argvchild[j++] = "--host";
+                   argvchild[j++] = g_options->hostname;
+               }
+               if (disk != NULL && bsu->disk == 1) {
+                   argvchild[j++] = "--disk";
+                   argvchild[j++] = disk;
+               }
+               argvchild[j++] = "--device";
+               argvchild[j++] = amdevice;
+               if(options && options->createindex && bsu->index_line == 1) {
+                   argvchild[j++] = "--index";
+                   argvchild[j++] = "line";
+               }
+               if (!options->no_record && bsu->record == 1) {
+                   argvchild[j++] = "--record";
+               }
+               argvchild[j++] = NULL;
+               dup2(property_pipe[0], 0);
+               aclose(property_pipe[1]);
+               safe_fd(-1, 0);
                execve(cmd,argvchild,safe_env());
+               g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
                exit(127);
            }
        default: /* parent */
            {
                int status;
-               waitpid(pid_wrapper, &status, 0);
+               aclose(property_pipe[0]);
+               toolin = fdopen(property_pipe[1],"w");
+               if (!toolin) {
+                   err = vstrallocf(_("Can't fdopen: %s"), strerror(errno));
+                   goto common_exit;
+               }
+               output_tool_property(toolin, options);
+               fflush(toolin);
+               fclose(toolin);
+               if (waitpid(backup_api_pid, &status, 0) < 0) {
+                   if (!WIFEXITED(status)) {
+                       err = vstrallocf(_("Tool exited with signal %d"),
+                                        WTERMSIG(status));
+                   } else if (WEXITSTATUS(status) != 0) {
+                       err = vstrallocf(_("Tool exited with status %d"),
+                                        WEXITSTATUS(status));
+                   } else {
+                       err = vstrallocf(_("waitpid returned negative value"));
+                   }
+                   goto common_exit;
+               }
            }
        }
-       fflush(stdout);fflush(stdin);
+       amfree(bsu);
+       fflush(stdout);fflush(stderr);
        amfree(device);
        amfree(qamdevice);
        amfree(qdisk);
@@ -748,10 +779,10 @@ check_disk(
     }
 
     qdevice = quote_string(device);
-    dbprintf(("%s: device %s\n", debug_prefix_time(NULL), qdevice));
+    dbprintf(_("device %s\n"), qdevice);
 
     /* skip accessability test if this is an AFS entry */
-    if(strncmp(device, "afs:", 4) != 0) {
+    if(strncmp_const(device, "afs:") != 0) {
 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
        access_result = open(device, O_RDONLY);
        access_type = "open";
@@ -760,8 +791,8 @@ check_disk(
        access_type = "access";
 #endif
        if(access_result == -1) {
-           err = vstralloc("could not ", access_type, " ", qdevice,
-                       " (", qdisk, "): ", strerror(errno), NULL);
+           err = vstrallocf(_("Could not access %s (%s): %s"),
+                       qdevice, qdisk, strerror(errno));
        }
 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
        aclose(access_result);
@@ -779,20 +810,19 @@ common_exit:
     amfree(domain);
 
     if(err) {
-       printf("ERROR [%s]\n", err);
-       dbprintf(("%s: %s\n", debug_prefix_time(NULL), err));
+       g_printf(_("ERROR [%s]\n"), err);
+       dbprintf(_("%s\n"), err);
        amfree(err);
     } else {
-       printf("OK %s\n", qdisk);
-       dbprintf(("%s: disk %s OK\n", debug_prefix_time(NULL), qdisk));
-       printf("OK %s\n", qamdevice);
-       dbprintf(("%s: amdevice %s OK\n",
-                 debug_prefix_time(NULL), qamdevice));
-       printf("OK %s\n", qdevice);
-       dbprintf(("%s: device %s OK\n", debug_prefix_time(NULL), qdevice));
+       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(extra_info) {
-       dbprintf(("%s: extra info: %s\n", debug_prefix_time(NULL), extra_info));
+       dbprintf(_("extra info: %s\n"), extra_info);
        amfree(extra_info);
     }
     amfree(qdisk);
@@ -814,7 +844,7 @@ check_overall(void)
 
     if( need_runtar )
     {
-       cmd = vstralloc(libexecdir, "/", "runtar", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "runtar", versionsuffix(), NULL);
        check_file(cmd,X_OK);
        check_suid(cmd);
        amfree(cmd);
@@ -822,7 +852,7 @@ check_overall(void)
 
     if( need_rundump )
     {
-       cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "rundump", versionsuffix(), NULL);
        check_file(cmd,X_OK);
        check_suid(cmd);
        amfree(cmd);
@@ -832,7 +862,7 @@ check_overall(void)
 #ifdef DUMP
        check_file(DUMP, X_OK);
 #else
-       printf("ERROR [DUMP program not available]\n");
+       g_printf(_("ERROR [DUMP program not available]\n"));
 #endif
     }
 
@@ -840,7 +870,7 @@ check_overall(void)
 #ifdef RESTORE
        check_file(RESTORE, X_OK);
 #else
-       printf("ERROR [RESTORE program not available]\n");
+       g_printf(_("ERROR [RESTORE program not available]\n"));
 #endif
     }
 
@@ -848,7 +878,7 @@ check_overall(void)
 #ifdef VDUMP
        check_file(VDUMP, X_OK);
 #else
-       printf("ERROR [VDUMP program not available]\n");
+       g_printf(_("ERROR [VDUMP program not available]\n"));
 #endif
     }
 
@@ -856,7 +886,7 @@ check_overall(void)
 #ifdef VRESTORE
        check_file(VRESTORE, X_OK);
 #else
-       printf("ERROR [VRESTORE program not available]\n");
+       g_printf(_("ERROR [VRESTORE program not available]\n"));
 #endif
     }
 
@@ -864,7 +894,7 @@ check_overall(void)
 #ifdef XFSDUMP
        check_file(XFSDUMP, F_OK);
 #else
-       printf("ERROR [XFSDUMP program not available]\n");
+       g_printf(_("ERROR [XFSDUMP program not available]\n"));
 #endif
     }
 
@@ -872,7 +902,7 @@ check_overall(void)
 #ifdef XFSRESTORE
        check_file(XFSRESTORE, X_OK);
 #else
-       printf("ERROR [XFSRESTORE program not available]\n");
+       g_printf(_("ERROR [XFSRESTORE program not available]\n"));
 #endif
     }
 
@@ -880,7 +910,7 @@ check_overall(void)
 #ifdef VXDUMP
        check_file(VXDUMP, X_OK);
 #else
-       printf("ERROR [VXDUMP program not available]\n");
+       g_printf(_("ERROR [VXDUMP program not available]\n"));
 #endif
     }
 
@@ -888,7 +918,7 @@ check_overall(void)
 #ifdef VXRESTORE
        check_file(VXRESTORE, X_OK);
 #else
-       printf("ERROR [VXRESTORE program not available]\n");
+       g_printf(_("ERROR [VXRESTORE program not available]\n"));
 #endif
     }
 
@@ -896,10 +926,10 @@ check_overall(void)
 #ifdef GNUTAR
        check_file(GNUTAR, X_OK);
 #else
-       printf("ERROR [GNUTAR program not available]\n");
+       g_printf(_("ERROR [GNUTAR program not available]\n"));
 #endif
        need_amandates = 1;
-       gnutar_list_dir = client_getconf_str(CLN_GNUTAR_LIST_DIR);
+       gnutar_list_dir = getconf_str(CNF_GNUTAR_LIST_DIR);
        if (strlen(gnutar_list_dir) == 0)
            gnutar_list_dir = NULL;
        if (gnutar_list_dir) 
@@ -908,13 +938,13 @@ check_overall(void)
 
     if (need_amandates) {
        char *amandates_file;
-       amandates_file = client_getconf_str(CLN_AMANDATES);
+       amandates_file = getconf_str(CNF_AMANDATES);
        check_file(amandates_file, R_OK|W_OK);
     }
     if( need_calcsize ) {
        char *cmd;
 
-       cmd = vstralloc(libexecdir, "/", "calcsize", versionsuffix(), NULL);
+       cmd = vstralloc(amlibexecdir, "/", "calcsize", versionsuffix(), NULL);
 
        check_file(cmd, X_OK);
 
@@ -925,23 +955,23 @@ check_overall(void)
 #ifdef SAMBA_CLIENT
        check_file(SAMBA_CLIENT, X_OK);
 #else
-       printf("ERROR [SMBCLIENT program not available]\n");
+       g_printf(_("ERROR [SMBCLIENT program not available]\n"));
 #endif
        testfd = open("/etc/amandapass", R_OK);
        if (testfd >= 0) {
            if(fstat(testfd, &buf) == 0) {
                if ((buf.st_mode & 0x7) != 0) {
-                   printf("ERROR [/etc/amandapass is world readable!]\n");
+                   g_printf(_("ERROR [/etc/amandapass is world readable!]\n"));
                } else {
-                   printf("OK [/etc/amandapass is readable, but not by all]\n");
+                   g_printf(_("OK [/etc/amandapass is readable, but not by all]\n"));
                }
            } else {
-               printf("OK [unable to stat /etc/amandapass: %s]\n",
+               g_printf(_("OK [unable to stat /etc/amandapass: %s]\n"),
                       strerror(errno));
            }
            aclose(testfd);
        } else {
-           printf("ERROR [unable to open /etc/amandapass: %s]\n",
+           g_printf(_("ERROR [unable to open /etc/amandapass: %s]\n"),
                   strerror(errno));
        }
     }
@@ -961,7 +991,7 @@ check_overall(void)
        } 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));
+               g_printf(_("ERROR [dump will not be able to create the /etc/dumpdates file: %s]\n"), strerror(errno));
            }
 #endif
        }
@@ -988,19 +1018,29 @@ check_space(
     char *     dir,
     off_t      kbytes)
 {
-    generic_fs_stats_t statp;
+    struct fs_usage fsusage;
     char *quoted = quote_string(dir);
+    intmax_t kb_avail;
+
+    if(get_fs_usage(dir, NULL, &fsusage) == -1) {
+       g_printf(_("ERROR [cannot get filesystem usage for %s: %s]\n"), quoted, strerror(errno));
+       amfree(quoted);
+       return;
+    }
+
+    /* do the division first to avoid potential integer overflow */
+    kb_avail = fsusage.fsu_bavail / 1024 * fsusage.fsu_blocksize;
 
-    if(get_fs_stats(dir, &statp) == -1) {
-       printf("ERROR [cannot statfs %s: %s]\n", quoted, strerror(errno));
-    } else if(statp.avail < kbytes) {
-       printf("ERROR [dir %s needs " OFF_T_FMT "KB, only has "
-               OFF_T_FMT "KB available.]\n", quoted,
-               (OFF_T_FMT_TYPE)kbytes,
-               (OFF_T_FMT_TYPE)statp.avail);
+    if (fsusage.fsu_bavail_top_bit_set || fsusage.fsu_bavail == 0) {
+       g_printf(_("ERROR [dir %s needs %lldKB, has nothing available.]\n"), quoted,
+               (long long)kbytes);
+    } else if (kb_avail < kbytes) {
+       g_printf(_("ERROR [dir %s needs %lldKB, only has %lldKB available.]\n"), quoted,
+               (long long)kbytes,
+               (long long)kb_avail);
     } else {
-       printf("OK %s has more than " OFF_T_FMT " KB available.\n",
-               quoted, (OFF_T_FMT_TYPE)kbytes);
+       g_printf(_("OK %s has more than %lldKB available.\n"),
+               quoted, (long long)kbytes);
     }
     amfree(quoted);
 }
@@ -1023,9 +1063,9 @@ check_access(
        noun = "access", adjective = "accessible";
 
     if(access(filename, mode) == -1)
-       printf("ERROR [can not %s %s: %s]\n", noun, quoted, strerror(errno));
+       g_printf(_("ERROR [can not %s %s: %s]\n"), noun, quoted, strerror(errno));
     else
-       printf("OK %s %s\n", quoted, adjective);
+       g_printf(_("OK %s %s\n"), quoted, adjective);
     amfree(quoted);
 }
 
@@ -1054,7 +1094,7 @@ check_file(
     if(!stat(filename, &stat_buf)) {
        if(!S_ISREG(stat_buf.st_mode)) {
            quoted = quote_string(filename);
-           printf("ERROR [%s is not a file]\n", quoted);
+           g_printf(_("ERROR [%s is not a file]\n"), quoted);
            amfree(quoted);
        }
     }
@@ -1073,7 +1113,7 @@ check_dir(
     if(!stat(dirname, &stat_buf)) {
        if(!S_ISDIR(stat_buf.st_mode)) {
            quoted = quote_string(dirname);
-           printf("ERROR [%s is not a directory]\n", quoted);
+           g_printf(_("ERROR [%s is not a directory]\n"), quoted);
            amfree(quoted);
        }
     }
@@ -1086,21 +1126,20 @@ static void
 check_suid(
     char *     filename)
 {
-/* The following is only valid for real Unixs */
-#ifndef IGNORE_UID_CHECK
+#ifndef SINGLE_USERID
     struct stat stat_buf;
     char *quoted = quote_string(filename);
 
     if(!stat(filename, &stat_buf)) {
        if(stat_buf.st_uid != 0 ) {
-           printf("ERROR [%s is not owned by root]\n", quoted);
+           g_printf(_("ERROR [%s is not owned by root]\n"), quoted);
        }
        if((stat_buf.st_mode & S_ISUID) != S_ISUID) {
-           printf("ERROR [%s is not SUID root]\n", quoted);
+           g_printf(_("ERROR [%s is not SUID root]\n"), quoted);
        }
     }
     else {
-       printf("ERROR [can not stat %s]\n", quoted);
+       g_printf(_("ERROR [can not stat %s]\n"), quoted);
     }
     amfree(quoted);
 #else