Changeset 1179


Ignore:
Timestamp:
Feb 18, 2007, 4:12:25 PM (13 years ago)
Author:
bruno
Message:

Merge trunk modifications for libmondo-verify.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-verify.c

    r1123 r1179  
    1 /*
    2  * $Id$
    3 */
    4 
     1/* $Id$ */
    52/**
    63 * @file
    74 * Functions for verifying backups (booted from hard drive, not CD).
    85 */
     6
     7#include <unistd.h>
    98
    109#include "my-stuff.h"
    1110#include "mr_mem.h"
    1211#include "mr_msg.h"
     12
    1313#include "mondostructures.h"
    1414#include "libmondo-verify.h"
    15 #include "libmondo-gui-EXT.h"
     15#include "newt-specific-EXT.h"
    1616#include "libmondo-files-EXT.h"
    1717#include "libmondo-fork-EXT.h"
     
    5151{
    5252    /*@ buffer ********************************************************** */
    53     char *command;
    54     char *afio_found_changes;
     53    char *command = NULL;
     54    char *afio_found_changes = NULL;
    5555
    5656    /*@ int ************************************************************* */
     
    6060    long afio_diffs = 0;
    6161
    62     command = mr_malloc(2000);
    63     afio_found_changes = mr_malloc(500);
    6462    assert_string_is_neither_NULL_nor_zerolength(changedfiles_fname);
    6563    assert_string_is_neither_NULL_nor_zerolength(ignorefiles_fname);
    6664    assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
    6765
    68     sprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
    69     paranoid_system("sync");
    70 
    71 /*  sprintf (command,
    72        "grep \"afio: \" %s | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort -u | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
    73        stderr_fname, afio_found_changes);
    74 */
     66    mr_asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
     67    sync();
     68
    7569
    7670    mr_msg(1, "Now scanning log file for 'afio: ' stuff");
    77     sprintf(command,
    78             "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s",
    79             stderr_fname, afio_found_changes);
     71    mr_asprintf(&command,
     72             "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s",
     73             stderr_fname, afio_found_changes);
    8074    mr_msg(2, command);
    8175    res = system(command);
     76    mr_free(command);
    8277    if (res) {
    8378        mr_msg(2, "Warning - failed to think");
     
    8580
    8681    mr_msg(1, "Now scanning log file for 'star: ' stuff");
    87     sprintf(command,
    88             "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s",
    89             stderr_fname, afio_found_changes);
     82    mr_asprintf(&command,
     83             "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s",
     84             stderr_fname, afio_found_changes);
    9085    mr_msg(2, command);
    9186    res = system(command);
     87    mr_free(command);
    9288    if (res) {
    9389        mr_msg(2, "Warning - failed to think");
     
    9591//  exclude_nonexistent_files (afio_found_changes);
    9692    afio_diffs = count_lines_in_file(afio_found_changes);
    97     sprintf(command,
    98             "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    99             ignorefiles_fname, afio_found_changes, afio_found_changes,
    100             changedfiles_fname);
     93    mr_asprintf(&command,
     94             "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
     95             ignorefiles_fname, afio_found_changes, afio_found_changes,
     96             changedfiles_fname);
    10197    mr_msg(2, command);
    10298    paranoid_system(command);
     
    122118
    123119    /*@ buffers ********************************************************* */
    124     char *tmp;
     120    char *tmp = NULL;
    125121
    126122    /*@ int ************************************************************* */
     
    132128    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    133129    assert(bkpinfo != NULL);
    134     malloc_string(tmp);
    135130
    136131    for (set_number = 0;
     
    150145        } else {
    151146            retval++;
    152             sprintf(tmp, "Warning - missing set(s) between %d and %d\n",
    153                     g_last_afioball_number, set_number - 1);
     147            mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",
     148                     g_last_afioball_number, set_number - 1);
    154149            log_to_screen(tmp);
    155         }
    156     }
    157     sprintf(tmp, "Verifying %s #%d's tarballs",
    158             media_descriptor_string(bkpinfo->backup_media_type),
    159             g_current_media_number);
     150            mr_free(tmp);
     151        }
     152    }
     153    mr_asprintf(&tmp, "Verifying %s #%d's tarballs",
     154             bkpinfo->backup_media_string,
     155             g_current_media_number);
    160156    open_evalcall_form(tmp);
     157    mr_free(tmp);
    161158
    162159    for (total_sets = set_number;
     
    180177    g_last_afioball_number = set_number - 1;
    181178    close_evalcall_form();
    182     mr_free(tmp);
    183179    return (retval);
    184180}
     
    190186 * - @c restore_path
    191187 * - @c use_lzo
    192  * - @c zip_exe
    193188 * - @c zip_suffix
    194189 * @param mtpt The mountpoint the CD/DVD/ISO is mounted on.
     
    199194
    200195    /*@ buffer ********************************************************** */
    201     char *tmp;
    202     char *mountpoint;
    203 //  char ca, cb;
    204     char *command;
    205     char *sz_exe;
     196    char *tmp = NULL;
     197    char *tmp2 = NULL;
     198    char *mountpoint = NULL;
     199    char *command = NULL;
     200    char *sz_exe = NULL;
    206201    static char *bufblkA = NULL;
    207202    static char *bufblkB = NULL;
    208203    const long maxbufsize = 65536L;
    209     long currsizA = 0;
    210     long currsizB = 0;
    211     long j;
    212 
    213     /*@ long ************************************************************ */
    214     long bigfile_num = 0;
     204    long currsizA = 0L;
     205    long currsizB = 0L;
     206    long j = 0L;
     207    long bigfile_num = 0L;
    215208    long slice_num = -1;
    216     int res;
     209    int res = 0;
    217210
    218211    static FILE *forig = NULL;
     
    220213    static long last_bigfile_num = -1;
    221214    static long last_slice_num = -1;
    222     FILE *pin;
    223     FILE *fin;
     215    FILE *pin = NULL;
     216    FILE *fin = NULL;
    224217    int retval = 0;
    225 //  long long outlen;
    226 
    227     malloc_string(tmp);
    228     malloc_string(mountpoint);
    229     malloc_string(command);
    230     malloc_string(sz_exe);
     218
    231219    if (!bufblkA) {
    232220        bufblkA = mr_malloc(maxbufsize);
     
    241229    if (bkpinfo->compression_level > 0) {
    242230        if (bkpinfo->use_lzo) {
    243             strcpy(sz_exe, "lzop");
     231            mr_asprintf(&sz_exe, "lzop");
    244232        } else if (bkpinfo->use_gzip) {
    245             strcpy(sz_exe, "gzip");
     233            mr_asprintf(&sz_exe, "gzip");
    246234        } else {
    247             strcpy(sz_exe, "bzip2");
     235            mr_asprintf(&sz_exe, "bzip2");
    248236        }
    249237    } else {
    250         sz_exe[0] = '\0';
     238        mr_asprintf(&sz_exe, "");
    251239    }
    252240
    253241    iamhere("before vsbf");
    254     sprintf(tmp, "Verifying %s#%d's big files",
    255             media_descriptor_string(bkpinfo->backup_media_type),
    256             g_current_media_number);
     242    mr_asprintf(&tmp, "Verifying %s#%d's big files",
     243             bkpinfo->backup_media_string,
     244             g_current_media_number);
    257245    open_evalcall_form(tmp);
     246    mr_free(tmp);
     247
    258248    iamhere("after vsbf");
    259     sprintf(mountpoint, "%s/archives", mtpt);
     249    mr_asprintf(&mountpoint, "%s/archives", mtpt);
    260250    if (last_bigfile_num == -1) {
    261251        bigfile_num = 0;
     
    291281                paranoid_fclose(fin);
    292282            }
    293             sprintf(tmp, "%s/%s", bkpinfo->restore_path,
    294                     biggiestruct.filename);
    295             mr_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    296             if (!(forig = fopen(tmp, "r"))) {
     283            mr_asprintf(&tmp2, "%s/%s", bkpinfo->restore_path,
     284                     biggiestruct.filename);
     285            mr_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp2);
     286            if (!(forig = fopen(tmp2, "r"))) {
    297287                mr_msg(2, "Failed to open bigfile. Darn.");
    298288                retval++;
    299289            }
     290            mr_free(tmp2);
     291
    300292            slice_num++;
    301293        } else if (does_file_exist
     
    310302                    g_current_media_number, bigfile_num, slice_num);
    311303            if (bkpinfo->compression_level > 0) {
    312                 sprintf(command, "%s -dc %s 2>> %s",
    313                         sz_exe,
     304                mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe,
    314305                        slice_fname(bigfile_num, slice_num, mountpoint,
    315306                                    bkpinfo->zip_suffix),
    316307                        MONDO_LOGFILE);
    317308            } else {
    318                 sprintf(command, "cat %s",
     309                mr_asprintf(&command, "cat %s",
    319310                        slice_fname(bigfile_num, slice_num, mountpoint,
    320311                                    bkpinfo->zip_suffix));
     
    356347                }
    357348            }
     349            mr_free(command);
    358350            slice_num++;
    359351        }
    360352    }
     353    mr_free(tmp);
     354    mr_free(mountpoint);
     355    mr_free(sz_exe);
     356
    361357    last_bigfile_num = bigfile_num;
    362358    last_slice_num = slice_num - 1;
     
    371367        mr_free(bufblkB);
    372368    }
    373     mr_free(tmp);
    374     mr_free(command);
    375     mr_free(sz_exe);
    376     mr_free(mountpoint);
    377369    return (0);
    378370}
    379 
    380 
    381 
    382 
    383371
    384372
     
    397385{
    398386    /*@ buffers ********************************************************* */
    399     char *command;
    400     char *outlog;
    401     char *tmp;
    402     //  char *p;
     387    char *command = NULL;
     388    char *outlog = NULL;
     389    char *tmp = NULL;
    403390
    404391    /*@ pointers ******************************************************* */
    405     FILE *pin;
     392    FILE *pin = NULL;
     393
     394    size_t n = 0;
    406395
    407396    /*@ long *********************************************************** */
    408397    long diffs = 0;
    409     /*  getcwd(old_pwd,MAX_STR_LEN-1); */
    410 
    411 
    412     command = mr_malloc(2000);
    413     malloc_string(outlog);
    414     malloc_string(tmp);
     398
    415399    assert(bkpinfo != NULL);
    416400    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    417401
    418402    log_it("Verifying fileset '%s'", tarball_fname);
    419     /*  chdir("/"); */
    420     sprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
    421 /* if programmer forgot to say which compression thingy to use then find out */
     403
     404    mr_asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);
     405
     406    /* if programmer forgot to say which compression thingy to use then find out */
    422407    if (strstr(tarball_fname, ".lzo")
    423408        && strcmp(bkpinfo->zip_suffix, "lzo")) {
     
    447432    if (strstr(tarball_fname, ".star")) {
    448433        bkpinfo->use_star = TRUE;
    449         if (strstr(tarball_fname, ".bz2"))
    450             sprintf(command,
    451                     "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
    452                     tarball_fname,
    453                     (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog,
    454                     outlog);
     434        if (strstr(tarball_fname, ".bz2")) {
     435            mr_asprintf(&command,
     436                     "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
     437                     tarball_fname,
     438                     (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog,
     439                     outlog);
     440        } else {
     441            mr_asprintf(&command,"");
     442        }
    455443    } else {
    456444        bkpinfo->use_star = FALSE;
    457         sprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s",
    458                 bkpinfo->zip_exe, tarball_fname, outlog, outlog);
     445        mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",
     446                 bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    459447    }
    460448    mr_msg(6, "command=%s", command);
    461449    paranoid_system(command);
     450    mr_free(command);
     451
    462452    if (length_of_file(outlog) < 10) {
    463         sprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
     453        /* BERLIOS: This seems useless !! */
     454        mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    464455    } else {
    465         sprintf(command, "cut -d: -f%d %s | sort -u",
    466                 (bkpinfo->use_star) ? 1 : 2, outlog);
     456        mr_asprintf(&command, "cut -d':' -f%d %s | sort -u",
     457                 (bkpinfo->use_star) ? 1 : 2, outlog);
    467458        pin = popen(command, "r");
    468459        if (pin) {
    469             for (fgets(tmp, MAX_STR_LEN, pin); !feof(pin);
    470                  fgets(tmp, MAX_STR_LEN, pin)) {
     460            for (mr_getline(&tmp, &n, pin); !feof(pin);
     461                 mr_getline(&tmp, &n, pin)) {
    471462                if (bkpinfo->use_star) {
    472463                    if (!strstr(tmp, "diffopts=")) {
     
    495486            }
    496487            paranoid_pclose(pin);
     488            mr_free(tmp);
    497489        } else {
    498490            log_OS_error(command);
    499491        }
    500492    }
    501     /*  chdir(old_pwd); */
    502     //  sprintf (tmp, "uniq -u %s >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
    503     //  paranoid_system (tmp);
    504     //  unlink ("/tmp/mondo-verify.err");
     493    mr_free(outlog);
    505494    mr_free(command);
    506     mr_free(outlog);
    507     mr_free(tmp);
     495
    508496    return (0);
    509497}
    510 
    511 
    512 
    513 
    514498
    515499
     
    561545
    562546    /*@ buffers ********************************************************** */
    563     char *tmp;
    564     char *tarball_fname;
     547    char *tmp = NULL;
     548    char *tarball_fname = NULL;
    565549
    566550    /*@ pointers ********************************************************* */
    567     char *p;
    568 
    569     malloc_string(tmp);
    570     malloc_string(tarball_fname);
     551    char *p = NULL;
     552
    571553    assert(bkpinfo != NULL);
    572554    assert_string_is_neither_NULL_nor_zerolength(orig_fname);
     
    578560        p++;
    579561    }
    580     sprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     562    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    581563    paranoid_system(tmp);
    582     sprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    583     sprintf(tmp, "Temporarily copying file from tape to '%s'",
    584             tarball_fname);
    585 /*  log_it(tmp); */
     564    mr_free(tmp);
     565
     566    mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    586567    read_file_from_stream_to_file(bkpinfo, tarball_fname, size);
    587568    res = verify_a_tarball(bkpinfo, tarball_fname);
    588569    if (res) {
    589         sprintf(tmp,
    590                 "Afioball '%s' no longer matches your live filesystem", p);
    591         mr_msg(0, tmp);
     570        mr_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
    592571        retval++;
    593572    }
    594573    unlink(tarball_fname);
    595     mr_free(tmp);
    596574    mr_free(tarball_fname);
    597575    return (retval);
     
    618596
    619597    /*@ char ************************************************************ */
    620     char *test_file;
    621     char *biggie_cksum;
    622     char *orig_cksum;
    623     char *tmp;
    624     char *slice_fnam;
     598    char *test_file = NULL;
     599    char *biggie_cksum = NULL;
     600    char *orig_cksum = NULL;
     601    char *tmp = NULL;
     602    char *slice_fnam = NULL;
    625603
    626604    /*@ pointers ******************************************************** */
     
    630608    long long slice_siz;
    631609
    632     malloc_string(test_file);
    633     malloc_string(biggie_cksum);
    634     malloc_string(orig_cksum);
    635     malloc_string(tmp);
    636610    malloc_string(slice_fnam);
    637611    assert(bkpinfo != NULL);
     
    644618        p++;
    645619    }
    646     sprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    647     sprintf(tmp,
    648             "Temporarily copying biggiefile %s's slices from tape to '%s'",
    649             p, test_file);
    650 /*  log_it(tmp); */
     620    mr_asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    651621    for (res =
    652622         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
     
    670640        retval += res;
    671641    }
    672     strcpy(biggie_cksum, slice_fnam);
     642    mr_free(test_file);
     643
     644    mr_asprintf(&biggie_cksum, slice_fnam);
     645    mr_free(slice_fnam);
     646
    673647    if (biggie_cksum[0] != '\0') {
    674         strcpy(orig_cksum, calc_checksum_of_file(biggie_fname));
     648        mr_asprintf(&orig_cksum, calc_checksum_of_file(biggie_fname));
    675649        if (strcmp(biggie_cksum, orig_cksum)) {
    676             sprintf(tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
    677                     orig_cksum);
     650            mr_asprintf(&tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
     651                     orig_cksum);
    678652            mr_msg(2, tmp);
    679             sprintf(tmp, "%s has changed on live filesystem",
    680                     biggie_fname);
     653            mr_free(tmp);
     654
     655            mr_asprintf(&tmp, _("%s has changed on live filesystem"),
     656                     biggie_fname);
    681657            log_to_screen(tmp);
    682             sprintf(tmp, "echo \"%s\" >> /tmp/biggies.changed",
    683                     biggie_fname);
     658            mr_free(tmp);
     659
     660            mr_asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",
     661                     biggie_fname);
    684662            system(tmp);
    685         }
    686     }
    687     mr_free(test_file);
     663            mr_free(tmp);
     664        }
     665        mr_free(orig_cksum);
     666    }
    688667    mr_free(biggie_cksum);
    689     mr_free(orig_cksum);
    690     mr_free(tmp);
    691     mr_free(slice_fnam);
    692668    return (retval);
    693669}
     
    712688
    713689    /*@ buffers ***************************************************** */
    714     char *tmp;
    715     char *fname;
    716     char *curr_xattr_list_fname;
    717     char *curr_acl_list_fname;
     690    char *tmp = NULL;
     691    char *fname = NULL;
     692    char *curr_xattr_list_fname = NULL;
     693    char *curr_acl_list_fname = NULL;
    718694
    719695    /*@ long long *************************************************** */
     
    721697
    722698    assert(bkpinfo != NULL);
    723     malloc_string(tmp);
    724699    malloc_string(fname);
    725     malloc_string(curr_xattr_list_fname);
    726     malloc_string(curr_acl_list_fname);
    727700
    728701    if (g_getfattr) {
    729         sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
     702        mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    730703            bkpinfo->tmpdir);
    731704    }
    732705    if (g_getfacl) {
    733         sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
     706        mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    734707            bkpinfo->tmpdir);
    735708    }
    736     log_to_screen("Verifying regular archives on tape");
     709    log_to_screen(_("Verifying regular archives on tape"));
    737710    total_afioballs = get_last_filelist_number(bkpinfo) + 1;
    738     open_progress_form("Verifying filesystem",
    739                        "I am verifying archives against your live filesystem now.",
    740                        "Please wait. This may take a couple of hours.", "",
     711    open_progress_form(_("Verifying filesystem"),
     712                       _("I am verifying archives against your live filesystem now."),
     713                       _("Please wait. This may take a couple of hours."), "",
    741714                       total_afioballs);
    742715    res = read_header_block_from_stream(&size, fname, &ctrl_chr);
     
    754727        wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
    755728    }
     729    mr_free(curr_xattr_list_fname);
     730    mr_free(curr_acl_list_fname);
    756731
    757732    for (res = read_header_block_from_stream(&size, fname, &ctrl_chr);
     
    759734         res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
    760735        if (g_getfattr) {
    761             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     736            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    762737                bkpinfo->tmpdir, current_afioball_number);
    763738        }
    764739        if (g_getfacl) {
    765             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     740            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    766741                bkpinfo->tmpdir, current_afioball_number);
    767742        }
     
    773748                                          curr_acl_list_fname);
    774749        }
     750        mr_free(curr_xattr_list_fname);
     751        mr_free(curr_acl_list_fname);
     752
    775753        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    776754            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    777755        }
    778         sprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
    779         /*log_it(tmp); */
     756        mr_asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);
    780757        update_progress_form(tmp);
     758        mr_free(tmp);
     759
    781760        res = verify_an_afioball_from_stream(bkpinfo, fname, size);
    782761        if (res) {
    783             sprintf(tmp, "Afioball %ld differs from live filesystem",
    784                     current_afioball_number);
     762            mr_asprintf(&tmp, _("Afioball %ld differs from live filesystem"),
     763                     current_afioball_number);
    785764            log_to_screen(tmp);
     765            mr_free(tmp);
    786766        }
    787767        retval += res;
     
    795775    mr_msg(1, "All done with afioballs");
    796776    close_progress_form();
    797     mr_free(tmp);
    798777    mr_free(fname);
    799     mr_free(curr_xattr_list_fname);
    800     mr_free(curr_acl_list_fname);
    801778    return (retval);
    802779}
     
    823800
    824801    /*@ buffers ******************************************************** */
    825     char *tmp;
    826     char *orig_fname, *logical_fname;
    827     char *comment;
    828     char *curr_xattr_list_fname;
    829     char *curr_acl_list_fname;
     802    char *orig_fname = NULL;
     803    char *logical_fname = NULL;
     804    char *comment = NULL;
     805    char *curr_xattr_list_fname = NULL;
     806    char *curr_acl_list_fname = NULL;
    830807    /*@ pointers ******************************************************* */
    831     char *p;
     808    char *p = NULL;
    832809
    833810    /*@ long long size ************************************************* */
     
    835812
    836813    assert(bkpinfo != NULL);
    837     malloc_string(tmp);
    838814    malloc_string(orig_fname);
    839     malloc_string(logical_fname);
    840     malloc_string(comment);
    841     malloc_string(curr_xattr_list_fname);
    842     malloc_string(curr_acl_list_fname);
    843815
    844816    if (g_getfattr) {
    845         sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
     817        mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
    846818            bkpinfo->tmpdir);
    847819    }
    848820    if (g_getfacl) {
    849         sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
     821        mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
    850822            bkpinfo->tmpdir);
    851823    }
    852     sprintf(comment, "Verifying all bigfiles.");
     824    mr_asprintf(&comment, "Verifying all bigfiles.");
    853825    log_to_screen(comment);
    854     sprintf(tmp, "%s/biggielist.txt", bkpinfo->tmpdir);
    855 //  noof_biggiefiles = count_lines_in_file (tmp); // pointless
    856826    res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    857827    if (ctrl_chr != BLK_START_BIGGIEFILES) {
     
    864834        }
    865835    }
     836    mr_free(curr_xattr_list_fname);
     837    mr_free(curr_acl_list_fname);
     838
    866839    if (ctrl_chr != BLK_START_BIGGIEFILES) {
    867840        wrong_marker(BLK_START_BIGGIEFILES, ctrl_chr);
     
    869842    noof_biggiefiles = (long) size;
    870843    mr_msg(1, "noof_biggiefiles = %ld", noof_biggiefiles);
    871     open_progress_form("Verifying big files", comment,
    872                        "Please wait. This may take some time.", "",
     844    open_progress_form(_("Verifying big files"), comment,
     845                       _("Please wait. This may take some time."), "",
    873846                       noof_biggiefiles);
     847    mr_free(comment);
     848
    874849    for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    875850         ctrl_chr != BLK_STOP_BIGGIEFILES;
     
    886861            p++;
    887862        }
    888         sprintf(comment, "Verifying bigfile #%ld (%ld K)",
    889                 current_biggiefile_number, (long) size >> 10);
     863        mr_asprintf(&comment, _("Verifying bigfile #%ld (%ld K)"),
     864                 current_biggiefile_number, (long) size >> 10);
    890865        update_progress_form(comment);
    891         sprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
     866        mr_free(comment);
     867
     868        mr_asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path,
     869                 orig_fname);
    892870        res =
    893871            verify_a_biggiefile_from_stream(bkpinfo, logical_fname, size);
     872        mr_free(logical_fname);
    894873        retval += res;
    895874        current_biggiefile_number++;
     
    898877    close_progress_form();
    899878    mr_free(orig_fname);
    900     mr_free(logical_fname);
    901     mr_free(curr_xattr_list_fname);
    902     mr_free(curr_acl_list_fname);
    903     mr_free(comment);
    904     mr_free(tmp);
    905879    return (retval);
    906880}
     
    930904
    931905    /*@ buffers ******************************************************** */
    932     char *mountpoint;
    933     char *command;
    934     char *tmp;
    935     char *fname;
     906    char *mountpoint = NULL;
     907    char *command = NULL;
     908    char *tmp = NULL;
     909    char *fname = NULL;
    936910#ifdef __FreeBSD__
    937911    char mdd[32];
     
    943917#endif
    944918
    945     command = mr_malloc(2000);
    946     malloc_string(mountpoint);
    947     malloc_string(tmp);
    948     malloc_string(fname);
    949 
    950919    assert(bkpinfo != NULL);
    951920
    952     sprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
    953     sprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    954             bkpinfo->prefix, g_current_media_number);
     921    mr_asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);
     922    mr_asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
     923             bkpinfo->prefix, g_current_media_number);
    955924
    956925    mkdir(mountpoint, 1777);
    957926    sync();
    958927    if (!does_file_exist(fname)) {
    959         sprintf(tmp,
    960                 "%s not found; assuming you backed up to CD; verifying CD...",
    961                 fname);
     928        mr_asprintf(&tmp,
     929                 "%s not found; assuming you backed up to CD; verifying CD...",
     930                 fname);
    962931        mr_msg(2, tmp);
     932        mr_free(tmp);
     933
    963934        if (bkpinfo->manual_cd_tray) {
    964             popup_and_OK("Please push CD tray closed.");
     935            popup_and_OK(_("Please push CD tray closed."));
    965936        }
    966937        if (find_and_mount_actual_cd(bkpinfo, mountpoint)) {
    967             log_to_screen("failed to mount actual CD");
     938            log_to_screen(_("failed to mount actual CD"));
    968939            return (1);
    969940        }
    970941    } else {
    971         sprintf(tmp, "%s found; verifying ISO...", fname);
     942        mr_asprintf(&tmp, "%s found; verifying ISO...", fname);
     943        log_to_screen(tmp);
     944        mr_free(tmp);
    972945#ifdef __FreeBSD__
    973946        ret = 0;
     
    975948        mddevice = make_vn(fname);
    976949        if (ret) {
    977             sprintf(tmp, "make_vn of %s failed; unable to verify ISO\n",
    978                     fname);
     950            mr_asprintf(&tmp, _("make_vn of %s failed; unable to verify ISO\n"),
     951                     fname);
    979952            log_to_screen(tmp);
     953            mr_free(tmp);
    980954            return (1);
    981955        }
    982         sprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
     956        mr_asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);
    983957#else
    984         sprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname,
    985                 mountpoint);
     958        mr_asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname,
     959                 mountpoint);
    986960#endif
    987961        if (run_program_and_log_output(command, FALSE)) {
    988             sprintf(tmp, "%s failed; unable to mount ISO image\n",
    989                     command);
     962            mr_asprintf(&tmp, _("%s failed; unable to mount ISO image\n"),
     963                     command);
    990964            log_to_screen(tmp);
     965            mr_free(tmp);
     966            mr_free(command);
    991967            return (1);
    992968        }
     969        mr_free(command);
    993970    }
    994971    mr_msg(2, "OK, I've mounted the ISO/CD\n");
    995     sprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     972    mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    996973    if (!does_file_exist(tmp)) {
    997974        mr_msg
     
    1005982*/
    1006983    }
     984    mr_free(tmp);
     985
    1007986    verify_afioballs_on_CD(bkpinfo, mountpoint);
    1008987    iamhere("before verify_all_slices");
    1009988    verify_all_slices_on_CD(bkpinfo, mountpoint);
    1010989
     990    mr_asprintf(&command, "umount %s", mountpoint);
    1011991#ifdef __FreeBSD__
    1012992    ret = 0;
    1013     sprintf(command, "umount %s", mountpoint);
    1014993    ret += system(command);
    1015994    ret += kick_vn(mddevice);
    1016995    if (ret)
    1017996#else
    1018     sprintf(command, "umount %s", mountpoint);
    1019997    if (system(command))
    1020998#endif
    1021999    {
    1022         sprintf(tmp, "%s failed; unable to unmount ISO image\n", command);
     1000        mr_asprintf(&tmp, "%s failed; unable to unmount ISO image\n",
     1001                 command);
    10231002        log_to_screen(tmp);
     1003        mr_free(tmp);
    10241004        retval++;
    10251005    } else {
    10261006        mr_msg(2, "OK, I've unmounted the ISO file\n");
    10271007    }
     1008    mr_free(command);
     1009    mr_free(mountpoint);
     1010
    10281011    if (!does_file_exist(fname)) {
    1029         sprintf(command, "umount %s", bkpinfo->media_device);
     1012        mr_asprintf(&command, "umount %s", bkpinfo->media_device);
    10301013        run_program_and_log_output(command, 2);
     1014        mr_free(command);
     1015
    10311016        if (!bkpinfo->please_dont_eject
    10321017            && eject_device(bkpinfo->media_device)) {
     
    10341019        }
    10351020    }
    1036     mr_free(command);
    1037     mr_free(mountpoint);
    1038     mr_free(tmp);
    10391021    mr_free(fname);
    10401022    return (retval);
    10411023}
     1024
    10421025
    10431026/**
     
    10551038
    10561039    /*@ buffers ******************************************************** */
    1057     char tmp[MAX_STR_LEN];
    1058     char changed_files_fname[MAX_STR_LEN];
     1040    char *tmp = NULL;
     1041    char *changed_files_fname = NULL;
    10591042
    10601043    /*@ long *********************************************************** */
     
    10641047
    10651048    mr_msg(3, "verify_tape_backups --- starting");
    1066     log_to_screen("Verifying backups");
     1049    log_to_screen(_("Verifying backups"));
    10671050    openin_tape(bkpinfo);
    1068 /* verify archives themselves */
     1051
     1052    /* verify archives themselves */
    10691053    retval += verify_afioballs_from_stream(bkpinfo);
    10701054    retval += verify_biggiefiles_from_stream(bkpinfo);
    1071 /* find the final blocks */
    1072     paranoid_system("sync");
     1055
     1056    /* find the final blocks */
     1057    sync();
    10731058    sleep(2);
    10741059    closein_tape(bkpinfo);
    1075 /* close tape; exit */
    1076 //  fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
     1060
     1061    /* close tape; exit */
    10771062    paranoid_system
    10781063        ("rm -f /tmp/biggies.changed /tmp/changed.files.[0-9]* 2> /dev/null");
    1079     sprintf(changed_files_fname, "/tmp/changed.files.%d",
    1080             (int) (random() % 32767));
    1081     sprintf(tmp,
    1082             "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s",
    1083             (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
    1084             changed_files_fname);
     1064    mr_asprintf(&changed_files_fname, "/tmp/changed.files.%d",
     1065             (int) (random() % 32767));
     1066    mr_asprintf(&tmp,
     1067             "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s",
     1068             (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
     1069             changed_files_fname);
    10851070    mr_msg(2, "Running command to derive list of changed files");
    10861071    mr_msg(2, tmp);
     
    10891074            && length_of_file(changed_files_fname) > 2) {
    10901075            log_to_screen
    1091                 ("Warning - unable to check logfile to derive list of changed files");
     1076                (_("Warning - unable to check logfile to derive list of changed files"));
    10921077        } else {
    10931078            log_to_screen
    1094                 ("No differences found. Therefore, no 'changed.files' text file.");
    1095         }
    1096     }
    1097     sprintf(tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);
     1079                (_("No differences found. Therefore, no 'changed.files' text file."));
     1080        }
     1081    }
     1082    mr_free(tmp);
     1083
     1084    mr_asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);
    10981085    paranoid_system(tmp);
     1086    mr_free(tmp);
    10991087
    11001088    diffs = count_lines_in_file(changed_files_fname);
    11011089    if (diffs > 0) {
    1102         sprintf(tmp, "cp -f %s %s", changed_files_fname,
    1103                 "/tmp/changed.files");
     1090        mr_asprintf(&tmp, "cp -f %s %s", changed_files_fname,
     1091                 "/tmp/changed.files");
    11041092        run_program_and_log_output(tmp, FALSE);
    1105         sprintf(tmp,
    1106                 "%ld files differed from live filesystem; type less %s or less %s to see",
    1107                 diffs, changed_files_fname, "/tmp/changed.files");
     1093        mr_free(tmp);
     1094
     1095        mr_asprintf(&tmp,
     1096                 "%ld files differed from live filesystem; type less %s or less %s to see",
     1097                 diffs, changed_files_fname, "/tmp/changed.files");
    11081098        mr_msg(0, tmp);
     1099        mr_free(tmp);
     1100
    11091101        log_to_screen
    1110             ("See /tmp/changed.files for a list of nonmatching files.");
     1102            (_("See /tmp/changed.files for a list of nonmatching files."));
    11111103        log_to_screen
    1112             ("The files probably changed on filesystem, not on backup media.");
     1104            (_("The files probably changed on filesystem, not on backup media."));
    11131105        //      retval++;
    11141106    }
     1107    mr_free(changed_files_fname);
    11151108    return (retval);
    11161109}
    1117 
    11181110
    11191111
Note: See TracChangeset for help on using the changeset viewer.