Changeset 1199 in MondoRescue


Ignore:
Timestamp:
Feb 25, 2007, 12:43:27 AM (17 years ago)
Author:
Bruno Cornec
Message:

merge trunk memory management for mondorestore.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondorestore/mondorestore.c

    r1193 r1199  
    1212 * #include statements                                                    *
    1313 **************************************************************************/
    14 #include <pthread.h>
     14#include <unistd.h>
     15
    1516#include "my-stuff.h"
    1617#include "mr_mem.h"
     
    7475 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode.
    7576 */
    76 char *g_isodir_device;
     77char *g_isodir_device = NULL;
    7778
    7879/**
    7980 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode.
    8081 */
    81 char *g_isodir_format;
     82char *g_isodir_format = NULL;
    8283
    8384/**
    8485 * The location of 'biggielist.txt', containing the biggiefiles on the current archive set.
    8586 */
    86 char *g_biggielist_txt;
     87char *g_biggielist_txt = NULL;
    8788
    8889/**
     
    9091 * the current archive set.
    9192 */
    92 char *g_filelist_full;
     93char *g_filelist_full = NULL;
    9394
    9495/**
     
    9697 * as images, not as individual files.
    9798 */
    98 char *g_filelist_imagedevs;
     99char *g_filelist_imagedevs = NULL;
    99100
    100101/**
     
    102103 * @see g_filelist_imagedevs
    103104 */
    104 char *g_imagedevs_restthese;
     105char *g_imagedevs_restthese = NULL;
    105106
    106107/**
     
    108109 * information for this backup.
    109110 */
    110 char *g_mondo_cfg_file;
     111char *g_mondo_cfg_file = NULL;
    111112
    112113/**
     
    114115 * user's partitions and hard drives.
    115116 */
    116 char *g_mountlist_fname;
     117char *g_mountlist_fname = NULL;
    117118
    118119/**
     
    120121 * to avoid link errors.
    121122 */
    122 char *g_mondo_home;
     123char *g_mondo_home = NULL;
    123124
    124125/* Busybox ps has no option and PID in first pos */
     
    131132/* @} - end of "Restore-Time Globals" in globalGroup */
    132133
    133 
    134 
    135134extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived,
    136135                                 char direction);
    137 
    138 
    139136
    140137/**************************************************************************
     
    145142 * The message to display if we detect that the user is using a Compaq Proliant.
    146143 */
    147 #define COMPAQ_PROLIANTS_SUCK "Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo CD/floppy in Interactive Mode."
    148 
    149 
     144#define COMPAQ_PROLIANTS_SUCK _("Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo CD/floppy in Interactive Mode.")
    150145
    151146
     
    175170    if (!does_file_exist(g_mountlist_fname)) {
    176171        log_to_screen(g_mountlist_fname);
    177         log_to_screen("does not exist");
     172        log_to_screen(_("does not exist"));
    178173        return (1);
    179174    }
     
    183178    if (retval) {
    184179        log_to_screen
    185             ("Warning - load_raidtab_into_raidlist returned an error");
     180            (_("Warning - load_raidtab_into_raidlist returned an error"));
    186181    }
    187182    res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
     
    193188    save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
    194189
    195     log_to_screen("I have finished editing the mountlist for you.");
     190    log_to_screen(_("I have finished editing the mountlist for you."));
    196191
    197192    return (retval);
    198193}
    199 
    200 
    201 
    202194
    203195
     
    242234    popup_and_OK(COMPAQ_PROLIANTS_SUCK);
    243235    if (ask_me_yes_or_no
    244         ("Would you like to reboot and use your Compaq CD to prep your hard drive?"))
     236        (_
     237         ("Would you like to reboot and use your Compaq CD to prep your hard drive?")))
    245238    {
    246         fatal_error
    247             ("Aborting. Please reboot and prep your hard drive with your Compaq CD.");
     239        fatal_error(_
     240                    ("Aborting. Please reboot and prep your hard drive with your Compaq CD."));
    248241    }
    249242}
     
    252245 *END_OFFER_TO_ABORT_BECAUSE_COMPAQ_PROLIANTS_SUCK                        *
    253246 **************************************************************************/
    254 
    255247
    256248
     
    275267    assert(mountlist != NULL);
    276268    assert(raidlist != NULL);
    277     malloc_string(tmp);
    278269    iamhere("pre wrm");
    279270    c = which_restore_mode();
     
    282273        interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
    283274    } else {
    284         popup_and_OK("No restoring or comparing will take place today.");
     275        popup_and_OK(_
     276                     ("No restoring or comparing will take place today."));
    285277        if (is_this_device_mounted("/mnt/cdrom")) {
    286278            run_program_and_log_output("umount /mnt/cdrom", FALSE);
    287279        }
    288280        if (g_ISO_restore_mode) {
    289             sprintf(tmp, "umount %s", bkpinfo->isodir);
     281            mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    290282            run_program_and_log_output(tmp, FALSE);
     283            mr_free(tmp);
    291284        }
    292285        paranoid_MR_finish(0);
     
    315308        retval += compare_mode(bkpinfo, mountlist, raidlist);
    316309    }
    317     mr_free(tmp);
    318310    return (retval);
    319311}
     
    326318 *END_  EXTRACT_CONFIG_FILE_FROM_RAMDISK                                  *
    327319 **************************************************************************/
    328 
    329 
    330 /**
    331  * Locate an executable in the directory structure rooted at @p restg.
    332  * @param out_path Where to put the executable.
    333  * @param fname The basename of the executable.
    334  * @param restg The directory structure to look in.
    335  * @note If it could not be found in @p restg then @p fname is put in @p out_path.
    336  * @ingroup restoreUtilityGroup
    337  */
    338 void
    339 find_pathname_of_executable_preferably_in_RESTORING(char *out_path,
    340                                                     char *fname,
    341                                                     char *restg)
    342 {
    343     assert(out_path != NULL);
    344     assert_string_is_neither_NULL_nor_zerolength(fname);
    345 
    346     sprintf(out_path, "%s/sbin/%s", restg, fname);
    347     if (does_file_exist(out_path)) {
    348         sprintf(out_path, "%s/usr/sbin/%s", restg, fname);
    349         if (does_file_exist(out_path)) {
    350             sprintf(out_path, "%s/bin/%s", restg, fname);
    351             if (does_file_exist(out_path)) {
    352                 sprintf(out_path, "%s/usr/bin/%s", restg, fname);
    353                 if (does_file_exist(out_path)) {
    354                     strcpy(out_path, fname);
    355                 }
    356             }
    357         }
    358     }
    359 }
    360 
    361 /**************************************************************************
    362  *END_FIND_PATHNAME_OF_EXECUTABLE_PREFERABLY_IN_RESTORING                 *
    363  **************************************************************************/
    364 
    365 
    366320
    367321
     
    392346    bool restore_all;
    393347
    394   /** needs malloc **********/
    395     char *tmp;
    396     char *fstab_fname;
    397     char *old_restpath;
    398 
    399     struct s_node *filelist;
     348    char *tmp = NULL;
     349    char *tmp1 = NULL;
     350    char *fstab_fname = NULL;
     351    char *old_restpath = NULL;
     352
     353    struct s_node *filelist = NULL;
    400354
    401355    /* try to partition and format */
     
    403357    mr_msg(2, "interactive_mode --- starting (great, assertions OK)");
    404358
    405     malloc_string(tmp);
    406     malloc_string(fstab_fname);
    407     malloc_string(old_restpath);
    408359    assert(bkpinfo != NULL);
    409360    assert(mountlist != NULL);
     
    414365    if (g_text_mode) {
    415366        if (!ask_me_yes_or_no
    416             ("Interactive Mode + textonly = experimental! Proceed anyway?"))
     367            (_
     368             ("Interactive Mode + textonly = experimental! Proceed anyway?")))
    417369        {
    418370            fatal_error("Wise move.");
     
    442394        if (g_text_mode) {
    443395            save_mountlist_to_disk(mountlist, g_mountlist_fname);
    444             sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
     396            mr_asprintf(&tmp, "%s %s", find_my_editor(), g_mountlist_fname);
    445397            res = system(tmp);
     398            mr_free(tmp);
    446399            load_mountlist(mountlist, g_mountlist_fname);
    447400        } else {
     
    455408        save_mountlist_to_disk(mountlist, g_mountlist_fname);
    456409        save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
    457         mvaddstr_and_log_it(1, 30, "Restoring Interactively");
     410        mvaddstr_and_log_it(1, 30, _("Restoring Interactively"));
    458411        if (bkpinfo->differential) {
    459             log_to_screen("Because this is a differential backup, disk");
    460             log_to_screen
    461                 (" partitioning and formatting will not take place.");
     412            log_to_screen(_
     413                          ("Because this is a differential backup, disk"));
     414            log_to_screen(_
     415                          (" partitioning and formatting will not take place."));
    462416            done = TRUE;
    463417        } else {
    464418            if (ask_me_yes_or_no
    465                 ("Do you want to erase and partition your hard drives?")) {
     419                (_
     420                 ("Do you want to erase and partition your hard drives?")))
     421            {
    466422                if (partition_table_contains_Compaq_diagnostic_partition
    467423                    (mountlist)) {
     
    474430                    if (ptn_errs) {
    475431                        log_to_screen
    476                             ("Warning. Errors occurred during disk partitioning.");
     432                            (_
     433                             ("Warning. Errors occurred during disk partitioning."));
    477434                    }
    478435
     
    480437                    if (!fmt_errs) {
    481438                        log_to_screen
    482                             ("Errors during disk partitioning were handled OK.");
    483                         log_to_screen
    484                             ("Partitions were formatted OK despite those errors.");
     439                            (_
     440                             ("Errors during disk partitioning were handled OK."));
     441                        log_to_screen(_
     442                                      ("Partitions were formatted OK despite those errors."));
    485443                        ptn_errs = 0;
    486444                    }
     
    492450            } else {
    493451                mvaddstr_and_log_it(g_currentY++, 0,
    494                                     "User opted not to partition the devices");
     452                                    _
     453                                    ("User opted not to partition the devices"));
    495454                if (ask_me_yes_or_no
    496                     ("Do you want to format your hard drives?")) {
    497                     fmt_errs = format_everything(mountlist, TRUE, raidlist);
     455                    (_("Do you want to format your hard drives?"))) {
     456                    fmt_errs =
     457                        format_everything(mountlist, TRUE, raidlist);
    498458                    if (!fmt_errs) {
    499459                        done = TRUE;
     
    507467                mvaddstr_and_log_it(g_currentY++,
    508468                                    0,
    509                                     "Errors occurred. Please repartition and format drives manually.");
     469                                    _
     470                                    ("Errors occurred. Please repartition and format drives manually."));
    510471                done = FALSE;
    511472            }
     
    513474                mvaddstr_and_log_it(g_currentY++,
    514475                                    0,
    515                                     "Errors occurred during partitioning. Formatting, however, went OK.");
     476                                    _
     477                                    ("Errors occurred during partitioning. Formatting, however, went OK."));
    516478                done = TRUE;
    517479            }
    518480            if (!done) {
    519                 if (!ask_me_yes_or_no("Re-edit the mountlist?")) {
     481                if (!ask_me_yes_or_no(_("Re-edit the mountlist?"))) {
    520482                    retval++;
    521                     goto end_of_func;
     483                    iamhere("Leaving interactive_mode()");
     484                    return (retval);
    522485                }
    523486            }
     
    529492        unmount_all_devices(mountlist);
    530493        retval++;
    531         goto end_of_func;
     494        iamhere("Leaving interactive_mode()");
     495        return (retval);
    532496    }
    533497    /* restore */
    534498    if ((restore_all =
    535          ask_me_yes_or_no("Do you want me to restore all of your data?")))
     499         ask_me_yes_or_no(_
     500                          ("Do you want me to restore all of your data?"))))
    536501    {
    537502        mr_msg(1, "Restoring all data");
    538503        retval += restore_everything(bkpinfo, NULL);
    539     } else
    540         if ((restore_all =
     504    } else if ((restore_all =
    541505             ask_me_yes_or_no
    542              ("Do you want me to restore _some_ of your data?"))) {
    543         strcpy(old_restpath, bkpinfo->restore_path);
     506             (_("Do you want me to restore _some_ of your data?")))) {
     507        mr_asprintf(&old_restpath,bkpinfo->restore_path);
    544508        for (done = FALSE; !done;) {
    545509            unlink("/tmp/filelist.full");
     
    549513             */
    550514            if (filelist) {
     515                malloc_string(tmp1);
    551516              gotos_suck:
    552                 strcpy(tmp, old_restpath);
    553 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING);
     517                strcpy(tmp1, old_restpath);
     518                // (NB: MNT_RESTORING is where your filesystem is mounted now, by default)
    554519                if (popup_and_get_string
    555                     ("Restore path", "Restore files to where?", tmp,
     520                    (_("Restore path"), _("Restore files to where?"), tmp1,
    556521                     MAX_STR_LEN / 4)) {
    557                     if (!strcmp(tmp, "/")) {
    558                         if (!ask_me_yes_or_no("Are you sure?")) {
     522                    if (!strcmp(tmp1, "/")) {
     523                        if (!ask_me_yes_or_no(_("Are you sure?"))) {
    559524                            goto gotos_suck;
    560525                        }
    561                         tmp[0] = '\0';  // so we restore to [blank]/file/name :)
     526                        tmp1[0] = '\0'; // so we restore to [blank]/file/name :)
    562527                    }
    563                     strcpy(bkpinfo->restore_path, tmp);
     528                    strcpy(bkpinfo->restore_path, tmp1);
    564529                    mr_msg(1, "Restoring subset");
    565530                    retval += restore_everything(bkpinfo, filelist);
     
    570535                }
    571536                if (!ask_me_yes_or_no
    572                     ("Restore another subset of your backup?")) {
     537                    (_("Restore another subset of your backup?"))) {
    573538                    done = TRUE;
    574539                }
     540                mr_free(tmp1);
    575541            } else {
    576542                done = TRUE;
    577543            }
    578544        }
    579         strcpy(old_restpath, bkpinfo->restore_path);
     545        mr_free(old_restpath);
    580546    } else {
    581547        mvaddstr_and_log_it(g_currentY++,
    582548                            0,
    583                             "User opted not to restore any data.                                  ");
     549                            _
     550                            ("User opted not to restore any data.                                  "));
    584551    }
    585552    if (retval) {
    586553        mvaddstr_and_log_it(g_currentY++,
    587554                            0,
    588                             "Errors occurred during the restore phase.            ");
    589     }
    590 
    591     if (ask_me_yes_or_no("Initialize the boot loader?")) {
     555                            _
     556                            ("Errors occurred during the restore phase.            "));
     557    }
     558
     559    if (ask_me_yes_or_no(_("Initialize the boot loader?"))) {
    592560        run_boot_loader(TRUE);
    593561    } else {
    594562        mvaddstr_and_log_it(g_currentY++,
    595563                            0,
    596                             "User opted not to initialize the boot loader.");
    597     }
    598 
    599 //  run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1);
     564                            _
     565                            ("User opted not to initialize the boot loader."));
     566    }
     567
    600568    protect_against_braindead_sysadmins();
    601     //  modify_rclocal_one_time( MNT_RESTORING "/etc" );
    602569    retval += unmount_all_devices(mountlist);
    603570    /*  if (restore_some || restore_all || */
    604571    if (ask_me_yes_or_no
    605         ("Label your ext2 and ext3 partitions if necessary?")) {
     572        (_("Label your ext2 and ext3 partitions if necessary?"))) {
    606573        mvaddstr_and_log_it(g_currentY, 0,
    607                             "Using e2label to label your ext2,3 partitions");
     574                            _
     575                            ("Using e2label to label your ext2,3 partitions"));
    608576        if (does_file_exist("/tmp/fstab.new")) {
    609             strcpy(fstab_fname, "/tmp/fstab.new");
     577            mr_asprintf(&fstab_fname, "/tmp/fstab.new");
    610578        } else {
    611             strcpy(fstab_fname, "/tmp/fstab");
    612         }
    613         sprintf(tmp,
     579            mr_asprintf(&fstab_fname, "/tmp/fstab");
     580        }
     581        mr_asprintf(&tmp,
    614582                "label-partitions-as-necessary %s < %s >> %s 2>> %s",
    615583                g_mountlist_fname, fstab_fname, MONDO_LOGFILE,
    616584                MONDO_LOGFILE);
     585        mr_free(fstab_fname);
     586
    617587        res = system(tmp);
     588        mr_free(tmp);
    618589        if (res) {
    619590            log_to_screen
    620                 ("label-partitions-as-necessary returned an error");
    621             mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     591                (_("label-partitions-as-necessary returned an error"));
     592            mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    622593        } else {
    623             mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     594            mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    624595        }
    625596        retval += res;
     
    630601        mvaddstr_and_log_it(g_currentY++,
    631602                            0,
    632                             "Warning - errors occurred during the restore phase.");
    633     }
    634   end_of_func:
    635     mr_free(tmp);
    636     mr_free(fstab_fname);
    637     mr_free(old_restpath);
     603                            _
     604                            ("Warning - errors occurred during the restore phase."));
     605    }
    638606    iamhere("Leaving interactive_mode()");
    639     return (retval);
     607    return(retval);
    640608}
    641609
     
    643611 *END_INTERACTIVE_MODE                                                    *
    644612 **************************************************************************/
    645 
    646613
    647614
     
    660627         struct raidlist_itself *raidlist, bool nuke_me_please)
    661628{
    662     char c;
     629    char c = ' ';
    663630    int retval = 0;
    664631
     
    682649            retval += compare_mode(bkpinfo, mountlist, raidlist);
    683650        } else {
    684             log_to_screen("OK, I shan't restore/compare any files.");
     651            log_to_screen(_("OK, I shan't restore/compare any files."));
    685652        }
    686653    }
     
    688655        paranoid_system("umount " MNT_CDROM);
    689656    }
    690 //  if (! already_mounted)
    691 //    {
    692657    if (system("umount /tmp/isodir 2> /dev/null")) {
    693658        log_to_screen
    694             ("WARNING - unable to unmount device where the ISO files are stored.");
    695     }
    696 //    }
     659            (_
     660             ("WARNING - unable to unmount device where the ISO files are stored."));
     661    }
    697662    return (retval);
    698663}
     
    701666 *END_ISO_MODE                                                            *
    702667 **************************************************************************/
    703 
    704 
    705 /*            MONDO - saving your a$$ since Feb 18th, 2000            */
    706 
    707 
     668static void call_me_after_the_nuke(int retval) {
     669
     670    char *tmp = NULL;
     671    char *tmp1 = NULL;
     672
     673    if (retval) {
     674        log_to_screen(_("Errors occurred during the nuke phase."));
     675        log_to_screen(_("Please visit our website at http://www.mondores
     676cue.org for more information."));
     677    } else {
     678#ifdef __FreeBSD__
     679    tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline");
     680#else
     681    tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline");
     682#endif
     683        if ((strstr(tmp1,"restore") == NULL) ||
     684        (strstr(tmp1,"RESTORE") == NULL)) {
     685            /* -H option */
     686            mr_asprintf(&tmp,
     687                _
     688                (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.
     689mondorescue.org for more information."));
     690            popup_and_OK(tmp);
     691            mr_free(tmp);
     692        }
     693
     694        log_to_screen(_
     695            ("Mondo has restored your system. Please remove the backup media and reboot."));
     696        log_to_screen(_
     697            ("Thank you for using Mondo Rescue."));
     698        log_to_screen(_
     699            ("Please visit our website at http://www.mondorescue.org for more information."));
     700    }
     701    g_I_have_just_nuked = TRUE;
     702    return;
     703}
    708704
    709705
     
    725721    int res = 0;
    726722    bool boot_loader_installed = FALSE;
    727   /** malloc **/
    728     char tmp[MAX_STR_LEN], tmpA[MAX_STR_LEN], tmpB[MAX_STR_LEN],
     723    char *tmp = NULL;
     724    char tmpA[MAX_STR_LEN], tmpB[MAX_STR_LEN],
    729725        tmpC[MAX_STR_LEN];
    730726
     
    738734    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    739735#ifdef __FreeBSD__
    740     if (strstr
    741         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    742          "noresize"))
     736    tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline");
    743737#else
    744     if (strstr
    745         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    746          "noresize"))
     738    tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline");
    747739#endif
    748     {
     740    if (strstr(tmp,"noresize")) {
    749741        mr_msg(2, "Not resizing mountlist.");
    750742    } else {
     
    752744    }
    753745    if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
    754         sprintf(tmp,
    755                 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?",
     746        mr_asprintf(&tmp,
     747                _
     748                ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"),
    756749                tmpA, tmpB, tmpC);
    757750        if (ask_me_yes_or_no(tmp)) {
     751            mr_free(tmp);
    758752            retval = interactive_mode(bkpinfo, mountlist, raidlist);
    759             goto after_the_nuke;
     753            call_me_after_the_nuke(retval);
     754            return(retval);
    760755        } else {
     756            mr_free(tmp);
    761757            fatal_error("Nuke Mode aborted. ");
    762758        }
    763759    }
    764760    save_mountlist_to_disk(mountlist, g_mountlist_fname);
    765     mvaddstr_and_log_it(1, 30, "Restoring Automatically");
     761    mvaddstr_and_log_it(1, 30, _("Restoring Automatically"));
    766762    if (bkpinfo->differential) {
    767         log_to_screen("Because this is a differential backup, disk");
    768         log_to_screen("partitioning and formatting will not take place.");
     763        log_to_screen(_("Because this is a differential backup, disk"));
     764        log_to_screen(_
     765                      ("partitioning and formatting will not take place."));
    769766        res = 0;
    770767    } else {
     
    776773            g_fprep = fopen("/tmp/prep.sh", "w");
    777774#ifdef __FreeBSD__
    778             if (strstr
    779                 (call_program_and_get_last_line_of_output
    780                  ("cat /tmp/cmdline"), "nopart"))
     775            tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline");
    781776#else
    782             if (strstr
    783                 (call_program_and_get_last_line_of_output
    784                  ("cat /proc/cmdline"), "nopart"))
     777            tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline");
    785778#endif
    786             {
     779            if (strstr(tmp,"nopart")) {
    787780                mr_msg(2,
    788781                        "Not partitioning drives due to 'nopart' option.");
     
    792785                if (res) {
    793786                    log_to_screen
    794                         ("Warning. Errors occurred during partitioning.");
     787                        (_
     788                         ("Warning. Errors occurred during partitioning."));
    795789                    res = 0;
    796790                }
     
    798792            retval += res;
    799793            if (!res) {
    800                 log_to_screen("Preparing to format your disk(s)");
     794                log_to_screen(_("Preparing to format your disk(s)"));
    801795                sleep(1);
    802                 system("sync");
    803                 log_to_screen("Please wait. This may take a few minutes.");
     796                sync();
     797                log_to_screen(_
     798                              ("Please wait. This may take a few minutes."));
    804799                res += format_everything(mountlist, FALSE, raidlist);
    805800            }
     
    811806        mvaddstr_and_log_it(g_currentY++,
    812807                            0,
    813                             "Failed to partition and/or format your hard drives.");
    814 
    815         if (ask_me_yes_or_no("Try in interactive mode instead?")) {
     808                            _
     809                            ("Failed to partition and/or format your hard drives."));
     810
     811        if (ask_me_yes_or_no(_("Try in interactive mode instead?"))) {
    816812            retval = interactive_mode(bkpinfo, mountlist, raidlist);
    817             goto after_the_nuke;
     813            call_me_after_the_nuke(retval);
     814            return(retval);
    818815        } else
    819816            if (!ask_me_yes_or_no
    820                 ("Would you like to try to proceed anyway?")) {
    821             return (retval);
     817                (_("Would you like to try to proceed anyway?"))) {
     818                return(retval);
    822819        }
    823820    }
     
    826823        unmount_all_devices(mountlist);
    827824        log_to_screen
    828             ("Unable to mount all partitions. Sorry, I cannot proceed.");
     825            (_
     826             ("Unable to mount all partitions. Sorry, I cannot proceed."));
    829827        return (retval);
    830828    }
     
    837835    }
    838836    protect_against_braindead_sysadmins();
    839 //  run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1);
    840     //  modify_rclocal_one_time( MNT_RESTORING "/etc" );
    841837    retval += unmount_all_devices(mountlist);
    842838    mvaddstr_and_log_it(g_currentY,
    843839                        0,
    844                         "Using e2label to label your ext2,3 partitions");
    845 
    846     sprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab",
     840                        _
     841                        ("Using e2label to label your ext2,3 partitions"));
     842
     843    mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab",
    847844            g_mountlist_fname);
    848845    res = run_program_and_log_output(tmp, TRUE);
     846    mr_free(tmp);
     847
    849848    if (res) {
    850         log_to_screen("label-partitions-as-necessary returned an error");
    851         mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     849        log_to_screen(_
     850                      ("label-partitions-as-necessary returned an error"));
     851        mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    852852    } else {
    853         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     853        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    854854    }
    855855    retval += res;
    856856
    857   after_the_nuke:
    858     if (retval) {
    859         log_to_screen("Errors occurred during the nuke phase.");
    860     } else if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "RESTORE"))    // Bruno's thing
    861     {
    862         log_to_screen
    863             ("PC was restored successfully. Thank you for using Mondo Rescue.");
    864         log_to_screen
    865             ("Please visit our website at http://www.mondorescue.org for more information.");
    866     } else {
    867         strcpy(tmp,"Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
    868         if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "restore") == NULL) {
    869             popup_and_OK(tmp);
    870         }
    871         log_to_screen
    872           ("Mondo has restored your system. Please wait for the command prompt.");
    873         log_to_screen
    874             ("Then remove the backup media and reboot.");
    875         log_to_screen
    876             ("Please visit our website at http://www.mondorescue.org for more information.");
    877     }
    878     g_I_have_just_nuked = TRUE;
    879 /*
    880   if (!boot_loader_installed && !does_file_exist(DO_MBR_PLEASE))
    881     {
    882       log_to_screen("PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR");
    883       write_one_liner_data_file(DO_MBR_PLEASE, "mondorestore --mbr");
    884     }
    885 */
     857    call_me_after_the_nuke(retval);
    886858    return (retval);
    887859}
     
    890862 *END_NUKE_MODE                                                           *
    891863 **************************************************************************/
    892 
    893864
    894865
     
    903874    int retval = 0;
    904875
    905   /** malloc **/
    906     char *old_restpath;
    907 
    908     struct mountlist_itself *mountlist;
    909 //  static
    910     struct raidlist_itself *raidlist;
    911     struct s_node *filelist;
     876    char *old_restpath = NULL;
     877
     878    struct mountlist_itself *mountlist = NULL;
     879    struct raidlist_itself *raidlist = NULL;
     880    struct s_node *filelist = NULL;
    912881
    913882    mr_msg(1, "restore_to_live_filesystem() - starting");
    914883    assert(bkpinfo != NULL);
    915     malloc_string(old_restpath);
     884
    916885    mountlist = mr_malloc(sizeof(struct mountlist_itself));
    917886    raidlist = mr_malloc(sizeof(struct raidlist_itself));
     
    920889    if (!g_restoring_live_from_cd) {
    921890        popup_and_OK
    922             ("Please insert tape/CD/boot floppy, then hit 'OK' to continue.");
     891            (_
     892             ("Please insert tape/CD/boot floppy, then hit 'OK' to continue."));
    923893        sleep(1);
    924894    }
    925895    interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
    926     mr_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device);
    927896    if (!bkpinfo->media_device[0]) {
    928897        mr_msg(2, "Warning - failed to find media dev");
     898    } else {
     899        mr_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device);
    929900    }
    930901
     
    932903    mr_msg(2, "bkpinfo->isodir = %s", bkpinfo->isodir);
    933904
    934     open_evalcall_form("Thinking...");
     905    open_evalcall_form(_("Thinking..."));
    935906
    936907    get_cfg_file_from_archive_or_bust(bkpinfo);
     
    944915    if (filelist) {
    945916        save_filelist(filelist, "/tmp/selected-files.txt");
    946         strcpy(old_restpath, bkpinfo->restore_path);
    947         if (popup_and_get_string("Restore path",
    948                                  "Restore files to where? )",
    949                                  bkpinfo->restore_path, MAX_STR_LEN / 4)) {
     917        mr_asprintf(&old_restpath,bkpinfo->restore_path);
     918        if (popup_and_get_string(_("Restore path"),
     919                                 _("Restore files to where? )"),
     920                                 bkpinfo->restore_path)) {
    950921            iamhere("Restoring everything");
    951922            retval += restore_everything(bkpinfo, filelist);
    952             free_filelist(filelist);
    953             strcpy(bkpinfo->restore_path, old_restpath);
    954         } else {
    955             free_filelist(filelist);
    956         }
     923        }
     924        free_filelist(filelist);
    957925        strcpy(bkpinfo->restore_path, old_restpath);
     926        mr_free(old_restpath);
    958927    }
    959928    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    962931    }
    963932    run_program_and_log_output("umount " MNT_CDROM, FALSE);
    964     if (!bkpinfo->please_dont_eject) {
     933    if ((!bkpinfo->please_dont_eject) && (bkpinfo->media_device != NULL)) {
    965934        eject_device(bkpinfo->media_device);
    966935    }
    967     mr_free(old_restpath);
    968936    mr_free(mountlist);
    969937    mr_free(raidlist);
     
    1000968                             char *pathname_of_last_file_restored)
    1001969{
    1002     FILE *fin;
    1003     FILE *fout;
    1004     FILE *fbzip2;
    1005 
    1006   /** malloc ***/
    1007     char *checksum, *outfile_fname, *tmp, *bzip2_command,
    1008         *ntfsprog_command, *suffix, *sz_devfile;
    1009     char *bigblk;
    1010     char *p;
     970    FILE *fin = NULL;
     971    FILE *fout = NULL;
     972    FILE *fbzip2 = NULL;
     973
     974    char *checksum = NULL;
     975    char *outfile_fname = NULL;
     976    char *tmp = NULL;
     977    char *bzip2_command = NULL;
     978    char *suffix = NULL;
     979    char *bigblk = NULL;
    1011980    int retval = 0;
    1012981    int finished = FALSE;
    1013     long sliceno;
     982    long sliceno = 0L;
    1014983    long siz;
    1015     char ntfsprog_fifo[MAX_STR_LEN];
     984    char *ntfsprog_fifo = NULL;
    1016985    char *file_to_openout = NULL;
    1017986    struct s_filename_and_lstat_info biggiestruct;
    1018     struct utimbuf the_utime_buf, *ubuf;
     987    struct utimbuf the_utime_buf, *ubuf = NULL;
    1019988    bool use_ntfsprog_hack = FALSE;
    1020989    pid_t pid;
    1021990    int res = 0;
    1022991    int old_loglevel;
    1023     char sz_msg[MAX_STR_LEN];
    1024     struct s_node *node;
     992    char *sz_msg = NULL;
     993    struct s_node *node = NULL;
    1025994
    1026995    old_loglevel = g_loglevel;
    1027996    ubuf = &the_utime_buf;
    1028997    assert(bkpinfo != NULL);
    1029 
    1030     malloc_string(checksum);
    1031     malloc_string(outfile_fname);
    1032     malloc_string(tmp);
    1033     malloc_string(bzip2_command);
    1034     malloc_string(ntfsprog_command);
    1035     malloc_string(suffix);
    1036     malloc_string(sz_devfile);
    1037998
    1038999    pathname_of_last_file_restored[0] = '\0';
     
    10521013    paranoid_fclose(fin);
    10531014
    1054     strcpy(checksum, biggiestruct.checksum);
     1015    mr_asprintf(&checksum, biggiestruct.checksum);
    10551016
    10561017    if (!checksum[0]) {
    1057         sprintf(tmp, "Warning - bigfile %ld does not have a checksum",
     1018        mr_msg(3, "Warning - bigfile %ld does not have a checksum",
    10581019                bigfileno + 1);
    1059         mr_msg(3, tmp);
    1060         p = checksum;
    1061     }
     1020    }
     1021    mr_free(checksum);
    10621022
    10631023    if (!strncmp(biggiestruct.filename, "/dev/", 5))    // Whether NTFS or not :)
    10641024    {
    1065         strcpy(outfile_fname, biggiestruct.filename);
     1025        mr_asprintf(&outfile_fname, biggiestruct.filename);
    10661026    } else {
    1067         sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,
     1027        mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
    10681028                biggiestruct.filename);
    10691029    }
     
    10751035            mr_msg(0, "Skipping %s (name isn't in filelist)",
    10761036                    biggiestruct.filename);
    1077             pathname_of_last_file_restored[0] = '\0';
    10781037            return (0);
    10791038        } else if (!(node->selected)) {
    10801039            mr_msg(1, "Skipping %s (name isn't in biggielist subset)",
    10811040                    biggiestruct.filename);
    1082             pathname_of_last_file_restored[0] = '\0';
    10831041            return (0);
    10841042        }
     
    10971055
    10981056    if (biggiestruct.use_ntfsprog)  // if it's an NTFS device
    1099 //  if (!strncmp ( biggiestruct.filename, "/dev/", 5))
    11001057    {
    11011058        g_loglevel = 4;
     
    11041061                "Calling ntfsclone in background because %s is an NTFS /dev entry",
    11051062                outfile_fname);
    1106         sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
     1063        mr_asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768),
    11071064                (int) (random() % 32768));
    1108         mkfifo(sz_devfile, 0x770);
    1109         strcpy(ntfsprog_fifo, sz_devfile);
     1065        mkfifo(ntfsprog_fifo, 0x770);
     1066
    11101067        file_to_openout = ntfsprog_fifo;
    11111068        switch (pid = fork()) {
     
    11181075            res =
    11191076                feed_outfrom_ntfsprog(biggiestruct.filename,
    1120                                        ntfsprog_fifo);
    1121 //          mr_msg(3, "CHILD - fip - exiting");
     1077                                      ntfsprog_fifo);
    11221078            exit(res);
    11231079            break;
     
    11291085    } else {
    11301086        use_ntfsprog_hack = FALSE;
    1131         ntfsprog_fifo[0] = '\0';
    11321087        file_to_openout = outfile_fname;
    11331088        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    11371092    }
    11381093
    1139     sprintf(tmp, "Reassembling big file %ld (%s)", bigfileno + 1,
     1094    mr_msg(2, "Reassembling big file %ld (%s)", bigfileno + 1,
    11401095            outfile_fname);
    1141     mr_msg(2, tmp);
    11421096
    11431097    /*
     
    11531107    mr_msg(3, "file_to_openout = %s", file_to_openout);
    11541108    if (!(fout = fopen(file_to_openout, "w"))) {
    1155         log_to_screen("Cannot openout outfile_fname - hard disk full?");
     1109        log_to_screen(_("Cannot openout file_to_openout - hard disk full?"));
    11561110        return (1);
    11571111    }
     1112
     1113    mr_free(ntfsprog_fifo);
    11581114    mr_msg(3, "Opened out to %s", outfile_fname);   // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself
    11591115
     
    11741130                    g_current_media_number);
    11751131            g_current_media_number++;
    1176             sprintf(tmp,
    1177                     "Asking for %s #%d so that I may read slice #%ld\n",
     1132            mr_msg(2, "Asking for %s #%d so that I may read slice #%ld\n",
    11781133                    media_descriptor_string(bkpinfo->backup_media_type),
    11791134                    g_current_media_number, sliceno);
    1180             mr_msg(2, tmp);
    1181             sprintf(tmp, "Restoring from %s #%d",
    1182                     media_descriptor_string(bkpinfo->backup_media_type),
     1135            log_to_screen(_("Restoring from %s #%d"),
     1136                    bkpinfo->backup_media_string,
    11831137                    g_current_media_number);
    1184             log_to_screen(tmp);
    11851138            insist_on_this_cd_number(bkpinfo, g_current_media_number);
    1186             log_to_screen("Continuing to restore.");
     1139            log_to_screen(_("Continuing to restore."));
    11871140        } else {
    1188             strcpy(tmp,
     1141            mr_asprintf(&tmp,
    11891142                   slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));
    11901143            if (does_file_exist(tmp) && length_of_file(tmp) == 0) {
     
    11931146                        bigfileno + 1, sliceno);
    11941147                finished = TRUE;
     1148                mr_free(tmp);
    11951149                continue;
    11961150            } else {
     1151                mr_free(tmp);
    11971152                if (does_file_exist
    11981153                    (slice_fname
    11991154                     (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) {
    1200                     strcpy(bzip2_command, "lzop");
    1201                     strcpy(suffix, "lzo");
     1155                    mr_asprintf(&bzip2_command, "lzop");
     1156                    mr_asprintf(&suffix, "lzo");
    12021157                } else
    12031158                    if (does_file_exist
    12041159                        (slice_fname
    12051160                         (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) {
    1206                     strcpy(bzip2_command, "gzip");
    1207                     strcpy(suffix, "gz");
     1161                    mr_asprintf(&bzip2_command, "gzip");
     1162                    mr_asprintf(&suffix, "gz");
    12081163                } else
    12091164                    if (does_file_exist
    12101165                        (slice_fname
    12111166                         (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
    1212                     strcpy(bzip2_command, "bzip2");
    1213                     strcpy(suffix, "bz2");
     1167                    mr_asprintf(&bzip2_command, "bzip2");
     1168                    mr_asprintf(&suffix, "bz2");
    12141169                } else
    12151170                    if (does_file_exist
    12161171                        (slice_fname
    12171172                         (bigfileno, sliceno, ARCHIVES_PATH, ""))) {
    1218                     strcpy(bzip2_command, "");
    1219                     strcpy(suffix, "");
     1173                    mr_asprintf(&bzip2_command, "");
     1174                    mr_asprintf(&suffix, "");
    12201175                } else {
    1221                     log_to_screen("OK, that's pretty fsck0red...");
     1176                    log_to_screen(_("OK, that's pretty fsck0red..."));
    12221177                    return (1);
    12231178                }
    12241179            }
    12251180            if (bzip2_command[0] != '\0') {
    1226                 sprintf(bzip2_command + strlen(bzip2_command),
     1181                mr_strcat(bzip2_command,
    12271182                        " -dc %s 2>> %s",
    12281183                        slice_fname(bigfileno, sliceno, ARCHIVES_PATH,
    12291184                                    suffix), MONDO_LOGFILE);
    12301185            } else {
    1231                 sprintf(bzip2_command, "cat %s 2>> %s",
     1186                mr_free(bzip2_command);
     1187                mr_asprintf(&bzip2_command, "cat %s 2>> %s",
    12321188                        slice_fname(bigfileno, sliceno, ARCHIVES_PATH,
    12331189                                    suffix), MONDO_LOGFILE);
    12341190            }
    1235             sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld    ",
    1236                     media_descriptor_string(bkpinfo->backup_media_type),
     1191            mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld",
     1192                    bkpinfo->backup_media_string,
    12371193                    g_current_media_number, bigfileno + 1, sliceno);
    12381194            mr_msg(2, tmp);
    1239 
    12401195            if (!g_text_mode) {
    12411196                newtDrawRootText(0, g_noof_rows - 2, tmp);
    12421197                newtRefresh();
    1243                 mr_strip_spaces(tmp);
    12441198                update_progress_form(tmp);
    12451199            }
     1200            mr_free(tmp);
     1201
    12461202            if (!(fbzip2 = popen(bzip2_command, "r"))) {
     1203                mr_free(bzip2_command);
     1204                mr_free(suffix);
    12471205                fatal_error("Can't run popen command");
    12481206            }
     1207            mr_free(bzip2_command);
     1208            mr_free(suffix);
     1209
    12491210            while (!feof(fbzip2)) {
    12501211                siz = fread(bigblk, 1, TAPE_BLOCK_SIZE, fbzip2);
    12511212                if (siz > 0) {
    1252                     sprintf(sz_msg, "Read %ld from fbzip2", siz);
    12531213                    siz = fwrite(bigblk, 1, siz, fout);
    1254                     sprintf(sz_msg + strlen(sz_msg),
    1255                             "; written %ld to fout", siz);
    1256 //        mr_msg(2. sz_msg);
    12571214                }
    12581215            }
    12591216            paranoid_pclose(fbzip2);
    1260 
    12611217
    12621218            sliceno++;
     
    12641220        }
    12651221    }
    1266 /*
    1267   memset(bigblk, TAPE_BLOCK_SIZE, 1); // This all looks very fishy...
    1268   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1269   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1270   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1271   fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);
    1272 */
    12731222    paranoid_fclose(fout);
    12741223    g_loglevel = old_loglevel;
     
    12761225    if (use_ntfsprog_hack) {
    12771226        mr_msg(3, "Waiting for ntfsclone to finish");
    1278         sprintf(tmp,
     1227        mr_asprintf(&tmp,
    12791228                " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    12801229        while (system(tmp) == 0) {
    12811230            sleep(1);
    12821231        }
     1232        mr_free(tmp);
    12831233        log_it("OK, ntfsclone has really finished");
    12841234    }
     
    12921242        utime(outfile_fname, ubuf);
    12931243    }
     1244    mr_free(outfile_fname);
    12941245    mr_free(bigblk);
    1295     mr_free(checksum);
    1296     mr_free(outfile_fname);
    1297     mr_free(tmp);
    1298     mr_free(bzip2_command);
    1299     mr_free(ntfsprog_command);
    1300     mr_free(suffix);
    1301     mr_free(sz_devfile);
    13021246
    13031247    return (retval);
    13041248}
     1249
    13051250
    13061251/**************************************************************************
    13071252 *END_ RESTORE_A_BIGGIEFILE_FROM_CD                                       *
    13081253 **************************************************************************/
    1309 
    13101254
    13111255
     
    13171261 * @param orig_bf_fname The original filename of the biggiefile.
    13181262 * @param biggiefile_number The number of the biggiefile (starting from 0).
    1319  * @param orig_checksum Unused.
    1320  * @param biggiefile_size Unused.
    13211263 * @param filelist The node structure containing the list of files to be restored.
    13221264 * If @p orig_bf_fname is not in the list, it will be ignored.
    13231265 * @return 0 for success (or skip), nonzero for failure.
    1324  * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL).
    13251266 */
    13261267int restore_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, char *orig_bf_fname, long biggiefile_number, char *orig_checksum,   //UNUSED
     
    13301271                                     char *pathname_of_last_file_restored)
    13311272{
    1332     FILE *pout;
    1333     FILE *fin;
     1273    FILE *pout = NULL;
     1274    FILE *fin = NULL;
    13341275
    13351276  /** mallocs ********/
    1336     char *tmp;
    1337     char *command;
    1338     char *outfile_fname;
    1339     char *ntfsprog_command;
    1340     char *sz_devfile;
    1341     char *ntfsprog_fifo;
     1277    char *tmp = NULL;
     1278    char *tmp1 = NULL;
     1279    char *command = NULL;
     1280    char *outfile_fname = NULL;
     1281    char *ntfsprog_fifo = NULL;
    13421282    char *file_to_openout = NULL;
    13431283
    1344     struct s_node *node;
    1345 
    1346     int old_loglevel;
     1284    struct s_node *node = NULL;
     1285
     1286    int old_loglevel = 0;
    13471287    long current_slice_number = 0;
    13481288    int retval = 0;
    13491289    int res = 0;
    13501290    int ctrl_chr = '\0';
    1351     long long slice_siz;
     1291    long long slice_siz = 0L;
    13521292    bool dummy_restore = FALSE;
    13531293    bool use_ntfsprog_hack = FALSE;
    13541294    pid_t pid;
    13551295    struct s_filename_and_lstat_info biggiestruct;
    1356     struct utimbuf the_utime_buf, *ubuf;
     1296    struct utimbuf the_utime_buf, *ubuf = NULL;
    13571297    ubuf = &the_utime_buf;
    13581298
    1359     malloc_string(tmp);
    1360     malloc_string(ntfsprog_fifo);
    1361     malloc_string(outfile_fname);
    1362     malloc_string(command);
    1363     malloc_string(sz_devfile);
    1364     malloc_string(ntfsprog_command);
    13651299    old_loglevel = g_loglevel;
    13661300    assert(bkpinfo != NULL);
     
    14041338    if (use_ntfsprog) {
    14051339        if (strncmp(orig_bf_fname, "/dev/", 5)) {
    1406             mr_msg(1,
    1407                     "I was in error when I set use_ntfsprog to TRUE.");
     1340            mr_msg(1, "I was in error when I set use_ntfsprog to TRUE.");
    14081341            mr_msg(1, "%s isn't even in /dev", orig_bf_fname);
    14091342            use_ntfsprog = FALSE;
     
    14131346    if (use_ntfsprog) {
    14141347        g_loglevel = 4;
    1415         strcpy(outfile_fname, orig_bf_fname);
     1348        mr_asprintf(&outfile_fname, orig_bf_fname);
    14161349        use_ntfsprog_hack = TRUE;
    14171350        mr_msg(2,
    14181351                "Calling ntfsclone in background because %s is a /dev entry",
    14191352                outfile_fname);
    1420         sprintf(sz_devfile, "%s/%d.%d.000",
     1353        mr_asprintf(&ntfsprog_fifo, "%s/%d.%d.000",
    14211354                bkpinfo->tmpdir,
    14221355                (int) (random() % 32768),
    14231356                (int) (random() % 32768));
    1424         mkfifo(sz_devfile, 0x770);
    1425         strcpy(ntfsprog_fifo, sz_devfile);
     1357        mkfifo(ntfsprog_fifo, 0x770);
     1358
    14261359        file_to_openout = ntfsprog_fifo;
    14271360        switch (pid = fork()) {
     
    14321365                    "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
    14331366                    outfile_fname, ntfsprog_fifo);
    1434             res =
    1435                 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    1436 //          mr_msg(3, "CHILD - fip - exiting");
     1367            res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    14371368            exit(res);
    14381369            break;
     
    14451376        if (!strncmp(orig_bf_fname, "/dev/", 5))    // non-NTFS partition
    14461377        {
    1447             strcpy(outfile_fname, orig_bf_fname);
     1378            mr_asprintf(&outfile_fname, orig_bf_fname);
    14481379        } else                  // biggiefile
    14491380        {
    1450             sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,
     1381            mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,
    14511382                    orig_bf_fname);
    14521383        }
    14531384        use_ntfsprog_hack = FALSE;
    1454         ntfsprog_fifo[0] = '\0';
    14551385        file_to_openout = outfile_fname;
    14561386        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    14581388            make_hole_for_file(outfile_fname);
    14591389        }
    1460         sprintf(tmp, "Reassembling big file %ld (%s)",
     1390        mr_msg(2, "Reassembling big file %ld (%s)",
    14611391                biggiefile_number + 1, orig_bf_fname);
    1462         mr_msg(2, tmp);
    14631392    }
    14641393
    14651394    if (dummy_restore) {
    1466         sprintf(outfile_fname, "/dev/null");
     1395        mr_free(outfile_fname);
     1396        mr_asprintf(&outfile_fname, "/dev/null");
    14671397    }
    14681398
    14691399    if (!bkpinfo->zip_exe[0]) {
    1470         sprintf(command, "cat > \"%s\"", file_to_openout);
     1400        mr_asprintf(&command, "cat > \"%s\"", file_to_openout);
    14711401    } else {
    1472         sprintf(command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,
     1402        mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,
    14731403                file_to_openout, MONDO_LOGFILE);
    14741404    }
    1475     sprintf(tmp, "Pipe command = '%s'", command);
    1476     mr_msg(3, tmp);
     1405    mr_msg(3, "Pipe command = '%s'", command);
     1406    mr_free(outfile_fname);
     1407    mr_free(ntfsprog_fifo);
    14771408
    14781409    /* restore biggiefile, one slice at a time */
     
    14801411        fatal_error("Cannot pipe out");
    14811412    }
    1482     for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
     1413    mr_free(command);
     1414
     1415    malloc_string(tmp1);
     1416    for (res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr);
    14831417         ctrl_chr != BLK_STOP_A_BIGGIE;
    1484          res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr)) {
     1418         res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr)) {
    14851419        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    14861420            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    14871421        }
    1488         sprintf(tmp, "Working on file #%ld, slice #%ld    ",
     1422        mr_asprintf(&tmp, "Working on file #%ld, slice #%ld    ",
    14891423                biggiefile_number + 1, current_slice_number);
    14901424        mr_msg(2, tmp);
     
    14951429        mr_strip_spaces(tmp);
    14961430        update_progress_form(tmp);
     1431        mr_free(tmp);
    14971432        if (current_slice_number == 0) {
    14981433            res =
     
    15171452        }
    15181453        retval += res;
    1519         res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
     1454        res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr);
    15201455        if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
    15211456            wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
     
    15241459        g_current_progress++;
    15251460    }
     1461    mr_free(tmp1);
    15261462    paranoid_pclose(pout);
    15271463
     
    15311467    if (use_ntfsprog_hack) {
    15321468        mr_msg(3, "Waiting for ntfsclone to finish");
    1533         sprintf(tmp,
     1469        mr_asprintf(&tmp,
    15341470                " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    15351471        while (system(tmp) == 0) {
    15361472            sleep(1);
    1537         }
     1473        }   
     1474        mr_free(tmp);
    15381475        mr_msg(3, "OK, ntfsclone has really finished");
    15391476    }
     
    15501487    }
    15511488
    1552     mr_free(tmp);
    1553     mr_free(outfile_fname);
    1554     mr_free(command);
    1555     mr_free(ntfsprog_command);
    1556     mr_free(sz_devfile);
    1557     mr_free(ntfsprog_fifo);
    15581489    g_loglevel = old_loglevel;
    15591490    return (retval);
     
    15631494 *END_RESTORE_A_BIGGIEFILE_FROM_STREAM                                    *
    15641495 **************************************************************************/
    1565 
    15661496
    15671497
     
    15831513{
    15841514    int retval = 0;
    1585     int res;
    1586     char *p;
     1515    int res = 0;
     1516    char *p = NULL;
    15871517
    15881518  /** malloc **/
    1589     char *command;
    1590     char *tmp;
    1591     char *filelist_name;
    1592     char *filelist_subset_fname;
    1593     char *executable;
    1594     char *temp_log;
    1595     char screen_message[100];
     1519    char *command = NULL;
     1520    char *tmp = NULL;
     1521    char *filelist_name = NULL;
     1522    char *filelist_subset_fname = NULL;
     1523    char *executable = NULL;
     1524    char *temp_log = NULL;
    15961525    long matches = 0;
    1597     bool use_star;
    1598     char *xattr_fname;
    1599     char *acl_fname;
    1600 //  char files_to_restore_this_time_fname[MAX_STR_LEN];
     1526    bool use_star = FALSE;
     1527    char *xattr_fname = NULL;
     1528    char *acl_fname = NULL;
    16011529
    16021530    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    1603     malloc_string(command);
    1604     malloc_string(tmp);
    1605     malloc_string(filelist_name);
    1606     malloc_string(filelist_subset_fname);
    1607     malloc_string(executable);
    1608     malloc_string(temp_log);
    1609     malloc_string(xattr_fname);
    1610     malloc_string(acl_fname);
    16111531
    16121532    mr_msg(5, "Entering");
    1613     filelist_subset_fname[0] = '\0';
    16141533    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    1615 //  sprintf(files_to_restore_this_time_fname, "/tmp/ftrttf.%d.%d", (int)getpid(), (int)random());
    1616     sprintf(command, "mkdir -p %s/tmp", MNT_RESTORING);
     1534    mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);
    16171535    run_program_and_log_output(command, 9);
    1618     sprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768),
    1619             (int) (random() % 32768));
    1620 
    1621     sprintf(filelist_name, MNT_CDROM "/archives/filelist.%ld",
     1536    mr_free(command);
     1537
     1538    mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld",
    16221539            current_tarball_number);
    16231540    if (length_of_file(filelist_name) <= 2) {
     
    16291546                "but it's non-critical. It's cosmetic. Don't worry about it.");
    16301547        retval = 0;
    1631         goto leave_sub;
     1548        mr_msg(5, "Leaving");
     1549        mr_free(filelist_name);
     1550        return (retval);
    16321551    }
    16331552    if (count_lines_in_file(filelist_name) <= 0
     
    16351554        mr_msg(3, "length_of_file(%s) = %llu", tarball_fname,
    16361555                length_of_file(tarball_fname));
    1637         sprintf(tmp, "Unable to restore fileset #%ld (CD I/O error)",
     1556        log_to_screen(_("Unable to restore fileset #%ld (CD I/O error)"),
    16381557                current_tarball_number);
    1639         log_to_screen(tmp);
    16401558        retval = 1;
    1641         goto leave_sub;
     1559        mr_msg(5, "Leaving");
     1560        mr_free(filelist_name);
     1561        return (retval);
    16421562    }
    16431563
    16441564    if (filelist) {
    1645         sprintf(filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",
     1565        mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",
    16461566                current_tarball_number);
    16471567        if ((matches =
     
    16501570                                             use_star))
    16511571            <= 0) {
    1652             sprintf(tmp, "Skipping fileset %ld", current_tarball_number);
    1653             mr_msg(1, tmp);
     1572            mr_msg(1, "Skipping fileset %ld", current_tarball_number);
    16541573        } else {
    16551574            mr_msg(3, "Saved fileset %ld's subset to %s",
    16561575                    current_tarball_number, filelist_subset_fname);
    16571576        }
    1658         sprintf(screen_message, "Tarball #%ld --- %ld matches",
     1577        log_to_screen("Tarball #%ld --- %ld matches",
    16591578                current_tarball_number, matches);
    1660         log_to_screen(screen_message);
    1661     } else {
    1662         filelist_subset_fname[0] = '\0';
    1663     }
     1579    }
     1580    mr_free(filelist_name);
    16641581
    16651582    if (filelist == NULL || matches > 0) {
    16661583        if (g_getfattr) {
    1667             sprintf(xattr_fname, XATTR_LIST_FNAME_RAW_SZ,
     1584            mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ,
    16681585                MNT_CDROM "/archives", current_tarball_number);
    16691586        }
    16701587        if (g_getfacl) {
    1671             sprintf(acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",
     1588            mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",
    16721589                current_tarball_number);
    16731590        }
    16741591        if (strstr(tarball_fname, ".bz2")) {
    1675             strcpy(executable, "bzip2");
     1592            mr_asprintf(&executable, "-P bzip2 -Z");
    16761593        } else if (strstr(tarball_fname, ".gz")) {
    1677             strcpy(executable, "gzip");
     1594            mr_asprintf(&executable, "-P gzip -Z");
    16781595        } else if (strstr(tarball_fname, ".lzo")) {
    1679             strcpy(executable, "lzop");
    1680         } else {
    1681             executable[0] = '\0';
    1682         }
    1683         if (executable[0]) {
    1684             sprintf(tmp, "which %s > /dev/null 2> /dev/null", executable);
     1596            mr_asprintf(&executable, "-P lzop -Z");
     1597        }
     1598
     1599        if (executable == NULL) {
     1600            mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);
    16851601            if (run_program_and_log_output(tmp, FALSE)) {
    16861602                log_to_screen
    1687                     ("(compare_a_tarball) Compression program not found - oh no!");
     1603                    (_
     1604                     ("(compare_a_tarball) Compression program not found - oh no!"));
     1605                mr_free(tmp);
     1606                mr_free(executable);
     1607                mr_free(acl_fname);
     1608                mr_free(xattr_fname);
     1609                mr_free(filelist_subset_fname);
    16881610                paranoid_MR_finish(1);
    16891611            }
    1690             strcpy(tmp, executable);
    1691             sprintf(executable, "-P %s -Z", tmp);
     1612            mr_free(tmp);
    16921613        }
    16931614#ifdef __FreeBSD__
     
    16971618#endif
    16981619
    1699 //      if (strstr(tarball_fname, ".star."))
    17001620        if (use_star) {
    1701             sprintf(command,
     1621            mr_sprintf(&command,
    17021622                    "star -x -force-remove -U " STAR_ACL_SZ
    17031623                    " errctl= file=%s", tarball_fname);
    17041624            if (strstr(tarball_fname, ".bz2")) {
    1705                 strcat(command, " -bz");
     1625                mr_strcat(command, " -bz");
    17061626            }
    17071627        } else {
    1708             if (filelist_subset_fname[0] != '\0') {
    1709                 sprintf(command,
     1628            if (filelist_subset_fname != NULL) {
     1629                mr_asprintf(&command,
    17101630                        "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s",
    17111631                        TAPE_BLOCK_SIZE,
    17121632                        BUFSIZE, executable, filelist_subset_fname,
    1713 //             files_to_restore_this_time_fname,
    17141633                        tarball_fname);
    17151634            } else {
    1716                 sprintf(command,
     1635                mr_asprintf(&command,
    17171636                        "afio -i -b %ld -c %ld -M 8m %s %s",
    17181637                        TAPE_BLOCK_SIZE,
     
    17201639            }
    17211640        }
     1641        mr_free(executable);
     1642
    17221643#undef BUFSIZE
    1723         sprintf(command + strlen(command), " 2>> %s >> %s", temp_log,
    1724                 temp_log);
     1644        mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),
     1645            (int) (random() % 32768));
     1646
     1647        mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log);
    17251648        mr_msg(1, "command = '%s'", command);
    17261649        unlink(temp_log);
     
    17341657            }
    17351658        }
     1659        mr_free(command);
     1660
    17361661        if (res && length_of_file(temp_log) < 5) {
    17371662            res = 0;
     
    17651690        }
    17661691        if (retval) {
    1767             sprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
     1692            mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
    17681693            system(command);
     1694            mr_free(command);
    17691695            mr_msg(2, "Errors occurred while processing fileset #%d",
    17701696                    current_tarball_number);
     
    17721698            mr_msg(2, "Fileset #%d processed OK", current_tarball_number);
    17731699        }
     1700        unlink(xattr_fname);
     1701        mr_free(xattr_fname);
     1702        unlink(acl_fname);
     1703        mr_free(acl_fname);
     1704        unlink(temp_log);
     1705        mr_free(temp_log);
    17741706    }
    17751707    if (does_file_exist("/PAUSE")) {
    17761708        popup_and_OK
    1777             ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
     1709            (_
     1710             ("Press ENTER to go on. Delete /PAUSE to stop these pauses."));
    17781711    }
    17791712    unlink(filelist_subset_fname);
    1780     unlink(xattr_fname);
    1781     unlink(acl_fname);
    1782     unlink(temp_log);
    1783 
    1784   leave_sub:
    1785     mr_free(command);
    1786     mr_free(tmp);
    1787     mr_free(filelist_name);
    17881713    mr_free(filelist_subset_fname);
    1789     mr_free(executable);
    1790     mr_free(temp_log);
    1791     mr_free(xattr_fname);
    1792     mr_free(acl_fname);
    17931714    mr_msg(5, "Leaving");
    17941715    return (retval);
     
    18271748
    18281749  /** malloc add ***/
    1829     char *tmp;
    1830     char *command;
    1831     char *afio_fname;
    1832     char *filelist_fname;
    1833     char *filelist_subset_fname;
    1834     char *executable;
     1750    char *tmp = NULL;
     1751    char *command = NULL;
     1752    char *afio_fname = NULL;
     1753    char *filelist_fname = NULL;
     1754    char *filelist_subset_fname = NULL;
     1755    char *executable = NULL;
    18351756    long matches = 0;
    18361757    bool restore_this_fileset = FALSE;
    1837     bool use_star;
     1758    bool use_star = FALSE;
    18381759
    18391760    assert(bkpinfo != NULL);
    18401761    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    1841     malloc_string(filelist_subset_fname);
    1842     malloc_string(filelist_fname);
    1843     malloc_string(afio_fname);
    1844     malloc_string(executable);
    1845     malloc_string(command);
    1846     malloc_string(tmp);
    1847     filelist_subset_fname[0] = '\0';
    18481762    /* to do it with a file... */
    18491763    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    1850     sprintf(tmp,
    1851             "Restoring from fileset #%ld (%ld KB) on %s #%d",
     1764    mr_msg(2, "Restoring from fileset #%ld (%ld KB) on %s #%d",
    18521765            current_tarball_number, (long) size >> 10,
    1853             media_descriptor_string(bkpinfo->backup_media_type),
     1766            bkpinfo->backup_media_string,
    18541767            g_current_media_number);
    1855     mr_msg(2, tmp);
    18561768    run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE);
    18571769
     
    18611773   * in afio or someting; oh darn.. OK, use tmpfs :-)                         *
    18621774   ****************************************************************************/
    1863     filelist_fname[0] = filelist_subset_fname[0] = '\0';
    1864     sprintf(afio_fname, "/tmp/tmpfs/archive.tmp.%ld",
     1775    mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld",
    18651776            current_tarball_number);
    1866     sprintf(filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,
     1777    mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,
    18671778            current_tarball_number);
    1868     sprintf(filelist_subset_fname, "%s/filelist-subset-%ld.tmp",
     1779    mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp",
    18691780            bkpinfo->tmpdir, current_tarball_number);
    1870 //  sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number);
    18711781    res = read_file_from_stream_to_file(bkpinfo, afio_fname, size);
    18721782    if (strstr(tarball_fname, ".star")) {
     
    18761786        mr_msg(1, "Warning - error reading afioball from tape");
    18771787    }
    1878     if (bkpinfo->compression_level == 0) {
    1879         executable[0] = '\0';
    1880     } else {
     1788    if (bkpinfo->compression_level != 0) {
    18811789        if (bkpinfo->use_star) {
    1882             strcpy(executable, " -bz");
     1790            mr_asprintf(&executable, " -bz");
    18831791        } else {
    1884             sprintf(executable, "-P %s -Z", bkpinfo->zip_exe);
     1792            mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);
    18851793        }
    18861794    }
     
    18931801        if (strstr(tarball_fname, ".star.")) {
    18941802            use_star = TRUE;
    1895             sprintf(command, "star -t file=%s %s", afio_fname, executable);
     1803            mr_asprintf(&command, "star -t file=%s %s", afio_fname, executable);
    18961804        } else {
    18971805            use_star = FALSE;
    1898             sprintf(command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE,
     1806            mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE,
    18991807                    executable, afio_fname);
    19001808        }
    1901         sprintf(command + strlen(command), " > %s 2>> %s", filelist_fname,
    1902                 MONDO_LOGFILE);
     1809        mr_strcat(command, " > %s 2>> %s", filelist_fname, MONDO_LOGFILE);
    19031810        mr_msg(1, "command = %s", command);
    19041811        if (system(command)) {
    19051812            mr_msg(4, "Warning - error occurred while retrieving TOC");
    19061813        }
     1814        mr_free(command);
     1815
    19071816        if ((matches =
    19081817             save_filelist_entries_in_common(filelist_fname, filelist,
     
    19141823                        current_tarball_number);
    19151824            }
    1916             sprintf(tmp, "Skipping fileset %ld", current_tarball_number);
    1917             mr_msg(2, tmp);
     1825            mr_msg(2, "Skipping fileset %ld", current_tarball_number);
    19181826            restore_this_fileset = FALSE;
    19191827        } else {
     
    19241832        }
    19251833    }
     1834    unlink(filelist_fname);
     1835    mr_free(filelist_fname);
    19261836
    19271837// Concoct the call to star/afio to restore files
    1928     if (strstr(tarball_fname, ".star."))    // star
    1929     {
    1930         sprintf(command, "star -x file=%s %s", afio_fname, executable);
     1838    if (strstr(tarball_fname, ".star.")) {
     1839        // star
    19311840        if (filelist) {
    1932             sprintf(command + strlen(command), " list=%s",
    1933                     filelist_subset_fname);
    1934         }
    1935     } else                      // afio
    1936     {
    1937         sprintf(command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE,
    1938                 executable);
     1841            mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, filelist_subset_fname, MONDO_LOGFILE);
     1842        } else {
     1843            mr_asprintf(&command, "star -x file=%s %s 2>> %s", afio_fname, executable, MONDO_LOGFILE);
     1844        }
     1845    } else {
     1846        // afio
    19391847        if (filelist) {
    1940             sprintf(command + strlen(command), " -w %s",
    1941                     filelist_subset_fname);
    1942         }
    1943         sprintf(command + strlen(command), " %s", afio_fname);
    1944     }
    1945     sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);
    1946 
    1947 // Call if IF there are files to restore (selectively/unconditionally)
     1848            mr_asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname, afio_fname, MONDO_LOGFILE);
     1849        } else {
     1850            mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, afio_fname, MONDO_LOGFILE);
     1851        }
     1852    }
     1853    mr_free(executable);
     1854
     1855    // Call if IF there are files to restore (selectively/unconditionally)
    19481856    if (restore_this_fileset) {
    19491857        mr_msg(1, "Calling command='%s'", command);
     
    19751883        mr_msg(1, "NOT CALLING '%s'", command);
    19761884    }
     1885    mr_free(command);
    19771886
    19781887    if (does_file_exist("/PAUSE") && current_tarball_number >= 50) {
    1979         log_to_screen("Paused after set %ld", current_tarball_number);
    1980         popup_and_OK("Pausing. Press ENTER to continue.");
     1888        log_to_screen(_("Paused after set %ld"), current_tarball_number);
     1889        popup_and_OK(_("Pausing. Press ENTER to continue."));
    19811890    }
    19821891
    19831892    unlink(filelist_subset_fname);
    1984     unlink(filelist_fname);
    19851893    unlink(afio_fname);
    19861894
    19871895    mr_free(filelist_subset_fname);
    1988     mr_free(filelist_fname);
    19891896    mr_free(afio_fname);
    1990     mr_free(command);
    1991     mr_free(tmp);
    19921897    return (retval);
    19931898}
     
    19961901 *END_RESTORE_A_TARBALL_FROM_STREAM                                       *
    19971902 **************************************************************************/
    1998 
    1999 
    20001903
    20011904
     
    20141917{
    20151918    int retval = 0;
    2016     int res;
    2017     long noof_biggiefiles, bigfileno = 0, total_slices;
    2018   /** malloc **/
    2019     char *tmp;
    2020     bool just_changed_cds = FALSE, finished;
    2021     char *xattr_fname;
    2022     char *acl_fname;
    2023     char *biggies_whose_EXATs_we_should_set;    // EXtended ATtributes
    2024     char *pathname_of_last_biggie_restored;
     1919    int res = 0;
     1920    long noof_biggiefiles = 0L, bigfileno = 0L, total_slices = 0L;
     1921    char *tmp = NULL;
     1922    char *tmp1 = NULL;
     1923    bool just_changed_cds = FALSE, finished = FALSE;
     1924    char *xattr_fname = NULL;
     1925    char *acl_fname = NULL;
     1926    char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
     1927    char *pathname_of_last_biggie_restored = NULL;
    20251928    FILE *fbw = NULL;
    20261929
    2027     malloc_string(xattr_fname);
    2028     malloc_string(acl_fname);
    2029     malloc_string(tmp);
    2030     malloc_string(biggies_whose_EXATs_we_should_set);
     1930    malloc_string(tmp1);
    20311931    malloc_string(pathname_of_last_biggie_restored);
    20321932    assert(bkpinfo != NULL);
    20331933
    2034     sprintf(biggies_whose_EXATs_we_should_set,
     1934    mr_asprintf(&biggies_whose_EXATs_we_should_set,
    20351935            "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    20361936    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
     
    20391939    }
    20401940
    2041     read_cfg_var(g_mondo_cfg_file, "total-slices", tmp);
    2042     total_slices = atol(tmp);
    2043     sprintf(tmp, "Reassembling large files      ");
     1941    read_cfg_var(g_mondo_cfg_file, "total-slices", tmp1);
     1942    total_slices = atol(tmp1);
     1943    mr_free(tmp1);
     1944
     1945    mr_asprintf(&tmp, _("Reassembling large files      "));
    20441946    mvaddstr_and_log_it(g_currentY, 0, tmp);
     1947    mr_free(tmp);
     1948
    20451949    if (length_of_file(BIGGIELIST) < 6) {
    20461950        mr_msg(1, "OK, no biggielist; not restoring biggiefiles");
     
    20531957        return (0);
    20541958    }
    2055     sprintf(tmp, "OK, there are %ld biggiefiles in the archives",
    2056             noof_biggiefiles);
    2057     mr_msg(2, tmp);
    2058 
    2059     open_progress_form("Reassembling large files",
    2060                        "I am now reassembling all the large files.",
    2061                        "Please wait. This may take some time.",
     1959    mr_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles);
     1960
     1961    open_progress_form(_("Reassembling large files"),
     1962                       _("I am now reassembling all the large files."),
     1963                       _("Please wait. This may take some time."),
    20621964                       "", total_slices);
    20631965    for (bigfileno = 0, finished = FALSE; !finished;) {
     
    20681970            mr_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d",
    20691971                    bigfileno + 1,
    2070                     media_descriptor_string(bkpinfo->backup_media_type),
     1972                    bkpinfo->backup_media_string,
    20711973                    g_current_media_number);
    20721974            mr_msg(3, "Slicename would have been %s",
     
    20801982                insist_on_this_cd_number(bkpinfo,
    20811983                                         ++g_current_media_number);
    2082                 sprintf(tmp, "Restoring from %s #%d",
    2083                         media_descriptor_string(bkpinfo->
    2084                                                 backup_media_type),
     1984                log_to_screen(_("Restoring from %s #%d"),
     1985                        bkpinfo->backup_media_string,
    20851986                        g_current_media_number);
    2086                 log_to_screen(tmp);
    20871987                just_changed_cds = TRUE;
    20881988            } else {
     
    20941994        } else {
    20951995            just_changed_cds = FALSE;
    2096             sprintf(tmp, "Restoring big file %ld", bigfileno + 1);
     1996            mr_asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1);
    20971997            update_progress_form(tmp);
     1998            mr_free(tmp);
     1999
    20982000            res =
    20992001                restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist,
     
    21052007            retval += res;
    21062008            bigfileno++;
    2107 
    21082009        }
    21092010    }
     
    21122013        fclose(fbw);
    21132014        if (g_getfattr) {
    2114             sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2015            mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    21152016            if (length_of_file(xattr_fname) > 0) {
    21162017                set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
     
    21182019        }
    21192020        if (g_getfacl) {
    2120             sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
     2021            mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    21212022            if (length_of_file(acl_fname) > 0) {
    21222023                set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    21232024            }
    21242025        }
    2125     }
     2026        mr_free(acl_fname);
     2027        mr_free(xattr_fname);
     2028    }
     2029    mr_free(biggies_whose_EXATs_we_should_set);
     2030
    21262031    if (does_file_exist("/PAUSE")) {
    21272032        popup_and_OK
    2128             ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
     2033            (_
     2034             ("Press ENTER to go on. Delete /PAUSE to stop these pauses."));
    21292035    }
    21302036    close_progress_form();
    21312037    if (retval) {
    2132         mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
     2038        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
    21332039    } else {
    2134         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    2135     }
    2136     mr_free(xattr_fname);
    2137     mr_free(acl_fname);
    2138     mr_free(tmp);
    2139     mr_free(biggies_whose_EXATs_we_should_set);
     2040        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     2041    }
    21402042    mr_free(pathname_of_last_biggie_restored);
    21412043    return (retval);
     
    21452047 *END_RESTORE_ALL_BIGGIFILES_FROM_CD                                      *
    21462048 **************************************************************************/
    2147 
    21482049
    21492050
     
    21632064{
    21642065    int retval = 0;
    2165     int res;
    2166     int attempts;
     2066    int res = 0;
     2067    int attempts = 0;
    21672068    long current_tarball_number = 0;
    2168     long max_val;
     2069    long max_val = 0L;
    21692070  /**malloc ***/
    2170     char *tmp;
    2171     char *tarball_fname;
    2172     char *progress_str;
    2173     char *comment;
    2174 
    2175     malloc_string(tmp);
     2071    char *tmp = NULL;
     2072    char *tmp1 = NULL;
     2073    char *tarball_fname = NULL;
     2074    char *progress_str = NULL;
     2075    char *comment = NULL;
     2076
     2077    malloc_string(tmp1);
    21762078    malloc_string(tarball_fname);
    21772079    malloc_string(progress_str);
     
    21802082    assert(bkpinfo != NULL);
    21812083
    2182     mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
     2084    mvaddstr_and_log_it(g_currentY, 0, _("Restoring from archives"));
    21832085    mr_msg(2,
    21842086            "Insisting on 1st CD, so that I can have a look at LAST-FILELIST-NUMBER");
     
    21882090    }
    21892091    insist_on_this_cd_number(bkpinfo, g_current_media_number);
    2190     read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    2191     max_val = atol(tmp) + 1;
    2192     sprintf(progress_str, "Restoring from %s #%d",
    2193             media_descriptor_string(bkpinfo->backup_media_type),
     2092    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp1);
     2093    max_val = atol(tmp1) + 1;
     2094    mr_free(tmp1);
     2095
     2096    mr_asprintf(&progress_str, _("Restoring from %s #%d"),
     2097            bkpinfo->backup_media_string,
    21942098            g_current_media_number);
    21952099    log_to_screen(progress_str);
    2196     open_progress_form("Restoring from archives",
    2197                        "Restoring data from the archives.",
    2198                        "Please wait. This may take some time.",
     2100    open_progress_form(_("Restoring from archives"),
     2101                       _("Restoring data from the archives."),
     2102                       _("Please wait. This may take some time."),
    21992103                       progress_str, max_val);
    22002104    for (;;) {
    22012105        insist_on_this_cd_number(bkpinfo, g_current_media_number);
    22022106        update_progress_form(progress_str);
    2203         sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
     2107        mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
    22042108                current_tarball_number);
    22052109        if (!does_file_exist(tarball_fname)) {
    2206             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.gz",
     2110            mr_free(tarball_fname);
     2111            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",
    22072112                current_tarball_number);
    22082113        }
    22092114        if (!does_file_exist(tarball_fname)) {
    2210             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",
     2115            mr_free(tarball_fname);
     2116            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.gz",
    22112117                    current_tarball_number);
    22122118        }
    22132119        if (!does_file_exist(tarball_fname)) {
    2214             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.",
     2120            mr_free(tarball_fname);
     2121            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.",
    22152122                    current_tarball_number);
    22162123        }
    22172124        if (!does_file_exist(tarball_fname)) {
    2218             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",
     2125            mr_free(tarball_fname);
     2126            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",
    22192127                    current_tarball_number);
    22202128        }
    22212129        if (!does_file_exist(tarball_fname)) {
    2222             sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.",
     2130            mr_free(tarball_fname);
     2131            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.",
    22232132                    current_tarball_number);
    22242133        }
    22252134        if (!does_file_exist(tarball_fname)) {
     2135            mr_free(tarball_fname);
    22262136            if (current_tarball_number == 0) {
    22272137                log_to_screen
    2228                     ("No tarballs. Strange. Maybe you only backed up freakin' big files?");
     2138                    (_
     2139                     ("No tarballs. Strange. Maybe you only backed up freakin' big files?"));
     2140                mr_free(progress_str);
    22292141                return (0);
    22302142            }
     
    22332145                          "/archives/slice* > /dev/null 2> /dev/null") ==
    22342146                0) {
     2147                mr_free(tarball_fname);
     2148                mr_free(progress_str);
    22352149                break;
    22362150            }
    22372151            g_current_media_number++;
    2238             sprintf(progress_str, "Restoring from %s #%d",
    2239                     media_descriptor_string(bkpinfo->backup_media_type),
     2152            mr_free(progress_str);
     2153
     2154            mr_asprintf(&progress_str, _("Restoring from %s #%d"),
     2155                    bkpinfo->backup_media_string,
    22402156                    g_current_media_number);
    22412157            log_to_screen(progress_str);
    22422158        } else {
    2243             sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
     2159            mr_free(progress_str);
     2160            mr_asprintf(&progress_str,
     2161                    _("Restoring from fileset #%ld on %s #%d"),
    22442162                    current_tarball_number,
    2245                     media_descriptor_string(bkpinfo->backup_media_type),
     2163                    bkpinfo->backup_media_string,
    22462164                    g_current_media_number);
    2247 //    mr_msg(3, "progress_str = %s", progress_str);
    22482165            for (res = 999, attempts = 0; attempts < 3 && res != 0;
    22492166                 attempts++) {
     
    22532170                                              filelist, bkpinfo);
    22542171            }
    2255             sprintf(tmp, "%s #%d, fileset #%ld - restore ",
     2172            mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore "),
    22562173                    media_descriptor_string(bkpinfo->backup_media_type),
    22572174                    g_current_media_number, current_tarball_number);
    22582175            if (res) {
    2259                 strcat(tmp, "reported errors");
    2260             } else if (attempts > 1) {
    2261                 strcat(tmp, "succeeded");
     2176                mr_strcat(tmp, _("reported errors"));
    22622177            } else {
    2263                 strcat(tmp, "succeeded");
     2178                mr_strcat(tmp, _("succeeded"));
    22642179            }
    22652180            if (attempts > 1) {
    2266                 sprintf(tmp + strlen(tmp), " (%d attempts) - review logs",
    2267                         attempts);
    2268             }
    2269             strcpy(comment, tmp);
     2181                mr_strcat(tmp, _(" (%d attempts) - review logs"), attempts);
     2182            }
    22702183            if (attempts > 1) {
    2271                 log_to_screen(comment);
    2272             }
     2184                log_to_screen(tmp);
     2185            }
     2186            mr_free(tmp);
    22732187
    22742188            retval += res;
     
    22762190            g_current_progress++;
    22772191        }
    2278     }
     2192        mr_free(tarball_fname);
     2193    }
     2194    mr_free(progress_str);
    22792195    close_progress_form();
     2196
    22802197    if (retval) {
    2281         mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
     2198        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
    22822199    } else {
    2283         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    2284     }
    2285     mr_free(tmp);
    2286     mr_free(tarball_fname);
    2287     mr_free(progress_str);
    2288     mr_free(comment);
    2289 
     2200        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     2201    }
    22902202    return (retval);
    22912203}
     
    22942206 *END_RESTORE_ALL_TARBALLS_FROM_CD                                        *
    22952207 **************************************************************************/
    2296 
    22972208
    22982209
     
    23082219                                    struct s_node *filelist)
    23092220{
    2310     long noof_biggiefiles;
    2311     long current_bigfile_number = 0;
    2312     long total_slices;
     2221    long noof_biggiefiles = 0L;
     2222    long current_bigfile_number = 0L;
     2223    long total_slices = 0L;
    23132224
    23142225    int retval = 0;
    23152226    int res = 0;
    2316     int ctrl_chr;
     2227    int ctrl_chr = 0;
    23172228
    23182229  /** malloc add ****/
    2319     char *tmp;
    2320     char *biggie_fname;
    2321     char *biggie_cksum;
    2322     char *xattr_fname;
    2323     char *acl_fname;
    2324     char *p;
    2325     char *pathname_of_last_biggie_restored;
    2326     char *biggies_whose_EXATs_we_should_set;    // EXtended ATtributes
    2327     long long biggie_size;
    2328     FILE *fbw = NULL;
     2230    char *tmp = NULL;
     2231    char *biggie_fname = NULL;
     2232    char *biggie_cksum = NULL;
     2233    char *xattr_fname = NULL;
     2234    char *acl_fname = NULL;
     2235    char *pathname_of_last_biggie_restored = NULL;
     2236    char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
     2237    long long biggie_size = (long long)0;
     2238    FILE *fbw;
     2239
     2240    assert(bkpinfo != NULL);
    23292241
    23302242    malloc_string(tmp);
    23312243    malloc_string(biggie_fname);
    23322244    malloc_string(biggie_cksum);
    2333     malloc_string(xattr_fname);
    2334     malloc_string(acl_fname);
    2335     malloc_string(biggies_whose_EXATs_we_should_set);
    23362245    malloc_string(pathname_of_last_biggie_restored);
    2337     assert(bkpinfo != NULL);
    2338 
    23392246    read_cfg_var(g_mondo_cfg_file, "total-slices", tmp);
    2340 
    23412247    total_slices = atol(tmp);
    2342     sprintf(tmp, "Reassembling large files      ");
     2248    mr_free(tmp);
     2249
     2250    mr_asprintf(&tmp, "Reassembling large files      ");
    23432251    if (g_getfattr) {
    2344         sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2252        mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    23452253    }
    23462254    if (g_getfacl) {
    2347         sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2255        mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    23482256    }
    23492257    mvaddstr_and_log_it(g_currentY, 0, tmp);
    2350     sprintf(biggies_whose_EXATs_we_should_set,
     2258    mr_free(tmp);
     2259
     2260    mr_asprintf(&biggies_whose_EXATs_we_should_set,
    23512261            "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
    23522262    if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
     
    23542264                biggies_whose_EXATs_we_should_set);
    23552265    }
    2356 // get xattr and acl files if they're there
     2266    // get xattr and acl files if they're there
    23572267    res =
    23582268        read_header_block_from_stream(&biggie_size, biggie_fname,
     
    23652275
    23662276    noof_biggiefiles = atol(biggie_fname);
    2367     sprintf(tmp, "OK, there are %ld biggiefiles in the archives",
     2277    mr_msg(2, "OK, there are %ld biggiefiles in the archives",
    23682278            noof_biggiefiles);
    2369     mr_msg(2, tmp);
    2370     open_progress_form("Reassembling large files",
    2371                        "I am now reassembling all the large files.",
    2372                        "Please wait. This may take some time.",
     2279    open_progress_form(_("Reassembling large files"),
     2280                       _("I am now reassembling all the large files."),
     2281                       _("Please wait. This may take some time."),
    23732282                       "", total_slices);
    23742283
     
    23842293            wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr);
    23852294        }
     2295        /* BERLIOS: useless
    23862296        p = strrchr(biggie_fname, '/');
    23872297        if (!p) {
     
    23902300            p++;
    23912301        }
    2392         sprintf(tmp, "Restoring big file %ld (%lld K)",
     2302        */
     2303        mr_asprintf(&tmp, _("Restoring big file %ld (%lld K)"),
    23932304                current_bigfile_number + 1, biggie_size / 1024);
    23942305        update_progress_form(tmp);
     2306        mr_free(tmp);
     2307
    23952308        res = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname,
    23962309                                               current_bigfile_number,
     
    24042317            fprintf(fbw, "%s\n", pathname_of_last_biggie_restored);
    24052318        }
     2319        mr_free(pathname_of_last_biggie_restored);
     2320
    24062321        retval += res;
    24072322        current_bigfile_number++;
     
    24102325    if (current_bigfile_number != noof_biggiefiles
    24112326        && noof_biggiefiles != 0) {
    2412         sprintf(tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",
     2327        mr_msg(1, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",
    24132328                current_bigfile_number, noof_biggiefiles);
    24142329    } else {
    2415         sprintf(tmp,
    2416                 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.",
     2330        mr_msg(1, "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.",
    24172331                noof_biggiefiles, current_bigfile_number);
    24182332    }
    2419     mr_msg(1, tmp);
    24202333
    24212334    if (fbw) {
     
    24432356        }
    24442357    }
     2358    mr_free(xattr_fname);
     2359    mr_free(acl_fname);
     2360    mr_free(biggies_whose_EXATs_we_should_set);
     2361
    24452362    if (does_file_exist("/PAUSE")) {
    24462363        popup_and_OK
    2447             ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
     2364            (_
     2365             ("Press ENTER to go on. Delete /PAUSE to stop these pauses."));
    24482366    }
    24492367
    24502368    close_progress_form();
    24512369    if (retval) {
    2452         mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
     2370        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
    24532371    } else {
    2454         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    2455     }
    2456     mr_free(biggies_whose_EXATs_we_should_set);
    2457     mr_free(pathname_of_last_biggie_restored);
     2372        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     2373    }
    24582374    mr_free(biggie_fname);
    24592375    mr_free(biggie_cksum);
    2460     mr_free(xattr_fname);
    2461     mr_free(acl_fname);
    2462     mr_free(tmp);
    24632376    return (retval);
    24642377}
     
    24672380 *END_RESTORE_ALL_BIGGIEFILES_FROM_STREAM                                 *
    24682381 **************************************************************************/
    2469 
    2470 
    2471 
    2472 
    24732382
    24742383
     
    24882397{
    24892398    int retval = 0;
    2490     int res;
     2399    int res = 0;
    24912400    long current_afioball_number = 0;
    2492     int ctrl_chr;
    2493     long max_val /*, total_noof_files */ ;
     2401    int ctrl_chr = 0;
     2402    long max_val = 0L /*, total_noof_files */ ;
    24942403
    24952404  /** malloc **/
    2496     char *tmp;
    2497     char *progress_str;
    2498     char *tmp_fname;
    2499     char *xattr_fname;
    2500     char *acl_fname;
    2501 
    2502     long long tmp_size;
    2503 
     2405    char *tmp = NULL;
     2406    char *progress_str = NULL;
     2407    char *tmp_fname = NULL;
     2408    char *xattr_fname = NULL;
     2409    char *acl_fname = NULL;
     2410
     2411    long long tmp_size = 0L;
     2412
     2413    malloc_string(tmp_fname);
    25042414    malloc_string(tmp);
    2505     malloc_string(progress_str);
    2506     malloc_string(tmp_fname);
    25072415    assert(bkpinfo != NULL);
    2508     malloc_string(xattr_fname);
    2509     malloc_string(acl_fname);
    2510     mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
     2416    mvaddstr_and_log_it(g_currentY, 0, _("Restoring from archives"));
    25112417    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    25122418    max_val = atol(tmp) + 1;
     2419    mr_free(tmp);
    25132420
    25142421    chdir(bkpinfo->restore_path);   /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */
     
    25162423    run_program_and_log_output("pwd", 5);
    25172424
    2518     sprintf(progress_str, "Restoring from media #%d",
     2425    mr_asprintf(&progress_str, _("Restoring from media #%d"),
    25192426            g_current_media_number);
    25202427    log_to_screen(progress_str);
    2521     open_progress_form("Restoring from archives",
    2522                        "Restoring data from the archives.",
    2523                        "Please wait. This may take some time.",
     2428    open_progress_form(_("Restoring from archives"),
     2429                       _("Restoring data from the archives."),
     2430                       _("Please wait. This may take some time."),
    25242431                       progress_str, max_val);
    25252432
     
    25392446        update_progress_form(progress_str);
    25402447        if (g_getfattr) {
    2541             sprintf(xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
     2448            mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
    25422449                current_afioball_number);
    25432450            unlink(xattr_fname);
    25442451        }
    25452452        if (g_getfacl) {
    2546             sprintf(acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,
     2453            mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,
    25472454                current_afioball_number);
    25482455            unlink(acl_fname);
     
    25582465            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    25592466        }
    2560         sprintf(tmp,
    2561                 "Restoring from fileset #%ld (name=%s, size=%ld K)",
     2467        /* BERLIOS: useless ?
     2468        mr_asprintf(&tmp,
     2469                _("Restoring from fileset #%ld (name=%s, size=%ld K)"),
    25622470                current_afioball_number, tmp_fname, (long) tmp_size >> 10);
     2471                */
    25632472        res =
    25642473            restore_a_tarball_from_stream(bkpinfo, tmp_fname,
     
    25682477        retval += res;
    25692478        if (res) {
    2570             sprintf(tmp, "Fileset %ld - errors occurred",
     2479            log_to_screen("Fileset %ld - errors occurred",
    25712480                    current_afioball_number);
    2572             log_to_screen(tmp);
    25732481        }
    25742482        res =
     
    25802488        current_afioball_number++;
    25812489        g_current_progress++;
    2582         sprintf(progress_str, "Restoring from fileset #%ld on %s #%d",
     2490
     2491        mr_free(progress_str);
     2492        mr_asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"),
    25832493                current_afioball_number,
    2584                 media_descriptor_string(bkpinfo->backup_media_type),
     2494                bkpinfo->backup_media_string,
    25852495                g_current_media_number);
    25862496        res =
     
    25922502            unlink(acl_fname);
    25932503        }
     2504        mr_free(xattr_fname);
     2505        mr_free(acl_fname);
    25942506    }                           // next
     2507    mr_free(progress_str);
     2508    mr_free(tmp_fname);
     2509
    25952510    mr_msg(1, "All done with afioballs");
    25962511    close_progress_form();
    25972512    if (retval) {
    2598         mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
     2513        mvaddstr_and_log_it(g_currentY++, 74, _("Errors."));
    25992514    } else {
    2600         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    2601     }
    2602     mr_free(tmp);
    2603     mr_free(progress_str);
    2604     mr_free(tmp_fname);
    2605     mr_free(xattr_fname);
    2606     mr_free(acl_fname);
     2515        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     2516    }
    26072517    return (retval);
    26082518}
     
    26292539
    26302540  /** mallco ***/
    2631     char *cwd;
    2632     char *newpath;
    2633     char *tmp;
     2541    char *cwd = NULL;
     2542    char *newpath = NULL;
     2543    char *tmp = NULL;
    26342544    assert(bkpinfo != NULL);
    26352545
    26362546    malloc_string(cwd);
    26372547    malloc_string(newpath);
    2638     malloc_string(tmp);
    26392548    mr_msg(2, "restore_everything() --- starting");
    26402549    g_current_media_number = 1;
     2550    /* BERLIOS: should test return value, or better change the function */
    26412551    getcwd(cwd, MAX_STR_LEN - 1);
    2642     sprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
     2552    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);
    26432553    run_program_and_log_output(tmp, FALSE);
     2554    mr_free(tmp);
     2555
    26442556    mr_msg(1, "Changing dir to %s", bkpinfo->restore_path);
    26452557    chdir(bkpinfo->restore_path);
     2558    /* BERLIOS: should test return value, or better change the function */
    26462559    getcwd(newpath, MAX_STR_LEN - 1);
    26472560    mr_msg(1, "path is now %s", newpath);
     
    26492562    if (!find_home_of_exe("petris") && !g_text_mode) {
    26502563        newtDrawRootText(0, g_noof_rows - 2,
    2651                          "Press ALT-<left cursor> twice to play Petris :-) ");
     2564                         _
     2565                         ("Press ALT-<left cursor> twice to play Petris :-) "));
    26522566        newtRefresh();
    26532567    }
    2654     mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives");
     2568    mvaddstr_and_log_it(g_currentY, 0, _("Preparing to read your archives"));
    26552569    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    26562570        mount_cdrom(bkpinfo);
    26572571        mvaddstr_and_log_it(g_currentY++, 0,
    2658                             "Restoring OS and data from streaming media");
     2572                            _
     2573                            ("Restoring OS and data from streaming media"));
    26592574        if (bkpinfo->backup_media_type == cdstream) {
    26602575            openin_cdstream(bkpinfo);
     
    26732588    } else {
    26742589        mvaddstr_and_log_it(g_currentY++, 0,
    2675                             "Restoring OS and data from CD       ");
     2590                            _("Restoring OS and data from CD       "));
    26762591        mount_cdrom(bkpinfo);
    26772592        resA = restore_all_tarballs_from_CD(bkpinfo, filelist);
     
    26802595    chdir(cwd);
    26812596    if (resA + resB) {
    2682         log_to_screen("Errors occurred while data was being restored.");
     2597        log_to_screen(_("Errors occurred while data was being restored."));
    26832598    }
    26842599    if (length_of_file("/etc/raidtab") > 0) {
     
    26912606    mr_free(cwd);
    26922607    mr_free(newpath);
    2693     mr_free(tmp);
    26942608    return (resA + resB);
    26952609}
     
    26982612 *END_RESTORE_EVERYTHING                                                  *
    26992613 **************************************************************************/
    2700 
    27012614
    27022615
     
    28202733extern void wait_until_software_raids_are_prepped(char *, int);
    28212734
    2822 
    28232735char which_restore_mode(void);
    28242736
     
    28532765            "stopped for some reason, chances are it's detailed here.    ");
    28542766    mr_msg(0,
    2855             "More than likely there's a message at the very end of this  ");
     2767            "More than likely there's a message near the end of this     ");
    28562768    mr_msg(0,
    28572769            "log that will tell you what is wrong.  Please read it!      ");
     
    28612773
    28622774
    2863 
    28642775/**
    28652776 * Restore the user's data.
     
    28682779int main(int argc, char *argv[])
    28692780{
    2870     FILE *fin;
    2871     FILE *fout;
     2781    FILE *fin = NULL;
     2782    FILE *fout = NULL;
    28722783    int retval = 0;
    2873     int res;
    2874 //  int c;
    2875     char *tmp;
    2876 
    2877     struct mountlist_itself *mountlist;
    2878     struct raidlist_itself *raidlist;
    2879     struct s_bkpinfo *bkpinfo;
    2880     struct s_node *filelist;
    2881     char *a, *b;
     2784    int res = 0;
     2785    char *tmp = NULL;
     2786
     2787    struct mountlist_itself *mountlist = NULL;
     2788    struct raidlist_itself *raidlist = NULL;
     2789    struct s_bkpinfo *bkpinfo = NULL;
     2790    struct s_node *filelist = NULL;
     2791    char *a = NULL, *b = NULL;
    28822792    bool run_postnuke = FALSE;
    28832793
    2884   /**************************************************************************
    2885    * hugo-                                                                  *
    2886    * busy stuff here - it needs some comments -stan                           *
    2887    *                                                                        *
    2888    **************************************************************************/
     2794#ifdef ENABLE_NLS
     2795    setlocale(LC_ALL, "");
     2796    (void) textdomain("mondo");
     2797#endif
     2798
    28892799    if (getuid() != 0) {
    2890         fprintf(stderr, "Please run as root.\n");
     2800        fprintf(stderr, _("Please run as root.\n"));
    28912801        exit(127);
    28922802    }
    28932803
    28942804    g_loglevel = DEFAULT_MR_LOGLEVEL;
    2895     malloc_string(tmp);
    28962805
    28972806/* Configure global variables */
     
    29262835    run_program_and_log_output("mkdir -p /mnt/floppy", FALSE);
    29272836
    2928     malloc_string(tmp);
    29292837    malloc_string(a);
    29302838    malloc_string(b);
     
    29322840    reset_bkpinfo(bkpinfo);
    29332841    bkpinfo->backup_media_type = none;  // in case boot disk was made for one backup type but user wants to restore from another backup type
     2842    bkpinfo->backup_media_string = NULL;
    29342843    bkpinfo->restore_data = TRUE;   // Well, yeah :-)
    29352844    if (am_I_in_disaster_recovery_mode()) {
     
    29502859
    29512860/* Backup original mountlist.txt */
    2952     sprintf(tmp, "%s.orig", g_mountlist_fname);
     2861    mr_asprintf(&tmp, "%s.orig", g_mountlist_fname);
    29532862    if (!does_file_exist(g_mountlist_fname)) {
    29542863        mr_msg(2,
     
    29562865                __LINE__, g_mountlist_fname);
    29572866    } else if (!does_file_exist(tmp)) {
    2958         sprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname,
     2867        mr_free(tmp);
     2868        mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname,
    29592869                g_mountlist_fname);
    29602870        run_program_and_log_output(tmp, FALSE);
    29612871    }
     2872    mr_free(tmp);
    29622873
    29632874/* Init directories */
    29642875    make_hole_for_dir(bkpinfo->tmpdir);
    2965     sprintf(tmp, "mkdir -p %s", bkpinfo->tmpdir);
     2876    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir);
    29662877    run_program_and_log_output(tmp, FALSE);
     2878    mr_free(tmp);
     2879
    29672880    make_hole_for_dir("/var/log");
    29682881    make_hole_for_dir("/tmp/tmpfs");    /* just in case... */
     
    29742887    run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE);
    29752888
    2976 /* Init GUI */
     2889    /* Init GUI */
    29772890    malloc_libmondo_global_strings();
    29782891    setup_newt_stuff();         /* call newtInit and setup screen log */
     
    29862899    iamhere("what time is it");
    29872900
    2988 /* Process command-line parameters */
     2901    /* Process command-line parameters */
    29892902    if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) {
    29902903#ifdef __FreeBSD__
     
    30242937        strcpy(bkpinfo->restore_path, "/tmp/TESTING");
    30252938        bkpinfo->backup_media_type = dvd;
    3026         open_progress_form("Reassembling /dev/hda1",
    3027                            "Shark is a bit of a silly person.",
    3028                            "Please wait. This may take some time.",
     2939        open_progress_form(_("Reassembling /dev/hda1"),
     2940                           _("Shark is a bit of a silly person."),
     2941                           _("Please wait. This may take some time."),
    30292942                           "", 1999);
    30302943        system("rm -Rf /tmp/*pih*");
    30312944
     2945        malloc_string(tmp);
    30322946        restore_a_biggiefile_from_CD(bkpinfo, 42, NULL, tmp);
     2947        mr_free(tmp);
    30332948    }
    30342949
     
    30432958        // BERLIOS: /usr/lib ???
    30442959        toggle_path_selection(filelist, "/usr/share", TRUE);
    3045 //      show_filelist(filelist);
    30462960        save_filelist(filelist, "/tmp/out.txt");
    3047 //      finish(0);
    3048 //      toggle_path_selection (filelist, "/root/stuff", TRUE);
    3049         strcpy(a, argv[3]);
    3050         strcpy(b, argv[4]);
     2961        mr_asprintf(&a, argv[3]);
     2962        mr_asprintf(&b, argv[4]);
    30512963
    30522964        res = save_filelist_entries_in_common(a, filelist, b, FALSE);
    30532965        free_filelist(filelist);
     2966        mr_free(a);
     2967        mr_free(b);
    30542968        printf("res = %d", res);
    30552969        finish(0);
     
    31023016        retval = run_grub(FALSE, "/dev/hda");
    31033017        if (retval) {
    3104             log_to_screen("Failed to write Master Boot Record");
     3018            log_to_screen(_("Failed to write Master Boot Record"));
    31053019        }
    31063020        paranoid_MR_finish(0);
     
    31133027        if (argc != 1) {
    31143028            popup_and_OK
    3115                 ("Live mode doesn't support command-line parameters yet.");
     3029                (_
     3030                 ("Live mode doesn't support command-line parameters yet."));
    31163031            paranoid_MR_finish(1);
    3117 //    return(1);
    31183032        }
    31193033        mr_msg(1, "I am in normal, live mode.");
     
    31353049        mr_msg(2, "Still here. Yay.");
    31363050        if (strlen(bkpinfo->tmpdir) > 0) {
    3137             sprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
     3051            mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
    31383052            run_program_and_log_output(tmp, FALSE);
     3053            mr_free(tmp);
    31393054        }
    31403055        unmount_boot_if_necessary();    /* for Gentoo users */
     
    31453060        mr_msg(2, "FYI, MOUNTLIST_FNAME = %s ", g_mountlist_fname);
    31463061        if (argc == 3 && strcmp(argv[1], "--monitas-memorex") == 0) {
    3147             log_to_screen("Uh, that hasn't been implemented yet.");
     3062            log_to_screen(_("Uh, that hasn't been implemented yet."));
    31483063            paranoid_MR_finish(1);
    31493064        }
     
    31653080                sprintf(bkpinfo->isodir, "/tmp/isodir");
    31663081                run_program_and_log_output("mkdir -p /tmp/isodir", 5);
    3167                 sprintf(tmp, "mount %s -t nfs -o nolock /tmp/isodir",
     3082                mr_asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir",
    31683083                        bkpinfo->nfs_mount);
    31693084                run_program_and_log_output(tmp, 1);
     3085                mr_free(tmp);
    31703086            }
    31713087        }
     
    31743090        if (retval) {
    31753091            log_to_screen
    3176                 ("Warning - load_raidtab_into_raidlist returned an error");
     3092                (_
     3093                 ("Warning - load_raidtab_into_raidlist returned an error"));
    31773094        }
    31783095
     
    32283145            }
    32293146            if (retval) {
    3230                 log_to_screen("Failed to write Master Boot Record");
     3147                log_to_screen(_("Failed to write Master Boot Record"));
    32313148            }
    32323149        } else if (argc == 2 && strcmp(argv[1], "--isonuke") == 0) {
     
    32343151            retval = iso_mode(bkpinfo, mountlist, raidlist, TRUE);
    32353152        } else if (argc != 1) {
    3236             log_to_screen("Invalid paremeters");
     3153            log_to_screen(_("Invalid paremeters"));
    32373154            paranoid_MR_finish(1);
    32383155        } else {
     
    32463163        if (does_file_exist("/tmp/changed.files")) {
    32473164            log_to_screen
    3248                 ("See /tmp/changed.files for list of files that have changed.");
     3165                (_
     3166                 ("See /tmp/changed.files for list of files that have changed."));
    32493167        }
    32503168        mvaddstr_and_log_it(g_currentY++,
    32513169                            0,
    3252                             "Run complete. Errors were reported. Please review the logfile.");
     3170                            _
     3171                            ("Run complete. Errors were reported. Please review the logfile."));
    32533172    } else {
    32543173        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    32553174            mvaddstr_and_log_it(g_currentY++,
    32563175                                0,
    3257                                 "Run complete. Please remove floppy/CD/media and reboot.");
     3176                                _
     3177                                ("Run complete. Please remove floppy/CD/media and reboot."));
    32583178        } else {
    32593179            run_program_and_log_output("sync", FALSE);
     
    32673187            if (!bkpinfo->please_dont_eject) {
    32683188                res = eject_device("/dev/cdrom");
    3269 /*
    3270               if (res)
    3271         {
    3272           log_to_screen( "WARNING - failed to eject CD-ROM disk" );
    3273         }
    3274 */
    32753189            }
    32763190            mvaddstr_and_log_it(g_currentY++,
    32773191                                0,
    3278                                 "Run complete. Please remove media and reboot.");
    3279         }
    3280     }
    3281 
    3282 // g_I_have_just_nuked is set true by nuke_mode() just before it returns
     3192                                _
     3193                                ("Run complete. Please remove media and reboot."));
     3194        }
     3195    }
     3196
     3197    // g_I_have_just_nuked is set true by nuke_mode() just before it returns
    32833198    if (!system("which post-nuke > /dev/null 2> /dev/null")) {
    32843199      mr_msg(1, "post-nuke found; find out whether we should run it...");
     
    33033218      } else {
    33043219        mr_msg(1, "Re-mounted partitions for post-nuke stuff");
    3305         sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,
     3220        mr_asprintf(&tmp, "post-nuke %s %d", bkpinfo->restore_path,
    33063221            retval);
    33073222        mr_msg(2, "Calling '%s'", tmp);
     
    33093224          log_OS_error(tmp);
    33103225        }
     3226        mr_free(tmp);
    33113227        mr_msg(1, "post-nuke returned w/ res=%d", res);
    33123228      }
     
    33153231    }
    33163232
    3317 /* 
    3318   log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");
    3319   log_to_screen("Otherwise, please wait until the RAID disks are done.");
    3320   wait_until_software_raids_are_prepped("/proc/mdstat", 100);
    3321   log_to_screen("Thank you.");
    3322 */
    33233233    unlink("/tmp/mondo-run-prog.tmp");
    33243234    set_signals(FALSE);
    3325     sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
     3235    mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);
    33263236    run_program_and_log_output(tmp, FALSE);
     3237    mr_free(tmp);
     3238
    33273239    log_to_screen
    3328         ("Restore log copied to /tmp/mondo-restore.log on your hard disk");
    3329     sprintf(tmp,
    3330             "Mondo-restore is exiting (retval=%d)                                      ",
    3331             retval);
    3332     log_to_screen(tmp);
    3333     sprintf(tmp, "umount %s", bkpinfo->isodir);
     3240        (_
     3241         ("Restore log copied to /tmp/mondo-restore.log on your hard disk"));
     3242    log_to_screen(_("Mondo-restore is exiting (retval=%d)"), retval);
     3243
     3244    mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
    33343245    run_program_and_log_output(tmp, 5);
     3246    mr_free(tmp);
     3247
    33353248    mr_free(mountlist);
    33363249    mr_free(raidlist);
     
    33403253    paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
    33413254    free_libmondo_global_strings(); // it's fine to have this here :) really :)
    3342     mr_free(a);
    3343     mr_free(b);
    3344     mr_free(tmp);
    33453255
    33463256    unlink("/tmp/filelist.full");
     
    33553265
    33563266
    3357 
    3358 
    3359 
    33603267/**************************************************************************
    33613268 *END_MONDO-RESTORE.C                                                     *
Note: See TracChangeset for help on using the changeset viewer.