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/mondorestore/mondo-rstr-compare.c

    r1638 r1663  
    1919extern char *MONDO_LOGFILE;
    2020
     21/* Reference to global bkpinfo */
     22extern struct s_bkpinfo *bkpinfo;
     23
    2124//static char cvsid[] = "$Id$";
    2225
     
    3437 * @note This function uses an MD5 checksum.
    3538 */
    36 int compare_a_biggiefile(struct s_bkpinfo *bkpinfo, long bigfileno)
     39int compare_a_biggiefile(long bigfileno)
    3740{
    3841
     
    5861    if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
    5962        if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
    60             insist_on_this_cd_number(bkpinfo, (++g_current_media_number));
     63            insist_on_this_cd_number((++g_current_media_number));
    6164        } else {
    6265            mr_msg(2, "No CD's left. No biggiefiles left. No problem.");
     
    133136
    134137    if (retval) {
    135         if (!(fout = fopen("/tmp/changed.txt", "a"))) {
     138        if (!(fout = fopen(MINDI_CACHE"/changed.txt", "a"))) {
    136139            fatal_error("Cannot openout changed.txt");
    137140        }
     
    151154/**
    152155 * Compare all biggiefiles in the backup.
    153  * @param bkpinfo The backup information structure. Used only in compare_a_biggiefile().
    154156 * @return 0 for success, nonzero for failure.
    155157 */
    156 int compare_all_biggiefiles(struct s_bkpinfo *bkpinfo)
     158int compare_all_biggiefiles()
    157159{
    158160    int retval = 0;
     
    161163    char *tmp = NULL;
    162164
    163     assert(bkpinfo != NULL);
    164165    mr_msg(1, "Comparing biggiefiles");
    165166
     
    187188        mr_free(tmp);
    188189
    189         res = compare_a_biggiefile(bkpinfo, bigfileno);
     190        res = compare_a_biggiefile(bigfileno);
    190191        retval += res;
    191192        g_current_progress++;
     
    303304    if (length_of_file(logfile) > 5) {
    304305        mr_asprintf(&command,
    305                 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> /tmp/changed.txt",
     306                "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MINDI_CACHE"/changed.txt",
    306307                logfile);
    307308        system(command);
     
    330331 * @return 0 for success, nonzero for failure.
    331332 */
    332 int compare_all_tarballs(struct s_bkpinfo *bkpinfo)
     333int compare_all_tarballs()
    333334{
    334335    int retval = 0;
     
    361362
    362363    for (;;) {
    363         insist_on_this_cd_number(bkpinfo, g_current_media_number);
     364        insist_on_this_cd_number(g_current_media_number);
    364365        update_progress_form(progress_str);
    365366        mr_asprintf(&tarball_fname,
     
    441442 * @return 0 for success, nonzero for failure.
    442443 */
    443 int compare_to_CD(struct s_bkpinfo *bkpinfo)
     444int compare_to_CD()
    444445{
    445446  /** needs malloc *********/
     
    460461    chdir(bkpinfo->restore_path);
    461462    getcwd(new, MAX_STR_LEN - 1);
    462     insist_on_this_cd_number(bkpinfo, g_current_media_number);
    463     unlink("/tmp/changed.txt");
    464 
    465     resA = compare_all_tarballs(bkpinfo);
    466     resB = compare_all_biggiefiles(bkpinfo);
     463    insist_on_this_cd_number(g_current_media_number);
     464    unlink(MINDI_CACHE"/changed.txt");
     465
     466    resA = compare_all_tarballs();
     467    resB = compare_all_biggiefiles();
    467468    chdir(cwd);
    468     noof_changed_files = count_lines_in_file("/tmp/changed.txt");
     469    noof_changed_files = count_lines_in_file(MINDI_CACHE"/changed.txt");
    469470    if (noof_changed_files) {
    470471        log_to_screen(_("%ld files do not match the backup            "),
    471472                noof_changed_files);
    472         mr_asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);
     473        mr_asprintf(&command, "cat "MINDI_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
    473474        paranoid_system(command);
    474475        mr_free(command);
     
    501502 */
    502503int
    503 compare_mode(struct s_bkpinfo *bkpinfo,
    504              struct mountlist_itself *mountlist,
     504compare_mode(struct mountlist_itself *mountlist,
    505505             struct raidlist_itself *raidlist)
    506506{
     
    522522    assert(raidlist != NULL);
    523523
    524     while (get_cfg_file_from_archive(bkpinfo)) {
     524    while (get_cfg_file_from_archive()) {
    525525        if (!ask_me_yes_or_no
    526526            (_
     
    529529            fatal_error("Unable to find config file/archives. Aborting.");
    530530        }
    531         interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
    532     }
    533 
    534     read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     531        interactively_obtain_media_parameters_from_user(FALSE);
     532    }
     533
     534    read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    535535    g_current_media_number = 1;
    536536    mvaddstr_and_log_it(1, 30, _("Comparing Automatically"));
     
    544544    if (bkpinfo->backup_media_type == tape
    545545        || bkpinfo->backup_media_type == udev) {
    546         retval += compare_to_tape(bkpinfo);
     546        retval += compare_to_tape();
    547547    } else if (bkpinfo->backup_media_type == cdstream) {
    548         retval += compare_to_cdstream(bkpinfo);
    549     } else {
    550         retval += compare_to_CD(bkpinfo);
     548        retval += compare_to_cdstream();
     549    } else {
     550        retval += compare_to_CD();
    551551    }
    552552    if (retval) {
     
    557557    }
    558558
    559     if (count_lines_in_file("/tmp/changed.txt") > 0) {
     559    if (count_lines_in_file(MINDI_CACHE"/changed.txt") > 0) {
    560560        mvaddstr_and_log_it(g_currentY++, 0,
    561561                            _
    562562                            ("Differences found while files were being compared."));
    563         streamline_changes_file("/tmp/changed.files", "/tmp/changed.txt");
    564         if (count_lines_in_file("/tmp/changed.files") <= 0) {
     563        streamline_changes_file(MINDI_CACHE"/changed.files", MINDI_CACHE"/changed.txt");
     564        if (count_lines_in_file(MINDI_CACHE"/changed.files") <= 0) {
    565565            mvaddstr_and_log_it(g_currentY++, 0,
    566566                                _
     
    569569                          ("The differences were logfiles and temporary files. Your archives are fine."));
    570570        } else {
    571             q = count_lines_in_file("/tmp/changed.files");
     571            q = count_lines_in_file(MINDI_CACHE"/changed.files");
    572572            mr_asprintf(&tmp, _("%ld significant difference%s found."), q,
    573573                    (q != 1) ? "s" : "");
     
    586586            chdir(bkpinfo->restore_path);
    587587            getcwd(new, MAX_STR_LEN - 1);
    588             popup_changelist_from_file("/tmp/changed.files");
     588            popup_changelist_from_file(MINDI_CACHE"/changed.files");
    589589            mr_msg(2, "Returning from popup_changelist_from_file()");
    590590            chdir(cwd);
     
    616616 * @return 0 for success, nonzero for failure.
    617617 */
    618 int compare_to_cdstream(struct s_bkpinfo *bkpinfo)
     618int compare_to_cdstream()
    619619{
    620620    int res;
     
    642642               last_line_of_file("/tmp/CDROM-LIVES-HERE"));
    643643    }
    644     res = verify_tape_backups(bkpinfo);
     644    res = verify_tape_backups();
    645645    chdir(dir);
    646     if (length_of_file("/tmp/changed.txt") > 2
    647         && length_of_file("/tmp/changed.files") > 2) {
     646    if (length_of_file(MINDI_CACHE"/changed.txt") > 2
     647        && length_of_file(MINDI_CACHE"/changed.files") > 2) {
    648648        mr_msg(0,
    649                 "Type 'less /tmp/changed.files' to see which files don't match the archives");
     649                "Type 'less "MINDI_CACHE"/changed.files' to see which files don't match the archives");
    650650        mr_msg(2, "Calling popup_changelist_from_file()");
    651         popup_changelist_from_file("/tmp/changed.files");
     651        popup_changelist_from_file(MINDI_CACHE"/changed.files");
    652652        mr_msg(2, "Returned from popup_changelist_from_file()");
    653653    }
     
    674674 * returns: int                                                           *
    675675 **************************************************************************/
    676 int compare_to_tape(struct s_bkpinfo *bkpinfo)
     676int compare_to_tape()
    677677{
    678678    int res = 0;
     
    692692    mvaddstr_and_log_it(g_currentY,
    693693                        0, _("Verifying archives against filesystem"));
    694     res = verify_tape_backups(bkpinfo);
     694    res = verify_tape_backups();
    695695    chdir(dir);
    696696    if (res) {
Note: See TracChangeset for help on using the changeset viewer.