Changeset 689 in MondoRescue for trunk


Ignore:
Timestamp:
Jul 17, 2006, 7:43:58 PM (18 years ago)
Author:
bcornec
Message:

Still other memory management improvements ( I hope :-)

Location:
trunk/mondo/mondo
Files:
13 edited

Legend:

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

    r688 r689  
    433433    if (bkpinfo->backup_media_type == dvd) {
    434434#ifdef DVDRWFORMAT
    435         if (!find_home_of_exe("dvd+rw-format")) {
     435        tmp = find_home_of_exe("dvd+rw-format");
     436        if (!tmp) {
    436437            fatal_error
    437438                ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
    438439        }
     440        paranoid_free(tmp);
    439441#endif
    440         if (!find_home_of_exe("growisofs")) {
     442        tmp = find_home_of_exe("growisofs");
     443        if (!tmp) {
    441444            fatal_error
    442445                ("Cannot find growisofs. Please install it or fix your PATH.");
    443446        }
     447        paranoid_free(tmp);
    444448    }
    445449
     
    30563060                "Not calculating checksum for %s: it would take too long",
    30573061                biggie_filename);
    3058         if ( !find_home_of_exe("ntfsresize")) {
     3062        tmp = find_home_of_exe("ntfsresize");
     3063        if ( !tmp) {
    30593064            fatal_error("ntfsresize not found");
    30603065        }
    3061         sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3066        paranoid_free(tmp);
     3067
     3068        asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    30623069        log_it("command = %s", command);
    30633070        tmp = call_program_and_get_last_line_of_output(command);
     3071        paranoid_free(command);
     3072
    30643073        log_it("res of it = %s", tmp);
    30653074        totallength = (off_t)atoll(tmp);
  • trunk/mondo/mondo/common/libmondo-devices.c

    r688 r689  
    495495char *find_cdrw_device(void)
    496496{
    497     /*@ buffers ************************ */
    498     char *comment;
    499     char *tmp;
    500     char *cdr_exe;
    501     char *command;
    502     char *cdrw_device;
     497    char *comment = NULL;
     498    char *tmp = NULL;
     499    char *tmp1 = NULL;
     500    char *cdr_exe = NULL;
     501    char *command = NULL;
     502    char *cdrw_device = NULL;
    503503
    504504    if (g_cdrw_drive_is_here != NULL) {
     
    513513    }
    514514    run_program_and_log_output("insmod ide-scsi", -1);
    515     if (find_home_of_exe("cdrecord")) {
     515    tmp = find_home_of_exe("cdrecord");
     516    if (tmp) {
    516517        asprintf(&cdr_exe, "cdrecord");
    517518    } else {
    518519        asprintf(&cdr_exe, "dvdrecord");
    519520    }
    520     if (find_home_of_exe(cdr_exe)) {
     521    paranoid_free(tmp);
     522
     523    tmp1 = find_home_of_exe(cdr_exe);
     524    if (tmp1) {
    521525        asprintf(&command,
    522526                "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1",
     
    527531        asprintf(&tmp, " ");
    528532    }
     533    paranoid_free(tmp1);
    529534    paranoid_free(cdr_exe);
    530535
     
    594599    }
    595600
    596     if (find_home_of_exe("cdrecord")) {
     601    tmp = find_home_of_exe("cdrecord");
     602    if (tmp) {
    597603        asprintf(&cdr_exe, "cdrecord");
    598604    } else {
    599605        asprintf(&cdr_exe, "dvdrecord");
    600606    }
    601     if (!find_home_of_exe(cdr_exe)) {
     607    paranoid_free(tmp);
     608
     609    tmp = find_home_of_exe(cdr_exe);
     610    if (!tmp) {
    602611        asprintf(&output, "/dev/cdrom");
    603612        log_msg(4, "Can't find cdrecord; assuming %s", output);
     
    612621        }
    613622    }
     623    paranoid_free(tmp);
    614624
    615625    asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);
  • trunk/mondo/mondo/common/libmondo-filelist.c

    r688 r689  
    479479int get_acl_list(char *filelist, char *facl_fname)
    480480{
    481     char *command;
     481    char *command = NULL;
     482    char *tmp = NULL;
    482483    int retval = 0;
    483484
     
    486487    paranoid_free(command);
    487488
    488     if (find_home_of_exe("getfacl")) {
     489    tmp = find_home_of_exe("getfacl");
     490    if (tmp) {
    489491//      sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary
    490492        asprintf(&command,
     
    495497        paranoid_free(command);
    496498    }
     499    paranoid_free(tmp);
    497500    return (retval);
    498501}
     
    501504int get_fattr_list(char *filelist, char *fattr_fname)
    502505{
    503     char *command;
     506    char *command = NULL;
     507    char *tmp = NULL;
    504508    int retval = 0;
    505509
     
    508512    paranoid_free(command);
    509513
    510     if (find_home_of_exe("getfattr")) {
     514    tmp = find_home_of_exe("getfattr");
     515    if (tmp) {
    511516//      sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary
    512517        retval =
     
    514519                         fattr_fname);
    515520    }
     521    paranoid_free(tmp);
    516522    return (retval);
    517523}
  • trunk/mondo/mondo/common/libmondo-files.c

    r688 r689  
    738738            if (0 == strncmp(fname, "/dev/", 5)) {
    739739                if (is_dev_an_NTFS_dev(fname)) {
    740                     if ( !find_home_of_exe("ntfsresize")) {
     740                    tmp = find_home_of_exe("ntfsresize");
     741                    if (!tmp) {
    741742                        fatal_error("ntfsresize not found");
    742743                    }
     744                    paranoid_free(tmp);
     745
    743746                    asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    744747                    log_it("command = %s", command);
  • trunk/mondo/mondo/common/libmondo-fork.c

    r688 r689  
    510510// BACKUP
    511511    int res = -1;
    512     char*command;
     512    char *command = NULL;
     513    char *tmp = NULL;
    513514
    514515    if (!does_file_exist(input_device)) {
    515516        fatal_error("input device does not exist");
    516517    }
    517     if ( !find_home_of_exe("ntfsclone")) {
     518    tmp = find_home_of_exe("ntfsclone");
     519    if (!tmp) {
    518520        fatal_error("ntfsclone not found");
    519521    }
    520     malloc_string(command);
    521     sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
     522    paranoid_free(tmp);
     523
     524    asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
    522525    res = run_program_and_log_output(command, 5);
    523526    paranoid_free(command);
     527
    524528    unlink(output_fname);
    525529    return (res);
     
    678682// RESTORE
    679683    int res = -1;
    680     char *command;
    681 
    682     if ( !find_home_of_exe("ntfsclone")) {
     684    char *command = NULL;
     685    char *tmp = NULL;
     686
     687    tmp = find_home_of_exe("ntfsclone");
     688    if (!tmp) {
    683689        fatal_error("ntfsclone not found");
    684690    }
     691    paranoid_free(tmp);
     692
    685693    asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
    686694    res = run_program_and_log_output(command, 5);
  • trunk/mondo/mondo/common/libmondo-raid.c

    r688 r689  
    403403 * @return 0 if the line was read and stored successfully, 1 if we're at end of file.
    404404 */
    405 int get_next_raidtab_line(FILE * fin, char *label, char *value)
     405int get_next_raidtab_line(FILE *fin, char *label, char *value)
    406406{
    407407    char *incoming = NULL;
    408     char *p;
     408    char *p = NULL;
    409409    size_t n = 0;
    410410
    411411    assert(fin != NULL);
    412     assert(label != NULL);
    413     assert(value != NULL);
    414 
    415     label[0] = value[0] = '\0';
     412
    416413    if (feof(fin)) {
    417414        return (1);
     
    429426            p++;
    430427        }
    431         strcpy(label, incoming);
    432         strcpy(value, p);
    433         paranoid_free(incoming);
     428        label = incoming;
     429        value = p;
    434430        return (0);
    435431    }
     
    576572                               char *fname)
    577573{
    578     FILE *fin;
    579     char *label;
    580     char *value;
     574    FILE *fin = NULL;
     575    char *label = NULL;
     576    char *value = NULL;
    581577    int items;
    582578    int v;
     
    596592    items = 0;
    597593    log_it("Loading raidtab...");
    598     malloc_string(label);
    599     malloc_string(value);
    600594    get_next_raidtab_line(fin, label, value);
    601595    while (!feof(fin)) {
     
    605599        /* find the 'raiddev' entry, indicating the start of the block of info */
    606600        while (!feof(fin) && strcmp(label, "raiddev")) {
    607             strcpy(raidlist->el[items].additional_vars.el[v].label, label);
    608             strcpy(raidlist->el[items].additional_vars.el[v].value, value);
     601            raidlist->el[items].additional_vars.el[v].label = label;
     602            raidlist->el[items].additional_vars.el[v].value = value;
    609603            v++;
    610604            get_next_raidtab_line(fin, label, value);
     
    616610        }
    617611        log_msg(2, "Record #%d (%s) found", items, value);
    618         strcpy(raidlist->el[items].raid_device, value);
     612        raidlist->el[items].raid_device = value;
    619613        for (get_next_raidtab_line(fin, label, value);
    620614             !feof(fin) && strcmp(label, "raiddev");
     
    628622    log_msg(1, "Raidtab loaded successfully.");
    629623    log_msg(1, "%d RAID devices in raidtab", items);
    630     paranoid_free(label);
    631     paranoid_free(value);
    632624    return (0);
    633625}
     
    644636 */
    645637void
    646 process_raidtab_line(FILE * fin,
     638process_raidtab_line(FILE *fin,
    647639                     struct raid_device_record *raidrec,
    648640                     char *label, char *value)
     
    650642
    651643    /*@ add mallocs * */
    652     char *tmp;
    653     char *labelB;
    654     char *valueB;
    655 
    656     struct list_of_disks *disklist;
    657     int index;
    658     int v;
    659 
    660     malloc_string(labelB);
    661     malloc_string(valueB);
     644    char *tmp = NULL;
     645    char *labelB = NULL;
     646    char *valueB = NULL;
     647
     648    struct list_of_disks *disklist = NULL;
     649    int index = 0;
     650    int v = 0;
     651
    662652    assert(fin != NULL);
    663653    assert(raidrec != NULL);
     
    716706            add_disk_to_raid_device(disklist, value, index);
    717707        }
     708        paranoid_free(labelB);
     709        paranoid_free(valueB);
    718710    } else {
    719711        v = raidrec->additional_vars.entries;
    720         strcpy(raidrec->additional_vars.el[v].label, label);
    721         strcpy(raidrec->additional_vars.el[v].value, value);
     712        raidrec->additional_vars.el[v].label = label;
     713        raidrec->additional_vars.el[v].value = value;
    722714        raidrec->additional_vars.entries = ++v;
    723715    }
    724     paranoid_free(labelB);
    725     paranoid_free(valueB);
    726716}
    727717#endif
  • trunk/mondo/mondo/common/libmondo-stream.c

    r688 r689  
    222222    dev = NULL;
    223223    siz = NULL;
    224     if (find_home_of_exe("cdrecord")) {
     224    tmp = find_home_of_exe("cdrecord");
     225    if (tmp) {
    225226        asprintf(&cdr_exe, "cdrecord");
    226227    } else {
    227228        asprintf(&cdr_exe, "dvdrecord");
    228229    }
     230    paranoid_free(tmp);
     231
    229232    asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
    230233             cdr_exe);
  • trunk/mondo/mondo/common/libmondo-tools.c

    r688 r689  
    348348    char *extra_cdrom_params = NULL;
    349349    char *mondo_mkisofs_sz = NULL;
    350     char *command;
    351     char *hostname, *ip_address;
     350    char *command = NULL;
     351    char *hostname = NULL, *ip_address = NULL;
    352352    int retval = 0;
    353353    long avm = 0;
    354     char *colon;
    355     char *cdr_exe;
    356     char *tmp;
    357     char *tmp1;
     354    char *colon = NULL;
     355    char *cdr_exe = NULL;
     356    char *tmp = NULL;
     357    char *tmp1 = NULL;
    358358    char call_before_iso_user[MAX_STR_LEN] = "\0";
    359359    int rdsiz_MB;
    360     char *iso_path;
     360    char *iso_path = NULL;
    361361
    362362    assert(bkpinfo != NULL);
     
    439439
    440440    if (bkpinfo->backup_media_type == dvd) {
    441         if (!(find_home_of_exe("growisofs"))) {
     441        tmp = find_home_of_exe("growisofs");
     442        if (!tmp) {
    442443            fatal_error("Please install growisofs.");
    443444        }
     445        paranoid_free(tmp);
     446
    444447        if (bkpinfo->nonbootable_backup) {
    445448            asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
     
    502505            }
    503506        }
    504         if (find_home_of_exe("cdrecord")) {
     507        tmp = find_home_of_exe("cdrecord");
     508        tmp1 = find_home_of_exe("dvdrecord");
     509        if (tmp) {
    505510            asprintf(&cdr_exe, "cdrecord");
    506         } else if (find_home_of_exe("dvdrecord")) {
     511        } else if (tmp1) {
    507512            asprintf(&cdr_exe, "dvdrecord");
    508513        } else {
    509514            fatal_error("Please install either cdrecord or dvdrecord.");
    510515        }
     516        paranoid_free(tmp);
     517        paranoid_free(tmp1);
     518
    511519        if (bkpinfo->nonbootable_backup) {
    512520            asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", mrconf->mondo_iso_creation_cmd);
     
    829837
    830838    /*@ buffers ************ */
    831     char *tmp;
     839    char *tmp = NULL;
    832840
    833841    /*@ int's *************** */
     
    913921        /* IA64 always has one vfat partition for EFI even without Windows */
    914922        // retval +=
    915         if (!find_home_of_exe("ms-sys")) {
     923        tmp = find_home_of_exe("ms-sys");
     924        if (!tmp) {
    916925            log_to_screen(_("Please install ms-sys just in case."));
    917926        }
    918 #endif
    919     }
    920 
    921     if (!find_home_of_exe("cmp")) {
    922         if (!find_home_of_exe("true")) {
    923             whine_if_not_found("cmp");
    924         } else {
    925             log_to_screen
    926                 (_("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."));
    927             if (run_program_and_log_output
    928                 ("cp -f `which true` /usr/bin/cmp", 0)) {
    929                 fatal_error("Failed to create dummy 'cmp' file.");
    930             }
    931         }
    932     }
     927        paranoid_free(tmp);
     928#endif
     929    }
     930
     931    tmp = find_home_of_exe("cmp");
     932    if (!tmp) {
     933        whine_if_not_found("cmp");
     934    }
     935    paranoid_free(tmp);
     936
    933937    run_program_and_log_output
    934938        ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
  • trunk/mondo/mondo/mondoarchive/mondo-cli.c

    r688 r689  
    216216
    217217    /*@ buffers ** */
    218     char *tmp;
    219     char *tmp1;
    220     char *psz;
    221     char *p;
    222     char *q;
     218    char *tmp = NULL;
     219    char *tmp1 = NULL;
     220    char *psz = NULL;
     221    char *p = NULL;
     222    char *q = NULL;
    223223
    224224    long itbs;
     
    263263    }
    264264
    265     if (!find_home_of_exe("afio")) {
    266         if (find_home_of_exe("star")) {
     265    tmp = find_home_of_exe("afio");
     266    tmp1 = find_home_of_exe("star");
     267    if (!tmp) {
     268        if (tmp1) {
    267269            flag_set['R'] = TRUE;
    268270            log_msg(1, "Using star instead of afio");
     
    272274        }
    273275    }
     276    paranoid_free(tmp);
    274277
    275278    if (flag_set['R']) {
     
    278281            fatal_error("You may not use star and lzop at the same time.");
    279282        }
    280         if (!find_home_of_exe("star")) {
     283        if (!tmp1) {
    281284            fatal_error
    282285                ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    283286        }
    284287    }
     288    paranoid_free(tmp1);
     289
    285290    if (flag_set['W']) {
    286291        bkpinfo->nonbootable_backup = TRUE;
     
    432437            }
    433438        }
    434         if (!find_home_of_exe("growisofs")) {
     439        tmp = find_home_of_exe("growisofs");
     440        if (!tmp) {
    435441            fatal_error
    436442                ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    437443        }
    438         if (!find_home_of_exe("dvd+rw-format")) {
     444        paranoid_free(tmp);
     445
     446        tmp = find_home_of_exe("dvd+rw-format");
     447        if (!tmp) {
    439448            fatal_error
    440449                ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    441450        }
     451        paranoid_free(tmp);
     452
    442453        if (strchr(flag_val['d'], ',')) {
    443454            fatal_error
  • trunk/mondo/mondo/mondorestore/mondo-prep.c

    r688 r689  
    203203    iamhere("STARTING");
    204204    log_msg(1, "OK, opened i-want-my-lvm. Shutting down LVM volumes...");
    205     if (find_home_of_exe("lvm"))    // found it :) cool
     205    tmp = find_home_of_exe("lvm");
     206    if (tmp)    // found it :) cool
    206207    {
    207208        asprintf(&lvscan_sz, "lvm lvscan");
     
    219220        asprintf(&vgremove_sz, "vgremove");
    220221    }
     222    paranoid_free(tmp);
     223
    221224    asprintf(&command,
    222225            "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> "
  • trunk/mondo/mondo/mondorestore/mondo-restore.c

    r688 r689  
    20492049        asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    20502050        asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
    2051         if (length_of_file(acl_fname) > 0 && find_home_of_exe("setfacl")) {
     2051        tmp = find_home_of_exe("setfacl");
     2052        if (length_of_file(acl_fname) > 0 && tmp) {
    20522053            set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
    20532054        }
    2054         if (length_of_file(xattr_fname) > 0
    2055             && find_home_of_exe("setfattr")) {
     2055        paranoid_free(tmp);
     2056
     2057        tmp = find_home_of_exe("setfattr");
     2058        if (length_of_file(xattr_fname) > 0 && tmp) {
    20562059            set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
    20572060        }
     2061        paranoid_free(tmp);
    20582062        paranoid_free(acl_fname);
    20592063        paranoid_free(xattr_fname);
     
    25662570    log_msg(1, "path is now %s", newpath);
    25672571    log_msg(1, "restoring everything");
    2568     if (!find_home_of_exe("petris") && !g_text_mode) {
     2572    tmp = find_home_of_exe("petris");
     2573    if (!tmp && !g_text_mode) {
    25692574        newtDrawRootText(0, g_noof_rows - 2,
    25702575                         _
     
    25722577        newtRefresh();
    25732578    }
     2579    paranoid_free(tmp);
     2580
    25742581    mvaddstr_and_log_it(g_currentY, 0,
    25752582                        _("Preparing to read your archives"));
  • trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c

    r688 r689  
    6868        return (1);
    6969    }
     70    paranoid_free(tmp1);
     71
    7072    fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin);
    7173    paranoid_fclose(fin);
     
    251253
    252254    if (compressor_exe != NULL) {
    253         if (!find_home_of_exe(compressor_exe)) {
     255        tmp = find_home_of_exe(compressor_exe);
     256        if (!tmp) {
    254257            fatal_error("(compare_a_tarball) Compression program missing");
    255258        }
     259        paranoid_free(tmp);
    256260        if (use_star) {
    257261            if (strcmp(compressor_exe, "bzip2")) {
  • trunk/mondo/mondo/mondorestore/mondo-rstr-tools.c

    r688 r689  
    659659        asprintf(&p1, "-o ro");
    660660    }
    661     if (find_home_of_exe("setfattr")) {
     661    tmp = find_home_of_exe("setfattr");
     662    if (tmp) {
    662663        asprintf(&p2, ",user_xattr");
    663664    } else {
    664665        asprintf(&p2, "");
    665666    }
    666     if (find_home_of_exe("setfacl")) {
     667    paranoid_free(tmp);
     668
     669    tmp = find_home_of_exe("setfacl");
     670    if (tmp) {
    667671        asprintf(&p3, ",acl");
    668672    } else {
    669673        asprintf(&p3, "");
    670674    }
     675    paranoid_free(tmp);
     676
    671677    asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);
    672678    paranoid_free(p1);
     
    13741380{
    13751381    char *output = NULL;
     1382    char *tmp = NULL;
    13761383
    13771384    /* BERLIOS: This should use $EDITOR + conf file rather first */
    1378     if (find_home_of_exe("pico")) {
     1385    tmp = find_home_of_exe("pico");
     1386    if (tmp) {
    13791387        asprintf(&output, "pico");
    1380     } else if (find_home_of_exe("nano")) {
    1381         asprintf(&output, "nano");
    1382     } else if (find_home_of_exe("e3em")) {
    1383         asprintf(&output, "e3em");
    1384     } else if (find_home_of_exe("e3vi")) {
    1385         asprintf(&output, "e3vi");
    1386     } else {
    1387         asprintf(&output, "vi");
    1388     }
    1389     if (!find_home_of_exe(output)) {
     1388    } else {
     1389        tmp = find_home_of_exe("nano");
     1390        if (tmp) {
     1391            asprintf(&output, "nano");
     1392        } else {
     1393            tmp = find_home_of_exe("vi");
     1394            if (tmp) {
     1395                asprintf(&output, "vi");
     1396            } else {
     1397                asprintf(&output, "emacs");
     1398            }
     1399        }
     1400    }
     1401    paranoid_free(tmp);
     1402
     1403    tmp = find_home_of_exe(output);
     1404    if (!tmp) {
    13901405        log_msg(2, " (find_my_editor) --- warning - %s not found", output);
    13911406    }
     1407    paranoid_free(tmp);
    13921408    return (output);
    13931409}
Note: See TracChangeset for help on using the changeset viewer.