Ignore:
Timestamp:
Sep 27, 2007, 12:21:18 PM (17 years ago)
Author:
Bruno Cornec
Message:
  • Fix bug #197 (based on an initial patch of Scott Cummings)
  • Fix a bug where df was using locale to print messages and wasn't filtered correctly
  • mkdtemp checked in configure
  • reset_bkpinfo called as early as possible by both main program.
  • It creates a tmpdir cleanly with mkdtemp in setup_tmpdir subfunction, which takes in account TMPIR and TMP env var. Remains to see what tmpfs does and tests
  • configure.in should also be filtered.
  • Remove g_bkpinfo_DONTUSETHIS
  • remove bkpinfo also from header files
  • Render bkpinfo global (potential issue on thread, but should not be a problem as that structure is indeed static during archive)
  • Apply patch from Andree Leidenfrost, modified a bit to use bkpinfo->tmpdir instead of /tmp or MINDI_CACHE when appropriate. Fix security issues in mondo. Thanks al ot Andree for catching all those issues.
  • /tmp => /var/log for mondorestore.log in mindi
  • Update linux terminfo to fix a color issue (Andree Leidenfrost)
  • Removes useless log file (Andree Leidenfrost)
  • replace vi with find_my_editor during restore (Andree Leidenfrost)
  • sync in bg in mindi (VMWare issue to look at)
  • mindi/mindi-busybox have a different version than mondo for pb
  • PB-SUF also added to spec file
  • Fix a bug for pb build (omission of PB-SUF declaration)

