Ignore:
Timestamp:
Feb 28, 2007, 9:36:10 AM (17 years ago)
Author:
Bruno Cornec
Message:

Integrates trunk memory mngt for mondo-rstr-tools.c
This ends the first round of modifications for memory management.

File:
1 edited

Legend:

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

    r1216 r1219  
    380380    int res = 0;
    381381
    382     char *tmp = NULL;
    383382    char *command = NULL;
    384383    char *mountdir = NULL;
    385384    char *mountpoint = NULL;
    386385    char *additional_parameters = NULL;
    387     char *p1 = NULL;
    388     char *p2 = NULL;
    389     char *p3 = NULL;
    390 
     386 
    391387    assert_string_is_neither_NULL_nor_zerolength(device);
    392388    assert_string_is_neither_NULL_nor_zerolength(mpt);
    393389    assert(format != NULL);
    394     malloc_string(tmp);
    395     malloc_string(command);
    396     malloc_string(mountdir);
    397     malloc_string(additional_parameters);
    398390
    399391    if (!strcmp(mpt, "/1")) {
     
    412404        return (0);
    413405    }
    414     sprintf(tmp, "Mounting device %s   ", device);
    415     mr_msg(1, tmp);
     406    mr_msg(1, "Mounting device %s   ", device);
    416407    if (writeable) {
    417         strcpy(additional_parameters, "-o rw");
    418     } else {
    419         strcpy(additional_parameters, "-o ro");
     408        mr_asprintf(&additional_parameters, "-o rw");
     409    } else {
     410        mr_asprintf(&additional_parameters, "-o ro");
    420411    }
    421412    if (find_home_of_exe("setfattr")) {
    422         strcat(additional_parameters, ",user_xattr");
     413        mr_strcat(additional_parameters, ",user_xattr");
    423414    }
    424415    if (find_home_of_exe("setfacl")) {
    425         strcat(additional_parameters, ",acl");
     416        mr_strcat(additional_parameters, ",acl");
    426417    }
    427418
    428419    if (!strcmp(mountpoint, "swap")) {
    429         sprintf(command, "swapon %s", device);
     420        mr_asprintf(&command, "swapon %s", device);
    430421    } else {
    431422        if (!strcmp(mountpoint, "/")) {
    432             strcpy(mountdir, MNT_RESTORING);
     423            mr_asprintf(&mountdir, MNT_RESTORING);
    433424        } else {
    434             sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
    435         }
    436         sprintf(command, "mkdir -p %s", mountdir);
     425            mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
     426        }
     427        mr_asprintf(&command, "mkdir -p %s", mountdir);
    437428        run_program_and_log_output(command, FALSE);
    438         sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device,
     429        mr_free(command);
     430
     431        mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
    439432                additional_parameters, mountdir, MONDO_LOGFILE);
    440433        mr_msg(2, "command='%s'", command);
    441434    }
     435    mr_free(additional_parameters);
     436
    442437    res = run_program_and_log_output(command, TRUE);
    443438    if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
    444439        mr_msg(1, "Re-trying without the fancy extra parameters");
    445         sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
     440        mr_free(command);
     441
     442        mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
    446443                mountdir, MONDO_LOGFILE);
    447444        res = run_program_and_log_output(command, TRUE);
     
    452449        mr_msg(1, "command was '%s'", command);
    453450        if (!strcmp(mountpoint, "swap")) {
    454             log_to_screen(tmp);
     451            log_to_screen("Unable to mount device %s (type %s) at %s", device,
     452                format, mountdir);
    455453        } else {
    456454            mr_msg(2, "Retrying w/o the '-t' switch");
    457             sprintf(command, "mount %s %s 2>> %s", device, mountdir,
     455            mr_free(command);
     456
     457            mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir,
    458458                    MONDO_LOGFILE);
    459459            mr_msg(2, "2nd command = '%s'", command);
     
    467467        }
    468468    }
     469    mr_free(command);
     470    mr_free(mountdir);
     471
    469472    if (res && !strcmp(mountpoint, "swap")) {
    470473        mr_msg(2, "That's ok. It's just a swap partition.");
     
    472475        res = 0;
    473476    }
    474 
    475     mr_free(tmp);
    476     mr_free(command);
    477     mr_free(mountdir);
    478477    mr_free(mountpoint);
    479     mr_free(additional_parameters);
    480478
    481479    return (res);
    482480}
    483 
    484481/**************************************************************************
    485482 *END_MOUNT_DEVICE                                                        *
    486483 **************************************************************************/
    487 
    488 
    489484
    490485
     
    498493                      *p_external_copy_of_mountlist, bool writeable)
    499494{
    500     int retval = 0, lino, res;
    501     char *tmp, *these_failed, *format;
    502     struct mountlist_itself *mountlist;
    503 
    504     malloc_string(tmp);
    505     malloc_string(format);
    506     malloc_string(these_failed);
     495    int retval = 0;
     496    int lino = 0;
     497    int res = 0;
     498    char *tmp = NULL;
     499    char *these_failed = NULL;
     500    char *format = NULL;
     501    struct mountlist_itself *mountlist = NULL;
     502
    507503    assert(p_external_copy_of_mountlist != NULL);
    508504    mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself));
     
    511507    sort_mountlist_by_mountpoint(mountlist, 0);
    512508
    513   /** menset **/
    514     these_failed[0] = '\0';
    515 
    516     mvaddstr_and_log_it(g_currentY, 0, "Mounting devices         ");
    517     open_progress_form("Mounting devices",
    518                        "I am now mounting all the drives.",
    519                        "This should not take long.",
     509    mvaddstr_and_log_it(g_currentY, 0, _("Mounting devices         "));
     510    open_progress_form(_("Mounting devices"),
     511                       _("I am now mounting all the drives."),
     512                       _("This should not take long."),
    520513                       "", mountlist->entries);
    521514
     
    525518                    "Again with the /proc - why is this in your mountlist?");
    526519        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    527             sprintf(tmp, "%s is already mounted",
     520            log_to_screen(_("%s is already mounted"),
    528521                    mountlist->el[lino].device);
    529             log_to_screen(tmp);
    530522        } else if (strcmp(mountlist->el[lino].mountpoint, "none")
    531523                   && strcmp(mountlist->el[lino].mountpoint, "lvm")
    532524                   && strcmp(mountlist->el[lino].mountpoint, "raid")
    533525                   && strcmp(mountlist->el[lino].mountpoint, "image")) {
    534             sprintf(tmp, "Mounting %s", mountlist->el[lino].device);
     526            mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
    535527            update_progress_form(tmp);
    536             strcpy(format, mountlist->el[lino].format);
     528            mr_free(tmp);
     529
     530            mr_asprintf(&format, mountlist->el[lino].format);
    537531            if (!strcmp(format, "ext3")) {
    538                 strcpy(format, "ext2");
     532                mr_free(format);
     533                mr_asprintf(&format, "ext2");
    539534            }
    540535            res = mount_device(mountlist->el[lino].device,
     
    543538            retval += res;
    544539            if (res) {
    545                 strcat(these_failed, mountlist->el[lino].device);
    546                 strcat(these_failed, " ");
    547             }
     540                if (these_failed != NULL) { /* not the first time */
     541                    mr_strcat(these_failed, " %s", mountlist->el[lino].device);
     542                } else { /* The first time */
     543                    mr_asprintf(&these_failed, "%s", mountlist->el[lino].device);
     544                }
     545            }
     546            mr_free(format);
    548547        }
    549548        g_current_progress++;
     
    554553        if (g_partition_table_locked_up > 0) {
    555554            log_to_screen
    556                 ("fdisk's ictol() call to refresh its copy of the partition table causes the kernel to");
    557             log_to_screen
    558                 ("lock up the partition table. You might have to reboot and use Interactive Mode to");
    559             log_to_screen
    560                 ("format and restore *without* partitioning first. Sorry for the inconvenience.");
    561         }
    562         sprintf(tmp, "Could not mount devices %s- shall I abort?",
     555                (_
     556                 ("fdisk's ioctl() call to refresh its copy of the partition table causes the kernel to"));
     557            log_to_screen(_
     558                          ("lock up the partition table. You might have to reboot and use Interactive Mode to"));
     559            log_to_screen(_
     560                          ("format and restore *without* partitioning first. Sorry for the inconvenience."));
     561        }
     562        mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),
    563563                these_failed);
     564        mr_free(these_failed);
     565
    564566        if (!ask_me_yes_or_no(tmp)) {
    565567            retval = 0;
    566568            log_to_screen
    567                 ("Continuing, although some devices failed to be mounted");
    568             mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     569                (_
     570                 ("Continuing, although some devices failed to be mounted"));
     571            mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    569572        } else {
    570             mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     573            mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    571574            log_to_screen
    572                 ("Unable to mount some or all of your partitions.");
    573         }
    574     } else {
    575         log_to_screen("All partitions were mounted OK.");
    576         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     575                (_("Unable to mount some or all of your partitions."));
     576        }
     577        mr_free(tmp);
     578    } else {
     579        log_to_screen(_("All partitions were mounted OK."));
     580        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    577581    }
    578582    run_program_and_log_output("df -m", 3);
    579583    mr_free(mountlist);
    580     mr_free(tmp);
    581     mr_free(format);
    582     mr_free(these_failed);
    583584    return (retval);
    584585}
    585 
    586586 /**************************************************************************
    587587  *END_MOUNT_ALL_DEVICES                                                   *
     
    600600int mount_cdrom(struct s_bkpinfo *bkpinfo)
    601601{
    602     char *mount_cmd;
    603     int i, res;
     602    char *mount_cmd = NULL;
     603    int i = 0, res = 0;
    604604#ifdef __FreeBSD__
    605     char mdd[32];
    606     char *mddev = mdd;
     605    char *mddev = NULL;
    607606#endif
    608607
    609     malloc_string(mount_cmd);
    610608    assert(bkpinfo != NULL);
    611609
     
    613611        || bkpinfo->backup_media_type == udev) {
    614612        mr_msg(8, "Tape/udev. Therefore, no need to mount CDROM.");
    615         mr_free(mount_cmd);
    616613        return 0;
    617614    }
     
    619616    if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
    620617        mr_msg(2, "mount_cdrom() - CD already mounted. Fair enough.");
    621         mr_free(mount_cmd);
    622618        return (0);
    623619    }
     
    632628        }
    633629#ifdef __FreeBSD__
    634         sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
    635                 bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
     630        mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
     631                bkpinfo->nfs_remote_dir, bkpinfo->prefix,
     632                g_current_media_number);
    636633        mddev = make_vn(mount_cmd);
    637         sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     634        mr_free(mount_cmd);
     635
     636        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     637        mr_free(mddev);
    638638#else
    639         sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
    640                 bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    641                 bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     639        mr_asprintf(&mount_cmd,
     640                "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
     641                bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix,
     642                g_current_media_number, MNT_CDROM);
    642643#endif
    643644
    644     } else
    645      if (bkpinfo->backup_media_type == iso) {
     645    } else if (bkpinfo->backup_media_type == iso) {
    646646#ifdef __FreeBSD__
    647         sprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
     647        mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
    648648                bkpinfo->prefix, g_current_media_number);
    649649        mddev = make_vn(mount_cmd);
    650         sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     650        mr_free(mount_cmd);
     651
     652        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     653        mr_free(mddev);
    651654#else
    652         sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
    653                 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     655        mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
     656                bkpinfo->isodir, bkpinfo->prefix, g_current_media_number,
     657                MNT_CDROM);
    654658#endif
    655659    } else if (strstr(bkpinfo->media_device, "/dev/"))
    656660#ifdef __FreeBSD__
    657661    {
    658         sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     662        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    659663                MNT_CDROM);
    660664    }
    661665#else
    662666    {
    663         sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
     667        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
    664668                bkpinfo->media_device, MNT_CDROM);
    665669    }
     
    676680
    677681#ifdef __FreeBSD__
    678         sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     682        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    679683                MNT_CDROM);
    680684#else
    681         sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
     685        mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
    682686                bkpinfo->media_device, MNT_CDROM);
    683687#endif
     
    695699        }
    696700    }
     701    mr_free(mount_cmd);
     702
    697703    if (res) {
    698704        mr_msg(2, "Failed, despite %d attempts", i);
     
    700706        mr_msg(2, "Mounted CD-ROM drive OK");
    701707    }
    702     mr_free(mount_cmd);
    703708    return (res);
    704709}
    705 
    706 
    707 
    708 
    709 
    710710/**************************************************************************
    711711 *END_MOUNT_CDROM                                                         *
     
    739739                               TRUE);
    740740}
    741 
    742741/**************************************************************************
    743742 *END_PROTECT_AGAINST_BRAINDEAD_SYSADMINS                                 *
    744743 **************************************************************************/
    745 
    746 
    747744
    748745
     
    756753int read_cfg_file_into_bkpinfo(char *cfgf, struct s_bkpinfo *bkpinfo)
    757754{
    758   /** add mallocs **/
    759755    char *value = NULL;
    760756    char *tmp = NULL;
     
    765761    char *iso_path = NULL;
    766762    char *old_isodir = NULL;
    767     char cfg_file[100];
     763    char *cfg_file = NULL;
    768764    t_bkptype media_specified_by_user;
    769765
    770     malloc_string(command);
    771     malloc_string(iso_mnt);
    772     malloc_string(iso_path);
    773     malloc_string(old_isodir);
    774766    malloc_string(value);
    775     malloc_string(tmp);
    776 //  assert_string_is_neither_NULL_nor_zerolength(cfg_file);
    777767    assert(bkpinfo != NULL);
    778768
    779769    if (!cfgf) {
    780         strcpy(cfg_file, g_mondo_cfg_file);
    781     } else {
    782         strcpy(cfg_file, cfgf);
     770        cfg_file = g_mondo_cfg_file;
     771    } else {
     772        cfg_file = cfgf;
    783773    }
    784774
     
    795785            bkpinfo->backup_media_type = dvd;
    796786        } else if (!strcmp(value, "iso")) {
    797 /*
    798       if (am_I_in_disaster_recovery_mode()
    799       && !run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1)
    800       && does_file_exist(MNT_CDROM"/archives/filelist.0"))
    801 */
    802 
    803 // Patch by Conor Daly - 2004/07/12
     787            // Patch by Conor Daly - 2004/07/12
    804788            bkpinfo->backup_media_type = iso;
    805789            if (am_I_in_disaster_recovery_mode()) {
     
    853837    if (bkpinfo->disaster_recovery) {
    854838        if (bkpinfo->backup_media_type == cdstream) {
    855             sprintf(bkpinfo->media_device, "/dev/cdrom");
    856 //          bkpinfo->media_size[0] = -1;
     839            strcpy(bkpinfo->media_device, "/dev/cdrom");
    857840            bkpinfo->media_size[0] = 1999 * 1024;
    858841            bkpinfo->media_size[1] = 650;   /* good guess */
     
    865848            read_cfg_var(cfg_file, "media-size", value);
    866849            bkpinfo->media_size[1] = atol(value);
    867             sprintf(tmp, "Backup medium is TAPE --- dev=%s",
     850            mr_msg(2, "Backup medium is TAPE --- dev=%s",
    868851                    bkpinfo->media_device);
    869             mr_msg(2, tmp);
    870852        } else {
    871853            strcpy(bkpinfo->media_device, "/dev/cdrom");    /* we don't really need this var */
     
    995977         * isodir in disaster recovery mode
    996978         */
    997         strcpy(old_isodir, bkpinfo->isodir);
     979        mr_asprintf(&old_isodir, bkpinfo->isodir);
    998980        read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt);
    999981        read_cfg_var(g_mondo_cfg_file, "isodir", iso_path);
     
    1010992            }
    1011993        }
     994        mr_free(old_isodir);
     995
    1012996        read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    1013         mr_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir,
    1014                 g_isodir_device);
     997        mr_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
    1015998        if (bkpinfo->disaster_recovery) {
    1016999            if (is_this_device_mounted(g_isodir_device)) {
    10171000                mr_msg(2, "NB: isodir is already mounted");
    10181001                /* Find out where it's mounted */
    1019                 sprintf(command,
     1002                mr_asprintf(&command,
    10201003                        "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3",
    10211004                        g_isodir_device);
    10221005                log_it("command = %s", command);
    1023                 log_it("res of it = %s",
    1024                        call_program_and_get_last_line_of_output(command));
    1025                 sprintf(iso_mnt, "%s",
     1006                mr_asprintf(&iso_mnt, "%s",
    10261007                        call_program_and_get_last_line_of_output(command));
     1008                log_it("res of it = %s", iso_mnt);
    10271009            } else {
    1028                 sprintf(iso_mnt, "/tmp/isodir");
    1029                 sprintf(tmp, "mkdir -p %s", iso_mnt);
     1010                mr_asprintf(&iso_mnt, "/tmp/isodir");
     1011                mr_asprintf(&tmp, "mkdir -p %s", iso_mnt);
    10301012                run_program_and_log_output(tmp, 5);
    1031                 sprintf(tmp, "mount %s %s", g_isodir_device, iso_mnt);
     1013                mr_free(tmp);
     1014
     1015                mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);
    10321016                if (run_program_and_log_output(tmp, 3)) {
    10331017                    mr_msg(1,
     
    10351019                    bkpinfo->backup_media_type = cdr;
    10361020                    strcpy(bkpinfo->media_device, "/dev/cdrom");    /* superfluous */
    1037                     bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0';
     1021                    bkpinfo->isodir[0] = '\0';
     1022                    mr_free(iso_mnt);
     1023                    mr_free(iso_path);
     1024                    mr_asprintf(&iso_mnt, "");
     1025                    mr_asprintf(&iso_path, "");
    10381026                    if (mount_cdrom(bkpinfo)) {
    10391027                        fatal_error
     
    10441032                    }
    10451033                }
     1034                mr_free(tmp);
    10461035            }
    10471036            /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
     
    10491038                sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
    10501039            }
     1040            mr_free(iso_mnt);
     1041            mr_free(iso_path);
    10511042        }
    10521043    }
     
    10571048                mr_msg(2,
    10581049                        "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
    1059                 interactively_obtain_media_parameters_from_user(bkpinfo,
    1060                                                                 FALSE);
     1050                interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
    10611051                media_specified_by_user = bkpinfo->backup_media_type;
    10621052                get_cfg_file_from_archive(bkpinfo);
    1063 /*
    1064               if (media_specified_by_user != cdr && media_specified_by_user == cdrw)
    1065                 { g_restoring_live_from_cd = FALSE; }
    1066 */
    10671053            }
    10681054        }
     
    10701056    }
    10711057    g_backup_media_type = bkpinfo->backup_media_type;
     1058    strcpy(bkpinfo->backup_media_string, bkptype_to_string(bkpinfo->backup_media_type));
     1059    strcpy(g_backup_media_string, bkpinfo->backup_media_string);
    10721060    mr_free(value);
    1073     mr_free(tmp);
    1074     mr_free(command);
    1075     mr_free(iso_mnt);
    1076     mr_free(iso_path);
    1077     mr_free(old_isodir);
    10781061    return (0);
    1079 
    1080 }
    1081 
     1062}
    10821063/**************************************************************************
    10831064 *END_READ_CFG_FILE_INTO_BKPINFO                                          *
    10841065 **************************************************************************/
    1085 
    1086 
    10871066
    10881067
     
    11001079s_node *process_filelist_and_biggielist(struct s_bkpinfo *bkpinfo)
    11011080{
    1102     struct s_node *filelist;
    1103 
    1104   /** add mallocs**/
    1105     char *command;
    1106     char *tmp;
     1081    struct s_node *filelist = NULL;
     1082
     1083    char *command = NULL;
     1084    char *tmp = NULL;
    11071085    int res = 0;
     1086    size_t n = 0;
    11081087    pid_t pid;
    11091088
    11101089    assert(bkpinfo != NULL);
    1111     malloc_string(command);
    11121090    malloc_string(tmp);
    11131091
     
    11271105        unlink("/tmp/i-want-my-lvm");
    11281106        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1129             sprintf(command,
     1107            mr_asprintf(&command,
    11301108                    "tar -zxf %s %s %s %s %s %s",
    11311109                    bkpinfo->media_device,
     
    11361114            mr_msg(1, "tarcommand = %s", command);
    11371115            run_program_and_log_output(command, 1);
     1116            mr_free(command);
    11381117        } else {
    11391118            mr_msg(2,
     
    11431122            mr_msg(2, "Back from iotcn");
    11441123            run_program_and_log_output("mount", 1);
    1145             sprintf(command,
     1124            mr_asprintf(&command,
    11461125                    "tar -zxf %s/images/all.tar.gz %s %s %s %s %s",
    11471126                    MNT_CDROM,
     
    11531132            mr_msg(1, "tarcommand = %s", command);
    11541133            run_program_and_log_output(command, 1);
    1155 //    popup_and_OK("Press ENTER to continue");
     1134            mr_free(command);
     1135
    11561136            if (!does_file_exist(BIGGIELIST_TXT_STUB)) {
    11571137                fatal_error
     
    11631143            }
    11641144        }
    1165         sprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
     1145        mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
    11661146                g_mondo_cfg_file);
    11671147        run_program_and_log_output(command, FALSE);
    1168 
    1169         sprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir,
     1148        mr_free(command);
     1149
     1150        mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,
    11701151                BIGGIELIST_TXT_STUB, g_biggielist_txt);
    11711152        mr_msg(1, "command = %s", command);
    11721153        paranoid_system(command);
    1173         sprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
     1154        mr_free(command);
     1155
     1156        mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
    11741157                FILELIST_FULL_STUB, g_filelist_full);
    11751158        mr_msg(1, "command = %s", command);
    11761159        paranoid_system(command);
     1160        mr_free(command);
    11771161    }
    11781162
    11791163    if (am_I_in_disaster_recovery_mode()
    11801164        &&
    1181         ask_me_yes_or_no("Do you want to retrieve the mountlist as well?"))
     1165        ask_me_yes_or_no(_
     1166                         ("Do you want to retrieve the mountlist as well?")))
    11821167    {
    1183 //      sprintf(command, "cp -f tmp/mountlist.txt /tmp");
    1184         sprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
     1168        mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
    11851169                bkpinfo->tmpdir);
    11861170        paranoid_system(command);
     1171        mr_free(command);
    11871172    }
    11881173
    11891174    chdir(tmp);
     1175    mr_free(tmp);
    11901176
    11911177    if (!does_file_exist(g_biggielist_txt)) {
     
    11951181        mr_msg(1, "Warning - %s does not exist", g_filelist_full);
    11961182    }
    1197 //  popup_and_OK("Wonderful.");
    11981183
    11991184    mr_msg(2, "Forking");
     
    12051190
    12061191    case 0:
    1207         log_to_screen("Pre-processing filelist");
     1192        log_to_screen(_("Pre-processing filelist"));
    12081193        if (!does_file_exist(g_biggielist_txt)) {
    1209             sprintf(command, "> %s", g_biggielist_txt);
     1194            mr_asprintf(&command, "> %s", g_biggielist_txt);
    12101195            paranoid_system(command);
    1211         }
    1212         sprintf(command, "grep -E '^/dev/.*' %s > %s",
     1196            mr_free(command);
     1197        }
     1198        mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s",
    12131199                g_biggielist_txt, g_filelist_imagedevs);
    12141200        paranoid_system(command);
     1201        mr_free(command);
    12151202        exit(0);
    12161203        break;
    12171204
    12181205    default:
    1219         open_evalcall_form("Pre-processing filelist");
     1206        open_evalcall_form(_("Pre-processing filelist"));
    12201207        while (!waitpid(pid, (int *) 0, WNOHANG)) {
    12211208            usleep(100000);
     
    12301217    unlink(g_filelist_full);
    12311218    if (g_text_mode) {
    1232         printf("Restore which directory? --> ");
    1233         fgets(tmp, sizeof(tmp), stdin);
     1219        printf(_("Restore which directory? --> "));
     1220        mr_getline(&tmp, &n, stdin);
    12341221        toggle_path_selection(filelist, tmp, TRUE);
    12351222        if (strlen(tmp) == 0) {
     
    12381225            res = 0;
    12391226        }
     1227        mr_free(tmp);
    12401228    } else {
    12411229        res = edit_filelist(filelist);
     
    12591247                                      TRUE);
    12601248    }
    1261 
    1262     mr_free(command);
    1263     mr_free(tmp);
    12641249    return (filelist);
    12651250}
    1266 
    12671251/**************************************************************************
    12681252 *END_ PROCESS_FILELIST_AND_BIGGIELIST                                    *
    12691253 **************************************************************************/
    1270 
    1271 
    12721254
    12731255
     
    12811263int backup_crucial_file(char *path_root, char *filename)
    12821264{
    1283     char *tmp;
    1284     char *command;
    1285     int res;
    1286 
    1287     malloc_string(tmp);
    1288     malloc_string(command);
     1265    char *command = NULL;
     1266    int res = 0;
     1267
    12891268    assert(path_root != NULL);
    12901269    assert_string_is_neither_NULL_nor_zerolength(filename);
    12911270
    1292     sprintf(tmp, "%s/%s", path_root, filename);
    1293     sprintf(command, "cp -f %s %s.pristine", tmp, tmp);
    1294 
     1271    mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);
    12951272    res = run_program_and_log_output(command, 5);
    1296     mr_free(tmp);
    12971273    mr_free(command);
    12981274    return (res);
     
    13081284int run_boot_loader(bool offer_to_hack_scripts)
    13091285{
    1310     int res;
     1286    int res = 0;
    13111287    int retval = 0;
    13121288
    1313   /** malloc *******/
    1314     char *device;
    1315     char *tmp;
    1316     char *name;
     1289    char *device = NULL;
     1290    char *tmp = NULL;
     1291    char *name = NULL;
    13171292
    13181293    malloc_string(device);
    1319     malloc_string(tmp);
    13201294    malloc_string(name);
    13211295    backup_crucial_file(MNT_RESTORING, "/etc/fstab");
     
    13251299    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    13261300    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1327     sprintf(tmp, "run_boot_loader: device='%s', name='%s'", device, name);
    1328     mr_msg(2, tmp);
    1329     system("sync");
     1301    mr_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
     1302    sync();
    13301303    if (!strcmp(name, "LILO")) {
    13311304        res = run_lilo(offer_to_hack_scripts);
     
    13331306        res = run_elilo(offer_to_hack_scripts);
    13341307    } else if (!strcmp(name, "GRUB")) {
    1335 //      if ( does_file_exist(DO_MBR_PLEASE) || (offer_to_hack_scripts && ask_me_yes_or_no("Because of bugs in GRUB, you're much better off running mondorestore --mbr after this program terminates. Are you sure you want to install GRUB right now?")))
    1336 //        {
    13371308        res = run_grub(offer_to_hack_scripts, device);
    1338 //    unlink(DO_MBR_PLEASE);
    1339 //  }
    1340 //      else
    1341 //        {
    1342 //    mr_msg(1, "Not running run_grub(). Was a bad idea anyway.");
    1343 //    res = 1;
    1344 //  }
    13451309    } else if (!strcmp(name, "RAW")) {
    13461310        res = run_raw_mbr(offer_to_hack_scripts, device);
     
    13481312#ifdef __FreeBSD__
    13491313    else if (!strcmp(name, "BOOT0")) {
    1350         sprintf(tmp, "boot0cfg -B %s", device);
     1314        mr_asprintf(&tmp, "boot0cfg -B %s", device);
    13511315        res = run_program_and_log_output(tmp, FALSE);
    1352     } else {
    1353         sprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
     1316        mr_free(tmp);
     1317    } else {
     1318        mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*$'", device);
    13541319        if (!system(tmp)) {
    1355             sprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
     1320            mr_free(tmp);
     1321            mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
    13561322            res = run_program_and_log_output(tmp, 3);
    13571323        } else {
     
    13591325                    "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
    13601326        }
     1327        mr_free(tmp);
    13611328    }
    13621329#else
    13631330    else {
    13641331        log_to_screen
    1365             ("Unable to determine type of boot loader. Defaulting to LILO.");
     1332            (_
     1333             ("Unable to determine type of boot loader. Defaulting to LILO."));
    13661334        res = run_lilo(offer_to_hack_scripts);
    13671335    }
    13681336#endif
     1337    mr_free(device);
     1338    mr_free(name);
     1339
    13691340    retval += res;
    13701341    if (res) {
    1371         log_to_screen("Your boot loader returned an error");
    1372     } else {
    1373         log_to_screen("Your boot loader ran OK");
    1374     }
    1375     mr_free(device);
    1376     mr_free(tmp);
    1377     mr_free(name);
     1342        log_to_screen(_("Your boot loader returned an error"));
     1343    } else {
     1344        log_to_screen(_("Your boot loader ran OK"));
     1345    }
    13781346    return (retval);
    13791347}
    1380 
    13811348/**************************************************************************
    13821349 *END_ RUN_BOOT_LOADER                                                    *
     
    13841351
    13851352
    1386 
    13871353/**
    13881354 * Attempt to find the user's editor.
     
    13931359{
    13941360    static char output[MAX_STR_LEN];
     1361
    13951362    if (find_home_of_exe("pico")) {
    13961363        strcpy(output, "pico");
     
    14191386int run_grub(bool offer_to_run_stabgrub, char *bd)
    14201387{
    1421   /** malloc **/
    1422     char *command;
    1423     char *boot_device;
    1424     char *rootdev;
    1425     char *rootdrive;
    1426     char *conffile;
    1427     char *tmp;
    1428     char *editor;
    1429 
    1430     int res;
    1431     int done;
    1432 
    1433     malloc_string(command);
     1388    char *command = NULL;
     1389    char *boot_device = NULL;
     1390    char *tmp = NULL;
     1391    char *editor = NULL;
     1392
     1393    int res = 0;
     1394    int done = 0;
     1395
    14341396    malloc_string(boot_device);
    1435     malloc_string(tmp);
    1436     malloc_string(editor);
    1437     malloc_string(rootdev);
    1438     malloc_string(rootdrive);
    1439     malloc_string(conffile);
     1397    strcpy(boot_device, bd);
    14401398    assert_string_is_neither_NULL_nor_zerolength(bd);
    1441     strcpy(editor, "vi");       // find_my_editor() );
    1442     strcpy(boot_device, bd);
    1443 
    1444     if (!run_program_and_log_output("which grub-MR", FALSE)) {
    1445         mr_msg(1, "Yay! grub-MR found...");
    1446         sprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device);
    1447         mr_msg(1, "command = %s", command);
    1448     } else {
    1449         sprintf(command, "chroot " MNT_RESTORING " grub-install %s",
    1450                 boot_device);
    1451         mr_msg(1, "WARNING - grub-MR not found; using grub-install");
    1452     }
     1399    mr_asprintf(&editor, find_my_editor());
     1400
    14531401    if (offer_to_run_stabgrub
    1454         && ask_me_yes_or_no("Did you change the mountlist?"))
     1402        && ask_me_yes_or_no(_("Did you change the mountlist?")))
    14551403        /* interactive mode */
    14561404    {
    14571405        mvaddstr_and_log_it(g_currentY,
    14581406                            0,
    1459                             "Modifying fstab and grub.conf, and running GRUB...                             ");
     1407                            _
     1408                            ("Modifying fstab and grub.conf, and running GRUB...                             "));
    14601409        for (done = FALSE; !done;) {
    1461             popup_and_get_string("Boot device",
    1462                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1463                                  boot_device, MAX_STR_LEN / 4);
    1464             sprintf(command, "stabgrub-me %s", boot_device);
     1410            popup_and_get_string(_("Boot device"),
     1411                                 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4);
     1412            mr_asprintf(&command, "stabgrub-me %s", boot_device);
    14651413            res = run_program_and_log_output(command, 1);
     1414            mr_free(command);
     1415
    14661416            if (res) {
    14671417                popup_and_OK
    1468                     ("GRUB installation failed. Please install manually using 'grub-install' or similar command. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
     1418                    (_
     1419                     ("GRUB installation failed. Please install manually using 'grub-install' or similar command. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."));
    14691420                newtSuspend();
    14701421                system("chroot " MNT_RESTORING);
    14711422                newtResume();
    1472                 popup_and_OK("Thank you.");
     1423                popup_and_OK(_("Thank you."));
    14731424            } else {
    14741425                done = TRUE;
    14751426            }
    1476             popup_and_OK("You will now edit fstab and grub.conf");
     1427            popup_and_OK(_("You will now edit fstab and grub.conf"));
    14771428            if (!g_text_mode) {
    14781429                newtSuspend();
    14791430            }
    1480             sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1431            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    14811432            paranoid_system(tmp);
    1482             sprintf(tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);
     1433            mr_free(tmp);
     1434
     1435            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);
    14831436            paranoid_system(tmp);
     1437            mr_free(tmp);
     1438
    14841439            if (!g_text_mode) {
    14851440                newtResume();
    14861441            }
    14871442        }
    1488     } else
     1443    } else {
    14891444        /* nuke mode */
    1490     {
     1445        if (!run_program_and_log_output("which grub-MR", FALSE)) {
     1446            mr_msg(1, "Yay! grub-MR found...");
     1447            mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);
     1448            mr_msg(1, "command = %s", command);
     1449        } else {
     1450            mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);
     1451            mr_msg(1, "WARNING - grub-MR not found; using grub-install");
     1452        }
    14911453        mvaddstr_and_log_it(g_currentY,
    14921454                            0,
    1493                             "Running GRUB...                                                 ");
     1455                            _
     1456                            ("Running GRUB...                                                 "));
    14941457        iamhere(command);
    14951458        res = run_program_and_log_output(command, 1);
     1459        mr_free(command);
     1460
    14961461        if (res) {
    14971462            popup_and_OK
    1498                 ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.");
     1463                (_
     1464                 ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished."));
    14991465            newtSuspend();
    15001466            system("chroot " MNT_RESTORING);
    15011467            newtResume();
    1502             popup_and_OK("Thank you.");
     1468            popup_and_OK(_("Thank you."));
    15031469        }
    15041470    }
    15051471    if (res) {
    1506         mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     1472        mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    15071473        log_to_screen
    1508             ("GRUB ran w/error(s). See /tmp/mondo-restore.log for more info.");
     1474            (_
     1475             ("GRUB ran w/error(s). See /tmp/mondo-restore.log for more info."));
    15091476        mr_msg(1, "Type:-");
    15101477        mr_msg(1, "    mount-me");
     
    15171484                "If you're really stuck, please e-mail the mailing list.");
    15181485    } else {
    1519         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    1520     }
    1521     mr_free(rootdev);
    1522     mr_free(rootdrive);
    1523     mr_free(conffile);
    1524     mr_free(command);
     1486        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     1487    }
    15251488    mr_free(boot_device);
    1526     mr_free(tmp);
    15271489    mr_free(editor);
    1528 
    15291490    return (res);
    15301491}
    1531 
    15321492/**************************************************************************
    15331493 *END_RUN_GRUB                                                            *
     
    15421502int run_elilo(bool offer_to_run_stabelilo)
    15431503{
    1544   /** malloc **/
    1545     char *command;
    1546     char *tmp;
    1547     char *editor;
    1548 
    1549     int res;
    1550     int done;
    1551 
    1552     malloc_string(command);
    1553     malloc_string(tmp);
    1554     malloc_string(editor);
    1555     strcpy(editor, find_my_editor());
     1504    char *command = NULL;
     1505    char *tmp = NULL;
     1506    char *editor = NULL;
     1507
     1508    int res = 0;
     1509    int done = 0;
     1510
     1511    mr_asprintf(&editor, find_my_editor());
    15561512    if (offer_to_run_stabelilo
    1557         && ask_me_yes_or_no("Did you change the mountlist?"))
     1513        && ask_me_yes_or_no(_("Did you change the mountlist?")))
    15581514
    15591515        /* interactive mode */
     
    15611517        mvaddstr_and_log_it(g_currentY,
    15621518                            0,
    1563                             "Modifying fstab and elilo.conf...                             ");
    1564         sprintf(command, "stabelilo-me");
     1519                            _
     1520                            ("Modifying fstab and elilo.conf...                             "));
     1521        mr_asprintf(&command, "stabelilo-me");
    15651522        res = run_program_and_log_output(command, 3);
     1523        mr_free(command);
     1524
    15661525        if (res) {
    15671526            popup_and_OK
    1568                 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist.");
     1527                (_
     1528                 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist."));
    15691529            for (done = FALSE; !done;) {
    15701530                if (!g_text_mode) {
    15711531                    newtSuspend();
    15721532                }
    1573                 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1533                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    15741534                paranoid_system(tmp);
    1575                 sprintf(tmp, "%s " MNT_RESTORING "/etc/elilo.conf",
    1576                         editor);
     1535                mr_free(tmp);
     1536
     1537                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);
    15771538                paranoid_system(tmp);
     1539                mr_free(tmp);
     1540
    15781541                if (!g_text_mode) {
    15791542                    newtResume();
    15801543                }
    15811544//              newtCls();
    1582                 if (ask_me_yes_or_no("Edit them again?")) {
     1545                if (ask_me_yes_or_no(_("Edit them again?"))) {
    15831546                    continue;
    15841547                }
     
    15861549            }
    15871550        } else {
    1588             log_to_screen("elilo.conf and fstab were modified OK");
     1551            log_to_screen(_("elilo.conf and fstab were modified OK"));
    15891552        }
    15901553    } else
     
    15931556        res = TRUE;
    15941557    }
    1595     mr_free(command);
    1596     mr_free(tmp);
    15971558    mr_free(editor);
    15981559    return (res);
    15991560}
    1600 
    16011561/**************************************************************************
    16021562 *END_RUN_ELILO                                                            *
     
    16121572{
    16131573  /** malloc **/
    1614     char *command;
    1615     char *tmp;
    1616     char *editor;
    1617 
    1618     int res;
    1619     int done;
     1574    char *command = NULL;
     1575    char *tmp = NULL;
     1576    char *editor = NULL;
     1577
     1578    int res = 0;
     1579    int done = 0;
    16201580    bool run_lilo_M = FALSE;
    1621     malloc_string(command);
    1622     malloc_string(tmp);
    1623     malloc_string(editor);
    16241581
    16251582    if (!run_program_and_log_output
     
    16281585    }
    16291586
    1630     strcpy(editor, find_my_editor());
     1587    mr_asprintf(&editor, find_my_editor());
    16311588    if (offer_to_run_stablilo
    1632         && ask_me_yes_or_no("Did you change the mountlist?"))
    1633 
     1589        && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
    16341590        /* interactive mode */
    1635     {
    16361591        mvaddstr_and_log_it(g_currentY,
    16371592                            0,
    1638                             "Modifying fstab and lilo.conf, and running LILO...                             ");
    1639         sprintf(command, "stablilo-me");
     1593                            _
     1594                            ("Modifying fstab and lilo.conf, and running LILO...                             "));
     1595        mr_asprintf(&command, "stablilo-me");
    16401596        res = run_program_and_log_output(command, 3);
     1597        mr_free(command);
     1598
    16411599        if (res) {
    16421600            popup_and_OK
    1643                 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist.");
     1601                (_
     1602                 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."));
    16441603            for (done = FALSE; !done;) {
    16451604                if (!g_text_mode) {
    16461605                    newtSuspend();
    16471606                }
    1648                 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1607                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    16491608                paranoid_system(tmp);
    1650                 sprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
     1609                mr_free(tmp);
     1610
     1611                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
    16511612                paranoid_system(tmp);
     1613                mr_free(tmp);
     1614
    16521615                if (!g_text_mode) {
    16531616                    newtResume();
    16541617                }
    1655 //              newtCls();
    1656                 if (ask_me_yes_or_no("Edit them again?")) {
     1618                if (ask_me_yes_or_no(_("Edit them again?"))) {
    16571619                    continue;
    16581620                }
     
    16681630                    done =
    16691631                        ask_me_yes_or_no
    1670                         ("LILO failed. Re-edit system files?");
     1632                        (_("LILO failed. Re-edit system files?"));
    16711633                } else {
    16721634                    done = TRUE;
     
    16741636            }
    16751637        } else {
    1676             log_to_screen("lilo.conf and fstab were modified OK");
    1677         }
    1678     } else
     1638            log_to_screen(_("lilo.conf and fstab were modified OK"));
     1639        }
     1640    } else {
    16791641        /* nuke mode */
    1680     {
    16811642        mvaddstr_and_log_it(g_currentY,
    16821643                            0,
    1683                             "Running LILO...                                                 ");
     1644                            _
     1645                            ("Running LILO...                                                 "));
    16841646        res =
    16851647            run_program_and_log_output("chroot " MNT_RESTORING " lilo -L",
     
    16911653        }
    16921654        if (res) {
    1693             mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     1655            mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    16941656            log_to_screen
    1695                 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please.");
     1657                (_
     1658                 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please."));
    16961659        } else {
    1697             mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     1660            mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    16981661        }
    16991662    }
     
    17041667                                   " lilo -M /dev/sda", 3);
    17051668    }
    1706     mr_free(command);
    1707     mr_free(tmp);
    17081669    mr_free(editor);
    17091670    return (res);
     
    17231684int run_raw_mbr(bool offer_to_hack_scripts, char *bd)
    17241685{
    1725   /** malloc **/
    1726     char *command;
    1727     char *boot_device;
    1728     char *tmp;
    1729     char *editor;
    1730     int res;
    1731     int done;
    1732 
    1733     malloc_string(command);
     1686    char *command = NULL;
     1687    char *boot_device = NULL;
     1688    char *tmp = NULL;
     1689    char *editor = NULL;
     1690    int res = 0;
     1691    int done = 0;
     1692
     1693    assert_string_is_neither_NULL_nor_zerolength(bd);
     1694
    17341695    malloc_string(boot_device);
    1735     malloc_string(tmp);
    1736     malloc_string(editor);
    1737     assert_string_is_neither_NULL_nor_zerolength(bd);
    1738 
    1739     strcpy(editor, find_my_editor());
     1696    mr_asprintf(&editor, find_my_editor());
    17401697    strcpy(boot_device, bd);
    1741     sprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device);
    1742     mr_msg(2, "run_raw_mbr() --- command='%s'", command);
    1743 
    17441698    if (offer_to_hack_scripts
    1745         && ask_me_yes_or_no("Did you change the mountlist?"))
     1699        && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
    17461700        /* interactive mode */
    1747     {
    17481701        mvaddstr_and_log_it(g_currentY, 0,
    1749                             "Modifying fstab and restoring MBR...                           ");
     1702                            _
     1703                            ("Modifying fstab and restoring MBR...                           "));
    17501704        for (done = FALSE; !done;) {
    17511705            if (!run_program_and_log_output("which vi", FALSE)) {
    1752                 popup_and_OK("You will now edit fstab");
     1706                popup_and_OK(_("You will now edit fstab"));
    17531707                if (!g_text_mode) {
    17541708                    newtSuspend();
    17551709                }
    1756                 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
     1710                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    17571711                paranoid_system(tmp);
     1712                mr_free(tmp);
     1713
    17581714                if (!g_text_mode) {
    17591715                    newtResume();
    17601716                }
    1761 //              newtCls();
    1762             }
    1763             popup_and_get_string("Boot device",
    1764                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1765                                  boot_device, MAX_STR_LEN / 4);
    1766             sprintf(command, "stabraw-me %s", boot_device);
     1717            }
     1718            popup_and_get_string(_("Boot device"),
     1719                                 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4);
     1720            mr_asprintf(&command, "stabraw-me %s", boot_device);
    17671721            res = run_program_and_log_output(command, 3);
     1722            mr_free(command);
     1723
    17681724            if (res) {
    1769                 done = ask_me_yes_or_no("Modifications failed. Re-try?");
     1725                done =
     1726                    ask_me_yes_or_no(_("Modifications failed. Re-try?"));
    17701727            } else {
    17711728                done = TRUE;
    17721729            }
    17731730        }
    1774     } else
     1731    } else {
    17751732        /* nuke mode */
    1776     {
    17771733        mvaddstr_and_log_it(g_currentY, 0,
    1778                             "Restoring MBR...                                               ");
     1734                            _("Restoring MBR...                                               "));
     1735        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
     1736        mr_msg(2, "run_raw_mbr() --- command='%s'", command);
    17791737        res = run_program_and_log_output(command, 3);
     1738        mr_free(command);
    17801739    }
    17811740    if (res) {
    1782         mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     1741        mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
    17831742        log_to_screen
    1784             ("MBR+fstab processed w/error(s). See /tmp/mondo-restore.log for more info.");
    1785     } else {
    1786         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    1787     }
    1788     mr_free(command);
     1743            (_
     1744             ("MBR+fstab processed w/error(s). See /tmp/mondo-restore.log for more info."));
     1745    } else {
     1746        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     1747    }
    17891748    mr_free(boot_device);
    1790     mr_free(tmp);
    17911749    mr_free(editor);
    17921750    return (res);
    17931751}
    1794 
    17951752/**************************************************************************
    17961753 *END_RUN_RAW_MBR                                                         *
     
    17981755
    17991756
    1800 
    1801 
    1802 
    18031757/**
    18041758 * Turn signal trapping on or off.
     
    18101764    int signals[] =
    18111765        { SIGKILL, SIGPIPE, SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT,
    1812 SIGSTOP, 0 };
     1766        SIGSTOP, 0
     1767    };
    18131768    int i;
    18141769    for (i = 0; signals[i]; i++) {
     
    18531808    sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
    18541809    sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
    1855 //  sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath);
    18561810    sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
    18571811            temppath);
     
    18811835    FILE *fin;
    18821836    FILE *fout;
    1883   /** malloc **/
    1884     char *incoming;
     1837    char *incoming = NULL;
     1838    size_t n = 0;
    18851839
    18861840    assert_string_is_neither_NULL_nor_zerolength(output_file);
    18871841    assert_string_is_neither_NULL_nor_zerolength(input_file);
    1888     malloc_string(incoming);
    18891842
    18901843    if (!(fin = fopen(input_file, "r"))) {
     
    18951848        fatal_error("cannot open output_file");
    18961849    }
    1897     for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);
    1898          fgets(incoming, MAX_STR_LEN - 1, fin)) {
     1850    for (mr_getline(&incoming, &n, fin); !feof(fin);
     1851         mr_getline(&incoming, &n, fin)) {
    18991852        if (strncmp(incoming, "etc/adjtime", 11)
    19001853            && strncmp(incoming, "etc/mtab", 8)
     
    19061859            fprintf(fout, "%s", incoming);  /* don't need \n here, for some reason.. */
    19071860    }
     1861    mr_free(incoming);
    19081862    paranoid_fclose(fout);
    19091863    paranoid_fclose(fin);
    1910     mr_free(incoming);
    1911 }
    1912 
     1864}
    19131865/**************************************************************************
    19141866 *END_STREAMLINE_CHANGES_FILE                                             *
     
    19231875{
    19241876    log_to_screen
    1925         ("Mondorestore is terminating in response to a signal from the OS");
     1877        (_("Mondorestore is terminating in response to a signal from the OS"));
    19261878    free_MR_global_filenames();
    19271879    finish(254);
    19281880}
    1929 
    19301881/**************************************************************************
    19311882 *END_TERMINATE_DAEMON                                                    *
     
    19391890{
    19401891    int i;
    1941     /* MALLOC * */
    1942     char *tmp;
    1943 
    1944     malloc_string(tmp);
     1892    char *tmp = NULL;
     1893
    19451894    if (does_file_exist("/tmp/NOPAUSE")) {
    19461895        return;
    19471896    }
    1948     open_progress_form("CAUTION",
    1949                        "Be advised: I am about to ERASE your hard disk(s)!",
    1950                        "You may press Ctrl+Alt+Del to abort safely.",
     1897    open_progress_form(_("CAUTION"),
     1898                       _
     1899                       ("Be advised: I am about to ERASE your hard disk(s)!"),
     1900                       _("You may press Ctrl+Alt+Del to abort safely."),
    19511901                       "", 20);
    19521902    for (i = 0; i < 20; i++) {
    19531903        g_current_progress = i;
    1954         sprintf(tmp, "You have %d seconds left to abort.", 20 - i);
     1904        mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);
    19551905        update_progress_form(tmp);
     1906        mr_free(tmp);
    19561907        sleep(1);
    19571908    }
    19581909    close_progress_form();
    1959     mr_free(tmp);
    1960 }
    1961 
     1910}
    19621911/**************************************************************************
    19631912 *END_TWENTY_SECONDS_TIL_YIKES                                            *
     
    19651914
    19661915
    1967 
    1968 
    1969 
    19701916/**
    19711917 * Exit due to a signal (no cleanup).
     
    19781924    pthread_exit(0);
    19791925}
    1980 
    19811926/**************************************************************************
    19821927 *END_TERMINATION_IN_PROGRESS                                             *
     
    19841929
    19851930
    1986 
    19871931/**
    19881932 * Unmount all devices in @p p_external_copy_of_mountlist.
     
    19941938{
    19951939    struct mountlist_itself *mountlist;
    1996     int retval = 0, lino, res = 0, i;
    1997     char *command;
    1998     char *tmp;
    1999 
    2000     malloc_string(command);
    2001     malloc_string(tmp);
     1940    int retval = 0;
     1941    int lino = 0;
     1942    int res = 0;
     1943    int i = 0;
     1944    char *command = NULL;
     1945    char *tmp = NULL;
     1946
    20021947    assert(p_external_copy_of_mountlist != NULL);
    20031948
     
    20081953
    20091954    run_program_and_log_output("df -m", 3);
    2010     mvaddstr_and_log_it(g_currentY, 0, "Unmounting devices      ");
    2011     open_progress_form("Unmounting devices",
    2012                        "Unmounting all devices that were mounted,",
    2013                        "in preparation for the post-restoration reboot.",
     1955    mvaddstr_and_log_it(g_currentY, 0, _("Unmounting devices      "));
     1956    open_progress_form(_("Unmounting devices"),
     1957                       _("Unmounting all devices that were mounted,"),
     1958                       _
     1959                       ("in preparation for the post-restoration reboot."),
    20141960                       "", mountlist->entries);
    20151961    chdir("/");
     
    20241970    }
    20251971
    2026     paranoid_system("sync");
     1972    sync();
    20271973
    20281974    if (run_program_and_log_output
     
    20441990            continue;
    20451991        }
    2046         sprintf(tmp, "Unmounting device %s  ", mountlist->el[lino].device);
     1992        mr_asprintf(&tmp, _("Unmounting device %s  "),
     1993                mountlist->el[lino].device);
    20471994
    20481995        update_progress_form(tmp);
     1996
    20491997        if (is_this_device_mounted(mountlist->el[lino].device)) {
    20501998            if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
    2051                 sprintf(command, "swapoff %s", mountlist->el[lino].device);
     1999                mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device);
    20522000            } else {
    20532001                if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
    2054                     sprintf(command, "umount %s/", MNT_RESTORING);
     2002                    mr_asprintf(&command, "umount %s/", MNT_RESTORING);
    20552003                    mr_msg(3,
    20562004                            "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
    20572005                } else {
    2058                     sprintf(command, "umount " MNT_RESTORING "%s",
     2006                    mr_asprintf(&command, "umount " MNT_RESTORING "%s",
    20592007                            mountlist->el[lino].mountpoint);
    20602008                }
     
    20622010            mr_msg(10, "The 'umount' command is '%s'", command);
    20632011            res = run_program_and_log_output(command, 3);
     2012            mr_free(command);
    20642013        } else {
    2065             strcat(tmp, "...not mounted anyway :-) OK");
     2014            mr_strcat(tmp, _("...not mounted anyway :-) OK"));
    20662015            res = 0;
    20672016        }
    20682017        g_current_progress++;
    20692018        if (res) {
    2070             strcat(tmp, "...Failed");
     2019            mr_strcat(tmp, _("...Failed"));
    20712020            retval++;
    20722021            log_to_screen(tmp);
     
    20742023            mr_msg(2, tmp);
    20752024        }
     2025        mr_free(tmp);
    20762026    }
    20772027    close_progress_form();
    20782028    if (retval) {
    2079         mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
    2080     } else {
    2081         mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     2029        mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
     2030    } else {
     2031        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    20822032    }
    20832033    if (retval) {
    2084         log_to_screen("Unable to unmount some of your partitions.");
    2085     } else {
    2086         log_to_screen("All partitions were unmounted OK.");
     2034        log_to_screen(_("Unable to unmount some of your partitions."));
     2035    } else {
     2036        log_to_screen(_("All partitions were unmounted OK."));
    20872037    }
    20882038    mr_free(mountlist);
    2089     mr_free(command);
    2090     mr_free(tmp);
    20912039    return (retval);
    20922040}
    2093 
    20942041/**************************************************************************
    20952042 *END_UNMOUNT_ALL_DEVICES                                                 *
    20962043 **************************************************************************/
    2097 
    20982044
    20992045
     
    21062052int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)
    21072053{
    2108     char *command;
     2054    char *command = NULL;
    21092055    int res = 0;
    2110     // BCO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0
     2056    // BERLIOS: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0
    21112057    long tape_block_size = 32768;
    21122058
    2113     malloc_string(command);
    2114 
    21152059    // tar -zxvf-
    2116     sprintf(command,
     2060    mr_asprintf(&command,
    21172061            "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s",
    21182062            dev,
     
    21232067    mr_msg(2, "command = '%s'", command);
    21242068    res = run_program_and_log_output(command, -1);
     2069    mr_free(command);
     2070
    21252071    if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) {
    21262072        res = 0;
    21272073    }
    2128     mr_free(command);
    21292074    return (res);
    21302075}
    2131 
    21322076
    21332077
     
    21432087{
    21442088    int retval = 0;
    2145 
    2146    /** malloc *****/
    2147     char *device;
    2148     char *command;
    2149     char *cfg_file;
    2150     char *mounted_cfgf_path;
    2151     char *tmp;
    2152     char *mountpt;
    2153     char *ramdisk_fname;
    2154     char *mountlist_file;
    2155     int res;
    2156 
    2157     bool try_plan_B;
     2089    char *command = NULL;
     2090    char *cfg_file = NULL;
     2091    char *mounted_cfgf_path = NULL;
     2092    char *tmp = NULL;
     2093    char *mountpt = NULL;
     2094    char *ramdisk_fname = NULL;
     2095    char *mountlist_file = NULL;
     2096    int res = 0;
     2097
     2098    bool try_plan_B = FALSE;
    21582099
    21592100    assert(bkpinfo != NULL);
    2160     malloc_string(cfg_file);
    2161     malloc_string(mounted_cfgf_path);
    2162     malloc_string(mountpt);
    2163     malloc_string(ramdisk_fname);
    2164     malloc_string(mountlist_file);
    2165     malloc_string(device);
    2166     malloc_string(command);
    2167     malloc_string(tmp);
    21682101    mr_msg(2, "gcffa --- starting");
    2169     log_to_screen("I'm thinking...");
    2170     sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    2171     device[0] = '\0';
     2102    log_to_screen(_("I'm thinking..."));
     2103    mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    21722104    chdir(bkpinfo->tmpdir);
    2173     strcpy(cfg_file, MONDO_CFG_FILE_STUB);
    2174     unlink(cfg_file);           // cfg_file[] is missing the '/' at the start, FYI, by intent
     2105    // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent
     2106    unlink(MONDO_CFG_FILE_STUB);
     2107
    21752108    unlink(FILELIST_FULL_STUB);
    21762109    unlink(BIGGIELIST_TXT_STUB);
    21772110    unlink("tmp/i-want-my-lvm");
    2178     sprintf(command, "mkdir -p %s", mountpt);
     2111    mr_asprintf(&command, "mkdir -p %s", mountpt);
    21792112    run_program_and_log_output(command, FALSE);
    2180 
    2181 //   unlink( "tmp/mondo-restore.cfg" ); // superfluous, surely?
    2182 
    2183     sprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
    2184     sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir,
     2113    mr_free(command);
     2114
     2115    mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     2116    mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,
    21852117            MOUNTLIST_FNAME_STUB);
    2186     //   make_hole_for_file( cfg_file );
    2187     //   make_hole_for_file( mountlist_file);
    21882118    mr_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
    21892119
    21902120    /* Floppy? */
    2191     sprintf(tmp, "mkdir -p %s", mountpt);
     2121    mr_asprintf(&tmp, "mkdir -p %s", mountpt);
    21922122    run_program_and_log_output(tmp, FALSE);
    2193     sprintf(tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);
     2123    mr_free(tmp);
     2124
     2125    mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);
    21942126    run_program_and_log_output(tmp, FALSE);
    2195 
    2196     sprintf(command, "mount /dev/fd0u1722 %s", mountpt);
    2197     sprintf(tmp,
     2127    mr_free(tmp);
     2128
     2129    mr_asprintf(&command, "mount /dev/fd0u1722 %s", mountpt);
     2130    mr_asprintf(&tmp,
    21982131            "(sleep 15; kill `ps | grep \"%s\" | cut -d' ' -f1` 2> /dev/null) &",
    21992132            command);
    22002133    mr_msg(1, "tmp = '%s'", tmp);
    22012134    system(tmp);
     2135    mr_free(tmp);
     2136
    22022137    res = run_program_and_log_output(command, FALSE);
     2138    mr_free(command);
     2139
    22032140    if (res) {
    2204         sprintf(command, "mount /dev/fd0H1440 %s", mountpt);
     2141        mr_asprintf(&command, "mount /dev/fd0H1440 %s", mountpt);
    22052142        res = run_program_and_log_output(command, FALSE);
     2143        mr_free(command);
    22062144    }
    22072145    if (res) {
     
    22112149        mr_msg(2,
    22122150                "Mounted floppy OK but I don't trust it because the archives might contain more up-to-date config file than the floppy does.");
    2213 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.
     2151        // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.
    22142152        mr_msg(2, "Processing floppy (plan A?)");
    2215         sprintf(ramdisk_fname, "%s/mindi.rdz", mountpt);
     2153        mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);
    22162154        if (!does_file_exist(ramdisk_fname)) {
    2217             sprintf(ramdisk_fname, "%s/initrd.img", mountpt);
     2155            mr_free(ramdisk_fname);
     2156            mr_asprintf(&ramdisk_fname, "%s/initrd.img", mountpt);
    22182157        }
    22192158        if (!does_file_exist(ramdisk_fname)) {
     
    22262165                    "Warning - failed to extract config file from ramdisk. I think this boot disk is mangled.");
    22272166        }
    2228         sprintf(command, "umount %s", mountpt);
     2167        mr_asprintf(&command, "umount %s", mountpt);
    22292168        run_program_and_log_output(command, 5);
     2169        mr_free(command);
     2170
    22302171        unlink(ramdisk_fname);
     2172        mr_free(ramdisk_fname);
    22312173    }
    22322174    if (!does_file_exist(cfg_file)) {
     
    22552197            if (strlen(bkpinfo->media_device) == 0) {
    22562198                strcpy(bkpinfo->media_device, "/dev/st0");
    2257                 mr_msg(2, "media_device is blank; assuming %s");
    2258             }
    2259             strcpy(tmp, bkpinfo->media_device);
     2199                mr_msg(2, "media_device is blank; assuming %s",
     2200                        bkpinfo->media_device);
     2201            }
     2202            mr_asprintf(&tmp, bkpinfo->media_device);
    22602203            if (extract_cfg_file_and_mountlist_from_tape_dev
    22612204                (bkpinfo->media_device)) {
     
    22762219                }
    22772220            }
     2221            mr_free(tmp);
    22782222
    22792223            if (!does_file_exist("tmp/mondo-restore.cfg")) {
    2280                 log_to_screen("Cannot find config info on tape/CD/floppy");
     2224                log_to_screen(_
     2225                              ("Cannot find config info on tape/CD/floppy"));
    22812226                return (1);
    22822227            }
     
    22842229            mr_msg(2,
    22852230                    "gcffa --- looking at mounted CD for mindi-boot.2880.img");
    2286             sprintf(command,
     2231            /* BERLIOS : Useless ?
     2232            mr_asprintf(&command,
    22872233                    "mount " MNT_CDROM
    22882234                    "/images/mindi-boot.2880.img -o loop %s", mountpt);
    2289             sprintf(mounted_cfgf_path, "%s/%s", mountpt, cfg_file);
     2235                    */
     2236            mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);
    22902237            if (!does_file_exist(mounted_cfgf_path)) {
    22912238                mr_msg(2,
    22922239                        "gcffa --- Plan C, a.k.a. untarring some file from all.tar.gz");
    2293                 sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm");  // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
     2240                mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
    22942241                run_program_and_log_output(command, TRUE);
     2242                mr_free(command);
     2243
    22952244                if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
    22962245                    fatal_error
     
    22982247                }
    22992248            }
    2300         }
    2301     }
     2249            mr_free(mounted_cfgf_path);
     2250        }
     2251    }
     2252    mr_free(mountpt);
     2253
    23022254    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    23032255        mr_msg(1, "gcffa --- great! We've got the config file");
    2304         sprintf(tmp, "%s/%s",
     2256        mr_asprintf(&tmp, "%s/%s",
    23052257                call_program_and_get_last_line_of_output("pwd"),
    23062258                MONDO_CFG_FILE_STUB);
    2307         sprintf(command, "cp -f %s %s", tmp, cfg_file);
     2259        mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file);
    23082260        iamhere(command);
     2261
    23092262        if (strcmp(tmp, cfg_file)
    23102263            && run_program_and_log_output(command, 1)) {
     
    23152268            mr_msg(1, "... and I moved it successfully to %s", cfg_file);
    23162269        }
    2317         sprintf(command, "cp -f %s/%s %s",
     2270        mr_free(command);
     2271
     2272        mr_asprintf(&command, "cp -f %s/%s %s",
    23182273                call_program_and_get_last_line_of_output("pwd"),
    23192274                MOUNTLIST_FNAME_STUB, mountlist_file);
     
    23242279        } else {
    23252280            mr_msg(1, "Got mountlist too");
    2326             sprintf(command, "cp -f %s %s", mountlist_file,
     2281            mr_free(command);
     2282            mr_asprintf(&command, "cp -f %s %s", mountlist_file,
    23272283                    g_mountlist_fname);
    23282284            if (run_program_and_log_output(command, 1)) {
     
    23302286            } else {
    23312287                mr_msg(1, "Copied mountlist to /tmp as well OK");
    2332                 sprintf(command, "cp -f tmp/i-want-my-lvm /tmp/");
     2288                mr_free(command);
     2289                mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
    23332290                run_program_and_log_output(command, 1);
    23342291            }
    23352292        }
     2293        mr_free(command);
     2294        mr_free(tmp);
    23362295    }
    23372296    run_program_and_log_output("umount " MNT_CDROM, FALSE);
     
    23402299        mr_msg(1, "%s not found", cfg_file);
    23412300        log_to_screen
    2342             ("Oh dear. Unable to recover configuration file from boot disk");
     2301            (_
     2302             ("Oh dear. Unable to recover configuration file from boot disk"));
    23432303        return (1);
    23442304    }
    23452305
    2346     log_to_screen("Recovered mondo-restore.cfg");
     2306    log_to_screen(_("Recovered mondo-restore.cfg"));
    23472307    if (!does_file_exist(MOUNTLIST_FNAME_STUB)) {
    2348         log_to_screen("...but not mountlist.txt - a pity, really...");
     2308        log_to_screen(_("...but not mountlist.txt - a pity, really..."));
    23492309    }
    23502310/* start SAH */
    23512311    else {
    2352         sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
     2312        mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
    23532313                bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    23542314        run_program_and_log_output(command, FALSE);
    2355     }
    2356 /*--commented out by SAH
    2357   sprintf( command, "cp -f %s %s/%s", cfg_file, bkpinfo->tmpdir, MONDO_CFG_FILE_STUB );
    2358   run_program_and_log_output( command, FALSE );
    2359   sprintf( command, "cp -f %s %s/%s", mountlist_file, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB );
    2360   run_program_and_log_output( command, FALSE );
    2361 */
     2315        mr_free(command);
     2316    }
    23622317/* end SAH */
    23632318
    2364     sprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2319    mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
     2320    mr_free(cfg_file);
    23652321    run_program_and_log_output(command, FALSE);
    2366     sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
     2322    mr_free(command);
     2323
     2324    mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
     2325    mr_free(mountlist_file);
    23672326    run_program_and_log_output(command, FALSE);
    2368     sprintf(command, "cp -f etc/raidtab /etc/");
     2327    mr_free(command);
     2328
     2329    mr_asprintf(&command, "cp -f etc/raidtab /etc/");
    23692330    run_program_and_log_output(command, FALSE);
    2370     sprintf(command, "cp -f tmp/i-want-my-lvm /tmp/");
     2331    mr_free(command);
     2332
     2333    mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
    23712334    run_program_and_log_output(command, FALSE);
     2335    mr_free(command);
     2336
    23722337    g_backup_media_type = bkpinfo->backup_media_type;
    2373     mr_free(device);
    2374     mr_free(command);
    2375     mr_free(tmp);
    2376     mr_free(cfg_file);
    2377     mr_free(mounted_cfgf_path);
    2378     mr_free(mountpt);
    2379     mr_free(ramdisk_fname);
    2380     mr_free(mountlist_file);
     2338    bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type);
     2339    g_backup_media_string = bkpinfo->backup_media_string;
    23812340    return (retval);
    23822341}
    2383 
    23842342/**************************************************************************
    23852343 *END_GET_CFG_FILE_FROM_ARCHIVE                                           *
    23862344 **************************************************************************/
    2387 
    23882345/* @} - end restoreUtilityGroup */
    2389 
    2390 
    2391 /***************************************************************************
    2392  * F@                                                                      *
    2393  * () -- Hugo Rabson                                  *
    2394  *                                                                         *
    2395  * Purpose:                                                                *
    2396  *                                                                         *
    2397  * Called by:                                                              *
    2398  * Params:    -                      -                                     *
    2399  * Returns:   0=success; nonzero=failure                                   *
    2400  ***************************************************************************/
    2401 
    24022346
    24032347
     
    24052349                                           int wait_for_percentage)
    24062350{
    2407     struct raidlist_itself *raidlist;
    2408     int unfinished_mdstat_devices = 9999, i;
    2409     char *screen_message;
    2410 
    2411     malloc_string(screen_message);
     2351    struct raidlist_itself *raidlist = NULL;
     2352    int unfinished_mdstat_devices = 9999, i = 0;
     2353    char *screen_message = NULL;
     2354
    24122355    raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself));
    24132356
     
    24182361        if (parse_mdstat(raidlist, "/dev/")) {
    24192362            log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
    2420             mr_msg(1,"Sorry, cannot read %s", MDSTAT_FILE);
     2363            mr_msg(1, "Sorry, cannot read %s", MDSTAT_FILE);
    24212364            return;
    24222365        }
     
    24292372                }
    24302373                mr_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i);
    2431                 sprintf(screen_message, "Sync'ing %s",
     2374                mr_asprintf(&screen_message, "Sync'ing %s",
    24322375                        raidlist->el[i].raid_device);
    24332376                open_evalcall_form(screen_message);
     2377                mr_free(screen_message);
     2378
    24342379                while (raidlist->el[i].progress < wait_for_percentage) {
    24352380                    mr_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress);
     
    24452390        }
    24462391    }
    2447     mr_free(screen_message);
    24482392    mr_free(raidlist);
    24492393}
Note: See TracChangeset for help on using the changeset viewer.