Changeset 3191


Ignore:
Timestamp:
Sep 25, 2013, 8:55:45 AM (6 years ago)
Author:
bruno
Message:
  • Lots of memory management backports from 3.1 to 3.2 - still not finished, nor working ATM. the common subdir was done during travel, so this is essentially a backup !
Location:
branches/3.2
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/mindi

    r3184 r3191  
    376376    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share/kbd     # Slackware
    377377    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/lib/kbd
     378    [ ! -e "$KEYDIR" ] && KEYDIR=/lib/kbd
    378379    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share
    379380    [ ! -e "$KEYDIR" ] && KEYDIR=/etc/condole
     
    423424        LogFile "INFO: Gentoo-style config detected."
    424425        keyfile=/etc/conf.d/keymaps
     426    elif [ -e "/etc/X11/xorg.conf.d/00-keyboard.conf" ] ; then
     427        LogFile "INFO: X11-style config detected."
     428        keyfile=/etc/X11/xorg.conf.d/00-keyboard.conf
    425429    else
    426430        LogFile "Searching for rc.config ..."
     
    442446    [ ! "$locale" ] && locale=`grep '.map$' "$keyfile" | sed 's/^.* //'`        # Slackware
    443447    [ ! "$locale" ] && locale=`grep -E '^KEYMAP=' "$keyfile" | grep -v '^#' | tr -d '"' |cut -d'=' -f2`     # Gentoo & ArchLinux
     448    [ ! "$locale" ] && locale=`grep -E 'XkbLayout' "$keyfile" | grep -v '^#' | awk '{print $3}' | tr -d '"'`        #  Fedora 19
    444449    LogFile "INFO: locale=$locale"
    445450    #
     
    707712    local lcMagicExt2fs="EXT2-fs: blocksize too small for device."
    708713    local lcMagicExt3fs="<3>EXT3-fs: blocksize too small for journal device."
    709     local lcMagicInitfs="<6>checking if image is initramfs...|<6>Unpacking initramfs...|<6>Trying to unpack rootfs image as initramfs"
     714    local lcMagicInitfs="<6>checking if image is initramfs...|[<]6[>]Unpacking initramfs...|<6>Trying to unpack rootfs image as initramfs"
    710715
    711716    # local variables
     
    23512356        if [ "$?" -eq "0" ] ; then
    23522357            # Used by ia64
    2353             fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep -E '[2-9]+[.][0-9]+[.][0-9]+[^\@]*@'`
     2358            fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
    23542359        else
    2355             fkern_ver=`strings $fname 2> /dev/null | grep -E '[2-9]+[.][0-9]+[.][0-9]+[^\@]*@'`
     2360            fkern_ver=`strings $fname 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
    23562361        fi
    23572362        echo "$fkern_ver"
  • branches/3.2/mondo/src/common/libmondo-archive.c

    r3185 r3191  
    6464extern bool g_cd_recovery;
    6565extern char *g_mondo_home;
    66 /*
    67 extern char *g_tmpfs_mountpt;
    68 */
    69 extern char *g_serial_string;
     66
     67/**
     68 * The serial string (used to differentiate between backups) of the current backup.
     69 */
     70char *g_serial_string = NULL;
     71
    7072extern char *g_getfacl;
    7173extern char *g_getfattr;
     
    200202
    201203    if (!does_file_exist(filelist)) {
    202         mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", filelist);
    203         log_to_screen(tmp);
    204         paranoid_free(tmp);
     204        log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
    205205        return (1);
    206206    }
     
    208208    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    209209    if (system(tmp)) {
    210         paranoid_free(tmp);
     210        mr_free(tmp);
    211211        fatal_error("Unable to write tarball to scratchdir");
    212212    }
    213213    paranoid_free(tmp);
    214214
    215     mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s",
    216             filelist, fname);
     215    mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname);
    217216    if (bkpinfo->use_lzo) {
     217        mr_free(command);
    218218        fatal_error("Can't use lzop");
    219219    }
     
    235235            res = 0;
    236236        }
    237         paranoid_free(tmp);
     237        mr_free(tmp);
    238238
    239239        if (res) {
     
    251251        }
    252252    }
    253     paranoid_free(command);
     253    mr_free(command);
    254254
    255255    retval += res;
     
    307307
    308308    if (!does_file_exist(filelist)) {
    309         mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
    310                 filelist);
    311         log_to_screen(tmp);
    312         paranoid_free(tmp);
     309        log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
    313310        return (1);
    314311    }
    315312    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    316313    if (system(tmp)) {
    317         paranoid_free(tmp);
     314        mr_free(tmp);
    318315        fatal_error("Unable to write tarball to scratchdir");
    319316    }
    320     paranoid_free(tmp);
     317    mr_free(tmp);
    321318
    322319
     
    324321        mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    325322        //       -b %ld, TAPE_BLOCK_SIZE
    326         mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    327                 bkpinfo->compression_level);
     323        mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level);
    328324        if (does_file_exist(tmp)) {
    329325            mr_strcat(zipparams, " -E %s",tmp);
     
    331327            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    332328        }
    333         paranoid_free(tmp);
     329        mr_free(tmp);
    334330    } else {
    335331        mr_asprintf(zipparams, "");
    336332    }
    337 
    338 //  make_hole_for_file(fname);
    339333
    340334    if (!does_file_exist(bkpinfo->tmpdir)) {
     
    346340        fatal_error("scratchdir not found");
    347341    }
    348     mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    349             fname, bkpinfo->zip_suffix);
     342    mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, fname, bkpinfo->zip_suffix);
    350343    paranoid_system(command);
    351     paranoid_free(command);
    352 
    353     mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    354             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    355     paranoid_free(zipparams);
     344    mr_free(command);
     345
     346    mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     347    mr_free(zipparams);
    356348
    357349    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    358350    if (system(tmp)) {
    359         paranoid_free(tmp);
     351        mr_free(tmp);
    360352        fatal_error("Unable to write tarball to scratchdir");
    361353    }
    362     paranoid_free(tmp);
     354    mr_free(tmp);
    363355
    364356    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    406398{
    407399    int retval = 0, res = 0;
    408     char *tmp;
     400    char *tmp = NULL;
    409401
    410402    assert(bkpinfo != NULL);
    411403    set_g_cdrom_and_g_dvd_to_bkpinfo_value();
    412     malloc_string(tmp);
    413404    if (bkpinfo->backup_media_type == dvd) {
    414405#ifdef DVDRWFORMAT
     
    431422    }
    432423
    433 /*
    434       sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
    435       if (run_program_and_log_output(tmp, 2))
    436         { fatal_error("Failed to count filelist.full"); }
    437 */
    438     sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
     424    mr_asprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
    439425    if (run_program_and_log_output(tmp, 2)) {
     426        mr_free(tmp);
    440427        fatal_error("Failed to gzip filelist.full");
    441428    }
    442     sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    443             bkpinfo->tmpdir);
     429    mr_free(tmp);
     430
     431    mr_asprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    444432    if (run_program_and_log_output(tmp, 2)) {
     433        mr_free(tmp);
    445434        fatal_error("Failed to copy to tmpdir");
    446435    }
     436    mr_free(tmp);
    447437
    448438    copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists
     
    464454    }
    465455    retval += do_that_initial_phase();  // prepare
    466     sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     456    mr_asprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    467457    run_program_and_log_output(tmp, 1);
     458    mr_free(tmp);
     459
    468460    retval += make_those_afios_phase(); // backup regular files
    469461    retval += make_those_slices_phase();    // backup BIG files
     
    473465        sleep(2);
    474466    }
    475     paranoid_free(tmp);
    476467    return (retval);
    477468}
     
    514505    char *use_lzo_sz = NULL;
    515506    char *use_gzip_sz = NULL;
     507    char *use_lzma_sz = NULL;
    516508    char *use_comp_sz = NULL;
    517509    char *use_star_sz = NULL;
     
    542534    assert(bkpinfo != NULL);
    543535
    544     mvaddstr_and_log_it(g_currentY, 0,
    545                         "Calling MINDI to create boot+data disks");
     536    mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks");
    546537    open_evalcall_form("Calling MINDI to create boot+data disks");
    547538    mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
     
    550541        mr_asprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    551542        if (!does_file_exist(tmp)) {
    552             fatal_error
    553                 ("Cannot find filelist.full, so I cannot count its lines");
     543            mr_free(tmp);
     544            fatal_error ("Cannot find filelist.full, so I cannot count its lines");
    554545        }
    555546    }
     
    571562            }
    572563        }
    573         paranoid_free(ntapedev);
     564        mr_free(ntapedev);
    574565        mr_asprintf(tape_device, "%s", bkpinfo->media_device);
    575566    } else {
     
    586577    } else {
    587578        mr_asprintf(use_gzip_sz, "no");
     579    }
     580    if (bkpinfo->use_lzma) {
     581        mr_asprintf(use_lzma_sz, "yes");
     582    } else {
     583        mr_asprintf(use_lzma_sz, "no");
    588584    }
    589585    if (bkpinfo->use_star) {
     
    660656            ch = 'U';
    661657        if (bkpinfo->boot_loader != '\0') {
    662             mr_asprintf(tmp, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
    663             log_msg(2, tmp);
    664             mr_free(tmp);
     658            log_msg(2, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
    665659        } else {
    666660            bkpinfo->boot_loader = ch;
    667661        }
    668662        if (bkpinfo->boot_device[0] != '\0') {
    669             mr_asprintf(tmp, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    670             log_msg(2, tmp);
    671             mr_free(tmp);
     663            log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    672664        } else {
    673665            strcpy(bkpinfo->boot_device, bootdev);
     
    692684        mr_asprintf(bootldr_str, "LILO");
    693685        if (!does_file_exist("/etc/lilo.conf")) {
    694             fatal_error
    695                 ("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
     686            fatal_error("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
    696687        }
    697688    } else if (bkpinfo->boot_loader == 'G') {
    698689        mr_asprintf(bootldr_str, "GRUB");
    699         if (!does_file_exist("/boot/grub/menu.lst")
    700             && does_file_exist("/boot/grub/grub.conf")) {
    701             run_program_and_log_output
    702                 ("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5);
     690        if (!does_file_exist("/boot/grub/menu.lst") && does_file_exist("/boot/grub/grub.conf")) {
     691            run_program_and_log_output("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5);
    703692        }
    704693        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
    705             fatal_error
    706                 ("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
     694            fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    707695        }
    708696        mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version"));
     
    710698        mr_asprintf(bootldr_str, "ELILO");
    711699        /* BCO: fix it for Debian, Mandrake, ... */
    712         if (!does_file_exist("/etc/elilo.conf")
    713             && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
    714             run_program_and_log_output
    715                 ("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf",
    716                  5);
    717         }
    718         if (!does_file_exist("/etc/elilo.conf")
    719             && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) {
    720             run_program_and_log_output
    721                 ("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf",
    722                  5);
    723         }
    724         if (!does_file_exist("/etc/elilo.conf")
    725             && does_file_exist("/boot/efi/efi/debian/elilo.conf")) {
    726             run_program_and_log_output
    727                 ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf",
    728                  5);
    729         }
    730         if (!does_file_exist("/etc/elilo.conf")
    731             && does_file_exist("/boot/efi/debian/elilo.conf")) {
    732             run_program_and_log_output
    733                 ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf",
    734                  5);
     700        if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
     701            run_program_and_log_output("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf", 5);
     702        }
     703        if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) {
     704            run_program_and_log_output("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf", 5);
     705        }
     706        if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/debian/elilo.conf")) {
     707            run_program_and_log_output ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf", 5);
     708        }
     709        if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/debian/elilo.conf")) {
     710            run_program_and_log_output ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf", 5);
    735711        }
    736712        if (!does_file_exist("/etc/elilo.conf")) {
    737             fatal_error
    738                 ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
     713            fatal_error("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
    739714        }
    740715    } else if (bkpinfo->boot_loader == 'R') {
     
    753728        mr_asprintf(bootldr_str, "unknown");
    754729    }
    755     mr_asprintf(tmp, "Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
    756     log_to_screen(tmp);
    757     mr_free(tmp);
     730    log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
     731
    758732    if (bootldr_ver != NULL) {
    759         mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver);
    760         log_to_screen(tmp);
    761         mr_free(tmp);
     733        log_to_screen("Boot loader version string: %s", bootldr_ver);
    762734    }
    763735
     
    799771        fatal_error("Unknown backup_media_type");
    800772    }
    801     if (bkpinfo->backup_media_type == usb) {
     773
     774    if ((bkpinfo->backup_media_type == usb) && (bkpinfo->media_device)) {
    802775        mr_asprintf(tmp2, "--usb %s", bkpinfo->media_device);
    803776    } else {
     
    808781    if (write_one_liner_data_file(tmp, value)) {
    809782        res++;
    810         log_msg(1, "%ld: Unable to write one-liner backup-media-type",
    811                 __LINE__);
     783        log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__);
    812784    }
    813785    mr_free(value);
     
    817789    if (write_one_liner_data_file(tmp, bootldr_str)) {
    818790        res++;
    819         log_msg(1, "%ld: Unable to write one-liner bootloader.name",
    820                 __LINE__);
     791        log_msg(1, "%ld: Unable to write one-liner bootloader.name", __LINE__);
    821792    }
    822793    mr_free(bootldr_str);
     
    865836    }
    866837
    867     estimated_total_noof_slices =
    868         size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    869     /* add netfs stuff here? */
     838    estimated_total_noof_slices = size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
     839
     840    /* TODO: add netfs stuff here? */
    870841    mr_asprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
    871842    if (system(command)) {
     
    873844        log_OS_error("Unable to make images directory");
    874845    }
    875     paranoid_free(command);
     846    mr_free(command);
    876847    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
    877848    update_evalcall_form(3);
     
    890861            use_lzo_sz,         // parameter #8
    891862            cd_recovery_sz,     // parameter #9
    892             bkpinfo->image_devs,    // parameter #10
     863            (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs,   // parameter #10
    893864            broken_bios_sz,     // parameter #11
    894865            last_filelist_number,   // parameter #12 (STRING)
     
    900871            bkpinfo->internal_tape_block_size,  // parameter #18 (LONG)
    901872            bkpinfo->differential,  // parameter #19 (INT)
    902             use_gzip_sz);       // parameter #20 (STRING)
     873            use_gzip_sz,        // parameter #19 (STRING)
     874            use_lzma_sz,        // parameter #20 (STRING)
     875            value,              // parameter #21 (STRING)
     876            MONDO_LOGFILE);
    903877
    904878    mr_free(last_filelist_number);
     
    906880    mr_free(use_lzo_sz);
    907881    mr_free(use_gzip_sz);
     882    mr_free(use_lzma_sz);
    908883    mr_free(use_star_sz);
    909884    mr_free(use_comp_sz);
     
    913888    mr_free(tape_size_sz);
    914889
     890    /* This parameter is always the last one and optional */
    915891    if (bkpinfo->nonbootable_backup) {
    916892        mr_strcat(command, " NONBOOTABLE");
     
    929905    if (!res) {
    930906        log_to_screen("Boot+data disks were created OK");
    931         mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
    932                 bkpinfo->scratchdir, MINDI_CACHE);
     907        mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE);
    933908        log_msg(2, command);
    934909        run_program_and_log_output(command, FALSE);
    935         paranoid_free(command);
     910        mr_free(command);
    936911
    937912        if (bkpinfo->nonbootable_backup) {
    938             mr_asprintf(command, "cp -f %s/all.tar.gz %s/images",
    939                     bkpinfo->tmpdir, bkpinfo->scratchdir);
     913            mr_asprintf(command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir);
    940914            if (system(command)) {
    941                 paranoid_free(command);
     915                mr_free(command);
    942916                fatal_error("Unable to create temporary all tarball");
    943917            }
    944             paranoid_free(command);
     918            mr_free(command);
    945919        }
    946920        /* For USB we already have everything on the key */
     
    948922            mr_asprintf(command, "rm -rf %s/images", bkpinfo->scratchdir);
    949923            run_program_and_log_output(command, FALSE);
    950             paranoid_free(command);
     924            mr_free(command);
    951925        } else {
    952             mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
    953                 bkpinfo->tmpdir);
     926            mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    954927            if (system(tmp)) {
    955928                fatal_error("Cannot find all.tar.gz in tmpdir");
     
    966939        mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log");
    967940        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    968         paranoid_free(command);
     941        mr_free(command);
    969942
    970943        if (strlen(tmp) > 1) {
     
    1017990void *create_afio_files_in_background(void *inbuf)
    1018991{
    1019     long int archiving_set_no;
    1020     char *archiving_filelist_fname;
    1021     char *archiving_afioball_fname;
     992    long int archiving_set_no = 0L;
     993    char *archiving_filelist_fname = NULL;
     994    char *archiving_afioball_fname = NULL;
    1022995    char *curr_xattr_list_fname = NULL;
    1023     char *curr_acl_list_fname;
    1024 
    1025     char *tmp;
     996    char *curr_acl_list_fname = NULL;
     997
     998    char *tmp = NULL;
    1026999    int res = 0, retval = 0;
    10271000    int *p_archival_threads_running;
     
    10311004    int this_thread_no = g_current_thread_no++;
    10321005
    1033     malloc_string(curr_xattr_list_fname);
    1034     malloc_string(curr_acl_list_fname);
    1035     malloc_string(archiving_filelist_fname);
    1036     malloc_string(archiving_afioball_fname);
    1037     malloc_string(tmp);
    10381006    p_last_set_archived = (int *) inbuf;
    10391007    p_archival_threads_running = (int *) (inbuf + 4);
     
    10411009    p_list_of_fileset_flags = (char *) (inbuf + 12);
    10421010
    1043     sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    1044             bkpinfo->tmpdir, 0L);
    1045     for (archiving_set_no = 0L; does_file_exist(archiving_filelist_fname);
    1046          sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    1047                  bkpinfo->tmpdir, archiving_set_no)) {
     1011    mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
     1012
     1013    while (does_file_exist(archiving_filelist_fname)) {
    10481014        if (g_exiting) {
     1015            mr_free(archiving_filelist_fname);
    10491016            fatal_error("Execution run aborted (pthread)");
    10501017        }
    10511018        if (archiving_set_no >= MAX_NOOF_SETS_HERE) {
    1052             fatal_error
    1053                 ("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
     1019            mr_free(archiving_filelist_fname);
     1020            fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
    10541021        }
    10551022        if (!semaphore_p()) {
    10561023            log_msg(3, "P sem failed (pid=%d)", (int) getpid());
     1024            mr_free(archiving_filelist_fname);
    10571025            fatal_error("Cannot get semaphore P");
    10581026        }
     
    10621030        *p_next_set_to_archive = *p_next_set_to_archive + 1;
    10631031        if (!semaphore_v()) {
     1032            mr_free(archiving_filelist_fname);
    10641033            fatal_error("Cannot get semaphore V");
    10651034        }
    10661035
    10671036        /* backup this set of files */
    1068         sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    1069                 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
    1070         sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    1071                 bkpinfo->tmpdir, archiving_set_no);
     1037        mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
     1038        mr_free(archiving_filelist_fname);
     1039        mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10721040        if (!does_file_exist(archiving_filelist_fname)) {
    1073             log_msg(3,
    1074                     "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.",
    1075                     FORTY_SPACES, getpid(), this_thread_no,
    1076                     archiving_set_no);
     1041            log_msg(3, "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
     1042            mr_free(archiving_afioball_fname);
    10771043            break;
    10781044        }
    10791045
    1080         sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
    1081                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
     1046        mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10821047        if (does_file_exist(tmp)) {
    1083             log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
    1084                     getpid(), this_thread_no);
     1048            log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, getpid(), this_thread_no);
    10851049            while (does_file_exist(tmp)) {
    10861050                sleep(1);
     
    10881052            log_msg(4, "[%d] - continuing", getpid());
    10891053        }
    1090 
    1091         log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    1092                 this_thread_no, archiving_set_no);
     1054        mr_free(tmp);
     1055
     1056        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
     1057
    10931058        if (g_getfattr) {
    1094             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1095                 bkpinfo->tmpdir, archiving_set_no);
     1059            mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10961060            get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
     1061            mr_free(curr_xattr_list_fname);
    10971062        }
    10981063        if (g_getfacl) {
    1099             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1100                 bkpinfo->tmpdir, archiving_set_no);
     1064            mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    11011065            get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    1102         }
    1103 
    1104         log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
    1105                 this_thread_no, archiving_set_no);
    1106         res =
    1107             archive_this_fileset(archiving_filelist_fname,
    1108                                  archiving_afioball_fname,
    1109                                  archiving_set_no);
     1066            mr_free(curr_acl_list_fname);
     1067        }
     1068
     1069        log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
     1070        res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no);
     1071        mr_free(archiving_afioball_fname);
     1072
    11101073        retval += res;
    11111074
    11121075        if (res) {
    1113             sprintf(tmp,
    1114                     "Errors occurred while archiving set %ld. Please review logs.",
    1115                     archiving_set_no);
    1116             log_to_screen(tmp);
    1117         }
     1076            log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no);
     1077        }
     1078
    11181079        if (!semaphore_p()) {
     1080            mr_free(archiving_filelist_fname);
    11191081            fatal_error("Cannot get semaphore P");
    11201082        }
     
    11271089
    11281090        if (!semaphore_v()) {
     1091            mr_free(archiving_filelist_fname);
    11291092            fatal_error("Cannot get semaphore V");
    11301093        }
    1131         log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(),
    1132                 this_thread_no, archiving_set_no);
     1094        log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    11331095        archiving_set_no++;
    1134     }
     1096
     1097        mr_free(archiving_filelist_fname);
     1098        mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1099    }
     1100    mr_free(archiving_filelist_fname);
     1101
    11351102    if (!semaphore_p()) {
    11361103        fatal_error("Cannot get semaphore P");
     
    11401107        fatal_error("Cannot get semaphore V");
    11411108    }
    1142     log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
    1143             this_thread_no);
    1144     paranoid_free(archiving_filelist_fname);
    1145     paranoid_free(archiving_afioball_fname);
    1146     paranoid_free(curr_xattr_list_fname);
    1147     paranoid_free(curr_acl_list_fname);
    1148     paranoid_free(tmp);
     1109    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), this_thread_no);
    11491110    pthread_exit(NULL);
    11501111}
     
    12281189
    12291190    /*@ buffers *********************************** */
    1230     char *command, *tmpfile, *data_disks_file;
     1191    char *command = NULL;
     1192    char *tmpfile = NULL;
     1193    char *data_disks_file = NULL;
    12311194
    12321195    assert(bkpinfo != NULL);
    1233     malloc_string(command);
    1234     malloc_string(tmpfile);
    1235     malloc_string(data_disks_file);
    1236     sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    1237 
    1238     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s",
    1239              call_program_and_get_last_line_of_output("dd \
    1240 if=/dev/urandom bs=16 count=1 2> /dev/null | \
    1241 hexdump | tr -s ' ' '0' | head -n1"));
     1196    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
     1197
     1198    snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));
    12421199    strip_spaces(g_serial_string);
    12431200    strcat(g_serial_string, "...word.");
     
    12451202    assert(strlen(g_serial_string) < MAX_STR_LEN);
    12461203
    1247     sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1204    mr_asprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    12481205    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    12491206        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    12501207    }
     1208    mr_free(tmpfile);
    12511209
    12521210    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12691227        }
    12701228    }
    1271 
    1272     sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
    1273             bkpinfo->netfs_remote_dir, bkpinfo->prefix);
     1229    mr_free(data_disks_file);
     1230
     1231    mr_asprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix);
    12741232    paranoid_system(command);
     1233    mr_free(command);
     1234
    12751235    wipe_archives(bkpinfo->scratchdir);
    12761236    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12811241                                     BLK_START_OF_BACKUP);
    12821242    }
    1283     paranoid_free(command);
    1284     paranoid_free(tmpfile);
    1285     paranoid_free(data_disks_file);
    12861243    return (retval);
    12871244}
     
    13561313
    13571314    /*@ buffers ********************************************** */
    1358     char *storing_filelist_fname;
    1359     char *storing_afioball_fname;
     1315    char *storing_filelist_fname = NULL;
     1316    char *storing_afioball_fname = NULL;
    13601317    char *tmp = NULL;
    13611318    char *media_usage_comment = NULL;
     
    13741331    assert(bkpinfo != NULL);
    13751332    malloc_string(result_str);
    1376     malloc_string(curr_xattr_list_fname);
    1377     malloc_string(curr_acl_list_fname);
    1378     malloc_string(storing_filelist_fname);
    1379     malloc_string(storing_afioball_fname);
    1380     transfer_block =
    1381         malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    1382     memset((void *) transfer_block, 0,
    1383            sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1333    transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1334    memset((void *) transfer_block, 0, sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    13841335    p_last_set_archived = (int *) transfer_block;
    13851336    p_archival_threads_running = (int *) (transfer_block + 4);
    13861337    p_next_set_to_archive = (int *) (transfer_block + 8);
    13871338    p_list_of_fileset_flags = (char *) (transfer_block + 12);
    1388     memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET),
    1389            (void *) bkpinfo, sizeof(struct s_bkpinfo));
     1339    memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo));
    13901340    pvp = &vp;
    13911341    vp = (void *) result_str;
     
    13991349                       "Please wait. This may take a couple of hours.",
    14001350                       "Working...",
    1401                        get_last_filelist_number() + 1);
     1351                       (long)get_last_filelist_number() + 1L);
    14021352
    14031353    log_msg(5, "We're gonna party like it's your birthday.");
     
    14381388            if (!get_bit_N_of_array
    14391389                (p_list_of_fileset_flags, storing_set_no)) {
    1440             misc_counter_that_is_not_important =
    1441                 (misc_counter_that_is_not_important + 1) % 5;
     1390            misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
    14421391            /* BCO the media_usage_comment is not really initialized there !
    14431392            if (!misc_counter_that_is_not_important) {
     
    14461395            */
    14471396            sleep(1);
    1448             } else
     1397            } else {
    14491398                // store set N
    1450             {
    1451                 sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
    1452                         bkpinfo->tmpdir, storing_set_no);
    1453                 sprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    1454                         bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
     1399                mr_asprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
     1400                mr_asprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
    14551401                if (g_getfattr) {
    1456                     sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1457                         bkpinfo->tmpdir, storing_set_no);
     1402                    mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14581403                }
    14591404                if (g_getfacl) {
    1460                     sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1461                         bkpinfo->tmpdir, storing_set_no);
     1405                    mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14621406                }
    14631407
     
    14701414                    sleep(5);
    14711415                }
    1472                 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    14731416                /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    14741417                if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    14751418                    register_in_tape_catalog(fileset, storing_set_no, -1,
    14761419                                         storing_afioball_fname);
    1477                     maintain_collection_of_recent_archives(bkpinfo->tmpdir,
    1478                                                        storing_afioball_fname);
     1420                    maintain_collection_of_recent_archives(bkpinfo->tmpdir, storing_afioball_fname);
    14791421                    log_it("Writing EXAT files");
    14801422                    res +=
     
    15101452                retval += res;
    15111453                g_current_progress++;
     1454                mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    15121455                update_progress_form(media_usage_comment);
    15131456                mr_free(media_usage_comment);
    15141457                if (res) {
    1515                     mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n",
    1516                         storing_set_no);
    1517                     log_to_screen(tmp);
    1518                     paranoid_free(tmp);
    1519                     fatal_error
    1520                         ("Is your hard disk full? If not, please send the author the logfile.");
     1458                    log_to_screen("Failed to add archive %ld's files to CD dir\n", storing_set_no);
     1459                    fatal_error("Is your hard disk full? If not, please send the author the logfile.");
    15211460                }
    15221461                storing_set_no++;
    15231462                //      sleep(2);
     1463                if (g_getfacl) {
     1464                    mr_free(curr_acl_list_fname);
     1465                }
     1466                if (g_getfattr) {
     1467                    mr_free(curr_xattr_list_fname);
     1468                }
     1469                mr_free(storing_filelist_fname);
     1470                mr_free(storing_afioball_fname);
    15241471        }
    15251472    }
     
    15401487    }
    15411488    log_to_screen(tmp);
    1542     paranoid_free(tmp);
     1489    mr_free(tmp);
    15431490
    15441491    paranoid_free(transfer_block);
    15451492    paranoid_free(result_str);
    1546     paranoid_free(storing_filelist_fname);
    1547     paranoid_free(storing_afioball_fname);
    1548     paranoid_free(curr_xattr_list_fname);
    1549     paranoid_free(curr_acl_list_fname);
    15501493    return (retval);
    15511494}
     
    15981541    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    15991542    run_program_and_log_output(tmp, FALSE);
    1600     paranoid_free(tmp);
     1543    mr_free(tmp);
    16011544    if (chdir(bkpinfo->scratchdir)) {
    16021545        // FIXME
     
    16081551    log_msg(1, message_to_screen);
    16091552
    1610     mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
     1553    if (bkpinfo->media_device) {
     1554        mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
     1555    } else {
     1556        mr_asprintf(tmp1, "");
     1557    }
    16111558    if (is_this_device_mounted(tmp1)) {
    16121559        log_msg(1, "USB device mounted. Remounting it at the right place");
    16131560        mr_asprintf(tmp, "umount %s", tmp1);
    16141561        run_program_and_log_output(tmp, FALSE);
    1615         paranoid_free(tmp);
    1616     }
    1617     paranoid_free(tmp1);
     1562        mr_free(tmp);
     1563    }
     1564    mr_free(tmp1);
    16181565
    16191566    log_msg(1, "Mounting USB device.");
     
    16211568    mr_asprintf(tmp, "mkdir -p %s", tmp1);
    16221569    run_program_and_log_output(tmp, FALSE);
    1623     paranoid_free(tmp);
     1570    mr_free(tmp);
     1571
    16241572
    16251573    /* Mindi always create one single parition on the USB dev */
    16261574    mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
    16271575    run_program_and_log_output(tmp, FALSE);
    1628     paranoid_free(tmp);
     1576    mr_free(tmp);
    16291577
    16301578    if (bkpinfo->nonbootable_backup) {
     
    16421590        }
    16431591        log_to_screen(result_sz);
    1644         paranoid_free(result_sz);
    1645         paranoid_free(tmp);
     1592        mr_free(result_sz);
     1593        mr_free(tmp);
    16461594        retval += res;
    16471595
     
    16491597        mr_asprintf(tmp,"mkdir %s/archive", bkpinfo->scratchdir);
    16501598        run_program_and_log_output(tmp, FALSE);
    1651         paranoid_free(tmp);
     1599        mr_free(tmp);
    16521600    }
    16531601    paranoid_free(message_to_screen);
     
    16571605        mr_asprintf(tmp, "umount %s1", bkpinfo->media_device);
    16581606        run_program_and_log_output(tmp, FALSE);
    1659         paranoid_free(tmp);
     1607        mr_free(tmp);
    16601608    }
    16611609
     
    16951643
    16961644    /*@ buffers ****************************************** */
    1697     char *tmp;
     1645    char *tmp = NULL;
     1646    char *tmp2 = NULL;
    16981647    char *old_pwd;
    16991648    char *result_sz = NULL;
    17001649    char *message_to_screen = NULL;
    17011650    char *sz_blank_disk = NULL;
    1702     char *fnam;
    1703     char *tmp2;
    1704     char *tmp3;
     1651    char *fnam = NULL;
     1652    char *tmp3 = NULL;
    17051653    char *isofs_cmd = NULL;
    17061654    char *full_isofs_cmd = NULL;
     
    17101658    malloc_string(old_pwd);
    17111659    malloc_string(fnam);
    1712     tmp = malloc(1200);
    1713     tmp2 = malloc(1200);
    1714     tmp3 = malloc(1200);
    17151660    assert(bkpinfo != NULL);
    17161661    assert_string_is_neither_NULL_nor_zerolength(destfile);
    17171662
    1718     sprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
    1719     sprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
     1663    /* Copy the files needed by isolinux in the right dir */
     1664    mr_asprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
     1665    mr_asprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
    17201666    if (does_file_exist(tmp)) {
    1721         sprintf(tmp3, "cp -f %s %s", tmp, tmp2);
     1667        mr_asprintf(tmp3, "cp -f %s %s", tmp, tmp2);
    17221668        paranoid_system(tmp3);
     1669        mr_free(tmp3);
    17231670    }
    17241671    if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
    1725         sprintf(tmp3, "cp -f %s %s", tmp2, tmp);
     1672        mr_asprintf(tmp3, "cp -f %s %s", tmp2, tmp);
    17261673        paranoid_system(tmp3);
    1727     }
    1728     free(tmp2);
    1729     free(tmp3);
    1730     tmp2 = NULL;
    1731     tmp3 = NULL;
     1674        mr_free(tmp3);
     1675    }
     1676    mr_free(tmp2);
     1677    mr_free(tmp3);
    17321678    if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
    17331679        popup_and_OK("Please insert new media and press Enter.");
    17341680    }
    17351681
    1736     log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s",
    1737             bkpinfo->scratchdir, destfile);
     1682    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
    17381683    tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1);
    1739     sprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
     1684    if (! tmp2) {
     1685        //FIXME
     1686    }
     1687    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    17401688    run_program_and_log_output(tmp, FALSE);
     1689    mr_free(tmp);
     1690
    17411691    if (chdir(bkpinfo->scratchdir)) {
    17421692        // FIXME
     
    17441694
    17451695    if (bkpinfo->call_before_iso[0] != '\0') {
    1746         mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d",
    1747                 g_current_media_number);
    1748         res =
    1749             eval_call_to_make_ISO(bkpinfo->call_before_iso,
    1750                                   destfile, g_current_media_number,
    1751                                   MONDO_LOGFILE, message_to_screen);
     1696        mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number);
     1697        res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17521698        if (res) {
    17531699            mr_strcat(message_to_screen, "...failed");
     
    17631709    if (bkpinfo->call_make_iso[0] != '\0') {
    17641710        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    1765         sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    17661711        mds = media_descriptor_string(bkpinfo->backup_media_type);
    17671712        mr_asprintf(message_to_screen, "Making an ISO (%s #%d)", mds, g_current_media_number);
     
    17741719        } else {
    17751720            res =
    1776                 eval_call_to_make_ISO(bkpinfo->call_make_iso,
    1777                                       bkpinfo->scratchdir,
    1778                                       g_current_media_number,
    1779                                       MONDO_LOGFILE, message_to_screen);
     1721                eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17801722            if (res) {
    17811723                log_to_screen("%s...failed to write", message_to_screen);
    17821724            } else {
    17831725                log_to_screen("%s...OK", message_to_screen);
    1784                 sprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
     1726                mr_asprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
    17851727                if (!run_program_and_log_output(tmp, 1)) {
    17861728                    log_to_screen
    17871729                        ("Despite nonfatal errors, growisofs confirms the write was successful.");
    17881730                }
     1731                mr_free(tmp);
    17891732            }
    17901733            retval += res;
    17911734#ifdef DVDRWFORMAT
    1792             sprintf(tmp,
    1793                     "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
    1794                     MONDO_LOGFILE);
     1735            mr_asprintf(tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE);
    17951736            if (g_backup_media_type == dvd
    17961737                && (res || !run_program_and_log_output(tmp, 1))) {
     
    18001741                /* reset error counter before trying to blank DVD */
    18011742                retval -= res;
    1802                 paranoid_system("sync");
     1743                sync();
    18031744                pause_for_N_seconds(5, "Letting DVD drive settle");
    18041745
     
    18101751                }
    18111752                pause_for_N_seconds(5, "Letting DVD drive settle");
    1812                 mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
     1753                if (bkpinfo->media_device) {
     1754                    mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
     1755                } else {
     1756                    mr_asprintf(sz_blank_disk, "dvd+rw-format");
     1757                }
    18131758                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
    1814                 res =
    1815                     run_external_binary_with_percentage_indicator_NEW
    1816                     ("Blanking DVD disk", sz_blank_disk);
     1759                res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
    18171760                if (res) {
    1818                     log_to_screen
    1819                         ("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath...");
    1820                     pause_for_N_seconds(5,
    1821                                         "Letting DVD drive settle... and trying again.");
    1822                     res =
    1823                         run_external_binary_with_percentage_indicator_NEW
    1824                         ("Blanking DVD disk", sz_blank_disk);
     1761                    log_to_screen("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath...");
     1762                    pause_for_N_seconds(5, "Letting DVD drive settle... and trying again.");
     1763                    res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
    18251764                    if (res) {
    18261765                        log_to_screen("Format failed a second time.");
     
    18381777                }
    18391778                pause_for_N_seconds(5, "Letting DVD drive settle");
    1840                 res =
    1841                     eval_call_to_make_ISO(bkpinfo->call_make_iso,
    1842                                           bkpinfo->scratchdir,
    1843                                           g_current_media_number,
    1844                                           MONDO_LOGFILE,
    1845                                           message_to_screen);
     1779                res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18461780                retval += res;
    18471781                if (!bkpinfo->please_dont_eject) {
     
    18561790                }
    18571791            }
     1792            mr_free(tmp);
    18581793#endif
    18591794            if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
     
    18761811            log_msg(1, "Making nonbootable backup");
    18771812            mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS);
    1878             res = eval_call_to_make_ISO(full_isofs_cmd,
    1879                                       destfile, g_current_media_number,
    1880                                       MONDO_LOGFILE, message_to_screen);
     1813            res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18811814            mr_free(full_isofs_cmd);
    18821815        } else {
     
    18881821
    18891822
    1890             log_msg(1, "make_cd_use_lilo is actually %d",
    1891                     bkpinfo->make_cd_use_lilo);
     1823            log_msg(1, "make_cd_use_lilo is actually %d", bkpinfo->make_cd_use_lilo);
    18921824            if (bkpinfo->make_cd_use_lilo) {
    18931825                log_msg(1, "make_cd_use_lilo = TRUE");
     
    18951827                log_msg(1, "IA64 --> elilo");
    18961828                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_ELILO);
    1897                 res = eval_call_to_make_ISO(full_isofs_cmd,
    1898                                             destfile,
    1899                                             g_current_media_number,
    1900                                             MONDO_LOGFILE,
    1901                                             message_to_screen);
     1829                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19021830                mr_free(full_isofs_cmd);
    19031831#else
    19041832                log_msg(1, "Non-ia64 --> lilo");
    19051833                mr_asprintf(full_isofs_cmd, "%s%s-b images/mindi-bootroot.2880.img -c boot.cat -o '_ISO_' -J -V _CD#_ .",isofs_cmd,MONDO_MKISOFS);
    1906                 res =
    1907                     // FIXME: fixed boot size probably wrong. lilo to be removed
    1908                     eval_call_to_make_ISO(full_isofs_cmd,
    1909                                           destfile, g_current_media_number,
    1910                                           MONDO_LOGFILE,
    1911                                           message_to_screen);
     1834                // FIXME: fixed boot size probably wrong. lilo to be removed
     1835                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19121836                mr_free(full_isofs_cmd);
    19131837#endif
     
    19161840                log_msg(1, "Isolinux");
    19171841                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX);
    1918                 res =
    1919                     eval_call_to_make_ISO(full_isofs_cmd,
    1920                                           destfile, g_current_media_number,
    1921                                           MONDO_LOGFILE,
    1922                                           message_to_screen);
     1842                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19231843                mr_free(full_isofs_cmd);
    19241844            }
     
    19401860        || bkpinfo->backup_media_type == cdrw) {
    19411861        if (is_this_device_mounted(bkpinfo->media_device)) {
    1942             log_msg(2,
    1943                     "Warning - %s mounted. I'm unmounting it before I burn to it.",
    1944                     bkpinfo->media_device);
    1945             sprintf(tmp, "umount %s", bkpinfo->media_device);
     1862            log_msg(2, "Warning - %s mounted. I'm unmounting it before I burn to it.", bkpinfo->media_device);
     1863            mr_asprintf(tmp, "umount %s", bkpinfo->media_device);
    19461864            run_program_and_log_output(tmp, FALSE);
     1865            mr_free(tmp);
    19471866        }
    19481867    }
     
    19541873        mr_free(mds);
    19551874        pause_and_ask_for_cdr(2, &cd_is_mountable);
    1956         res =
    1957             eval_call_to_make_ISO(bkpinfo->call_burn_iso,
    1958                                   destfile, g_current_media_number,
    1959                                   MONDO_LOGFILE, message_to_screen);
     1875        res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19601876        if (res) {
    19611877            mr_strcat(message_to_screen, "...failed");
     
    19731889        mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
    19741890        mr_free(mds);
    1975         res =
    1976             eval_call_to_make_ISO(bkpinfo->call_after_iso,
    1977                                   destfile, g_current_media_number,
    1978                                   MONDO_LOGFILE, message_to_screen);
     1891        res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19791892        if (res) {
    19801893            mr_strcat(message_to_screen, "...failed");
     
    20441957
    20451958    /*@ pointers ******************************************* */
    2046     FILE *fin;
     1959    FILE *fin = NULL;
    20471960    char *p;
    20481961    char *q;
     
    20501963    /*@ buffers ******************************************** */
    20511964    char *tmp = NULL;
    2052     char *bigfile_fname;
     1965    char *bigfile_fname = NULL;
    20531966    char *sz_devfile = NULL;
    20541967    char *ntfsprog_fifo = NULL;
     
    20861999    log_to_screen(tmp);
    20872000    noof_biggie_files = count_lines_in_file(biggielist_fname);
    2088     open_progress_form("Backing up big files", tmp,
    2089                        "Please wait. This may take some time.", "",
    2090                        estimated_total_noof_slices);
    2091     paranoid_free(tmp);
     2001    open_progress_form("Backing up big files", tmp, "Please wait. This may take some time.", "", estimated_total_noof_slices);
     2002    mr_free(tmp);
    20922003
    20932004    if (!(fin = fopen(biggielist_fname, "r"))) {
     
    21212032            log_msg(2, "bigfile_fname = %s", bigfile_fname);
    21222033            use_ntfsprog = FALSE;
    2123             if (!strncmp(bigfile_fname, "/dev/", 5)
    2124                 && is_dev_an_NTFS_dev(bigfile_fname)) {
     2034            if (!strncmp(bigfile_fname, "/dev/", 5) && is_dev_an_NTFS_dev(bigfile_fname)) {
    21252035                use_ntfsprog = TRUE;
    2126                 log_msg(2,
    2127                         "Calling ntfsclone in background because %s is an NTFS partition",
    2128                         bigfile_fname);
    2129                 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir,
    2130                         (int) (random() % 32768),
    2131                         (int) (random() % 32768));
     2036                log_msg(2, "Calling ntfsclone in background because %s is an NTFS partition", bigfile_fname);
     2037                mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
    21322038                mkfifo(sz_devfile, 0x770);
    21332039                ntfsprog_fifo = sz_devfile;
     
    21372043                    fatal_error("Fork failure");
    21382044                case 0:
    2139                     log_msg(2,
    2140                             "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
    2141                             bigfile_fname, sz_devfile);
     2045                    log_msg(2, "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", bigfile_fname, sz_devfile);
    21422046                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
    21432047                    /* BCO/BERLIOS Does the child need to unalocate memory as well ?
    2144                     paranoid_free(bigfile_fname);
     2048                    mr_free(bigfile_fname);
    21452049                    mr_free(sz_devfile);
    21462050                    */
     
    21482052                    break;
    21492053                default:
    2150                     log_msg(2,
    2151                             "feed_into_ntfsprog() called in background --- pid=%ld",
    2152                             (long int) (pid));
     2054                    log_msg(2, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
    21532055                }
    21542056            }
     
    21602062            // Whether partition or biggiefile, just do your thang :-)
    21612063            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2162                 write_header_block_to_stream(biggie_fsize, bigfile_fname,
    2163                                              use_ntfsprog ?
    2164                                              BLK_START_A_PIHBIGGIE :
    2165                                              BLK_START_A_NORMBIGGIE);
    2166             }
    2167             res =
    2168                 slice_up_file_etc(bigfile_fname,
    2169                                   ntfsprog_fifo, biggie_file_number,
    2170                                   noof_biggie_files, use_ntfsprog);
     2064                write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ?  BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE);
     2065            }
     2066            res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog);
    21712067
    21722068            /* Free it here as ntfsprog_fifo is not used anymore */
     
    21972093            }
    21982094        }
    2199 #ifndef _XWIN
    22002095        if (!g_text_mode) {
    22012096            newtDrawRootText(0, g_noof_rows - 2, tmp);
    22022097            newtRefresh();
    22032098        }
    2204 #endif
    2205         paranoid_free(tmp);
    2206     }
     2099        mr_free(tmp);
     2100    }
     2101    mr_free(bigfile_fname);
     2102
    22072103    log_msg(1, "Finished backing up bigfiles");
    22082104    log_msg(1, "estimated slices = %ld; actual slices = %ld",
     
    22102106    close_progress_form();
    22112107    paranoid_fclose(fin);
    2212     paranoid_free(bigfile_fname);
    22132108    return (retval);
    22142109}
     
    22712166        retval += res;
    22722167        if (res) {
    2273             mr_asprintf(tmp, "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
    2274             log_to_screen(tmp);
    2275             mr_free(tmp);
    2276         }
    2277 
    2278         mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
     2168            log_to_screen("Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
     2169        }
    22792170
    22802171        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
     
    23192210        retval += res;
    23202211        g_current_progress++;
     2212
     2213        mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    23212214        update_progress_form(media_usage_comment);
    23222215        mr_free(media_usage_comment);
    23232216
    23242217        if (res) {
    2325             mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n", curr_set_no);
    2326             log_to_screen(tmp);
    2327             mr_free(tmp);
    2328             fatal_error
    2329                 ("Is your hard disk is full? If not, please send the author the logfile.");
     2218            log_to_screen("Failed to add archive %ld's files to CD dir\n", curr_set_no);
     2219            fatal_error("Is your hard disk is full? If not, please send the author the logfile.");
    23302220        }
    23312221        mr_free(curr_filelist_fname);
     
    24282318    }
    24292319
    2430     mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    2431             biggielist);
     2320    mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist);
    24322321    paranoid_system(command);
    24332322    mr_free(command);
     
    24432332    if (g_getfattr) {
    24442333        get_fattr_list(biggielist, xattr_fname);
    2445         mr_asprintf(command, "cp %s %s/archives/", xattr_fname,
    2446             bkpinfo->scratchdir);
     2334        mr_asprintf(command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir);
    24472335        paranoid_system(command);
    24482336        mr_free(command);
     
    27332621    /*@ buffers ********************************************* */
    27342622    char *tmp = NULL;
    2735     char *cdrom_dev;
    2736     char *cdrw_dev;
     2623    char *cdrom_dev = NULL;
     2624    char *cdrw_dev = NULL;
    27372625    char *our_serial_str = NULL;
    27382626    bool ok_go_ahead_burn_it;
     
    27402628    int attempt_to_mount_returned_this = 999;
    27412629    char *mtpt = NULL;
    2742     char *szcdno;
    2743     char *szserfname;
    2744     char *szunmount;
     2630    char *szcdno = NULL;
     2631    char *szserfname = NULL;
     2632    char *szunmount = NULL;
    27452633    char *mds = NULL;
    27462634
    27472635    malloc_string(cdrom_dev);
    27482636    malloc_string(cdrw_dev);
    2749     malloc_string(szcdno);
    2750     malloc_string(szserfname);
    2751     malloc_string(szunmount);
    2752     malloc_string(mtpt);
    27532637
    27542638    mds = media_descriptor_string(g_backup_media_type);
    2755     mr_asprintf(tmp, "I am about to burn %s #%d", mds, g_current_media_number);
     2639    log_to_screen("I am about to burn %s #%d", mds, g_current_media_number);
    27562640    mr_free(mds);
    2757     log_to_screen(tmp);
    2758     mr_free(tmp);
    27592641    if (g_current_media_number < ask_for_one_if_more_than_this) {
    27602642        return;
    27612643    }
    27622644    log_to_screen("Scanning CD-ROM drive...");
    2763     sprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
     2645    mr_asprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
    27642646    make_hole_for_dir(mtpt);
    27652647
     
    27672649    ok_go_ahead_burn_it = TRUE;
    27682650    if (!find_cdrom_device(cdrom_dev, FALSE)) {
    2769 /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
    2770       log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
    2771       retract_CD_tray_and_defeat_autorun();
    2772 */
     2651        /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
     2652        log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
     2653        retract_CD_tray_and_defeat_autorun();
     2654        */
    27732655        mr_asprintf(tmp, "umount %s", cdrom_dev);
    27742656        run_program_and_log_output(tmp, 1);
    2775         sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2776         sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2777         sprintf(szunmount, "umount %s", mtpt);
     2657        mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
     2658        mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
     2659        mr_asprintf(szunmount, "umount %s", mtpt);
    27782660        cd_number = -1;
    27792661        mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
     
    27812663        attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1);
    27822664        mr_free(tmp);
     2665
    27832666        if (attempt_to_mount_returned_this) {
    27842667            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    27852668            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2786             /*
    2787                if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
    2788                {
    2789                ok_go_ahead_burn_it = FALSE;
    2790                log_to_screen("There isn't a writable CD/DVD in the drive.");
    2791                }
    2792                else
    2793                {
    2794                log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
    2795                }
    2796              */
    2797         } else if (!does_file_exist(szcdno)
    2798                    || !does_file_exist(szserfname)) {
     2669        } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) {
    27992670            mds = media_descriptor_string(g_backup_media_type);
    2800             log_to_screen
    2801                 ("%s has data on it but it's probably not a Mondo CD.", mds);
     2671            log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds);
    28022672            mr_free(mds);
    28032673        } else {
     
    28092679            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    28102680            mr_free(our_serial_str);
    2811             mr_asprintf(our_serial_str, "%s",
    2812                    call_program_and_get_last_line_of_output(tmp));
     2681            mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
    28132682            mr_free(tmp);
    28142683            // FIXME - should be able to use last_line_of_file(), surely?
    28152684        }
     2685        mr_free(szcdno);
     2686        mr_free(szserfname);
     2687
    28162688        run_program_and_log_output(szunmount, 1);
     2689        mr_free(szunmount);
     2690
    28172691        log_msg(2, "paafcd: cd_number = %d", cd_number);
    2818         log_msg(2, "our serial str = %s; g_serial_string = %s",
    2819                 our_serial_str, g_serial_string);
     2692        log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
    28202693        if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
    28212694            mds = media_descriptor_string(g_backup_media_type);
     
    28492722        }
    28502723        mds = media_descriptor_string(g_backup_media_type);
    2851         mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    2852                 mds, g_current_media_number, mds);
     2724        mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", mds, g_current_media_number, mds);
    28532725        mr_free(mds);
    28542726
     
    28612733
    28622734    mds = media_descriptor_string(g_backup_media_type);
    2863     log_msg(2,
    2864             "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
     2735    log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
    28652736
    28662737    log_to_screen("Proceeding w/ %s in drive.", mds);
     
    28692740    paranoid_free(cdrom_dev);
    28702741    paranoid_free(cdrw_dev);
    2871     paranoid_free(mtpt);
    2872     paranoid_free(szcdno);
    2873     paranoid_free(szserfname);
    2874     paranoid_free(szunmount);
     2742    mr_free(mtpt);
    28752743    if (pmountable) {
    28762744        if (attempt_to_mount_returned_this) {
     
    28822750
    28832751}
    2884 
    2885 
    2886 
    2887 
    2888 
    2889 
    28902752
    28912753
     
    29172779
    29182780/* @} - end of utilityGroup */
    2919 
    2920 
    2921 
    2922 
    2923 
    2924 
    29252781
    29262782
     
    29452801 */
    29462802int
    2947 slice_up_file_etc(char *biggie_filename,
    2948                   char *ntfsprog_fifo, long biggie_file_number,
    2949                   long noof_biggie_files, bool use_ntfsprog)
    2950 {
     2803slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
    29512804
    29522805    /*@ buffers ************************************************** */
    29532806    char *tmp = NULL;
    2954     char *checksum_line, *command;
    2955     char *tempblock;
     2807    char *checksum_line = NULL;
     2808    char *command = NULL;
     2809    char *tempblock = NULL;
    29562810    char *curr_slice_fname_uncompressed = NULL;
    29572811    char *curr_slice_fname_compressed = NULL;
    29582812    char *file_to_archive = NULL;
    2959     char *file_to_openin;
     2813    char *file_to_openin = NULL;
    29602814    /*@ pointers ************************************************** */
    2961     char *pB;
    2962     FILE *fin = NULL, *fout = NULL;
     2815    char *pB = NULL;
     2816    FILE *fin = NULL;
     2817    FILE *fout = NULL;
    29632818
    29642819    /*@ bool ****************************************************** */
     
    29662821
    29672822    /*@ long ****************************************************** */
    2968     size_t blksize = 0;
    2969     long slice_num = 0;
    2970     long i;
    2971     long optimal_set_size;
    2972     bool should_I_compress_slices;
     2823    size_t blksize = (size_t)0;
     2824    long slice_num = 0L;
     2825    long i = 0L;
     2826    bool should_I_compress_slices = TRUE;
    29732827    char *suffix = NULL;                // for compressed slices
    29742828
     
    29832837    /*@ structures ************************************************** */
    29842838    struct s_filename_and_lstat_info biggiestruct;
    2985 //  struct stat statbuf;
    29862839
    29872840    assert(bkpinfo != NULL);
    29882841    assert_string_is_neither_NULL_nor_zerolength(biggie_filename);
    2989     malloc_string(checksum_line);
    29902842
    29912843    biggiestruct.for_backward_compatibility = '\n';
    29922844    biggiestruct.use_ntfsprog = use_ntfsprog;
    2993     optimal_set_size = bkpinfo->optimal_set_size;
    2994     if (is_this_file_compressed(biggie_filename)
    2995         || bkpinfo->compression_level == 0) {
     2845    if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) {
    29962846        mr_asprintf(suffix, "%s", "");
    2997         //      log_it("%s is indeed compressed :-)", filename);
    29982847        should_I_compress_slices = FALSE;
    29992848    } else {
     
    30022851    }
    30032852
    3004     if (optimal_set_size < 999) {
     2853    if (bkpinfo->optimal_set_size < 999L) {
    30052854        fatal_error("bkpinfo->optimal_set_size is insanely small");
    30062855    }
     2856
    30072857    if (ntfsprog_fifo) {
    30082858        file_to_openin = ntfsprog_fifo;
    3009         strcpy(checksum_line, "IGNORE");
    3010         log_msg(2,
    3011                 "Not calculating checksum for %s: it would take too long",
    3012                 biggie_filename);
     2859        mr_asprintf(checksum_line, "IGNORE");
     2860        log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename);
    30132861        if ( !find_home_of_exe("ntfsresize")) {
    30142862            fatal_error("ntfsresize not found");
     
    30202868        log_it("res of it = %s", tmp);
    30212869        totallength = (off_t)atoll(tmp);
    3022         paranoid_free(tmp);
     2870        mr_free(tmp);
    30232871    } else {
    30242872        file_to_openin = biggie_filename;
     
    30342882        }
    30352883        mr_free(command);
    3036         tmp = fgets(checksum_line, MAX_STR_LEN, fin);
     2884        mr_getline(checksum_line, fin);
    30372885        pclose(fin);
    30382886        totallength = length_of_file (biggie_filename);
     
    30482896    }
    30492897    strcpy(biggiestruct.checksum, checksum_line);
     2898    mr_free(checksum_line);
    30502899
    30512900    mr_asprintf(tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
     
    30532902    if (fout == NULL) {
    30542903        log_msg(1, "Unable to open and write to %s\n", tmp);
    3055         paranoid_free(tmp);
     2904        mr_free(tmp);
    30562905        mr_free(suffix);
    30572906        return (1);
    30582907    }
    3059     paranoid_free(tmp);
     2908    mr_free(tmp);
    30602909
    30612910    res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
     
    30632912        paranoid_fclose(fout);
    30642913    }
    3065     log_msg(1, "Opening in %s; slicing it and writing to CD/tape",
    3066             file_to_openin);
     2914    log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin);
    30672915    if (!(fin = fopen(file_to_openin, "r"))) {
    30682916        log_OS_error("Unable to openin biggie_filename");
    3069         mr_asprintf(tmp, "Cannot archive bigfile '%s': not found", biggie_filename);
    3070         log_to_screen(tmp);
    3071         paranoid_free(tmp);
    3072 
    3073         paranoid_free(checksum_line);
     2917        log_to_screen("Cannot archive bigfile '%s': not found", biggie_filename);
     2918
    30742919        mr_free(suffix);
    30752920        return (1);
     
    30942939        mr_asprintf(tmp, "%s", percent_media_full_comment());
    30952940        update_progress_form(tmp);
    3096         paranoid_free(tmp);
     2941        mr_free(tmp);
    30972942
    30982943        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
     
    31012946            return (1);
    31022947        }
    3103         if ((i == bkpinfo->optimal_set_size / 256)
    3104             && (totalread < 1.1 * totallength)) {
    3105             for (i = 0; i < bkpinfo->optimal_set_size / 256; i++) {
     2948        if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) {
     2949            for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) {
    31062950                blksize = fread(tempblock, 1, 256 * 1024, fin);
    31072951                if (blksize > 0) {
     
    31122956                }
    31132957            }
     2958            mr_free(tempblock);
    31142959        } else {
    3115             i = 0;
     2960            i = 0L;
    31162961        }
    31172962        paranoid_fclose(fout);
    3118         if (i > 0)              // length_of_file (curr_slice_fname_uncompressed)
     2963        if (i > 0L)             // length_of_file (curr_slice_fname_uncompressed)
    31192964        {
    31202965            if (!does_file_exist(curr_slice_fname_uncompressed)) {
    3121                 log_msg(2,
    3122                         "Warning - '%s' doesn't exist. How can I compress slice?",
    3123                         curr_slice_fname_uncompressed);
     2966                log_msg(2, "Warning - '%s' doesn't exist. How can I compress slice?", curr_slice_fname_uncompressed);
    31242967            }
    31252968            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
     
    31412984                log_msg(2, "Failed to compress the slice");
    31422985            }
    3143             if (bkpinfo->use_lzo
    3144                 && strcmp(curr_slice_fname_compressed,
    3145                           curr_slice_fname_uncompressed)) {
     2986            if (bkpinfo->use_lzo && strcmp(curr_slice_fname_compressed, curr_slice_fname_uncompressed)) {
    31462987                unlink(curr_slice_fname_uncompressed);
    31472988            }
     
    31492990                mr_asprintf(tmp, "Problem with slice # %ld", slice_num);
    31502991            } else {
    3151                 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1,
    3152                         slice_num);
    3153             }
    3154 #ifndef _XWIN
     2992                mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1, slice_num);
     2993            }
    31552994            if (!g_text_mode) {
    31562995                newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    31592998                log_msg(2, tmp);
    31602999            }
    3161 #else
    3162             log_msg(2, tmp);
    3163 #endif
    3164             paranoid_free(tmp);
     3000            mr_free(tmp);
    31653001
    31663002            mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed);
     
    31783014
    31793015        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    3180             register_in_tape_catalog(biggieslice, biggie_file_number,
    3181                                      slice_num, file_to_archive);
    3182             maintain_collection_of_recent_archives(bkpinfo->tmpdir,
    3183                                                    file_to_archive);
     3016            register_in_tape_catalog(biggieslice, biggie_file_number, slice_num, file_to_archive);
     3017            maintain_collection_of_recent_archives(bkpinfo->tmpdir, file_to_archive);
    31843018            res = move_files_to_stream(file_to_archive, NULL);
    31853019        } else {
     
    31903024        retval += res;
    31913025        if (res) {
    3192             mr_asprintf(tmp, "Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1);
    3193             log_to_screen(tmp);
    3194             paranoid_free(tmp);
    3195             fatal_error
    3196                 ("Hard disk full. You should have bought a bigger one.");
    3197         }
    3198     }
    3199     mr_free(tempblock);
     3026            log_to_screen("Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1);
     3027            fatal_error("Hard disk full. You should have bought a bigger one.");
     3028        }
     3029    }
    32003030    mr_free(suffix);
    32013031    paranoid_fclose(fin);
     
    32073037    }
    32083038    log_msg(1, tmp);
    3209     paranoid_free(tmp);
    3210 
    3211     paranoid_free(checksum_line);
     3039    mr_free(tmp);
     3040
    32123041    return (retval);
    32133042}
     
    32883117    log_msg(2, tmp);
    32893118    center_string(tmp, 80);
    3290 #ifndef _XWIN
    32913119    if (!g_text_mode) {
    32923120        newtPushHelpLine(tmp);
    32933121    }
    3294 #endif
    32953122    res = write_iso_and_go_on(TRUE);
    3296 #ifndef _XWIN
    32973123    if (!g_text_mode) {
    32983124        newtPopHelpLine();
    32993125    }
    3300 #endif
    33013126    log_msg(2, "Returning from writing final ISO (res=%d)", res);
    33023127    paranoid_free(tmp);
     
    33273152
    33283153    /*@ buffers ***************************************************** */
    3329     char *tmp;
    3330     char *cdno_fname;
    3331     char *lastcd_fname;
    3332     char *isofile;
     3154    char *tmp = NULL;
     3155    char *tmp1 = NULL;
     3156    char *cdno_fname = NULL;
     3157    char *lastcd_fname = NULL;
     3158    char *isofile = NULL;
    33333159    char *mds = NULL;
    33343160
     
    33413167
    33423168    malloc_string(tmp);
    3343     malloc_string(cdno_fname);
    3344     malloc_string(lastcd_fname);
    3345     malloc_string(isofile);
    33463169
    33473170    assert(bkpinfo != NULL);
     
    33573180    /* label the ISO with its number */
    33583181
    3359     sprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
     3182    mr_asprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
    33603183    fout = fopen(cdno_fname, "w");
     3184    mr_free(cdno_fname);
     3185
    33613186    fprintf(fout, "%d", g_current_media_number);
    33623187    paranoid_fclose(fout);
    33633188
    3364     sprintf(tmp, "cp -f %s/autorun %s/", g_mondo_home,
    3365             bkpinfo->scratchdir);
    3366     if (run_program_and_log_output(tmp, FALSE)) {
     3189    mr_asprintf(tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir);
     3190    if (run_program_and_log_output(tmp1, FALSE)) {
    33673191        log_msg(2, "Warning - unable to copy autorun to scratchdir");
    33683192    }
     3193    mr_free(tmp1);
    33693194
    33703195    /* last CD or not? Label accordingly */
    3371     sprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     3196    mr_asprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    33723197    if (last_cd) {
    33733198        unlink(lastcd_fname);
     
    33803205        paranoid_fclose(fout);
    33813206    }
     3207    mr_free(lastcd_fname);
     3208
    33823209    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
    3383         sprintf(tmp,
    3384                 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    3385                 (long) space_occupied_by_cd(bkpinfo->scratchdir),
    3386                 (long) bkpinfo->media_size);
    3387         log_to_screen(tmp);
    3388     }
    3389     sprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
     3210        log_to_screen("Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",(long) space_occupied_by_cd(bkpinfo->scratchdir),(long) bkpinfo->media_size);
     3211    }
     3212    mr_asprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    33903213            bkpinfo->netfs_remote_dir, bkpinfo->prefix,
    33913214            g_current_media_number);
     
    34023225            {
    34033226                log_msg(3, "*Sigh* Mike, I hate your computer.");
     3227                // if it can't be found then force pausing
    34043228                bkpinfo->manual_cd_tray = TRUE;
    3405             }                   // if it can't be found then force pausing
    3406             else {
     3229            } else {
    34073230                log_msg(3, "Great. Found Mike's CD-ROM drive.");
    34083231            }
     
    34103233        if (bkpinfo->verify_data && !res) {
    34113234            mds = media_descriptor_string(g_backup_media_type);
    3412             log_to_screen
    3413                 ("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
     3235            log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
    34143236            mr_free(mds);
    34153237            if (chdir("/")) {
     
    34283250        } else {
    34293251            mds = media_descriptor_string(bkpinfo->backup_media_type);
    3430             sprintf(tmp, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
     3252            mr_asprintf(tmp1, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
    34313253            mr_free(mds);
    3432             res = ask_me_yes_or_no(tmp);
     3254            res = ask_me_yes_or_no(tmp1);
     3255            mr_free(tmp1);
     3256
    34333257            if (!res) {
    34343258                if (ask_me_yes_or_no("Abort the backup?")) {
     
    34433267        }
    34443268    }
     3269    mr_free(isofile);
     3270
    34453271    g_current_media_number++;
    34463272    wipe_archives(bkpinfo->scratchdir);
    3447     sprintf(tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
    3448             bkpinfo->scratchdir, bkpinfo->scratchdir);
    3449     if (system(tmp)) {
    3450         log_msg
    3451             (2,
    3452              "Error occurred when I tried to delete the redundant IMGs and GZs");
    3453     }
     3273    mr_asprintf(tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir);
     3274    if (system(tmp1)) {
     3275        log_msg(2, "Error occurred when I tried to delete the redundant IMGs and GZs");
     3276    }
     3277    mr_free(tmp1);
    34543278
    34553279    if (last_cd) {
     
    34613285    bkpinfo->verify_data = orig_vfy_flag_val;
    34623286    paranoid_free(tmp);
    3463     paranoid_free(cdno_fname);
    3464     paranoid_free(lastcd_fname);
    3465     paranoid_free(isofile);
    34663287    return (0);
    34673288}
     
    35323353            if (res) {
    35333354                mds = media_descriptor_string(bkpinfo->backup_media_type);
    3534                 mr_asprintf(tmp, "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
     3355                log_to_screen("Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
    35353356                mr_free(mds);
    3536                 log_to_screen(tmp);
    3537                 mr_free(tmp);
    35383357
    35393358            }
  • branches/3.2/mondo/src/common/libmondo-cli.c

    r3185 r3191  
    9797    for (i = 0; i < 128; i++) {
    9898        if (flag_set[i]) {
    99             mr_asprintf(tmp, "-%c %s", i, flag_val[i]);
    100             log_msg(3, tmp);
    101             mr_free(tmp);
     99            log_msg(3, "-%c %s", i, flag_val[i]);
    102100        }
    103101    }
     
    150148    char *tmp = NULL;
    151149    char *tmp1 = NULL;
     150    char *tmp2 = NULL;
    152151    char *psz = NULL;
    153152    char *p = NULL;
     
    208207            log_msg(1, "Using star instead of afio");
    209208        } else {
    210             fatal_error
    211                 ("Neither afio nor star is installed. Please install at least one.");
     209            fatal_error("Neither afio nor star is installed. Please install at least one.");
    212210        }
    213211    }
     
    219217        }
    220218        if (!find_home_of_exe("star")) {
    221             fatal_error
    222                 ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     219            fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    223220        }
    224221    }
     
    234231
    235232    if (flag_set['I']) {
    236         if (bkpinfo->include_paths[0] == '-') {
     233        if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') {
    237234            retval++;
    238235            log_to_screen("Please supply a sensible value with '-I'\n");
     
    268265            }
    269266        }
    270         paranoid_free(tmp1);
     267        mr_free(tmp1);
    271268        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    272269        log_msg(4, "Finished with the -I option");
    273270    }
    274271
    275     if (g_kernel_version >= 2.6 && !flag_set['d']
    276         && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
    277         fatal_error
    278             ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     272    if (g_kernel_version >= 2.6 && !flag_set['d'] && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
     273        fatal_error("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
    279274    }
    280275
     
    283278        if (flag_set['I']) {
    284279            retval++;
    285             log_to_screen
    286                 ("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
     280            log_to_screen("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
    287281        }
    288282        bkpinfo->make_filelist = FALSE;
    289         strcpy(bkpinfo->include_paths, flag_val['J']);
     283        mr_asprintf(bkpinfo->include_paths, "%s", flag_val['J']);
    290284    }
    291285
    292286    if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) {
    293         if (!flag_set['r'] && g_kernel_version <= 2.5
    294             && strstr(flag_val['d'], "/dev/")) {
    295             fatal_error
    296                 ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
    297         }
    298         if (flag_set['r'] && g_kernel_version <= 2.5
    299             && !strstr(flag_val['d'], "/dev/")) {
    300             fatal_error
    301                 ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
     287        if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/")) {
     288            fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
     289        }
     290        if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/")) {
     291            fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
    302292        }
    303293        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
    304             log_to_screen
    305                 ("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
    306         }
    307 
    308         if (system("which cdrecord > /dev/null 2> /dev/null")
    309             && system("which dvdrecord > /dev/null 2> /dev/null")) {
    310             fatal_error
    311                 ("Please install dvdrecord/cdrecord and try again.");
     294            log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
     295        }
     296
     297        if (system("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null")) {
     298            fatal_error("Please install dvdrecord/cdrecord and try again.");
    312299        }
    313300        if (flag_set['C']) {
    314301            bkpinfo->cdrw_speed = atoi(flag_val['C']);
    315302            if (bkpinfo->cdrw_speed < 1) {
    316                 fatal_error
    317                     ("You specified a silly speed for a CD-R[W] drive");
     303                fatal_error("You specified a silly speed for a CD-R[W] drive");
    318304            }
    319305            if (!flag_set['L']) {
    320                 log_to_screen
    321                     ("You must use -L with -C. Therefore I am setting it for you.");
     306                log_to_screen("You must use -L with -C. Therefore I am setting it for you.");
    322307                flag_set['L'] = 1;
    323308                flag_val['L'][0] = '\0';
     
    326311            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
    327312            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
    328 //    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    329313            if (flag_set['c']) {
    330314                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     
    336320
    337321            if (bkpinfo->cdrw_speed < 1) {
    338                 fatal_error
    339                     ("You specified a silly speed for a CD-R[W] drive");
     322                fatal_error("You specified a silly speed for a CD-R[W] drive");
    340323            }
    341324        }
     
    345328        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    346329        if (find_tape_device_and_size(flag_val['d'], tmp)) {
    347             fatal_error
    348                 ("Tape device not specified. I couldn't find it either.");
     330            fatal_error("Tape device not specified. I couldn't find it either.");
    349331        }
    350332        flag_set['d'] = TRUE;
    351         sprintf(tmp,
    352                 "You didn't specify a tape streamer device. I'm assuming %s",
    353                 flag_val['d']);
    354         log_to_screen(tmp);
     333        log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    355334    }
    356335
     
    358337    {
    359338        if (! flag_set['d']) {
    360             fatal_error
    361                 ("You need to specify a device file with -d for bootable USB device usage");
     339            fatal_error("You need to specify a device file with -d for bootable USB device usage");
    362340        }
    363341        if ((!flag_set['s']) && (! bkpinfo->restore_data)) {
     
    369347    {
    370348        if (flag_set['m']) {
    371             fatal_error
    372                 ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     349            fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
    373350        }
    374351        if (!flag_set['d']) {
     
    379356        }
    380357        if (strchr(flag_val['d'], ',')) {
    381             fatal_error
    382                 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     358            fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    383359        }
    384360        if (! bkpinfo->restore_data) {
    385361            if (!find_home_of_exe("growisofs")) {
    386                 fatal_error
    387                     ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     362                fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    388363            }
    389364            if (!find_home_of_exe("dvd+rw-format")) {
    390                 fatal_error
    391                     ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     365                fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    392366            }
    393367            if (!flag_set['s']) {
    394368                sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    395369                strcat(flag_val['s'], "m");
    396                 log_to_screen
    397                     ("You did not specify a size (-s) for DVD. I'm guessing %s.",
    398                     flag_val['s']);
     370                log_to_screen("You did not specify a size (-s) for DVD. I'm guessing %s.", flag_val['s']);
    399371                flag_set['s'] = 1;
    400372            }
    401373        }
    402 /*
    403       if (flag_set['Z']) {
    404       bkpinfo->blank_dvd_first = TRUE;
    405       }
    406 */
    407374    }
    408375
    409376    if (flag_set['t'] || flag_set['u']) {   /* tape size */
    410377        if (strchr(flag_val['d'], ',')) {
    411             fatal_error
    412                 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     378            fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    413379        }
    414380        if ((flag_set['O']) && (! bkpinfo->restore_data)) {
    415381            if (flag_set['s']) {
    416382                if (flag_set['t']) {
    417                     fatal_error
    418                         ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     383                    fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    419384                }
    420385                if (process_the_s_switch(flag_val['s'])) {
     
    440405
    441406    if (flag_set['n']) {
    442         strncpy(bkpinfo->netfs_mount, flag_val['n'], MAX_STR_LEN);
     407        mr_free(bkpinfo->netfs_mount);
     408        mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']);
    443409        if (!flag_set['d']) {
    444             strncpy(bkpinfo->netfs_remote_dir, "/", MAX_STR_LEN);
     410            mr_free(bkpinfo->netfs_remote_dir);
     411            mr_asprintf(bkpinfo->netfs_remote_dir, "/");
    445412        }
    446413        /* test for protocol */
     
    473440        /* Store the 2 values */
    474441        /*  using memmove instead of strcpy as per #584 */
    475         memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN);
     442        /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
     443        bkpinfo->netfs_mount = p;
    476444
    477445        /* test if we specified a user */
     
    479447        if (p != NULL) {
    480448            /* User found. Store the 2 values */
     449            bkpinfo->netfs_user = bkpinfo->netfs_mount;
    481450            p++;
    482451            /* new netfs mount */
    483             strcpy(tmp,p);
     452            mr_asprintf(bkpinfo->netfs_mount, "%s", p);
     453            /* now that user is computed, create the right value by removing end of string */
    484454            p--;
    485455            *p = '\0';
    486             mr_asprintf(q,"%s",bkpinfo->netfs_mount);
    487             bkpinfo->netfs_user = q;
    488             strcpy(bkpinfo->netfs_mount,tmp);
    489         }
    490         sprintf(tmp, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
    491                 bkpinfo->netfs_mount);
    492         strncpy(bkpinfo->isodir,
    493                 call_program_and_get_last_line_of_output(tmp),
    494                 MAX_STR_LEN / 4);
     456        }
     457        mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     458        strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
     459        mr_free(tmp1);
     460
    495461        if (strlen(bkpinfo->isodir) < 3) {
    496462            log_to_screen("Network share is not mounted. Trying to mount it for you.\n");
    497463            if (bkpinfo->netfs_user) {
    498464                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    499                     sprintf(tmp, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     465                    mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    500466                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    501                     sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
     467                    mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    502468                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    503                     sprintf(tmp, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     469                    mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    504470                } else {
    505471                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    508474            } else {
    509475                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    510                     sprintf(tmp, "sshfs %s", bkpinfo->netfs_mount);
     476                    mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount);
    511477                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    512                     sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);
     478                    mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
    513479                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    514                     sprintf(tmp, "mount %s", bkpinfo->netfs_mount);
     480                    mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
    515481                } else {
    516482                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    518484                }
    519485            }
    520             if (system(tmp)) {
     486            i = system(tmp1);
     487            mr_free(tmp1);
     488
     489            if (i) {
    521490                log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount);
    522491                retval++;
    523492            } else {
    524493                if (bkpinfo->netfs_user) {
    525                     sprintf(tmp, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
    526                         bkpinfo->netfs_mount);
     494                    mr_asprintf(tmp1, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    527495                } else {
    528                     sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
     496                    mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    529497                }
    530                 strncpy(bkpinfo->isodir,
    531                         call_program_and_get_last_line_of_output(tmp),
    532                         MAX_STR_LEN / 4);
     498                strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
    533499                if (strlen(bkpinfo->isodir) < 3) {
    534500                    retval++;
     
    624590            }
    625591        }
    626         paranoid_free(tmp1);
     592        mr_free(tmp1);
    627593
    628594        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
     
    668634        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    669635        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
    670             fatal_error
    671                 ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     636            fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
    672637        }
    673638        bkpinfo->internal_tape_block_size = itbs;
     
    678643//      bkpinfo->differential = atoi (flag_val['D']);
    679644        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
    680             fatal_error
    681                 ("The D option should be between 1 and 9 inclusive");
     645            fatal_error("The D option should be between 1 and 9 inclusive");
    682646        }
    683647    }
     
    702666            && !does_file_exist(bkpinfo->kernel_path)) {
    703667            retval++;
    704             sprintf(tmp,
    705                     "You specified kernel '%s', which does not exist\n",
    706                     bkpinfo->kernel_path);
    707             log_to_screen(tmp);
     668            log_to_screen("You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
    708669        }
    709670    }
     
    723684            }
    724685        } else if (flag_set['n']) {
    725             strncpy(bkpinfo->netfs_remote_dir, flag_val['d'], MAX_STR_LEN);
     686            mr_free(bkpinfo->netfs_remote_dir);
     687            mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']);
    726688        } else {                /* backup device (if tape/CD-R/CD-RW) */
    727689            strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     
    732694        mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir);
    733695        if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
    734             sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
     696            mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
    735697        } else {
    736             sprintf(tmp, "echo hi > %s", tmp1);
    737         }
    738         if (run_program_and_log_output(tmp, 2)) {
    739             retval++;
    740             sprintf(tmp,
    741                     "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
    742                     bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
    743             log_to_screen(tmp);
     698            mr_asprintf(tmp2, "echo hi > %s", tmp1);
     699        }
     700        i = run_program_and_log_output(tmp2, 2);
     701        mr_free(tmp2);
     702
     703        if (i) {
     704            retval++;
     705            log_to_screen("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
    744706        }
    745707        unlink(tmp1);
    746         paranoid_free(tmp1);
    747     }
    748 
    749     if (!flag_set['d']
    750         && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
     708        mr_free(tmp1);
     709    }
     710
     711    if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
    751712        if (g_kernel_version >= 2.6) {
    752713            if (popup_and_get_string
     
    769730        retval++;
    770731        log_to_screen("Please specify the backup device/directory.\n");
    771         fatal_error
    772             ("You didn't use -d to specify the backup device/directory.");
     732        fatal_error("You didn't use -d to specify the backup device/directory.");
    773733    }
    774734
     
    781741    if (flag_set['S']) {
    782742        setup_scratchdir(flag_val['S']);
    783         sprintf(tmp, "touch %s/.foo.dat", bkpinfo->scratchdir);
    784         if (run_program_and_log_output(tmp, 1)) {
    785             retval++;
     743        mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->scratchdir);
     744        if (run_program_and_log_output(tmp1, 1)) {
     745            retval++;
     746            mr_free(tmp1);
    786747            log_to_screen("Please specify a scratchdir which I can write to. :)");
    787748            fatal_error("I cannot write to the scratchdir you specified.");
    788749        }
    789         sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
    790         if (run_program_and_log_output(tmp, 1)) {
    791             retval++;
     750        mr_free(tmp1);
     751
     752        mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
     753        if (run_program_and_log_output(tmp1, 1)) {
     754            retval++;
     755            mr_free(tmp1);
    792756            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
    793757            fatal_error("I cannot write to the scratchdir you specified.");
    794758        }
     759        mr_free(tmp1);
    795760    }
    796761
    797762    if (flag_set['T']) {
    798763        setup_tmpdir(flag_val['T']);
    799         sprintf(tmp, "touch %s/.foo.dat", bkpinfo->tmpdir);
    800         if (run_program_and_log_output(tmp, 1)) {
     764        mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->tmpdir);
     765        i = run_program_and_log_output(tmp1, 1);
     766        mr_free(tmp1);
     767
     768        if (i) {
    801769            retval++;
    802770            log_to_screen("Please specify a tempdir which I can write to. :)");
    803771            fatal_error("I cannot write to the tempdir you specified.");
    804772        }
    805         sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
    806         if (run_program_and_log_output(tmp, 1)) {
     773        mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
     774        i = run_program_and_log_output(tmp1, 1);
     775        mr_free(tmp1);
     776
     777        if (i) {
    807778            retval++;
    808779            log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     
    833804#  endif
    834805#endif
    835         if (!strchr
    836             (BOOT_LOADER_CHARS,
    837              (bkpinfo->boot_loader = flag_val['l'][0]))) {
    838             log_msg(1, "%c? WTF is %c? I need G, L, E or R.",
    839                     bkpinfo->boot_loader, bkpinfo->boot_loader);
    840             fatal_error
    841                 ("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
     806        if (!strchr(BOOT_LOADER_CHARS, (bkpinfo->boot_loader = flag_val['l'][0]))) {
     807            log_msg(1, "%c? What is %c? I need G, L, E or R.", bkpinfo->boot_loader, bkpinfo->boot_loader);
     808            fatal_error("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
    842809        }
    843810#undef BOOT_LOADER_CHARS
     
    845812
    846813    if (flag_set['f']) {
    847         strncpy(bkpinfo->boot_device,
    848                 resolve_softlinks_to_get_to_actual_device_file(flag_val
    849                                                                ['f']),
    850                 MAX_STR_LEN / 4);
     814        strncpy(bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']),MAX_STR_LEN / 4);
    851815    }
    852816
     
    866830        if (run_program_and_log_output("which lzop", 2)) {
    867831            retval++;
    868             log_to_screen
    869                 ("Please install LZOP. You can't use '-L' until you do.\n");
     832            log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
    870833        }
    871834    }
     
    880843        if (run_program_and_log_output("which gzip", 2)) {
    881844            retval++;
    882             log_to_screen
    883                 ("Please install gzip. You can't use '-G' until you do.\n");
     845            log_to_screen("Please install gzip. You can't use '-G' until you do.\n");
     846        }
     847    }
     848
     849    if ((flag_set['Y']) && (! bkpinfo->restore_data)) {
     850        bkpinfo->use_lzma = TRUE;
     851        if (run_program_and_log_output("which lzma", 2)) {
     852            retval++;
     853            log_to_screen("Please install lzma. You can't use '-Y' until you do.\n");
    884854        }
    885855    }
     
    897867    if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) {
    898868        bkpinfo->make_cd_use_lilo = TRUE;
    899         log_to_screen
    900             ("Your kernel appears not to support vfat filesystems. I am therefore");
    901         log_to_screen
    902             ("using LILO instead of SYSLINUX as the media boot loader.");
     869        log_to_screen("Your kernel appears not to support vfat filesystems. I am therefore");
     870        log_to_screen("using LILO instead of SYSLINUX as the media boot loader.");
    903871    }
    904872    if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) {
    905873        bkpinfo->make_cd_use_lilo = TRUE;
    906874#ifdef __IA32__
    907         log_to_screen
    908             ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
    909         log_to_screen
    910             ("your boot loader. I shall therefore use LILO instead.");
     875        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
     876        log_to_screen("your boot loader. I shall therefore use LILO instead.");
    911877#endif
    912878#ifdef __IA64__
    913         log_to_screen
    914             ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     879        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    915880        log_to_screen("environment correctly. Please install it.");
    916881        fatal_error("Aborting");
     
    932897
    933898    if ((! bkpinfo->restore_data) && (flag_set['Z'])) {
    934             fatal_error
    935                 ("The -Z switch is only valid in restore mode");
     899            fatal_error("The -Z switch is only valid in restore mode");
    936900    }
    937901
     
    973937 * @return The number of problems with the command line (0 for success).
    974938 */
    975 int
    976 retrieve_switches_from_command_line(int argc, char *argv[],
    977                                     char flag_val[128][MAX_STR_LEN],
    978                                     bool flag_set[128])
     939int retrieve_switches_from_command_line(int argc, char *argv[], char flag_val[128][MAX_STR_LEN], bool flag_set[128])
    979940{
    980941    /*@ ints ** */
    981942    int opt = 0;
    982     char *tmp = NULL;
    983943    int i = 0;
    984944    int len;
     
    994954        flag_set[i] = FALSE;
    995955    }
    996     while ((opt =
    997             getopt(argc, argv, MONDO_OPTIONS))
    998            != -1) {
     956    while ((opt = getopt(argc, argv, MONDO_OPTIONS)) != -1) {
    999957        if (opt == '?') {
    1000958            bad_switches = TRUE;
    1001             /*log_it("Invalid option: %c\n",optopt); */
    1002959        } else {
    1003960            if (flag_set[opt]) {
    1004961                bad_switches = TRUE;
    1005                 mr_asprintf(tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]);
    1006                 log_to_screen(tmp);
    1007                 paranoid_free(tmp);
     962                log_to_screen("Switch -%c previously defined as %s\n", opt, flag_val[opt]);
    1008963            } else {
    1009964                flag_set[opt] = TRUE;
     
    1019974                        if (strchr(flag_val[opt], '/')
    1020975                            && flag_val[opt][0] != '/') {
    1021                             mr_asprintf(tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    1022                             log_to_screen(tmp);
    1023                             paranoid_free(tmp);
     976                            log_to_screen("-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    1024977                            bad_switches = TRUE;
    1025978                        }
     
    1032985    for (i = optind; i < argc; i++) {
    1033986        bad_switches = TRUE;
    1034         mr_asprintf(tmp, "Invalid arg -- %s\n", argv[i]);
    1035         log_to_screen(tmp);
    1036         paranoid_free(tmp);
     987        log_to_screen("Invalid arg -- %s\n", argv[i]);
    1037988    }
    1038989    return (bad_switches);
     
    10971048    mr_strcat(tmp, " signal received from OS");
    10981049    log_to_screen(tmp);
    1099     paranoid_free(tmp);
     1050    mr_free(tmp);
    11001051
    11011052    log_to_screen(tmp2);
    1102     paranoid_free(tmp2);
     1053    mr_free(tmp2);
    11031054    if (sig == SIGABRT) {
    11041055        sleep(10);
     
    11081059    free_MR_global_filenames();
    11091060
    1110     fatal_error
    1111         ("MondoRescue is terminating in response to a signal from the OS");
     1061    fatal_error("MondoRescue is terminating in response to a signal from the OS");
    11121062    finish(254);                // just in case
    11131063}
     
    11221072void set_signals(int on)
    11231073{
    1124     int signals[] =
    1125         { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
     1074    int signals[] = { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
    11261075    int i;
    11271076
  • branches/3.2/mondo/src/common/libmondo-devices-EXT.h

    r3154 r3191  
    1616extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    1717                                    char *device);
    18 extern int mount_CDROM_here(char *device, char *mountpoint);
     18extern int mount_CDROM_here(char *device, const char *mountpoint);
    1919extern long long size_of_specific_device_in_mountlist(struct
    2020                                                      mountlist_itself
     
    5757extern int inject_device(char *dev);
    5858extern bool does_nonMS_partition_exist(void);
    59 extern char *resolve_softlinks_to_get_to_actual_device_file(char
    60                                                             *incoming);
     59extern char *resolve_softlinks_to_get_to_actual_device_file(char *incoming);
    6160
    6261extern void set_g_cdrom_and_g_dvd_to_bkpinfo_value();
  • branches/3.2/mondo/src/common/libmondo-devices.c

    r3185 r3191  
    2121#include "libmondo-stream-EXT.h"
    2222
     23extern void mr_strip_spaces(char *);
     24
    2325#include <sys/types.h>
    2426#ifdef __FreeBSD__
     
    127129{
    128130    char *tmp = NULL;
    129     char *comment;
    130131    bool is_this_a_ramdisk = FALSE;
    131132
    132     malloc_string(comment);
    133133    mr_asprintf(tmp, "%s", where_is_root_mounted());
    134     sprintf(comment, "root is mounted at %s\n", tmp);
    135     log_msg(0, comment);
    136     log_msg(0,
    137             "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().",
    138             tmp);
     134    log_msg(0, "root is mounted at %s\n", tmp);
     135    log_msg(0, "That doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().", tmp);
    139136
    140137#ifdef __FreeBSD__
     
    156153    if (is_this_a_ramdisk) {
    157154        if (!does_file_exist("/THIS-IS-A-RAMDISK")) {
    158             log_to_screen
    159                 ("Using /dev/root is stupid of you but I'll forgive you.");
     155            log_to_screen("Using /dev/root is stupid of you but I'll forgive you.");
    160156            is_this_a_ramdisk = FALSE;
    161157        }
     
    164160        is_this_a_ramdisk = TRUE;
    165161    }
    166     paranoid_free(comment);
    167     log_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk);
     162
     163    log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE");
    168164    return (is_this_a_ramdisk);
    169165}
     
    229225int eject_device(char *dev)
    230226{
    231     char *command;
     227    char *command = NULL;
    232228    int res1 = 0, res2 = 0;
    233229
    234     malloc_string(command);
     230    if (dev == NULL) {
     231        return (1);
     232    }
    235233
    236234    if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type)
    237235        && g_backup_media_type != udev) {
    238         sprintf(command, "mt -f %s offline", dev);
     236        mr_asprintf(command, "mt -f %s offline", dev);
    239237        res1 = run_program_and_log_output(command, 1);
     238        mr_free(command);
    240239    } else {
    241240        res1 = 0;
     
    244243#ifdef __FreeBSD__
    245244    if (strstr(dev, "acd")) {
    246         sprintf(command, "cdcontrol -f %s eject", dev);
     245        mr_asprintf(command, "cdcontrol -f %s eject", dev);
    247246    } else {
    248         sprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
    249                 dev);
     247        mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`", dev);
    250248    }
    251249#else
    252     sprintf(command, "eject %s", dev);
     250    mr_asprintf(command, "eject %s", dev);
    253251#endif
    254252
    255253    log_msg(3, "Ejecting %s", dev);
    256254    res2 = run_program_and_log_output(command, 1);
    257     paranoid_free(command);
     255    mr_free(command);
    258256    if (res1 && res2) {
    259257        return (1);
     
    270268int inject_device(char *dev)
    271269{
    272     char *command;
     270    char *command = NULL;
    273271    int i;
    274272
    275     malloc_string(command);
    276 
     273    if (dev == NULL) {
     274        return (1);
     275    }
    277276
    278277#ifdef __FreeBSD__
    279278    if (strstr(dev, "acd")) {
    280         sprintf(command, "cdcontrol -f %s close", dev);
     279        mr_asprintf(command, "cdcontrol -f %s close", dev);
    281280    } else {
    282         sprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`",
    283                 dev);
     281        mr_asprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);
    284282    }
    285283#else
    286     sprintf(command, "eject -t %s", dev);
     284    mr_asprintf(command, "eject -t %s", dev);
    287285#endif
    288286    i = run_program_and_log_output(command, FALSE);
    289     paranoid_free(command);
     287    mr_free(command);
    290288    return (i);
    291289}
     
    301299
    302300    /*@ buffers *********************************************************** */
    303     char *tmp;
     301    char *tmp = NULL;
    304302    bool ret;
    305303
    306     malloc_string(tmp);
    307304    assert_string_is_neither_NULL_nor_zerolength(device);
    308305
    309     sprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
     306    mr_asprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
    310307
    311308    if (system(tmp)) {
     
    314311        ret = TRUE;
    315312    }
    316     paranoid_free(tmp);
     313    mr_free(tmp);
    317314    return (ret);
    318315}
     
    345342{
    346343    /*@ buffers **************************************************** */
    347     char *program;
    348     char *incoming;
     344    char *program = NULL;
     345    char *incoming = NULL;
    349346    char *searchstr = NULL;
    350     char *tmp;
    351     char *p;
    352347
    353348    /*@ ints ******************************************************* */
     
    356351    /*@ pointers *************************************************** */
    357352    FILE *fin;
    358 
    359353
    360354    /*@ end vars *************************************************** */
     
    362356    assert(partno >= 0 && partno < 999);
    363357
    364     malloc_string(program);
    365     malloc_string(incoming);
    366358    malloc_string(searchstr);
    367     malloc_string(tmp);
    368359
    369360#ifdef __FreeBSD__
    370361    // We assume here that this is running from mondorestore. (It is.)
    371     sprintf(program, "ls %s %s >/dev/null 2>&1", drive,
    372             build_partition_name(tmp, drive, partno));
    373     return system(program);
    374 #else
    375     tmp[0] = '\0';
    376 #endif
    377 
    378     sprintf(program, "parted2fdisk -l %s 2> /dev/null", drive);
     362    mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno));
     363    res = system(program);
     364    mr_free(program);
     365    return(res);
     366#endif
     367
     368    mr_asprintf(program, "parted2fdisk -l %s 2> /dev/null", drive);
    379369    fin = popen(program, "r");
    380370    if (!fin) {
    381371        log_it("program=%s", program);
    382372        log_OS_error("Cannot popen-in program");
     373        mr_free(program);
    383374        return (0);
    384375    }
     376    mr_free(program);
     377
    385378    (void) build_partition_name(searchstr, drive, partno);
    386379    strcat(searchstr, " ");
    387     for (res = 0; !res && (p = fgets(incoming, MAX_STR_LEN - 1, fin));) {
     380    for (res = 0, mr_getline(incoming, fin); !res && !feof(fin) ; mr_getline(incoming, fin)) {
    388381        if (strstr(incoming, searchstr)) {
    389382            res = 1;
    390383        }
    391     }
     384        mr_free(incoming);
     385    }
     386    mr_free(incoming);
     387
    392388    if (pclose(fin)) {
    393389        log_OS_error("Cannot pclose fin");
    394390    }
    395     paranoid_free(program);
    396     paranoid_free(incoming);
    397391    paranoid_free(searchstr);
    398     paranoid_free(tmp);
    399392    return (res);
    400393}
     
    413406{
    414407    /*@ buffers **************************************************** */
    415     char *command;
     408    char *command = NULL;
    416409
    417410    /*@ end vars *************************************************** */
     
    421414    assert_string_is_neither_NULL_nor_zerolength(str);
    422415
    423     malloc_string(command);
    424     sprintf(command,
    425             "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    426             dev, str);
     416    /* For UEFI detection, this should be extended to count=2 */
     417    mr_asprintf(command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
    427418    i = system(command);
    428     paranoid_free(command);
     419    mr_free(command);
    429420    if (i) {
    430421        return (FALSE);
     
    444435{
    445436    /*@ buffers **************************************************** */
    446     char *command;
     437    char *command = NULL;
    447438    /*@ end vars *************************************************** */
    448439    int i;
    449440
    450     malloc_string(command);
    451     sprintf(command,
    452             "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    453             dev, n, str);
     441    mr_asprintf(command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);
    454442    i = system(command);
    455     paranoid_free(command);
     443    mr_free(command);
    456444    if (i) {
    457445        return (FALSE);
     
    466454 * Try to mount CD-ROM at @p mountpoint. If the CD-ROM is not found or has
    467455 * not been specified, call find_cdrom_device() to find it.
    468  * @param bkpinfo The backup information structure. The only field used is @c bkpinfo->media_device.
    469456 * @param mountpoint Where to mount the CD-ROM.
    470457 * @return 0 for success, nonzero for failure.
    471458 * @see mount_CDROM_here
    472459 */
    473 int find_and_mount_actual_cd(char *mountpoint)
    474 {
     460int find_and_mount_actual_cd(char *mountpoint) {
     461
    475462    /*@ buffers ***************************************************** */
    476463
    477464    /*@ int's  ****************************************************** */
    478465    int res;
    479     char *dev;
     466    char *dev = NULL;
    480467
    481468    /*@ end vars **************************************************** */
     
    532519{
    533520    /*@ buffers ************************ */
    534     char *comment;
    535521    char *tmp = NULL;
    536522    char *cdr_exe = NULL;
    537     char *command;
    538 
    539     malloc_string(comment);
    540     malloc_string(command);
     523    char *command = NULL;
     524
    541525    if (g_cdrw_drive_is_here[0]) {
    542526        strcpy(cdrw_device, g_cdrw_drive_is_here);
    543527        log_msg(3, "Been there, done that. Returning %s", cdrw_device);
    544         paranoid_free(comment);
    545         paranoid_free(command);
    546528        return (0);
    547529    }
    548530    if (g_backup_media_type == dvd) {
    549         log_msg(1,
    550                 "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?");
    551         paranoid_free(comment);
    552         paranoid_free(command);
     531        log_msg(1, "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?");
    553532        return (1);
    554533    }
     
    560539    }
    561540    if (find_home_of_exe(cdr_exe)) {
    562         sprintf(command,
    563                 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1",
    564                 cdr_exe);
     541        mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1", cdr_exe);
    565542        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     543        mr_free(command);
    566544    }
    567545    if ((tmp == NULL) || (strlen(tmp) < 2)) {
    568         paranoid_free(comment);
    569546        mr_free(tmp);
    570547        mr_free(cdr_exe);
    571         paranoid_free(command);
    572548        return 1;
    573549    } else {
    574550        strcpy(cdrw_device, tmp);
    575         sprintf(comment, "Found CDRW device - %s", cdrw_device);
    576         log_it(comment);
     551        log_it("Found CDRW device - %s", cdrw_device);
    577552        strcpy(g_cdrw_drive_is_here, cdrw_device);
    578         paranoid_free(comment);
    579553        mr_free(tmp);
    580554        mr_free(cdr_exe);
    581         paranoid_free(command);
    582555        return (0);
    583556    }
    584557}
    585 
    586 
    587558
    588559
     
    609580
    610581    /*@ buffers ***************************************************** */
    611     char *tmp;
     582    char *tmp = NULL;
    612583    char *tmp1 = NULL;
    613584    char *cdr_exe = NULL;
    614585    char *phrase_one;
    615     char *phrase_two;
    616     char *command;
    617     char *dvd_last_resort;
    618     char *mountpoint;
     586    char *phrase_two = NULL;
     587    char *command = NULL;
     588#ifndef __FreeBSD__
     589    char *dvd_last_resort = NULL;
     590#endif
     591    char *mountpoint = NULL;
    619592    static char the_last_place_i_found_it[MAX_STR_LEN] = "";
    620593
     
    622595    malloc_string(tmp);
    623596    malloc_string(phrase_one);
    624     malloc_string(phrase_two);
    625     malloc_string(command);
    626     malloc_string(dvd_last_resort);
    627597    malloc_string(mountpoint);
    628598
    629599    output[0] = '\0';
    630600    phrase_one[0] = '\0';
    631     phrase_two[0] = '\0';
    632     dvd_last_resort[0] = '\0';
    633601
    634602    /*@ end vars **************************************************** */
     
    642610    if (the_last_place_i_found_it[0] != '\0' && !try_to_mount) {
    643611        strcpy(output, the_last_place_i_found_it);
    644         log_msg(3,
    645                 "find_cdrom_device() --- returning last found location - '%s'",
    646                 output);
     612        log_msg(3, "find_cdrom_device() --- returning last found location - '%s'", output);
    647613        retval = 0;
    648614        goto end_of_find_cdrom_device;
     
    671637    }
    672638
    673     sprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
     639    mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
    674640    fin = popen(command, "r");
    675641    if (!fin) {
     
    677643        log_OS_error("Cannot popen command");
    678644        mr_free(cdr_exe);
     645        mr_free(command);
    679646        return (1);
    680647    }
     648    mr_free(command);
     649
    681650    for (tmp1 = fgets(tmp, MAX_STR_LEN, fin); !feof(fin) && (tmp1 != NULL);
    682651         tmp1 = fgets(tmp, MAX_STR_LEN, fin)) {
     
    696665                        }
    697666                        *q = '\0';
    698                         strcpy(phrase_two, p);
     667                        mr_asprintf(phrase_two, "%s", p);
    699668                    }
    700669                }
     
    705674
    706675#ifndef __FreeBSD__
    707     if (strlen(phrase_two) == 0) {
     676    if (!phrase_two || strlen(phrase_two) == 0) {
    708677        log_msg(4, "Not running phase two. String is empty.");
    709678    } else {
    710         sprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
     679        mr_asprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
    711680        fin = popen(command, "r");
     681        mr_free(command);
     682
    712683        if (!fin) {
    713684            log_msg(4, "Cannot run 2nd command - non-fatal, fortunately");
     
    721692                        *p = '\0';
    722693                        if (strstr(tmp, "DVD")) {
    723                             sprintf(dvd_last_resort, "/dev/%s", tmp);
    724                             log_msg(4,
    725                                     "Ignoring '%s' because it's a DVD drive",
    726                                     tmp);
     694                            mr_free(dvd_last_resort);
     695                            mr_asprintf(dvd_last_resort, "/dev/%s", tmp);
     696                            log_msg(4, "Ignoring '%s' because it's a DVD drive", tmp);
    727697                        } else {
    728698                            sprintf(output, "/dev/%s", tmp);
     
    775745#else
    776746    if (!found_it && strlen(dvd_last_resort) > 0) {
    777         log_msg(4, "Well, I'll use the DVD - %s - as a last resort",
    778                 dvd_last_resort);
     747        log_msg(4, "Well, I'll use the DVD - %s - as a last resort", dvd_last_resort);
    779748        strcpy(output, dvd_last_resort);
    780749        found_it = TRUE;
    781750    }
    782751    if (found_it) {
    783         sprintf(tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null",
    784                 strrchr(output, '/') + 1);
     752        sprintf(tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null", strrchr(output, '/') + 1);
    785753        if (system(tmp) == 0) {
    786             log_msg(4,
    787                     "%s is not right. It's being SCSI-emulated. Continuing.",
    788                     output);
     754            log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output);
    789755            found_it = FALSE;
    790756            output[0] = '\0';
     
    852818                found_it = FALSE;
    853819            } else {
    854                 sprintf(command, "umount %s", output);
     820                mr_asprintf(command, "umount %s", output);
    855821                paranoid_system(command);
     822                mr_free(command);
     823
    856824                log_msg(4, "I'm confident the Mondo CD is in %s", output);
    857825            }
     
    872840    }
    873841
    874     sprintf(command,
    875             "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2",
    876             cdr_exe, g_cdrw_drive_is_here);
     842    mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);
     843
    877844    log_msg(1, "command=%s", command);
    878845    mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output(command));
     846    mr_free(command);
     847
    879848    if (strlen(tmp1) > 0) {
    880849        strcpy(output, tmp1);
     
    888857
    889858  end_of_find_cdrom_device:
     859    mr_free(cdr_exe);
     860    mr_free(phrase_two);
     861    mr_free(dvd_last_resort);
     862
    890863    paranoid_free(tmp);
    891     mr_free(cdr_exe);
    892864    paranoid_free(phrase_one);
    893     paranoid_free(phrase_two);
    894     paranoid_free(command);
    895     paranoid_free(dvd_last_resort);
    896865    paranoid_free(mountpoint);
    897866    return (retval);
     
    899868
    900869
    901 
    902 
    903 
    904870int find_dvd_device(char *output, bool try_to_mount)
    905871{
    906     char *command;
    907872    char *tmp;
    908873    int retval = 0, devno = -1;
    909 
    910     malloc_string(command);
    911     malloc_string(tmp);
    912874
    913875    if (g_dvd_drive_is_here[0]) {
     
    917879    }
    918880
    919     sprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));
     881    malloc_string(tmp);
     882    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));
    920883    log_msg(5, "tmp = '%s'", tmp);
    921     if (!tmp[0])
    922         sprintf(tmp, "%s", call_program_and_get_last_line_of_output
    923                 ("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1")
    924             );
     884    if (!tmp[0]) {
     885        mr_free(tmp);
     886        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1"));
     887    }
    925888    if (tmp[0]) {
    926889        devno = atoi(tmp) - 1;
    927890    }
     891    mr_free(tmp);
     892
    928893    if (devno >= 0) {
    929894        retval = 0;
     
    936901    }
    937902
    938     if (try_to_mount) {
    939         log_msg(1, "Ignoring the fact that try_to_mount==TRUE");
    940     }
    941903    return (retval);
    942904}
     
    10531015{
    10541016    char *good_formats = NULL;
    1055     char *command;
    1056     char *format_sz;
     1017    char *command = NULL;
     1018    char *format_sz = NULL;
    10571019    char *p;
    10581020
     
    10601022    int retval;
    10611023    malloc_string(good_formats);
    1062     malloc_string(command);
    1063     malloc_string(format_sz);
    10641024
    10651025    assert_string_is_neither_NULL_nor_zerolength(format);
    10661026
    1067     sprintf(format_sz, "%s ", format);
     1027    mr_asprintf(format_sz, "%s ", format);
    10681028
    10691029#ifdef __FreeBSD__
    1070     sprintf(command,
    1071             "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
     1030    mr_asprintf(command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
    10721031#else
    1073     sprintf(command,
    1074             "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
     1032    mr_asprintf(command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    10751033#endif
    10761034
    10771035    pin = popen(command, "r");
     1036    mr_free(command);
     1037
    10781038    if (!pin) {
    10791039        log_OS_error("Unable to read good formats");
     
    10941054    }
    10951055    paranoid_free(good_formats);
    1096     paranoid_free(command);
    1097     paranoid_free(format_sz);
     1056    mr_free(format_sz);
     1057
    10981058    return (retval);
    10991059}
     
    11141074
    11151075    /*@ buffers ***************************************************** */
    1116     char *incoming;
     1076    char *incoming = NULL;
    11171077    char *device_with_tab = NULL;
    11181078    char *device_with_space = NULL;
     
    11281088    /*@ end vars **************************************************** */
    11291089
    1130     malloc_string(incoming);
    1131     assert(device_raw != NULL);
    1132 //  assert_string_is_neither_NULL_nor_zerolength(device_raw);
     1090    if (device_raw == NULL) {
     1091        return(FALSE);
     1092    }
     1093
    11331094    if (device_raw[0] != '/' && !strstr(device_raw, ":/")) {
    11341095        log_msg(1, "%s needs to have a '/' prefixed - I'll do it",
     
    11531114        return(FALSE);
    11541115    }
    1155     for (tmp = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (tmp != NULL);
    1156          tmp = fgets(incoming, MAX_STR_LEN - 1, fin)) {
    1157         if (strstr(incoming, device_with_space) //> incoming
    1158             || strstr(incoming, device_with_tab))   // > incoming)
    1159         {
     1116
     1117    for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
     1118        if (strstr(incoming, device_with_space) || strstr(incoming, device_with_tab)) {
    11601119            paranoid_pclose(fin);
    1161             paranoid_free(incoming);
     1120            mr_free(incoming);
    11621121            return(TRUE);
    11631122        }
    1164     }
     1123        mr_free(incoming);
     1124    }
     1125    mr_free(incoming);
    11651126    mr_free(device_with_tab);
    11661127    paranoid_pclose(fin);
     
    11721133    }
    11731134    mr_free(tmp);
    1174     paranoid_free(incoming);
    11751135    return(retval);
    11761136}
     
    11891149    char command[MAX_STR_LEN];
    11901150    int vndev = 2;
    1191     if (atoi
    1192         (call_program_and_get_last_line_of_output
    1193          ("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1151    if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
    11941152        do {
    11951153            sprintf(mddevice, "vn%ic", vndev++);
     
    12231181int kick_vn(char *dname)
    12241182{
    1225     char command[MAX_STR_LEN];
     1183    char *command = NULL;
     1184    int res = 0;
    12261185
    12271186    if (strncmp(dname, "/dev/", 5) == 0) {
     
    12291188    }
    12301189
    1231     if (atoi
    1232         (call_program_and_get_last_line_of_output
    1233          ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    1234         sprintf(command, "vnconfig -d %s", dname);
    1235         return system(command);
     1190    if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1191        mr_asprintf(command, "vnconfig -d %s", dname);
    12361192    } else {
    1237         sprintf(command, "mdconfig -d -u %s", dname);
    1238         return system(command);
    1239     }
    1240      /*NOTREACHED*/ return 255;
     1193        mr_asprintf(command, "mdconfig -d -u %s", dname);
     1194    }
     1195    res = system(command);
     1196    mr_free(command);
     1197    return(res);
    12411198}
    12421199#endif
     
    12521209{
    12531210    /*@ buffer ****************************************************** */
    1254     char *command;
     1211    char *command = NULL;
    12551212    int retval;
    12561213
    1257     malloc_string(command);
    12581214    assert_string_is_neither_NULL_nor_zerolength(device);
    12591215    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
     
    12631219        return(1);
    12641220    }
    1265     log_msg(4, "(mount_USB_here --- device=%s, mountpoint=%s", device,
    1266             mountpoint);
     1221    log_msg(4, "(mount_USB_here --- device=%s, mountpoint=%s", device, mountpoint);
    12671222
    12681223#ifdef __FreeBSD__
    1269     sprintf(command, "mount_vfat %s %s 2>> %s",
    1270             device, mountpoint, MONDO_LOGFILE);
     1224    mr_asprintf(command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12711225
    12721226#else
    1273     sprintf(command, "mount %s -t vfat %s 2>> %s",
    1274             device, mountpoint, MONDO_LOGFILE);
     1227    mr_asprintf(command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12751228#endif
    12761229
     
    12781231    retval = system(command);
    12791232    log_msg(1, "system(%s) returned %d", command, retval);
    1280 
    1281     paranoid_free(command);
     1233    mr_free(command);
     1234
    12821235    return (retval);
    12831236}
     
    12891242 * @return 0 for success, nonzero for failure.
    12901243 */
    1291 int mount_CDROM_here(char *device, char *mountpoint)
     1244int mount_CDROM_here(char *device, const char *mountpoint)
    12921245{
    12931246    /*@ buffer ****************************************************** */
     
    13271280
    13281281    }
    1329     log_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device,
    1330             mountpoint);
     1282    log_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device, mountpoint);
    13311283    /*@ end vars *************************************************** */
    13321284
     
    13451297    retval = system(command);
    13461298    log_msg(1, "system(%s) returned %d", command, retval);
    1347     paranoid_free(command);
     1299    mr_free(command);
    13481300
    13491301    return (retval);
     
    13621314int mount_media()
    13631315{
    1364 char *mount_cmd;
     1316char *mount_cmd = NULL;
    13651317char *mountdir = NULL;
    13661318int i, res;
    13671319#ifdef __FreeBSD__
    1368 char mdd[32];
    1369 char *mddev = mdd;
    1370 #endif
    1371 
    1372 malloc_string(mount_cmd);
    1373 assert(bkpinfo != NULL);
    1374 
    1375     if (bkpinfo->backup_media_type == tape
    1376         || bkpinfo->backup_media_type == udev) {
     1320    char mdd[32];
     1321    char *mddev = mdd;
     1322#endif
     1323
     1324    if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) {
    13771325        log_msg(8, "Tape/udev. Therefore, no need to mount a media.");
    1378         paranoid_free(mount_cmd);
    13791326        return 0;
    13801327    }
     
    13821329    if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
    13831330        log_msg(2, "mount_media() - media already mounted. Fair enough.");
    1384         paranoid_free(mount_cmd);
    13851331        return (0);
    13861332    }
     
    13891335        log_msg(2, "Mounting for Network thingy");
    13901336        log_msg(2, "isodir = %s", bkpinfo->isodir);
    1391         if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/"))
    1392             && am_I_in_disaster_recovery_mode()) {
     1337        if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/")) && am_I_in_disaster_recovery_mode()) {
    13931338            strcpy(bkpinfo->isodir, "/tmp/isodir");
    13941339            log_msg(1, "isodir is being set to %s", bkpinfo->isodir);
    13951340        }
    13961341#ifdef __FreeBSD__
    1397         sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
     1342        mr_asprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
    13981343            bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    13991344        mddev = make_vn(mount_cmd);
    1400         sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     1345        mr_free(mount_cmd);
     1346
     1347        mr_asprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    14011348#else
    1402         sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
    1403             bkpinfo->isodir, bkpinfo->netfs_remote_dir,
    1404             bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     1349        mr_asprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    14051350#endif
    14061351
     
    14121357        }
    14131358#ifdef __FreeBSD__
    1414         sprintf(mount_cmd, "%s/%s-%d.iso", mountdir,
    1415             bkpinfo->prefix, g_current_media_number);
     1359        mr_asprintf(mount_cmd, "%s/%s-%d.iso", mountdir, bkpinfo->prefix, g_current_media_number);
    14161360        mddev = make_vn(mount_cmd);
    1417         sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     1361        mr_free(mount_cmd);
     1362
     1363        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    14181364#else
    1419         sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
    1420             mountdir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     1365        mr_asprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", mountdir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    14211366#endif
    14221367        mr_free(mountdir);
    14231368    } else if (bkpinfo->backup_media_type == usb) {
    1424         sprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
     1369        mr_asprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
    14251370    } else if (strstr(bkpinfo->media_device, "/dev/")) {
    14261371#ifdef __FreeBSD__
    1427         sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    1428         MNT_CDROM);
     1372        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    14291373#else
    1430         sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
    1431         bkpinfo->media_device, MNT_CDROM);
     1374        mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    14321375#endif
    14331376    } else {
     
    14411384
    14421385#ifdef __FreeBSD__
    1443     sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
    1444         MNT_CDROM);
     1386        mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
    14451387#else
    1446     sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
    1447         bkpinfo->media_device, MNT_CDROM);
     1388        mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
    14481389#endif
    14491390    }
     
    14571398            log_msg(2, "Failed to mount device.");
    14581399            sleep(5);
    1459             run_program_and_log_output("sync", FALSE);
    1460         }
    1461     }
     1400            sync();
     1401        }
     1402    }
     1403    mr_free(mount_cmd);
    14621404
    14631405    if (res) {
     
    14661408        log_msg(2, "Mounted media drive OK");
    14671409    }
    1468     paranoid_free(mount_cmd);
    14691410    return (res);
    14701411}
     
    14961437
    14971438    /*@ buffers ********************************************************* */
    1498     char *tmp;
     1439    char *tmp = NULL;
    14991440    char *mds = NULL;
    1500     char *request;
     1441    char *request = NULL;
    15011442
    15021443    assert(bkpinfo != NULL);
     
    15101451        return;
    15111452    }
    1512     if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso
    1513         || bkpinfo->backup_media_type == netfs) {
     1453    mr_asprintf(tmp, "mkdir -p " MNT_CDROM);
     1454    run_program_and_log_output(tmp, 5);
     1455    mr_free(tmp);
     1456
     1457    if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso || bkpinfo->backup_media_type == netfs) {
    15141458        g_ISO_restore_mode = TRUE;
    15151459    }
    1516     malloc_string(tmp);
    1517     malloc_string(request);
    1518     sprintf(tmp, "mkdir -p " MNT_CDROM);
    1519     run_program_and_log_output(tmp, 5);
    15201460    if ((res = what_number_cd_is_this()) != cd_number_i_want) {
    1521         log_msg(3, "Currently, we hold %d but we want %d", res,
    1522                 cd_number_i_want);
     1461        log_msg(3, "Currently, we hold %d but we want %d", res, cd_number_i_want);
    15231462
    15241463        /* Now we need to umount the current media to have the next mounted after */
     
    15291468
    15301469        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1531         sprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want);
    1532         sprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
     1470        log_msg(3, "Insisting on %s #%d", mds, cd_number_i_want);
     1471        mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
    15331472        mr_free(mds);
    1534         log_msg(3, tmp);
     1473
    15351474        while (what_number_cd_is_this() != cd_number_i_want) {
    1536             paranoid_system("sync");
     1475            sync();
    15371476            if (is_this_device_mounted(MNT_CDROM)) {
    15381477                res =
     
    15561495                inject_device(bkpinfo->media_device);
    15571496            }
    1558             paranoid_system("sync");
    1559         }
     1497            sync();
     1498        }
     1499        mr_free(request);
     1500
    15601501        log_msg(1, "Thankyou. Proceeding...");
    15611502        g_current_media_number = cd_number_i_want;
    15621503    }
    1563     paranoid_free(tmp);
    1564     paranoid_free(request);
    15651504}
    15661505
     
    16761615    log_msg(5, "Running: %s", command);
    16771616    mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    1678     paranoid_free(command);
     1617    mr_free(command);
    16791618
    16801619    mount_cnt = atoi(mounted_file_system);
    16811620    log_msg (5, "mount_cnt: %d", mount_cnt);
    1682     paranoid_free(mounted_file_system);
     1621    mr_free(mounted_file_system);
    16831622
    16841623    for (i=mount_cnt; i > 0; i--) {
     
    16861625        log_msg(5, "Running: %s", command);
    16871626        mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    1688         paranoid_free(command);
     1627        mr_free(command);
    16891628
    16901629        log_msg (5, "mounted_file_system: %s", mounted_file_system);
    16911630        if ((token = mr_strtok(mounted_file_system, token_chars, &lastpos)) == NULL) {
    16921631            log_msg (4, "Could not get the list of mounted file systems");
    1693             paranoid_free(mounted_file_system);
     1632            mr_free(mounted_file_system);
    16941633            mr_free(token);
    16951634            return (1);
     
    17191658        mr_free(mounted_file_system);
    17201659    }
    1721     /********
    1722     * DSFptr = DSF_Head;
    1723     * while (DSFptr != NULL) {
    1724     * printf ("Dev: %s  MP: %s  Check: %d\n", DSFptr->device, DSFptr->mount_point, DSFptr->check);
    1725     * DSFptr = DSFptr->next;
    1726     * }
    1727     ********/
    17281660    return (0);
    17291661}
     
    17731705    log_msg(5, "  Executing: %s", command);
    17741706    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1775     paranoid_free(command);
     1707    mr_free(command);
    17761708
    17771709    log_msg(5, "  Return value: %s", tmp);
    17781710    c = atoi(tmp);
    1779     paranoid_free(tmp);
     1711    mr_free(tmp);
    17801712
    17811713    if (!c) {
     
    17991731    log_msg(5, "Executing: %s", command);
    18001732    mr_asprintf(partition_list, "%s", call_program_and_get_last_line_of_output(command));
    1801     paranoid_free(command);
     1733    mr_free(command);
    18021734    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
    18031735    if (!strlen(partition_list)) {
     
    18621794        log_msg(4, "Processing partition: %s", partitions[i]);
    18631795        /* See if it's swap. If it is, ignore it. */
    1864         mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
    1865           ndsf, partitions[i]);
     1796        mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", ndsf, partitions[i]);
    18661797        log_msg(5, "  Running: %s", command);
    18671798        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1868         paranoid_free(command);
     1799        mr_free(command);
     1800
    18691801        log_msg(5, "  Return value: %s", tmp);
    18701802        c = strlen(tmp);
    1871         paranoid_free(tmp);
     1803        mr_free(tmp);
     1804
    18721805        if (c) {
    18731806            log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
    18741807            continue;
    18751808        }
     1809
    18761810        /* It's not swap. See if we can find the mount point from the mount command. */
    18771811        mr_asprintf(command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    18781812        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1879         paranoid_free(command);
     1813        mr_free(command);
     1814
    18801815        if (strlen(tmp)) {
    18811816            log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
    18821817            if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
    18831818                log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
    1884                 paranoid_free(tmp);
     1819                mr_free(tmp);
    18851820                return (1);
    18861821            }
    18871822            DSFptr->check = 1;
    1888             paranoid_free(tmp);
     1823            mr_free(tmp);
    18891824            continue;
    18901825        }
    1891         paranoid_free(tmp);
     1826        mr_free(tmp);
     1827
    18921828        /* It's not swap and it's not mounted. See if it's LVM */
    18931829        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
     1830
    18941831        /* Check for LVM */
    18951832        mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]);
    18961833        log_msg(5, "  Running: %s", command);
    18971834        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1898         paranoid_free(command);
     1835        mr_free(command);
     1836
    18991837        if (strlen(tmp)) {
    19001838            log_msg(4, "Found an LVM partition at %s. Find the VG it's in...", partitions[i]);
     
    19031841            log_msg(5, "  Running: %s", command);
    19041842            strcpy(VG, call_program_and_get_last_line_of_output(command));
    1905             paranoid_free(command);
     1843            mr_free(command);
     1844
    19061845            log_msg(4, "  Volume Group: %s", VG);
    19071846            if (strlen(VG)) {
     
    19111850                log_msg(5, "  Running: %s", command);
    19121851                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1913                 paranoid_free(command);
     1852                mr_free(command);
     1853
    19141854                log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    19151855                lastpos = 0;
     
    19181858                    if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    19191859                        log_msg (4, "Can't find mount point %s in mounted file systems list", token);
    1920                         paranoid_free(tmp);
     1860                        mr_free(tmp);
    19211861                        mr_free(token);
    19221862                        return (1);
     
    19291869                 * any of the Logical Volumes on the Volume Group.
    19301870                 *******/
    1931                 paranoid_free(mount_list);
     1871                mr_free(mount_list);
    19321872
    19331873                mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    19341874                log_msg (5, "Running: %s", command);
    19351875                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1936                 paranoid_free(command);
     1876                mr_free(command);
    19371877                log_msg(4, "  Software raid device list: %s", mount_list);
    19381878                lastpos = 0;
     
    19401880                    mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    19411881                    log_msg (5, "Running: %s", command);
    1942                     paranoid_free(tmp);
     1882                    mr_free(tmp);
    19431883                    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1944                     paranoid_free(command);
     1884                    mr_free(command);
    19451885                    log_msg(4, "Number of Software raid device: %s", tmp);
    19461886                    if (atoi(tmp)) {
     
    19481888                        if ((DSFptr = find_device_in_list(token)) == NULL) {
    19491889                            log_msg (4, "Can't find device %s in mounted file systems list", token);
    1950                             paranoid_free(tmp);
     1890                            mr_free(tmp);
    19511891                            mr_free(token);
    19521892                            return (1);
     
    19591899            } else {
    19601900                log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    1961                 paranoid_free(tmp);
     1901                mr_free(tmp);
    19621902                return (1);
    19631903            }
    1964             paranoid_free(tmp);
     1904            mr_free(tmp);
    19651905            continue;
    19661906        } else {
    19671907            log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
    19681908        }
    1969         paranoid_free(tmp);
     1909        mr_free(tmp);
     1910
    19701911        /********
    19711912         * It's not swap, mounted, or LVM. See if it's used in a software raid device.
     
    19751916        log_msg(4, "  Running: %s", command);
    19761917        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1977         paranoid_free(command);
     1918        mr_free(command);
     1919
    19781920        if (!strlen(tmp)) {
    19791921            log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
    1980             paranoid_free(tmp);
     1922            mr_free(tmp);
    19811923            continue;
    19821924        }
    19831925        log_msg (5, "  UUID: %s", tmp);
     1926
    19841927        /* Get the Software raid device list */
    19851928        mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    19861929        log_msg (5, "  Running: %s", command);
    19871930        mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1988         paranoid_free(command);
     1931        mr_free(command);
     1932
    19891933        log_msg(4, "  Software raid device list: %s", mount_list);
    19901934        /* Loop through the software raid device list to see if we can find the partition */
     
    19931937            mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    19941938            log_msg(4, "  Running: %s", command);
    1995             paranoid_free(tmp);
     1939            mr_free(tmp);
    19961940            mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1997             paranoid_free(command);
     1941            mr_free(command);
     1942
    19981943            if (!atoi(tmp)) {
    19991944                log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
     
    20011946                if ((DSFptr = find_device_in_list(token)) == NULL) {
    20021947                    log_msg (4, "Can't find device %s in mounted file systems list", token);
    2003                     paranoid_free(tmp);
     1948                    mr_free(tmp);
    20041949                    mr_free(token);
    20051950                    return (1);
     
    20101955            mr_free(token);
    20111956        }
    2012         paranoid_free(tmp);
    2013         paranoid_free(mount_list);
     1957        mr_free(tmp);
     1958        mr_free(mount_list);
    20141959    }
    20151960
     
    20471992    return (0);
    20481993}
    2049 
    2050 
    2051 
    20521994
    20531995
     
    20992041            log_to_screen("Archiving only the following file systems on %s:", token);
    21002042            log_to_screen("==> %s", mounted_on_dsf);
    2101             strcpy(bkpinfo->include_paths, "/");
     2043            mr_free(bkpinfo->include_paths);
     2044            mr_asprintf(bkpinfo->include_paths, "%s", "/");
    21022045            if (strlen(not_mounted_on_dsf)) {
    21032046                log_msg (5, "Adding to bkpinfo->exclude_paths due to -I option: %s", not_mounted_on_dsf);
     
    21362079            mr_asprintf(tmp,"|%s|",bkpinfo->include_paths);
    21372080            if (strstr(tmp,tmp2) == NULL) {
    2138                 strcat(bkpinfo->include_paths,tmp1);
     2081                mr_strcat(bkpinfo->include_paths, "%s", tmp1);
    21392082            }
    21402083            mr_free(tmp1);
     
    21812124    char *q = NULL;
    21822125    char p[16*MAX_STR_LEN];
    2183     char *sz_size;
    2184     char *command;
     2126    char *sz_size = NULL;
     2127    char *command = NULL;
    21852128    char *compression_type = NULL;
    2186     char *comment;
    2187     char *prompt;
     2129    char *comment = NULL;
    21882130    int i;
    21892131    FILE *fin;
    21902132
    2191     malloc_string(sz_size);
    2192     malloc_string(command);
    2193     malloc_string(comment);
    2194     malloc_string(prompt);
    21952133    malloc_string(tmp1);
    21962134    assert(bkpinfo != NULL);
    2197     sz_size[0] = '\0';
    21982135    bkpinfo->nonbootable_backup = FALSE;
    21992136
     
    22322169        setup_scratchdir(tmp);
    22332170    }
    2234     log_msg(3, "media type = %s",
    2235             bkptype_to_string(bkpinfo->backup_media_type));
     2171    log_msg(3, "media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    22362172    bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4;
    2237     bkpinfo->compression_level =
    2238         (bkpinfo->backup_media_type == cdstream) ? 1 : 5;
    2239     bkpinfo->use_lzo =
    2240         (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE;
     2173    bkpinfo->compression_level = (bkpinfo->backup_media_type == cdstream) ? 1 : 5;
     2174    bkpinfo->use_lzo = (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE;
    22412175    mvaddstr_and_log_it(2, 0, " ");
    22422176
     
    22532187        if (archiving_to_media) {
    22542188            if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) {
    2255                 if (ask_me_yes_or_no
    2256                     ("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?"))
    2257                 {
     2189                if (ask_me_yes_or_no("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?")) {
    22582190                    bkpinfo->manual_cd_tray = TRUE;
    22592191                }
     
    22632195                finish(1);
    22642196            }
    2265             if ((bkpinfo->compression_level =
    2266                 which_compression_level()) == -1) {
     2197
     2198            if ((bkpinfo->compression_level = which_compression_level()) == -1) {
    22672199                log_to_screen("User has chosen not to backup the PC");
    22682200                finish(1);
    22692201            }
    22702202            mds = media_descriptor_string(bkpinfo->backup_media_type);
    2271             sprintf(comment, "What speed is your %s (re)writer?", mds);
     2203            mr_asprintf(comment, "What speed is your %s (re)writer?", mds);
    22722204            if (bkpinfo->backup_media_type == dvd) {
    22732205                find_dvd_device(bkpinfo->media_device, FALSE);
    22742206                strcpy(tmp1, "1");
    2275                 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2207                mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    22762208                log_msg(1, "Setting to DVD defaults");
    22772209            } else {
    22782210                strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);
    22792211                strcpy(tmp1, "4");
    2280                 strcpy(sz_size, "650");
     2212                mr_asprintf(sz_size, "%d", 650);
    22812213                log_msg(1, "Setting to CD defaults");
    22822214            }
     
    22842216                if (!popup_and_get_string("Speed", comment, tmp1, 4)) {
    22852217                    log_to_screen("User has chosen not to backup the PC");
     2218                    mr_free(comment);
    22862219                    finish(1);
    22872220                }
    22882221            }
     2222            mr_free(comment);
    22892223            bkpinfo->cdrw_speed = atoi(tmp1);   // if DVD then this shouldn't ever be used anyway :)
    22902224
    2291             sprintf(comment,
    2292                     "How much data (in Megabytes) will each %s store?", mds);
     2225            strcpy(tmp1, sz_size);
     2226            mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds);
    22932227            mr_free(mds);
    2294             if (!popup_and_get_string("Size", comment, sz_size, 5)) {
     2228            if (!popup_and_get_string("Size", comment, tmp1, 5)) {
    22952229                log_to_screen("User has chosen not to backup the PC");
    22962230                finish(1);
    22972231            }
     2232            mr_asprintf(sz_size, "%s", tmp1);
    22982233            bkpinfo->media_size = atoi(sz_size);
     2234
    22992235            if (bkpinfo->media_size <= 0) {
    23002236                log_to_screen("User has chosen not to backup the PC");
     
    23082244        if ((bkpinfo->disaster_recovery) && (bkpinfo->backup_media_type != usb)) {
    23092245            strcpy(bkpinfo->media_device, "/dev/cdrom");
    2310             log_msg(2, "CD-ROM device assumed to be at %s",
    2311                     bkpinfo->media_device);
    2312         } else if ((bkpinfo->restore_data && (bkpinfo->backup_media_type != usb))
    2313                    || bkpinfo->backup_media_type == dvd) {
     2246            log_msg(2, "CD-ROM device assumed to be at %s", bkpinfo->media_device);
     2247        } else if ((bkpinfo->restore_data && (bkpinfo->backup_media_type != usb))  || bkpinfo->backup_media_type == dvd) {
    23142248            if (!bkpinfo->media_device[0]) {
    23152249                strcpy(bkpinfo->media_device, "/dev/cdrom");
    23162250            }                   // just for the heck of it :)
    2317             log_msg(1, "bkpinfo->media_device = %s",
    2318                     bkpinfo->media_device);
    2319             if (bkpinfo->backup_media_type == dvd
    2320                 || find_cdrom_device(bkpinfo->media_device, FALSE)) {
    2321                 log_msg(1, "bkpinfo->media_device = %s",
    2322                         bkpinfo->media_device);
    2323                 sprintf(comment,
    2324                         "Please specify your %s drive's /dev entry", mds);
    2325                 if (!popup_and_get_string
    2326                     ("Device?", comment, bkpinfo->media_device,
    2327                      MAX_STR_LEN / 4)) {
     2251            log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
     2252            if (bkpinfo->backup_media_type == dvd || find_cdrom_device(bkpinfo->media_device, FALSE)) {
     2253                log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
     2254                mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds);
     2255                if (!popup_and_get_string("Device?", comment, bkpinfo->media_device, MAX_STR_LEN / 4)) {
    23282256                    log_to_screen("User has chosen not to backup the PC");
    23292257                    finish(1);
     
    23992327            } else {
    24002328                if (does_file_exist("/tmp/mondo-restore.cfg")) {
    2401                     read_cfg_var("/tmp/mondo-restore.cfg", "media-dev",
    2402                                  bkpinfo->media_device);
     2329                    read_cfg_var("/tmp/mondo-restore.cfg", "media-dev", bkpinfo->media_device);
    24032330                }
    24042331            }
     
    24552382                finish(1);
    24562383            }
    2457             if ((bkpinfo->compression_level =
    2458                  which_compression_level()) == -1) {
     2384            if ((bkpinfo->compression_level = which_compression_level()) == -1) {
    24592385                log_to_screen("User has chosen not to backup the PC");
    24602386                finish(1);
     
    24682394        /* Never try to eject a NETFS device */
    24692395        bkpinfo->please_dont_eject = TRUE;
     2396        /*  Force NFS to be the protocol by default */
     2397        if (bkpinfo->netfs_proto == NULL) {
     2398            mr_asprintf(bkpinfo->netfs_proto, "nfs");
     2399        }
    24702400
    24712401        /* Initiate bkpinfo netfs_mount path from running environment if not already done */
    2472         if (!bkpinfo->netfs_mount[0]) {
    2473             strcpy(bkpinfo->netfs_mount,
    2474                    call_program_and_get_last_line_of_output
    2475                    ("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
     2402        if (!bkpinfo->netfs_mount == NULL) {
     2403            mr_asprintf(bkpinfo->netfs_mount, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
    24762404        }
    24772405#ifdef __FreeBSD__
     
    24842412                ("Network shared dir.",
    24852413                 "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)",
    2486                  bkpinfo->netfs_mount, MAX_STR_LEN / 4)) {
     2414                 p, MAX_STR_LEN / 4)) {
    24872415                log_to_screen("User has chosen not to backup the PC");
    24882416                finish(1);
    24892417            }
     2418            mr_free(bkpinfo->netfs_mount);
     2419            mr_asprintf(bkpinfo->netfs_mount, "%s", p;
    24902420            if (!bkpinfo->restore_data) {
    24912421                if ((compression_type = which_compression_type()) == NULL) {
     
    24932423                    finish(1);
    24942424                }
    2495                 if ((bkpinfo->compression_level =
    2496                     which_compression_level()) == -1) {
     2425
     2426                if ((bkpinfo->compression_level = which_compression_level()) == -1) {
    24972427                    log_to_screen("User has chosen not to backup the PC");
    24982428                    finish(1);
     
    25012431            // check whether already mounted - we better remove
    25022432            // surrounding spaces and trailing '/' for this
    2503             strip_spaces(bkpinfo->netfs_mount);
     2433            mr_strip_spaces(bkpinfo->netfs_mount);
    25042434            if (bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] == '/')
    25052435                bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] = '\0';
     
    25132443                strcpy(tmp1,bkpinfo->netfs_mount);
    25142444            }
    2515             sprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1);
     2445            mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1);
    25162446            strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(command));
     2447            mr_free(command);
    25172448
    25182449            if (!bkpinfo->restore_data) {
    2519                 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    2520                 sprintf(comment,
    2521                     "How much data (in Megabytes) will each media store?");
    2522                 if (!popup_and_get_string("Size", comment, sz_size, 5)) {
     2450                mr_sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);   // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2451                mr_asprintf(comment, "How much data (in Megabytes) will each media store?");
     2452                strcpy(tmp1, sz_size);
     2453                mr_free(sz_size);
     2454                if (!popup_and_get_string("Size", comment, tmp1, 5)) {
    25232455                    log_to_screen("User has chosen not to backup the PC");
    25242456                    finish(1);
    25252457                }
     2458                mr_free(comment);
     2459                mr_asprintf(sz_size, "%s", tmp1);
    25262460            } else {
    2527                 strcpy(sz_size, "0");
     2461                mr_asprintf(sz_size, "0");
    25282462            }
    25292463            bkpinfo->media_size = atoi(sz_size);
     2464            mr_free(sz_size);
     2465
    25302466            if (bkpinfo->media_size < 0) {
    25312467                log_to_screen("User has chosen not to backup the PC");
     
    25332469            }
    25342470        }
    2535         /*  Force NFS to be the protocol by default */
    2536         if (bkpinfo->netfs_proto == NULL) {
    2537             mr_asprintf(bkpinfo->netfs_proto, "nfs");
    2538         }
    25392471        if (bkpinfo->disaster_recovery) {
    2540             sprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
     2472            mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
    25412473            paranoid_system(command);
     2474            mr_free(command);
     2475
    25422476        }
    25432477        strcpy(tmp1, bkpinfo->netfs_proto);
    2544         if (!popup_and_get_string
    2545             ("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",
    2546              tmp1, MAX_STR_LEN)) {
     2478        if (!popup_and_get_string("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",tmp1, MAX_STR_LEN)) {
    25472479            log_to_screen("User has chosen not to backup the PC");
    25482480            finish(1);
     
    25502482        mr_free(bkpinfo->netfs_proto);
    25512483        mr_asprintf(bkpinfo->netfs_proto, "%s", tmp1);
    2552         if (!popup_and_get_string
    2553             ("Network share", "Which remote share should I mount?",
    2554              bkpinfo->netfs_mount, MAX_STR_LEN)) {
     2484
     2485        strcpy(tmp1, bkpinfo->netfs_mount);
     2486        if (!popup_and_get_string("Network share", "Which remote share should I mount?", tmp1, MAX_STR_LEN)) {
    25552487            log_to_screen("User has chosen not to backup the PC");
    25562488            finish(1);
    25572489        }
     2490        mr_free(bkpinfo->netfs_mount);
     2491        mr_asprintf(bkpinfo->netfs_mount, "%s", tmp1);
    25582492
    25592493        if (bkpinfo->netfs_user) {
     
    25622496            strcpy(tmp1, "");
    25632497        }
    2564         if (!popup_and_get_string
    2565             ("Network user", "Which user should I use if any ?",
    2566              tmp1, MAX_STR_LEN)) {
     2498        if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1)) {
    25672499            log_to_screen("User has chosen not to backup the PC");
    25682500            finish(1);
     
    25752507        /* Initiate bkpinfo isodir path from running environment if mount already done */
    25762508        if (is_this_device_mounted(bkpinfo->netfs_mount)) {
    2577             strcpy(bkpinfo->isodir,
    2578                    call_program_and_get_last_line_of_output
    2579                    ("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     2509            strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
    25802510        } else {
    25812511            sprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir);
    2582             sprintf(command, "mkdir -p %s", bkpinfo->isodir);
     2512            mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    25832513            run_program_and_log_output(command, 5);
     2514            mr_free(command);
    25842515
    25852516            if (bkpinfo->restore_data) {
     
    26152546        }
    26162547        if (!is_this_device_mounted(bkpinfo->netfs_mount)) {
    2617             popup_and_OK
    2618                 ("Please mount that partition before you try to backup to or restore from it.");
     2548            popup_and_OK("Please mount that partition before you try to backup to or restore from it.");
    26192549            finish(1);
    26202550        }
     
    26402570        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    26412571
    2642         log_msg(3, "Just set netfs_remote_dir to %s",
    2643                 bkpinfo->netfs_remote_dir);
     2572        log_msg(3, "Just set netfs_remote_dir to %s", bkpinfo->netfs_remote_dir);
    26442573        log_msg(3, "isodir is still %s", bkpinfo->isodir);
    26452574        break;
     
    26592588                    finish(1);
    26602589                }
    2661                 if ((bkpinfo->compression_level =
    2662                      which_compression_level()) == -1) {
     2590                if ((bkpinfo->compression_level = which_compression_level()) == -1) {
    26632591                    log_to_screen("User has chosen not to backup the PC");
    26642592                    finish(1);
    26652593                }
    2666                 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2594                sprintf(tmp1, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    26672595                if (!popup_and_get_string
    26682596                    ("ISO size.",
    26692597                     "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s (700) or DVD's (4480) you plan to backup to.",
    2670                      sz_size, 16)) {
     2598                     tmp1, 16)) {
    26712599                    log_to_screen("User has chosen not to backup the PC");
    26722600                    finish(1);
    26732601                }
    2674                 bkpinfo->media_size = atoi(sz_size);
     2602                bkpinfo->media_size = atoi(tmp1);
    26752603            } else {
    26762604                bkpinfo->media_size = 650;
     
    27232651                finish(1);
    27242652            }
    2725             if (does_string_exist_in_boot_block
    2726                 (bkpinfo->boot_device, "LILO")) {
     2653            if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) {
    27272654                i = 'L';
    27282655            } else
    2729                 if (does_string_exist_in_boot_block
    2730                     (bkpinfo->boot_device, "ELILO")) {
     2656                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "ELILO")) {
    27312657                i = 'E';
    27322658            } else
    2733                 if (does_string_exist_in_boot_block
    2734                     (bkpinfo->boot_device, "GRUB")) {
     2659                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "GRUB")) {
    27352660                i = 'G';
    27362661            } else {
     
    27392664#endif
    27402665            if (i == 'U') {
    2741                 if (ask_me_yes_or_no
    2742                     ("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?"))
    2743                 {
     2666                if (ask_me_yes_or_no("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?")) {
    27442667                    i = 'R';    // raw
    27452668                } else {
    2746                     log_to_screen
    2747                         ("I cannot find your boot loader. Please run mondoarchive with parameters.");
     2669                    log_to_screen("I cannot find your boot loader. Please run mondoarchive with parameters.");
    27482670                    finish(1);
    27492671                }
     
    27512673        }
    27522674        bkpinfo->boot_loader = i;
    2753         strcpy(bkpinfo->include_paths, "/");
     2675
     2676        mr_free(bkpinfo->include_paths);
     2677        strcpy(tmp1, "/");
    27542678        if (!popup_and_get_string
    27552679            ("Backup paths",
    27562680             "Please enter paths (separated by '|') which you want me to backup. The default is '/' (i.e. everything).",
    2757              bkpinfo->include_paths, MAX_STR_LEN)) {
     2681             tmp1, MAX_STR_LEN)) {
    27582682            log_to_screen("User has chosen not to backup the PC");
    27592683            finish(1);
    27602684        }
     2685        mr_asprintf(bkpinfo->include_paths, "%s", tmp1);
     2686
    27612687        tmp = list_of_NETFS_mounts_only();
    27622688        if (strlen(tmp) > 2) {
     
    28152741        if (ask_me_yes_or_no("Do you want to backup extended attributes?")) {
    28162742            if (find_home_of_exe("getfattr")) {
     2743                mr_free(g_getfattr);
    28172744                mr_asprintf(g_getfattr,"getfattr");
    28182745            }
    28192746            if (find_home_of_exe("getfacl")) {
     2747                mr_free(g_getfacl);
    28202748                mr_asprintf(g_getfacl,"getfacl");
    28212749            }
     
    28352763            strcpy(bkpinfo->zip_exe, "gzip");
    28362764            strcpy(bkpinfo->zip_suffix, "gz");
    2837         //} else if (strcmp(compression_type,"lzma") == 0) {
     2765        } else if (strcmp(compression_type,"lzma") == 0) {
    28382766            //strcpy(bkpinfo->zip_exe, "xy");
    28392767            //strcpy(bkpinfo->zip_suffix, "xy");
     
    28492777            ("Will you want to verify your backups after Mondo has created them?");
    28502778
    2851 #ifndef __FreeBSD__
    2852         if (!ask_me_yes_or_no
    2853             ("Are you confident that your kernel is a sane, sensible, standard Linux kernel? Say 'no' if you are using a Gentoo <1.4 or Debian <3.0, please."))
    2854 #endif
    2855         {
    2856             strcpy(bkpinfo->kernel_path, "FAILSAFE");
    2857         }
    2858 
    28592779        if (!ask_me_yes_or_no
    28602780            ("Are you sure you want to proceed? Hit 'no' to abort.")) {
     
    28752795#else
    28762796    if (bkpinfo->backup_media_type == netfs) {
    2877         log_msg(3, "I think the Remote mount is mounted at %s",
    2878                 bkpinfo->isodir);
     2797        log_msg(3, "I think the Remote mount is mounted at %s", bkpinfo->isodir);
    28792798    }
    28802799    log_it("isodir = %s", bkpinfo->isodir);
    2881     log_it("netfs_mount = '%s'", bkpinfo->netfs_mount);
     2800    if (bkpinfo->netfs_mount) {
     2801        log_it("netfs_mount = '%s'", bkpinfo->netfs_mount);
     2802    }
     2803    if (bkpinfo->netfs_user) {
     2804        log_it("netfs_user = '%s'", bkpinfo->netfs_user);
     2805    }
    28822806    if (bkpinfo->netfs_proto) {
    28832807        log_it("netfs_proto = '%s'", bkpinfo->netfs_proto);
    2884     }
    2885     if (bkpinfo->netfs_user) {
    2886         log_it("netfs_user = '%s'", bkpinfo->netfs_user);
    28872808    }
    28882809#endif
     
    28912812    log_it("media size = %ld", bkpinfo->media_size);
    28922813    log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    2893     log_it("prefix = %s", bkpinfo->prefix);
     2814    if (bkpinfo->prefix) {
     2815        log_it("prefix = %s", bkpinfo->prefix);
     2816    }
    28942817    log_it("compression = %ld", bkpinfo->compression_level);
    28952818    log_it("exclude_path = %s", bkpinfo->exclude_paths);
     
    28972820
    28982821    /* Handle devices passed in bkpinfo and print result */
    2899     /*  the mr_make_devlist_from_pathlist function appends 
    2900      *  to the *_paths variables so copy before */
     2822    /*  the mr_make_devlist_from_pathlist function appends
     2823    /*  to the *_paths variables so copy before */
    29012824    mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E');
    29022825    mr_make_devlist_from_pathlist(bkpinfo->include_paths, 'I');
     
    29042827    log_it("scratchdir = '%s'", bkpinfo->scratchdir);
    29052828    log_it("tmpdir = '%s'", bkpinfo->tmpdir);
    2906     log_it("image_devs = '%s'", bkpinfo->image_devs);
    2907     log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device,
    2908            bkpinfo->boot_loader);
     2829    if (bkpinfo->image_devs) {
     2830        log_it("image_devs = '%s'", bkpinfo->image_devs);
     2831    }
     2832    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device, bkpinfo->boot_loader);
    29092833    if (bkpinfo->media_size < 0) {
    29102834        if (archiving_to_media) {
     
    29172841    paranoid_free(sz_size);
    29182842    paranoid_free(tmp1);
    2919     paranoid_free(command);
    2920     paranoid_free(comment);
    2921     paranoid_free(prompt);
    29222843    return (0);
    29232844}
     
    31703091
    31713092    malloc_string(current_drive);
     3093
     3094    /* UEFI is not supported here - but should be managed as a BIOS/UEFI option not a Boot Loader one per se */
    31723095
    31733096#ifdef __IA64__
  • branches/3.2/mondo/src/common/libmondo-fifo.c

    r3185 r3191  
    8585    wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32);
    8686    wise_lower_limit = 1;       // wise_upper_limit/2 + 1;
    87     paranoid_system("sync");
     87    sync();
    8888    for (bufsize = wise_upper_limit, res = -1;
    8989         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    90         mr_asprintf(tmp,
    91                 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
    92                 internal_tape_block_size, bufsize, 'm');
     90        mr_asprintf(tmp,"dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", internal_tape_block_size, bufsize, 'm');
    9391        res = run_program_and_log_output(tmp, 2);
    9492        mr_free(tmp);
     
    9694    if (!res) {
    9795        bufsize++;
    98         mr_asprintf(tmp, "Negotiated max buffer of %d MB ", bufsize);
    99         log_to_screen(tmp);
    100         mr_free(tmp);
     96        log_to_screen(tmp, "Negotiated max buffer of %d MB ", bufsize);
    10197    } else {
    10298        bufsize = 0;
     
    166162        return;
    167163    }
    168     paranoid_system("sync");
     164    sync();
    169165    mr_asprintf(command, "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $2;}' | grep -v PID | head -1", ps_options, g_sz_call_to_buffer);
    170166    log_msg(2, "kill_buffer() --- command = %s", command);
  • branches/3.2/mondo/src/common/libmondo-filelist.c

    r3185 r3191  
    8686
    8787    /*@ pointers ********************** */
    88     char *ptr;
     88    char *ptr = NULL;
    8989    FILE *fout;
    9090
     
    116116    mr_free(tempfile);
    117117
    118     log_it(bkpinfo->image_devs);
    119 
    120     ptr = bkpinfo->image_devs;
    121 
    122     malloc_string(dev);
    123     while (ptr && *ptr) {
    124         strcpy(dev, ptr);
    125         log_it("Examining imagedev %s", dev);
    126         for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
    127         dev[i] = '\0';
    128         if (!strlen(dev)) {
    129             continue;
    130         }
    131         fprintf(fout, "%s\n", dev);
    132         log_it("Adding '%s' to biggielist", dev);
    133         if ((ptr = strchr(ptr, ' '))) {
    134             ptr++;
     118    if (bkpinfo->image_devs) {
     119        log_it("image_devs : %s", bkpinfo->image_devs);
     120
     121        ptr = bkpinfo->image_devs;
     122
     123        while (ptr && *ptr) {
     124            mr_asprintf(dev, "%s", ptr);
     125            log_it("Examining imagedev %s", dev);
     126            for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
     127            dev[i] = '\0';
     128            if (!strlen(dev)) {
     129                mr_free(dev);
     130                continue;
     131            }
     132            fprintf(fout, "%s\n", dev);
     133            log_it("Adding '%s' to biggielist", dev);
     134            if ((ptr = strchr(ptr, ' '))) {
     135                ptr++;
     136            }
     137            mr_free(dev);
    135138        }
    136139    }
     
    138141    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    139142
    140     paranoid_free(dev);
    141143    return (retval);
    142144}
     
    158160
    159161    mr_asprintf(tmp_fname, "%s/sortfile", bkpinfo->tmpdir);
    160 
    161162    mr_asprintf(command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE);
    162163    retval = system(command);
     
    331332
    332333    if (curr_set_no == 0) {
    333         mr_asprintf(tmp, "Only one fileset. Fine.");
     334        log_msg(1, "Only one fileset. Fine.");
    334335    } else {
    335         mr_asprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1);
    336     }
    337     log_msg(1, tmp);
    338     mr_free(tmp);
     336        log_msg(1, "Filelist divided into %ld sets", curr_set_no + 1);
     337    }
    339338    close_evalcall_form();
    340339    /* This is to work around an obscure bug in Newt; open a form, close it,
     
    342341       then update_progress_form() won't show the "time taken / time remaining"
    343342       line. The bug only crops up AFTER the call to chop_filelist(). Weird. */
    344 #ifndef _XWIN
    345343    if (!g_text_mode) {
    346344        open_progress_form("", "", "", "", 100);
     
    349347        newtPopWindow();
    350348    }
    351 #endif
    352349    return (err ? 0 : curr_set_no + 1);
    353350}
     
    410407int call_exe_and_pipe_output_to_fd(char *syscall, FILE * pout)
    411408{
    412     FILE *pattr;
    413     char *tmp;
    414     char *p;
     409    FILE *pattr = NULL;
     410    char *tmp = NULL;
    415411
    416412    pattr = popen(syscall, "r");
     
    424420        return (2);
    425421    }
    426     malloc_string(tmp);
    427     for (p = fgets(tmp, MAX_STR_LEN, pattr); !feof(pattr) && (p != NULL);
    428          p = fgets(tmp, MAX_STR_LEN, pattr)) {
     422    for (mr_getline(tmp, pattr); !feof(pattr); mr_getline(tmp, pattr)) {
    429423        fputs(tmp, pout);
    430     }
     424        mr_free(tmp);
     425    }
     426    mr_free(tmp);
    431427    paranoid_pclose(pattr);
    432     paranoid_free(tmp);
    433428    return (0);
    434429}
     
    439434                 char *auxlist_fname)
    440435{
    441     FILE *fin;
    442     FILE *pout;
     436    FILE *fin = NULL;
     437    FILE *pout = NULL;
    443438    char *pout_command = NULL;
    444     char *syscall;
    445     char *file_to_analyze;
     439    char *syscall = NULL;
     440    char *file_to_analyze = NULL;
    446441    char *strtmp = NULL;
    447442    char *tmp = NULL;
    448     char *p = NULL;
    449443    int i;
    450444
     
    462456    mr_free(pout_command);
    463457
    464     malloc_string(file_to_analyze);
    465     for (p = fgets(file_to_analyze, MAX_STR_LEN, fin); !feof(fin) && (p != NULL);
    466          p = fgets(file_to_analyze, MAX_STR_LEN, fin)) {
     458    for (mr_getline(file_to_analyze, fin); !feof(fin); mr_getline(file_to_analyze, fin)) {
    467459        i = strlen(file_to_analyze);
    468460        if (i > 0 && file_to_analyze[i - 1] < 32) {
     
    472464        tmp = mr_stresc(file_to_analyze, "'", '\\', '\'');
    473465        mr_asprintf(syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp);    // " MONDO_LOGFILE);
    474         paranoid_free(tmp);
     466        mr_free(tmp);
    475467        log_msg(20,"calling %s\n",syscall);
    476468        call_exe_and_pipe_output_to_fd(syscall, pout);
    477         paranoid_free(syscall);
    478     }
     469        mr_free(syscall);
     470        mr_free(file_to_analyze);
     471    }
     472    mr_free(file_to_analyze);
    479473    paranoid_fclose(fin);
    480474    paranoid_pclose(pout);
    481     paranoid_free(file_to_analyze);
    482475    return (0);
    483476}
     
    522515    char *syscall_pin = NULL;
    523516    char *syscall_pout = NULL;
    524     char *incoming;
    525     char *current_subset_file, *current_master_file;
     517    char *incoming = NULL;
     518    char *current_subset_file = NULL;
     519    char *current_master_file = NULL;
    526520    char *masklist = NULL;
    527521    int retval = 0;
    528522    int i;
    529     char *p, *q, *r;
     523    char *p, *q;
    530524    char *tmp = NULL;
    531525    FILE *pin, *pout, *faclin;
    532526
    533     log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist,
    534             original_exat_fname, executable);
     527    log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist, original_exat_fname, executable);
    535528    if (!orig_msklist || !orig_msklist[0]
    536529        || !does_file_exist(orig_msklist)) {
     
    552545    }
    553546    if (length_of_file(original_exat_fname) <= 0) {
    554         log_msg(1,
    555                 "original_exat_fname %s is empty or missing, so no need to set EXAT list",
    556                 original_exat_fname);
     547        log_msg(1, "original_exat_fname %s is empty or missing, so no need to set EXAT list", original_exat_fname);
    557548        return (0);
    558549    }
    559     malloc_string(incoming);
    560     malloc_string(current_subset_file);
    561     malloc_string(current_master_file);
    562550    mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir);
    563551    mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist);
     
    566554
    567555    sort_file(masklist);
    568     current_subset_file[0] = current_master_file[0] = '\0';
    569556
    570557    mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);
     
    599586//  printf("Hi there. Starting the loop\n");
    600587
    601     r = fgets(current_subset_file, MAX_STR_LEN, faclin);
    602     r = fgets(incoming, MAX_STR_LEN, pin);
    603     while (!feof(pin) && !feof(faclin) && (r != NULL)) {
    604 //      printf("incoming = %s", incoming);
    605 
    606         strcpy(current_master_file, incoming + 8);
     588    mr_getline(current_subset_file, faclin);
     589    mr_getline(incoming, pin);
     590    while (!feof(pin) && !feof(faclin)) {
     591        mr_asprintf(current_master_file, "%s", incoming + 8);
    607592
    608593        p = current_subset_file;
     
    632617        if (i < 0) {            // read another subset file in.
    633618            log_msg(my_depth, "Reading next subset line in\n\n");
    634             r = fgets(current_subset_file, MAX_STR_LEN, faclin);
     619            mr_free(current_subset_file);
     620            mr_getline(current_subset_file, faclin);
    635621            continue;
    636622        }
     
    639625            fputs(incoming, pout);
    640626        }
    641         r = fgets(incoming, MAX_STR_LEN, pin);
     627        mr_free(incoming);
     628        mr_getline(incoming, pin);
    642629        if (!i) {
    643630            log_msg(my_depth, "Copying master %s", q);
    644631        }
    645 //      if (!i) { printf("Match --- %s\n", q); }
    646632
    647633        while (!feof(pin) && strncmp(incoming, "# file: ", 8)) {
    648634            if (!i) {
    649 
    650 //    printf("%s", incoming);
    651 
    652635                fputs(incoming, pout);
    653636            }
    654             r = fgets(incoming, MAX_STR_LEN, pin);
     637            mr_free(incoming);
     638            mr_getline(incoming, pin);
    655639        }
    656640        if (!i) {
    657             r = fgets(current_subset_file, MAX_STR_LEN, faclin);
    658         }
    659     }
    660     while (!feof(pin)) {
    661         r = fgets(incoming, MAX_STR_LEN, pin);
    662     }
     641            mr_free(current_subset_file);
     642            mr_getline(current_subset_file, faclin);
     643        }
     644        mr_free(current_master_file);
     645    }
     646    mr_free(current_subset_file);
     647    mr_free(incoming);
    663648    fclose(faclin);
    664649    pclose(pin);
    665650    pclose(pout);
    666651
    667 //  printf("OK, loop is done\n");
    668 
    669652    unlink(masklist);
    670653    mr_free(masklist);
    671654
    672     paranoid_free(current_subset_file);
    673     paranoid_free(current_master_file);
    674     paranoid_free(incoming);
    675655    return (retval);
    676656}
     
    770750    noof_chars = strlen(string_to_add) + 1; /* we include the '\0' */
    771751
    772 /* walk across tree if necessary */
     752    /* walk across tree if necessary */
    773753    node = startnode;
    774754    char_to_add = string_to_add[0];
     
    779759    }
    780760
    781 /* walk down tree if appropriate */
     761    /* walk down tree if appropriate */
    782762    if (node->down != NULL && node->ch == char_to_add) {
    783763        log_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_add);
     
    793773    }
    794774
    795 /* add here */
     775    /* add here */
    796776    if (!(newnode = (struct s_node *) malloc(sizeof(struct s_node)))) {
    797777        log_to_screen("failed to malloc");
     
    864844    /*@ buffers **************************************************** */
    865845    char *command_to_open_fname = NULL;
    866     char fname[MAX_STR_LEN];
    867     char tmp[MAX_STR_LEN];
     846    char *fname = NULL;
     847    char *tmp = NULL;
    868848    char *tmp1 = NULL;
    869849    int pos_in_fname;
     
    911891
    912892    open_evalcall_form("Loading filelist from disk");
    913     for (tmp1 = fgets(fname, MAX_STR_LEN, pin); !feof(pin);
    914          tmp1 = fgets(fname, MAX_STR_LEN, pin)) {
    915         if (((fname[strlen(fname) - 1] == 13) || (fname[strlen(fname) - 1] == 10)) && (strlen(fname) > 0)) {
     893    for (mr_getline(fname, pin); !feof(pin); mr_getline(fname, pin)) {
     894        if ((strlen(fname) > 0) && (fname[strlen(fname) - 1] == 13 || fname[strlen(fname) - 1] == 10)) {
    916895            fname[strlen(fname) - 1] = '\0';
    917896        }
    918 //      strip_spaces (fname);
    919897        if (!strlen(fname)) {
     898            mr_free(fname);
    920899            continue;
    921900        }
     
    924903                continue;
    925904            }
    926             strcpy(tmp, fname);
     905            mr_asprintf(tmp, "%s", fname);
    927906            tmp[pos_in_fname] = '\0';
    928907            if (strlen(tmp)) {
    929908                add_string_at_node(filelist, tmp);
    930909            }
     910            mr_free(tmp);
    931911        }
    932912        add_string_at_node(filelist, fname);
     913
    933914        if (!(++lino % 1111)) {
    934915            percentage = (int) (lino * 100 / lines_in_filelist);
    935916            update_evalcall_form(percentage);
    936917        }
    937     }
     918        mr_free(fname);
     919    }
     920    mr_free(fname);
     921
    938922    paranoid_pclose(pin);
    939923    close_evalcall_form();
     
    12971281
    12981282
    1299 
    1300 
    13011283/**
    13021284 * Number of entries in the skeleton filelist.
     
    13141296 * @bug Return value should be @c void.
    13151297 */
    1316 int open_and_list_dir(char *dir1, char *sth, FILE * fout,
    1317                       time_t time_of_last_full_backup)
    1318 {
     1298int open_and_list_dir(char *dir1, char *sth, FILE * fout, time_t time_of_last_full_backup) {
     1299
    13191300    const char delims[] = "|";
    13201301
     
    13231304    struct stat statbuf;
    13241305    char *new;
    1325     char *tmp;
     1306    char *tmp = NULL;
    13261307    char *dir = NULL;
    13271308    static int percentage = 0;
    1328     char *skip_these;
     1309    char *skip_these = NULL;
    13291310    char *new_with_pipe;
    13301311    char *strtmp = NULL;
    13311312    char *token = NULL;
    13321313    char *find_excludes = NULL;
    1333     static char *name_of_evalcall_form;
     1314    char *name_of_evalcall_form = NULL;
     1315    char *find_skeleton_marker = NULL;
    13341316    int i;
    13351317    int lastpos = 0;
     
    13381320    static int counter = 0;
    13391321    static int uberctr = 0;
    1340     static char *find_skeleton_marker;
    1341     static long skeleton_lino = 0;
    1342     static time_t last_time = 0;
     1322    static long skeleton_lino = 0L;
     1323    static time_t last_time = (time_t)0;
    13431324    time_t this_time;
    13441325
     
    13551336
    13561337    if (!depth) {
    1357         malloc_string(name_of_evalcall_form);
    1358         malloc_string(find_skeleton_marker);
    13591338        while((token = mr_strtok(sth, delims, &lastpos)) != NULL) {
    13601339          mr_strcat(find_excludes," -path %s -prune -o", token);
     
    13751354        mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);
    13761355#endif
    1377         paranoid_free(find_excludes);
     1356        mr_free(find_excludes);
     1357
    13781358        log_msg(5, "find command = %s", strtmp);
    13791359        paranoid_system(strtmp);
    1380         paranoid_free(strtmp);
     1360        mr_free(strtmp);
     1361
    13811362        mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1382         g_skeleton_entries =
    1383             1 + atol(call_program_and_get_last_line_of_output(tmp));
    1384         paranoid_free(tmp);
    1385         sprintf(name_of_evalcall_form, "Making catalog of %s", dir1);
     1363        g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
     1364        mr_free(tmp);
     1365
     1366        mr_asprintf(name_of_evalcall_form, "Making catalog of %s", dir1);
    13861367        open_evalcall_form(name_of_evalcall_form);
    1387         find_skeleton_marker[0] = '\0';
     1368        mr_free(name_of_evalcall_form);
     1369
    13881370        skeleton_lino = 1;
    13891371        log_msg(5, "entries = %ld", g_skeleton_entries);
     
    13911373    } else if (depth <= MAX_SKEL_DEPTH) // update evalcall form if appropriate
    13921374    {
    1393         sprintf(find_skeleton_marker,
    1394                 "grep -Fv '%s' %s > %s.new 2> /dev/null", dir,
    1395                 g_skeleton_filelist, g_skeleton_filelist);
    1396 //    log_msg(0, "fsm = %s", find_skeleton_marker);
     1375        mr_asprintf(find_skeleton_marker, "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, g_skeleton_filelist, g_skeleton_filelist);
    13971376        if (!system(find_skeleton_marker)) {
    13981377            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    13991378            skeleton_lino++;
    1400 //        log_msg(5, "Found %s", dir);
    1401 //        log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
    1402             sprintf(find_skeleton_marker, "mv -f %s.new %s",
    1403                     g_skeleton_filelist, g_skeleton_filelist);
    1404 //        log_msg(6, "fsm = %s", find_skeleton_marker);
     1379            mr_free(find_skeleton_marker);
     1380
     1381            mr_asprintf(find_skeleton_marker, "mv -f %s.new %s", g_skeleton_filelist, g_skeleton_filelist);
    14051382            paranoid_system(find_skeleton_marker);
    14061383            time(&this_time);
    14071384            if (this_time != last_time) {
    14081385                last_time = this_time;
    1409 #ifndef _XWIN
    14101386                if (!g_text_mode) {
    14111387                    int cols, rows;
     
    14151391                    mr_free(tmp);
    14161392                }
    1417 #endif
    14181393                update_evalcall_form(percentage);
    14191394            }
    14201395        }
     1396        mr_free(find_skeleton_marker);
    14211397    }
    14221398
     
    14301406        mr_asprintf(tmp,"opendir %s", dir1);
    14311407        log_OS_error(tmp);
    1432         paranoid_free(tmp);
     1408        mr_free(tmp);
    14331409    } else if (strstr(skip_these, new_with_pipe)) {
    14341410        log_msg(10, "Found dir ***%s**** excluded", dir1);
     
    14441420                mr_asprintf(new,"%s%s",dir1,dit->d_name);
    14451421            }
    1446             paranoid_free(new_with_pipe);
     1422            mr_free(new_with_pipe);
    14471423            mr_asprintf(new_with_pipe, "|%s|", new);
    14481424            if (strstr(skip_these, new_with_pipe)) {
    14491425                fprintf(fout, "%s\n", new);
    14501426                log_msg(10, "Found child dir ***%s**** excluded", new);
    1451                 paranoid_free(new_with_pipe);
     1427                mr_free(new_with_pipe);
    14521428            } else {
    1453                 paranoid_free(new_with_pipe);
     1429                mr_free(new_with_pipe);
    14541430                if (!lstat(new, &statbuf)) {
    14551431                    if (!S_ISLNK(statbuf.st_mode)
    14561432                        && S_ISDIR(statbuf.st_mode)) {
    14571433                        log_msg(10, "Found child dir ***%s**** parsed", new);
    1458                         open_and_list_dir(new, skip_these, fout,
    1459                                           time_of_last_full_backup);
     1434                        open_and_list_dir(new, skip_these, fout, time_of_last_full_backup);
    14601435                    } else {
    1461                         if (time_of_last_full_backup == 0
    1462                             || time_of_last_full_backup <
    1463                             statbuf.st_ctime) {
     1436                        if (time_of_last_full_backup == 0 || time_of_last_full_backup < statbuf.st_ctime) {
    14641437                            log_msg(10, "Found child file ***%s**** parsed", new);
    14651438                            fprintf(fout, "%s\n", new);
     
    14681441                                uberctr++;
    14691442                                mr_asprintf(tmp, " %c ", special_dot_char(uberctr));
    1470 #ifndef _XWIN
    14711443                                if (!g_text_mode) {
    1472                                     newtDrawRootText(77, g_noof_rows - 3,
    1473                                                      tmp);
     1444                                    newtDrawRootText(77, g_noof_rows - 3, tmp);
    14741445                                    newtRefresh();
    14751446                                }
    1476 #endif
    1477                                 paranoid_free(tmp);
     1447                                mr_free(tmp);
    14781448                            }
    14791449                        }
     
    14811451                }
    14821452            }
    1483             paranoid_free(new);
    1484         }
    1485     }
    1486     paranoid_free(new_with_pipe);
    1487     paranoid_free(skip_these);
     1453            mr_free(new);
     1454        }
     1455    }
     1456    mr_free(new_with_pipe);
     1457    mr_free(skip_these);
    14881458    mr_free(dir);
    14891459
     
    14961466    if (!depth) {
    14971467        close_evalcall_form();
    1498         paranoid_free(name_of_evalcall_form);
    1499         paranoid_free(find_skeleton_marker);
    15001468        unlink(g_skeleton_filelist);
    15011469        log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    15251493    char *p, *q;
    15261494    char *sz_datefile;
    1527     char *sz_filelist, *tmp;
     1495    char *sz_filelist;
    15281496    char *exclude_paths = NULL;
    15291497    FILE *fout;
     
    15341502    char *tmp2 = NULL;
    15351503
    1536     malloc_string(tmp);
    1537     malloc_string(g_skeleton_filelist);
    15381504    mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15391505    if (!include_paths && !userdef_filelist) {
    1540         fatal_error
    1541             ("Please supply either include_paths or userdef_filelist");
    1542     }
    1543 // make hole for filelist
     1506        fatal_error("Please supply either include_paths or userdef_filelist");
     1507    }
     1508    // make hole for filelist
    15441509    mr_asprintf(command, "mkdir -p %s/archives", scratchdir);
    15451510    paranoid_system(command);
     
    15571522        // backup last known good datefile just in case :)
    15581523        if (does_file_exist(sz_datefile)) {
    1559             mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile,
    1560                     sz_datefile);
     1524            mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile, sz_datefile);
    15611525            paranoid_system(command);
    15621526            mr_free(command);
     
    15671531                                  ("date +%s"));
    15681532    } else if (lstat(sz_datefile, &statbuf)) {
    1569         log_msg(2,
    1570                 "Warning - unable to find date of previous backup. Full backup instead.");
     1533        log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");
    15711534        differential = 0;
    15721535        time_of_last_full_backup = 0;
     
    15791542// use user-specified filelist (if specified)
    15801543    if (userdef_filelist) {
    1581         log_msg(1,
    1582                 "Using the user-specified filelist - %s - instead of calculating one",
    1583                 userdef_filelist);
     1544        log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist);
    15841545        mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);
    15851546        if (run_program_and_log_output(command, 3)) {
     
    15891550        mr_free(command);
    15901551    } else {
    1591         log_msg(2, "include_paths = '%s'", include_paths);
     1552        if (include_paths) {
     1553            log_msg(2, "include_paths = '%s'", include_paths);
     1554        }
    15921555        log_msg(1, "Calculating filelist");
    15931556        mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     
    15971560            log_msg(2, "Found windows FS: %s",tmp2);
    15981561            mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    1599             paranoid_free(tmp2);
     1562            mr_free(tmp2);
    16001563            mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
    16011564            log_msg(2, "Found windows files: %s",tmp2);
    16021565        }
    1603         paranoid_free(tmp1);
     1566        mr_free(tmp1);
    16041567
    16051568        mr_asprintf(exclude_paths, MONDO_CACHE"|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/run|/dev/shm|"MINDI_CACHE, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
     
    16071570            mr_strcat(exclude_paths,"|%s",excp);
    16081571        }
    1609         paranoid_free(tmp2);
     1572        mr_free(tmp2);
    16101573
    16111574        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    1612         log_msg(2,
    1613                 "Generating skeleton filelist so that we can track our progress");
    1614         sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
     1575        log_msg(2, "Generating skeleton filelist so that we can track our progress");
     1576        mr_asprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    16151577        make_hole_for_file(g_skeleton_filelist);
     1578
    16161579        log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
    16171580        log_msg(2, "Opening out filelist to %s", sz_filelist);
     
    16191582            fatal_error("Cannot openout to sz_filelist");
    16201583        }
    1621         if (strlen(include_paths) == 0) {
     1584        if ((include_paths != NULL) && (strlen(include_paths) == 0)) {
    16221585            log_msg(1, "Including only '/' in %s", sz_filelist);
    16231586            open_and_list_dir("/", exclude_paths, fout,
     
    16371600            }
    16381601        }
     1602        mr_free(exclude_paths);
    16391603        paranoid_fclose(fout);
    16401604    }
     
    16541618    paranoid_free(sz_filelist);
    16551619    log_msg(2, "Freeing variables");
    1656     paranoid_free(exclude_paths);
    1657     paranoid_free(tmp);
    1658     paranoid_free(g_skeleton_filelist);
     1620    mr_free(g_skeleton_filelist);
    16591621    log_msg(2, "Exiting");
    16601622    return (0);
    16611623}
     1624
    16621625
    16631626/**
     
    16801643
    16811644    assert(bkpinfo != NULL);
    1682     log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir,
    1683            bkpinfo->scratchdir);
     1645    log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    16841646    if (bkpinfo->make_filelist) {
    16851647        mvaddstr_and_log_it(g_currentY, 0,
     
    17921754    FILE *fin;
    17931755    FILE *fout;
    1794     char *fname;
    1795     char *tmp;
    1796     size_t len = 0;             // Scrub's patch doesn't work without that
    1797 
    1798 //  log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");