(merge -r1631:1662 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

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

    r1609 r1663  
    2525//static char cvsid[] = "$Id$";
    2626
    27 char *vfy_tball_fname(struct s_bkpinfo *, char *, int);
    28 
    29 
    3027/**
    3128 * The number of the most recently verified afioball.
     
    3734extern char *g_getfattr;
    3835extern char *MONDO_LOGFILE;
     36
     37/* Reference to global bkpinfo */
     38extern struct s_bkpinfo *bkpinfo;
     39
     40
     41/**
     42 * Generate the filename of a tarball to verify.
     43 * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used.
     44 * @param mountpoint The directory where the CD/DVD/ISO is mounted.
     45 * @param setno The afioball number to get the location of.
     46 * @return The absolute path to the afioball.
     47 * @note The returned string points to static data that will be overwritten with each call.
     48 * @ingroup stringGroup
     49 */
     50char *vfy_tball_fname(char *mountpoint, int setno)
     51{
     52    /*@ buffers ******************************************************* */
     53    static char output[MAX_STR_LEN];
     54
     55    assert(bkpinfo != NULL);
     56    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
     57    sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno,
     58            bkpinfo->zip_suffix);
     59    if (!does_file_exist(output)) {
     60        sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno,
     61                bkpinfo->zip_suffix);
     62    }
     63    return (output);
     64}
     65
    3966
    4067/**
     
    116143 * @return The number of sets containing differences (0 for success).
    117144 */
    118 int verify_afioballs_on_CD(struct s_bkpinfo *bkpinfo, char *mountpoint)
     145int verify_afioballs_on_CD(char *mountpoint)
    119146{
    120147
     
    134161         set_number < 9999
    135162         &&
    136          !does_file_exist(vfy_tball_fname
    137                           (bkpinfo, mountpoint, set_number));
     163         !does_file_exist(vfy_tball_fname(mountpoint, set_number));
    138164         set_number++);
    139     if (!does_file_exist(vfy_tball_fname(bkpinfo, mountpoint, set_number))) {
     165    if (!does_file_exist(vfy_tball_fname(mountpoint, set_number))) {
    140166        return (0);
    141167    }
     
    160186
    161187    for (total_sets = set_number;
    162          does_file_exist(vfy_tball_fname(bkpinfo, mountpoint, total_sets));
     188         does_file_exist(vfy_tball_fname(mountpoint, total_sets));
    163189         total_sets++) {
    164190        mr_msg(1, "total_sets = %d", total_sets);
    165191    }
    166192    for (;
    167          does_file_exist(vfy_tball_fname(bkpinfo, mountpoint, set_number));
     193         does_file_exist(vfy_tball_fname(mountpoint, set_number));
    168194         set_number++) {
    169195        percentage =
     
    173199        mr_msg(1, "set = %d", set_number);
    174200        retval +=
    175             verify_an_afioball_from_CD(bkpinfo,
    176                                        vfy_tball_fname(bkpinfo, mountpoint,
    177                                                        set_number));
     201            verify_an_afioball_from_CD(vfy_tball_fname(mountpoint, set_number));
    178202    }
    179203    g_last_afioball_number = set_number - 1;
     
    192216 * @return The number of differences (0 for perfect biggiefiles).
    193217 */
    194 int verify_all_slices_on_CD(struct s_bkpinfo *bkpinfo, char *mtpt)
     218int verify_all_slices_on_CD(char *mtpt)
    195219{
    196220
     
    291315                            bkpinfo->restore_path,
    292316                            biggiestruct.filename);
    293                 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> /tmp/biggies.changed",
     317                mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed",
    294318                            bkpinfo->restore_path,
    295                             biggiestruct.filename);
     319                            biggiestruct.filename,
     320                            bkpinfo->tmpdir);
    296321                system(tmp);
    297322                mr_free(tmp);
     
    396421 * @return 0, always.
    397422 */
    398 int verify_a_tarball(struct s_bkpinfo *bkpinfo, char *tarball_fname)
     423int verify_a_tarball(char *tarball_fname)
    399424{
    400425    /*@ buffers ********************************************************* */
     
    522547 */
    523548int
    524 verify_an_afioball_from_CD(struct s_bkpinfo *bkpinfo, char *tarball_fname)
     549verify_an_afioball_from_CD(char *tarball_fname)
    525550{
    526551
     
    528553    int res = 0;
    529554
    530     assert(bkpinfo != NULL);
    531555    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    532556
     
    535559        fatal_error("Cannot verify nonexistent afioball");
    536560    }
    537     res = verify_a_tarball(bkpinfo, tarball_fname);
     561    res = verify_a_tarball(tarball_fname);
    538562    return (res);
    539563}
     
    550574 */
    551575int
    552 verify_an_afioball_from_stream(struct s_bkpinfo *bkpinfo, char *orig_fname,
    553                                long long size)
     576verify_an_afioball_from_stream(char *orig_fname, long long size)
    554577{
    555578
     
    579602
    580603    mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    581     read_file_from_stream_to_file(bkpinfo, tarball_fname, size);
    582     res = verify_a_tarball(bkpinfo, tarball_fname);
     604    read_file_from_stream_to_file(tarball_fname, size);
     605    res = verify_a_tarball(tarball_fname);
    583606    if (res) {
    584607        mr_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
     
    599622 */
    600623int
    601 verify_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo,
    602                                 char *biggie_fname, long long size)
     624verify_a_biggiefile_from_stream(char *biggie_fname, long long size)
    603625{
    604626
     
    642664            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    643665        }
    644         res = read_file_from_stream_to_file(bkpinfo, test_file, slice_siz);
     666        res = read_file_from_stream_to_file(test_file, slice_siz);
    645667        unlink(test_file);
    646668        res =
     
    672694            mr_free(tmp);
    673695
    674             mr_asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",
    675                      biggie_fname);
     696            mr_asprintf(&tmp, "echo \"%s\" >> %s/biggies.changed",
     697                    biggie_fname, bkpinfo->tmpdir);
    676698            system(tmp);
    677699            mr_free(tmp);
     
    692714 * @return 0 for success (even if there are differences); nonzero for a tape error.
    693715 */
    694 int verify_afioballs_from_stream(struct s_bkpinfo *bkpinfo)
     716int verify_afioballs_from_stream()
    695717{
    696718    /*@ int ********************************************************** */
     
    722744    }
    723745    log_to_screen(_("Verifying regular archives on tape"));
    724     total_afioballs = get_last_filelist_number(bkpinfo) + 1;
     746    total_afioballs = get_last_filelist_number() + 1;
    725747    open_progress_form(_("Verifying filesystem"),
    726748                       _("I am verifying archives against your live filesystem now."),
     
    733755        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    734756            res =
    735                 read_EXAT_files_from_tape(bkpinfo, &size, fname, &ctrl_chr,
     757                read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
    736758                                          curr_xattr_list_fname,
    737759                                          curr_acl_list_fname);
     
    758780            iamhere("Reading EXAT files from tape");
    759781            res =
    760                 read_EXAT_files_from_tape(bkpinfo, &size, fname, &ctrl_chr,
     782                read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
    761783                                          curr_xattr_list_fname,
    762784                                          curr_acl_list_fname);
     
    772794        mr_free(tmp);
    773795
    774         res = verify_an_afioball_from_stream(bkpinfo, fname, size);
     796        res = verify_an_afioball_from_stream(fname, size);
    775797        if (res) {
    776798            mr_asprintf(&tmp, _("Afioball %ld differs from live filesystem"),
     
    801823 * @return 0 for success (even if there are differences); nonzero for a tape error.
    802824 */
    803 int verify_biggiefiles_from_stream(struct s_bkpinfo *bkpinfo)
     825int verify_biggiefiles_from_stream()
    804826{
    805827
     
    843865            iamhere("Grabbing the EXAT biggiefiles");
    844866            res =
    845                 read_EXAT_files_from_tape(bkpinfo, &size, orig_fname,
     867                read_EXAT_files_from_tape(&size, orig_fname,
    846868                                          &ctrl_chr, curr_xattr_list_fname,
    847869                                          curr_acl_list_fname);
     
    883905                 orig_fname);
    884906        res =
    885             verify_a_biggiefile_from_stream(bkpinfo, logical_fname, size);
     907            verify_a_biggiefile_from_stream(logical_fname, size);
    886908        mr_free(logical_fname);
    887909        retval += res;
     
    911933 * @ingroup verifyGroup
    912934 */
    913 int verify_cd_image(struct s_bkpinfo *bkpinfo)
     935int verify_cd_image()
    914936{
    915937
     
    949971            popup_and_OK(_("Please push CD tray closed."));
    950972        }
    951         if (find_and_mount_actual_cd(bkpinfo, mountpoint)) {
     973        if (find_and_mount_actual_cd(mountpoint)) {
    952974            log_to_screen(_("failed to mount actual CD"));
    953975            return (1);
     
    9981020    mr_free(tmp);
    9991021
    1000     verify_afioballs_on_CD(bkpinfo, mountpoint);
     1022    verify_afioballs_on_CD(mountpoint);
    10011023    iamhere("before verify_all_slices");
    1002     verify_all_slices_on_CD(bkpinfo, mountpoint);
     1024    verify_all_slices_on_CD(mountpoint);
    10031025
    10041026    mr_asprintf(&command, "umount %s", mountpoint);
     
    10451067 * @ingroup verifyGroup
    10461068 */
    1047 int verify_tape_backups(struct s_bkpinfo *bkpinfo)
     1069int verify_tape_backups()
    10481070{
    10491071
     
    10621084    mr_msg(3, "verify_tape_backups --- starting");
    10631085    log_to_screen(_("Verifying backups"));
    1064     openin_tape(bkpinfo);
     1086    openin_tape();
    10651087
    10661088    /* verify archives themselves */
    1067     retval += verify_afioballs_from_stream(bkpinfo);
    1068     retval += verify_biggiefiles_from_stream(bkpinfo);
     1089    retval += verify_afioballs_from_stream();
     1090    retval += verify_biggiefiles_from_stream();
    10691091
    10701092    /* find the final blocks */
    10711093    sync();
    10721094    sleep(2);
    1073     closein_tape(bkpinfo);
     1095    closein_tape();
    10741096
    10751097    /* close tape; exit */
    1076     paranoid_system
    1077         ("rm -f /tmp/biggies.changed /tmp/changed.files.[0-9]* 2> /dev/null");
    1078     mr_asprintf(&changed_files_fname, "/tmp/changed.files.%d",
    1079              (int) (random() % 32767));
     1098    mr_asprintf(&tmp,"rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
     1099    paranoid_system(tmp);
     1100    mr_free(tmp);
     1101
     1102    mr_asprintf(&changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
    10801103    mr_asprintf(&tmp,
    10811104             "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",
     
    10961119    mr_free(tmp);
    10971120
    1098     mr_asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);
     1121    mr_asprintf(&tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
    10991122    paranoid_system(tmp);
    11001123    mr_free(tmp);
     
    11021125    diffs = count_lines_in_file(changed_files_fname);
    11031126    if (diffs > 0) {
    1104         mr_asprintf(&tmp, "cp -f %s %s", changed_files_fname,
    1105                  "/tmp/changed.files");
     1127        mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, MINDI_CACHE);
    11061128        run_program_and_log_output(tmp, FALSE);
    11071129        mr_free(tmp);
    11081130
    11091131        mr_asprintf(&tmp,
    1110                  "%ld files differed from live filesystem; type less %s or less %s to see",
    1111                  diffs, changed_files_fname, "/tmp/changed.files");
     1132                 "%ld files differed from live filesystem; type less %s or less %s/changed.files to see",
     1133                 diffs, changed_files_fname, MINDI_CACHE);
    11121134        mr_msg(0, tmp);
    11131135        mr_free(tmp);
    11141136
    11151137        log_to_screen
    1116             (_("See /tmp/changed.files for a list of nonmatching files."));
     1138            (_("See "MINDI_CACHE"/changed.files for a list of nonmatching files."));
    11171139        log_to_screen
    11181140            (_("The files probably changed on filesystem, not on backup media."));
     
    11241146
    11251147
    1126 /**
    1127  * Generate the filename of a tarball to verify.
    1128  * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used.
    1129  * @param mountpoint The directory where the CD/DVD/ISO is mounted.
    1130  * @param setno The afioball number to get the location of.
    1131  * @return The absolute path to the afioball.
    1132  * @note The returned string points to static data that will be overwritten with each call.
    1133  * @ingroup stringGroup
    1134  */
    1135 char *vfy_tball_fname(struct s_bkpinfo *bkpinfo, char *mountpoint,
    1136                       int setno)
    1137 {
    1138     /*@ buffers ******************************************************* */
    1139     static char output[MAX_STR_LEN];
    1140 
    1141     assert(bkpinfo != NULL);
    1142     assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    1143     sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno,
    1144             bkpinfo->zip_suffix);
    1145     if (!does_file_exist(output)) {
    1146         sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno,
    1147                 bkpinfo->zip_suffix);
    1148     }
    1149     return (output);
    1150 }
Note: See TracChangeset for help on using the changeset viewer.