Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-files.c


Ignore:
Timestamp:
Oct 24, 2006, 8:49:18 AM (18 years ago)
Author:
Bruno Cornec
Message:

Huge patch to introduce low level functions that will bw used everywhere (mr_free, mr_asprintf, ...)
Nearly linking now due to that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/src/common/libmondo-files.c

    r839 r900  
    1818#include "libmondo-fork-EXT.h"
    1919#include "libmondo-string-EXT.h"
     20#include "mr_mem.h"
    2021
    2122/*@unused@*/
     
    5960
    6061    if (does_file_exist(filename)) {
    61         asprintf(&command, "md5sum \"%s\"", filename);
     62        mr_asprintf(&command, "md5sum \"%s\"", filename);
    6263        fin = popen(command, "r");
    63         paranoid_free(command);
     64        mr_free(command);
    6465
    6566        if (fin) {
    66             (void) getline(&output, &n, fin);
     67            mr_getline(&output, &n, fin);
    6768            p = strchr(output, ' ');
    6869            paranoid_pclose(fin);
    6970        }
    7071    } else {
    71         asprintf(&tmp, "File '%s' not found; cannot calc checksum",
     72        mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum",
    7273                filename);
    7374        log_it(tmp);
    74         paranoid_free(tmp);
     75        mr_free(tmp);
    7576    }
    7677    if (p) {
     
    106107    assert_string_is_neither_NULL_nor_zerolength(filename);
    107108    if (!does_file_exist(filename)) {
    108         asprintf(&tmp,
     109        mr_asprintf(&tmp,
    109110                "%s does not exist, so I cannot found the number of lines in it",
    110111                filename);
    111112        log_it(tmp);
    112         paranoid_free(tmp);
     113        mr_free(tmp);
    113114        return (0);
    114115    }
    115     asprintf(&command, "cat %s | wc -l", filename);
     116    mr_asprintf(&command, "cat %s | wc -l", filename);
    116117    if (!does_file_exist(filename)) {
    117118        return (-1);
    118119    }
    119120    fin = popen(command, "r");
    120     paranoid_free(command);
     121    mr_free(command);
    121122
    122123    if (fin) {
     
    124125            noof_lines = 0;
    125126        } else {
    126             (void) getline(&incoming, &n, fin);
     127            mr_getline(&incoming, &n, fin);
    127128            while (strlen(incoming) > 0
    128129                   && incoming[strlen(incoming) - 1] < 32) {
     
    130131            }
    131132            noof_lines = atol(incoming);
    132             paranoid_free(incoming);
     133            mr_free(incoming);
    133134        }
    134135        paranoid_pclose(fin);
     
    189190    assert_string_is_neither_NULL_nor_zerolength(inout);
    190191
    191     asprintf(&infname, "%s.in", inout);
    192 
    193     asprintf(&tmp, "cp -f %s %s", inout, infname);
     192    mr_asprintf(&infname, "%s.in", inout);
     193
     194    mr_asprintf(&tmp, "cp -f %s %s", inout, infname);
    194195    run_program_and_log_output(tmp, FALSE);
    195     paranoid_free(tmp);
     196    mr_free(tmp);
    196197
    197198    if (!(fin = fopen(infname, "r"))) {
    198199        log_OS_error("Unable to openin infname");
    199         paranoid_free(infname);
     200        mr_free(infname);
    200201        return;
    201202    }
    202203
    203     asprintf(&outfname, "%s", inout);
     204    mr_asprintf(&outfname, "%s", inout);
    204205    if (!(fout = fopen(outfname, "w"))) {
    205206        log_OS_error("Unable to openout outfname");
    206         paranoid_free(outfname);
     207        mr_free(outfname);
    207208        return;
    208209    }
    209     paranoid_free(outfname);
    210 
    211     for (getline(&incoming, &n, fin); !feof(fin);
    212          getline(&incoming, &n, fin)) {
     210    mr_free(outfname);
     211
     212    for (mr_getline(&incoming, &n, fin); !feof(fin);
     213         mr_getline(&incoming, &n, fin)) {
    213214        i = strlen(incoming) - 1;
    214215        if (i >= 0 && incoming[i] < 32) {
     
    218219            fprintf(fout, "%s\n", incoming);
    219220        } else {
    220             asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);
     221            mr_asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);
    221222            log_it(tmp);
    222             paranoid_free(tmp);
    223         }
    224     }
    225     paranoid_free(incoming);
     223            mr_free(tmp);
     224        }
     225    }
     226    mr_free(incoming);
    226227    paranoid_fclose(fout);
    227228    paranoid_fclose(fin);
    228229    unlink(infname);
    229     paranoid_free(infname);
     230    mr_free(infname);
    230231}
    231232
     
    249250    // If we didn't get anything back, check whether mindi raised a fatal error
    250251    if (kernel == NULL) {
    251         asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
     252        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
    252253        tmp = call_program_and_get_last_line_of_output(command);
    253254        if (strlen(tmp) > 1) {
     
    255256            fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'.");
    256257        }
    257         paranoid_free(command);
    258         paranoid_free(tmp);
     258        mr_free(command);
     259        mr_free(tmp);
    259260    }
    260261
     
    303304    assert_string_is_neither_NULL_nor_zerolength(fname);
    304305
    305     asprintf(&command, "which %s 2> /dev/null", fname);
     306    mr_asprintf(&command, "which %s 2> /dev/null", fname);
    306307    incoming = call_program_and_get_last_line_of_output(command);
    307     paranoid_free(command);
     308    mr_free(command);
    308309
    309310    if (incoming == NULL) {
     
    311312            return (NULL);      // forget it :)
    312313        }
    313         asprintf(&command,
     314        mr_asprintf(&command,
    314315                "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
    315316                incoming);
    316         paranoid_free(incoming);
     317        mr_free(incoming);
    317318
    318319        incoming = call_program_and_get_last_line_of_output(command);
    319         paranoid_free(command);
     320        mr_free(command);
    320321    }
    321322    if (incoming == NULL)   // yes, it is == '\0' twice, not once :)
    322323    {
    323         asprintf(&command, "dirname %s 2> /dev/null", incoming);
    324         paranoid_free(incoming);
     324        mr_asprintf(&command, "dirname %s 2> /dev/null", incoming);
     325        mr_free(incoming);
    325326
    326327        incoming = call_program_and_get_last_line_of_output(command);
    327         paranoid_free(command);
     328        mr_free(command);
    328329    }
    329330    output = incoming;
     
    332333        log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output);
    333334    } else {
    334         paranoid_free(output);
     335        mr_free(output);
    335336        log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
    336337    }
     
    395396         && !strstr(err_log_lines[i], "% done"); i--);
    396397    if (i < 0) {
    397         asprintf(&command,
     398        mr_asprintf(&command,
    398399                "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
    399400                filename, '%');
    400401        lastline = call_program_and_get_last_line_of_output(command);
    401         paranoid_free(command);
     402        mr_free(command);
    402403        if (!lastline) {
    403404            return (0);
    404405        }
    405406    } else {
    406         asprintf(&lastline, err_log_lines[i]);
     407        mr_asprintf(&lastline, err_log_lines[i]);
    407408    }
    408409
     
    412413    }
    413414    if (!p) {
    414         paranoid_free(lastline);
     415        mr_free(lastline);
    415416        return (0);
    416417    }
     
    421422    }
    422423    i = atoi(p);
    423     paranoid_free(lastline);
     424    mr_free(lastline);
    424425
    425426    return (i);
     
    447448
    448449    if (!does_file_exist(filename)) {
    449         asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),
     450        mr_asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),
    450451                filename);
    451452        log_it(tmp);
    452         paranoid_free(tmp);
     453        mr_free(tmp);
    453454        return (NULL);
    454455    }
    455     asprintf(&command, "tail -n1 %s", filename);
     456    mr_asprintf(&command, "tail -n1 %s", filename);
    456457    fin = popen(command, "r");
    457     paranoid_free(command);
    458 
    459     getline(&output, &n, fin);
     458    mr_free(command);
     459
     460    mr_getline(&output, &n, fin);
    460461    paranoid_pclose(fin);
    461462    while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
     
    504505
    505506    assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
    506     asprintf(&tmp, "mkdir -p %s", outdir_fname);
     507    mr_asprintf(&tmp, "mkdir -p %s", outdir_fname);
    507508    res = system(tmp);
    508     paranoid_free(tmp);
     509    mr_free(tmp);
    509510    return (res);
    510511}
     
    532533    assert(!strstr(outfile_fname, "/dev/cdrom"));
    533534
    534     asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
     535    mr_asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
    535536    res += system(command);
    536     paranoid_free(command);
    537 
    538     asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
     537    mr_free(command);
     538
     539    mr_asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
    539540    res += system(command);
    540     paranoid_free(command);
    541 
    542     asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
     541    mr_free(command);
     542
     543    mr_asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
    543544    res += system(command);
    544     paranoid_free(command);
     545    mr_free(command);
    545546    unlink(outfile_fname);
    546547    return (0);
     
    575576        return (0);
    576577    }
    577     (void) getline(&incoming, &n, fin);
     578    mr_getline(&incoming, &n, fin);
    578579    while (!feof(fin)) {
    579580        if (strstr(incoming, wildcard)) {
    580581            matches++;
    581582        }
    582         (void) getline(&incoming, &n, fin);
     583        mr_getline(&incoming, &n, fin);
    583584    }
    584585    paranoid_fclose(fin);
    585     paranoid_free(incoming);
     586    mr_free(incoming);
    586587    return (matches);
    587588}
     
    603604    FILE *fin;
    604605
    605     asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);
     606    mr_asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);
    606607    if (!pid) {
    607608        log_it("Unregistering PID");
     
    609610            log_it("Error unregistering PID");
    610611        }
    611         paranoid_free(lockfile_fname);
     612        mr_free(lockfile_fname);
    612613        return;
    613614    }
    614615    if (does_file_exist(lockfile_fname)) {
    615616        if ((fin = fopen(lockfile_fname, "r"))) {
    616             (void) getline(&tmp, &n, fin);
     617            mr_getline(&tmp, &n, fin);
    617618            paranoid_fclose(fin);
    618619        } else {
     
    620621        }
    621622        pid = (pid_t) atol(tmp);
    622         paranoid_free(tmp);
    623 
    624         asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);
     623        mr_free(tmp);
     624
     625        mr_asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);
    625626        res = system(tmp);
    626         paranoid_free(tmp);
     627        mr_free(tmp);
    627628        if (!res) {
    628629            log_it
     
    631632        }
    632633    }
    633     asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),
     634    mr_asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),
    634635            lockfile_fname);
    635     paranoid_free(lockfile_fname);
     636    mr_free(lockfile_fname);
    636637
    637638    if (system(tmp)) {
    638639        fatal_error("Cannot register PID");
    639640    }
    640     paranoid_free(tmp);
     641    mr_free(tmp);
    641642    return;
    642643}
     
    655656    long file_len_K = 0L;
    656657
    657     asprintf(&command,
     658    mr_asprintf(&command,
    658659            "grep '%s ' %s/mountlist.txt | head -n1 | awk '{print $4;}'",
    659660            dev, tmpdir);
     
    662663    file_len_K = atol(sz_res);
    663664    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
    664     paranoid_free(command);
    665     paranoid_free(sz_res);
     665    mr_free(command);
     666    mr_free(sz_res);
    666667    return (file_len_K);
    667668}
     
    692693
    693694    log_it("Calculating size of all biggiefiles (in total)");
    694     asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     695    mr_asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
    695696    log_it("biggielist = %s", biggielist);
    696697    if (!(fin = fopen(biggielist, "r"))) {
     
    699700    } else {
    700701        log_msg(4, "Reading it...");
    701         for (getline(&fname, &n, fin); !feof(fin);
    702              getline(&fname, &n, fin)) {
     702        for (mr_getline(&fname, &n, fin); !feof(fin);
     703             mr_getline(&fname, &n, fin)) {
    703704            if (fname[strlen(fname) - 1] <= 32) {
    704705                fname[strlen(fname) - 1] = '\0';
     
    710711                        fatal_error("ntfsresize not found");
    711712                    }
    712                     paranoid_free(tmp);
    713 
    714                     asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
     713                    mr_free(tmp);
     714
     715                    mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    715716                    log_it("command = %s", command);
    716717                    tmp = call_program_and_get_last_line_of_output(command);
    717                     paranoid_free(command);
     718                    mr_free(command);
    718719
    719720                    log_it("res of it = %s", tmp);
    720721                    file_len_K = atoll(tmp) / 1024L;
    721                     paranoid_free(tmp);
     722                    mr_free(tmp);
    722723                } else {
    723724                    file_len_K = get_phys_size_of_drive(fname) * 1024L;
     
    731732                log_msg(4, "%s --> %ld K", fname, file_len_K);
    732733            }
    733             asprintf(&comment,
     734            mr_asprintf(&comment,
    734735                    "After adding %s, scratchL+%ld now equals %ld", fname,
    735736                    file_len_K, scratchL);
    736737            log_msg(4, comment);
    737             paranoid_free(comment);
     738            mr_free(comment);
    738739
    739740            if (feof(fin)) {
     
    741742            }
    742743        }
    743         paranoid_free(fname);
    744     }
    745     paranoid_free(biggielist);
     744        mr_free(fname);
     745    }
     746    mr_free(biggielist);
    746747
    747748    log_it("Closing...");
     
    771772    /*@ end vars *************************************************** */
    772773
    773     asprintf(&command, "du -sk %s", mountpt);
     774    mr_asprintf(&command, "du -sk %s", mountpt);
    774775    errno = 0;
    775776    fin = popen(command, "r");
     
    778779      llres = 0;
    779780    } else {
    780         (void) getline(&tmp, &n, fin);
     781        mr_getline(&tmp, &n, fin);
    781782        paranoid_pclose(fin);
    782783        p = strchr(tmp, '\t');
     
    790791    }
    791792
    792     paranoid_free(command);
    793     paranoid_free(tmp);
     793    mr_free(command);
     794    mr_free(tmp);
    794795    return (llres);
    795796}
     
    842843
    843844
    844     asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);
     845    mr_asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);
    845846    res = system(command);
    846     paranoid_free(command);
     847    mr_free(command);
    847848
    848849    if (res) {
    849         asprintf(&errorstr,
     850        mr_asprintf(&errorstr,
    850851            _("Please install '%s'. I cannot find it on your system."),
    851852            fname);
    852853        log_to_screen(errorstr);
    853         paranoid_free(errorstr);
     854        mr_free(errorstr);
    854855        log_to_screen
    855856            (_("There may be an hyperlink at http://www.mondorescue.org which"));
     
    949950    log_msg(4, "g_mondo_home='%s'", g_mondo_home);
    950951    if ((g_mondo_home == NULL) || strlen(g_mondo_home) < 2) {
    951         paranoid_free(g_mondo_home);
     952        mr_free(g_mondo_home);
    952953        g_mondo_home = find_and_store_mondoarchives_home();
    953954    }
    954     asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
     955    mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
    955956            bkpinfo->scratchdir);
    956957
     
    959960        fatal_error("Failed to copy Mondo's stuff to scratchdir");
    960961    }
    961     paranoid_free(command);
    962 
    963     asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
     962    mr_free(command);
     963
     964    mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
    964965
    965966    /* i18n */
    966     asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);
     967    mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);
    967968    log_msg(4, "command = %s", command);
    968969    run_program_and_log_output(command, 1);
    969     paranoid_free(command);
     970    mr_free(command);
    970971
    971972    if (does_file_exist(tmp)) {
     
    974975        (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    975976        chdir(bkpinfo->scratchdir);
    976         asprintf(&command, "tar -zxvf %s", tmp);
     977        mr_asprintf(&command, "tar -zxvf %s", tmp);
    977978        if (run_program_and_log_output(command, FALSE)) {
    978979            fatal_error("Failed to untar payload");
    979980        }
    980         paranoid_free(command);
     981        mr_free(command);
    981982        chdir(old_pwd);
    982983    }
    983     paranoid_free(tmp);
    984 
    985     asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
     984    mr_free(tmp);
     985
     986    mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    986987            bkpinfo->scratchdir);
    987988    if (run_program_and_log_output(command, FALSE)) {
    988989        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    989990    }
    990     paranoid_free(command);
     991    mr_free(command);
    991992
    992993    tmp = call_program_and_get_last_line_of_output("which mondorestore");
     
    995996            ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
    996997    }
    997     asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
    998     paranoid_free(tmp);
     998    mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     999    mr_free(tmp);
    9991000
    10001001    if (run_program_and_log_output(command, FALSE)) {
    10011002        fatal_error("Failed to copy mondorestore to tmpdir");
    10021003    }
    1003     paranoid_free(command);
    1004 
    1005     asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
     1004    mr_free(command);
     1005
     1006    mr_asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
    10061007    paranoid_system(command);
    1007     paranoid_free(command);
     1008    mr_free(command);
    10081009
    10091010    if (bkpinfo->postnuke_tarball) {
    1010         asprintf(&command, "cp -f %s %s/post-nuke.tgz",
     1011        mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz",
    10111012                bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    10121013        if (run_program_and_log_output(command, FALSE)) {
    10131014            fatal_error("Unable to copy post-nuke tarball to tmpdir");
    10141015        }
    1015         paranoid_free(command);
     1016        mr_free(command);
    10161017    }
    10171018
     
    10471048
    10481049    log_it("Storing NFS configuration");
    1049     asprintf(&tmp, bkpinfo->nfs_mount);
     1050    mr_asprintf(&tmp, bkpinfo->nfs_mount);
    10501051    p = strchr(tmp, ':');
    10511052    if (!p) {
     
    10541055    }
    10551056    *(p++) = '\0';
    1056     asprintf(&nfs_server_ipaddr, tmp);
    1057     paranoid_free(tmp);
    1058 
    1059     asprintf(&nfs_mount, p);
     1057    mr_asprintf(&nfs_server_ipaddr, tmp);
     1058    mr_free(tmp);
     1059
     1060    mr_asprintf(&nfs_mount, p);
    10601061    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1061     asprintf(&command,
     1062    mr_asprintf(&command,
    10621063            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    10631064    nfs_dev = call_program_and_get_last_line_of_output(command);
    1064     paranoid_free(command);
    1065 
    1066     asprintf(&command,
     1065    mr_free(command);
     1066
     1067    mr_asprintf(&command,
    10671068            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    10681069    nfs_client_ipaddr = call_program_and_get_last_line_of_output(command);
    1069     paranoid_free(command);
    1070 
    1071     asprintf(&command,
     1070    mr_free(command);
     1071
     1072    mr_asprintf(&command,
    10721073            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    10731074    nfs_client_netmask = call_program_and_get_last_line_of_output(command);
    1074     paranoid_free(command);
    1075 
    1076     asprintf(&command,
     1075    mr_free(command);
     1076
     1077    mr_asprintf(&command,
    10771078            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    10781079    nfs_client_broadcast = call_program_and_get_last_line_of_output(command);
    1079     paranoid_free(command);
    1080 
    1081     asprintf(&command,
     1080    mr_free(command);
     1081
     1082    mr_asprintf(&command,
    10821083            "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    10831084    nfs_client_defgw = call_program_and_get_last_line_of_output(command);
    1084     paranoid_free(command);
    1085 
    1086     asprintf(&tmp,
     1085    mr_free(command);
     1086
     1087    mr_asprintf(&tmp,
    10871088            "nfs_client_ipaddr=%s; nfs_client_netmask=%s; nfs_server_ipaddr=%s; nfs_mount=%s; nfs_client_defgw=%s;  ",
    10881089            nfs_client_ipaddr, nfs_client_netmask, nfs_server_ipaddr, nfs_mount, nfs_client_defgw);
    1089     paranoid_free(nfs_mount);
     1090    mr_free(nfs_mount);
    10901091    log_it(tmp);
    1091     paranoid_free(tmp);
     1092    mr_free(tmp);
    10921093
    10931094    if (strlen(nfs_dev) < 2) {
     
    11071108    if (!strncmp(nfs_dev, "bond", 4)) {
    11081109        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev);
    1109         asprintf(&command,
     1110        mr_asprintf(&command,
    11101111                "ifconfig %s | awk '{print $5}'", nfs_dev);
    11111112        mac_addr = call_program_and_get_last_line_of_output(command);
    1112         asprintf(&command,
     1113        mr_asprintf(&command,
    11131114                "ifconfig | grep -E '%s' | head -n1  | cut -d' ' -f1", mac_addr);
    1114         paranoid_free(nfs_dev);
     1115        mr_free(nfs_dev);
    11151116        nfs_dev = call_program_and_get_last_line_of_output(command);
    1116         paranoid_free(command);
    1117         paranoid_free(mac_addr);
     1117        mr_free(command);
     1118        mr_free(mac_addr);
    11181119
    11191120        log_to_screen("Replacing it with %s\n", nfs_dev);
    11201121    }
    11211122
    1122     asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
     1123    mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
    11231124    write_one_liner_data_file(tmp, nfs_dev);
    1124     paranoid_free(nfs_dev);
    1125     paranoid_free(tmp);
    1126 
    1127     asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
     1125    mr_free(nfs_dev);
     1126    mr_free(tmp);
     1127
     1128    mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11281129    write_one_liner_data_file(tmp, nfs_client_ipaddr);
    1129     paranoid_free(nfs_client_ipaddr);
    1130     paranoid_free(tmp);
    1131 
    1132     asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
     1130    mr_free(nfs_client_ipaddr);
     1131    mr_free(tmp);
     1132
     1133    mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    11331134    write_one_liner_data_file(tmp, nfs_client_netmask);
    1134     paranoid_free(nfs_client_netmask);
    1135     paranoid_free(tmp);
    1136 
    1137     asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
     1135    mr_free(nfs_client_netmask);
     1136    mr_free(tmp);
     1137
     1138    mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    11381139    write_one_liner_data_file(tmp, nfs_client_defgw);
    1139     paranoid_free(nfs_client_defgw);
    1140     paranoid_free(tmp);
    1141 
    1142     asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
     1140    mr_free(nfs_client_defgw);
     1141    mr_free(tmp);
     1142
     1143    mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    11431144    write_one_liner_data_file(tmp, nfs_client_broadcast);
    1144     paranoid_free(nfs_client_broadcast);
    1145     paranoid_free(tmp);
    1146 
    1147     asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
     1145    mr_free(nfs_client_broadcast);
     1146    mr_free(tmp);
     1147
     1148    mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
    11481149    write_one_liner_data_file(tmp, nfs_server_ipaddr);
    1149     paranoid_free(nfs_server_ipaddr);
    1150     paranoid_free(tmp);
    1151 
    1152     asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
     1150    mr_free(nfs_server_ipaddr);
     1151    mr_free(tmp);
     1152
     1153    mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
    11531154    write_one_liner_data_file(tmp, bkpinfo->nfs_mount);
    1154     paranoid_free(tmp);
    1155 
    1156     asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
     1155    mr_free(tmp);
     1156
     1157    mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
    11571158    write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir);
    1158     paranoid_free(tmp);
    1159 
    1160     asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     1159    mr_free(tmp);
     1160
     1161    mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    11611162    write_one_liner_data_file(tmp, bkpinfo->prefix);
    1162     paranoid_free(tmp);
     1163    mr_free(tmp);
    11631164
    11641165    log_it("Finished storing NFS configuration");
     
    12111212    }
    12121213    if (scratchLL <= 1) {
    1213         asprintf(&tmp,
     1214        mr_asprintf(&tmp,
    12141215                _("Your backup will probably occupy a single %s. Maybe two."),
    12151216                bkpinfo->backup_media_string);
    12161217    } else {
    1217         asprintf(&tmp, _("Your backup will occupy approximately %s media."),
     1218        mr_asprintf(&tmp, _("Your backup will occupy approximately %s media."),
    12181219                number_to_text((int) (scratchLL + 1)));
    12191220    }
     
    12211222        log_to_screen(tmp);
    12221223    }
    1223     paranoid_free(tmp);
     1224    mr_free(tmp);
    12241225    return;
    12251226}
     
    12381239    char *p = NULL;
    12391240
    1240     asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
     1241    mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    12411242    if (!does_file_exist(tmp)) {
    1242         paranoid_free(tmp);
     1243        mr_free(tmp);
    12431244        return (FALSE);
    12441245    }
    1245     paranoid_free(tmp);
     1246    mr_free(tmp);
    12461247
    12471248    do_not_compress_these = last_line_of_file(tmp);
    12481249    for (p = do_not_compress_these; p != NULL; p++) {
    1249         asprintf(&tmp, p);
     1250        mr_asprintf(&tmp, p);
    12501251        if (strchr(tmp, ' ')) {
    12511252            *(strchr(tmp, ' ')) = '\0';
    12521253        }
    12531254        if (!strcmp(strrchr(filename, '.'), tmp)) {
    1254             paranoid_free(do_not_compress_these);
    1255             paranoid_free(tmp);
     1255            mr_free(do_not_compress_these);
     1256            mr_free(tmp);
    12561257            return (TRUE);
    12571258        }
    1258         paranoid_free(tmp);
     1259        mr_free(tmp);
    12591260
    12601261        if (!(p = strchr(p, ' '))) {
     
    12621263        }
    12631264    }
    1264     paranoid_free(do_not_compress_these);
     1265    mr_free(do_not_compress_these);
    12651266    return (FALSE);
    12661267}
     
    12961297        paranoid_fclose(fout);
    12971298        log_msg(2, "Created %s", outfile);
    1298         asprintf(&tmp, "chmod +x %s", outfile);
     1299        mr_asprintf(&tmp, "chmod +x %s", outfile);
    12991300        paranoid_system(tmp);
    1300         paranoid_free(tmp);
     1301        mr_free(tmp);
    13011302
    13021303        retval = 0;
     
    13081309
    13091310/* @} - end fileGroup */
    1310 
    1311 void paranoid_alloc(char *alloc, char *orig)
    1312 {
    1313         paranoid_free(alloc);
    1314         asprintf(&alloc, orig);
    1315 }
    1316 
Note: See TracChangeset for help on using the changeset viewer.