Changeset 2383 in MondoRescue for branches/2.2.10/mondo/src/mondorestore


Ignore:
Timestamp:
Sep 10, 2009, 2:55:51 AM (15 years ago)
Author:
Bruno Cornec
Message:

call_program_and_get_last_line_of_output is now allocating memory and returning that string

Location:
branches/2.2.10/mondo/src/mondorestore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2376 r2383  
    336336            if (lvmversion == 2) {
    337337                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    338                 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
     338                tmp = call_program_and_get_last_line_of_output(tmp1);
    339339                mr_free(tmp1);
    340340            } else {
    341341                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    342                 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(tmp1));
     342                tmp = call_program_and_get_last_line_of_output(tmp1);
    343343                mr_free(tmp1);
    344344            }
     
    14141414    char *format = NULL;
    14151415    char *tmp = NULL;
     1416    char *tmp1 = NULL;
    14161417
    14171418    /** end *************************************************************/
     
    15781579    if (pout_to_fdisk) {
    15791580        // mark relevant partition as bootable
    1580         mr_asprintf(tmp, "a\n%s\n", call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy"));
     1581        tmp1 = call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy");
     1582        mr_asprintf(tmp, "a\n%s\n", tmp1);
     1583        mr_free(tmp1);
     1584
    15811585        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    15821586        mr_free(tmp);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2382 r2383  
    756756        }
    757757   
    758         if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
     758        tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     759        if (strstr(tmp, "pxe")) {
    759760            /* We need to override prefix value in PXE mode as it's
    760761            * already done in start-netfs */
     
    766767            mr_asprintf(bkpinfo->prefix, "%s", envtmp1);
    767768        }
     769        mr_free(tmp);
    768770
    769771    } else if (!strcmp(value, "tape")) {
     
    939941
    940942tmp = read_cfg_var(g_mondo_cfg_file, "please-dont-eject");
    941 if (tmp || strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "donteject")) {
     943tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     944if (tmp || strstr(tmp1, "donteject")) {
    942945    bkpinfo->please_dont_eject = TRUE;
    943946    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    944947}
    945948mr_free(tmp);
     949mr_free(tmp1);
    946950
    947951if (bkpinfo->backup_media_type == netfs) {
     
    971975        }
    972976    }
    973     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "pxe")) {
     977    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     978    if (strstr(tmp1, "pxe")) {
     979        mr_free(tmp1);
    974980        /* We need to override values in PXE mode as it's
    975981        * already done in start-netfs */
     
    987993        mr_free(bkpinfo->netfs_remote_dir);
    988994        mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2);
    989     }
     995    } else {
     996        mr_free(tmp1);
     997    }
     998
    990999} else if (bkpinfo->backup_media_type == iso) {
    9911000    /* Patch by Conor Daly 23-june-2004
     
    10251034            mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    10261035            log_it("command = %s", command);
    1027             log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    1028             mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     1036            iso_mnt = call_program_and_get_last_line_of_output(command);
     1037            log_it("res of it = %s", iso_mnt);
    10291038            mr_free(command);
    10301039        } else {
     
    21742183    char *mounted_cfgf_path;
    21752184    char *tmp = NULL;
     2185    char *tmp1 = NULL;
    21762186    char *mountpt = NULL;
    21772187    char *ramdisk_fname;
     
    22902300    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    22912301        log_msg(1, "gcffa --- great! We've got the config file");
    2292         mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2302        tmp = call_program_and_get_last_line_of_output("pwd");
     2303        mr_strcat(tmp, "/%s", MONDO_CFG_FILE_STUB);
    22932304        mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
    22942305        log_it("%s",command);
     
    23002311        mr_free(command);
    23012312
    2302         mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"),
    2303             MOUNTLIST_FNAME_STUB, mountlist_file);
     2313        tmp1 = call_program_and_get_last_line_of_output("pwd");
     2314        mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);
     2315        mr_free(tmp1);
     2316
    23042317        log_it("%s",command);
    23052318        if (extract_mountlist_stub) {
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2382 r2383  
    470470    log_it("Done loading config file; resizing ML");
    471471
    472     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
     472    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     473    if (strstr(tmp1, "noresize")) {
    473474        log_msg(1, "Not resizing mountlist.");
    474475    } else {
    475476        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    476477    }
     478    mr_free(tmp1);
     479
    477480    for (done = FALSE; !done;) {
    478481        log_it("About to edit mountlist");
     
    750753    int res = 0;
    751754    bool boot_loader_installed = FALSE;
    752   /** malloc **/
    753755    char *tmp = NULL;
     756    char *tmp1 = NULL;
    754757    char *flaws_str = NULL;
    755758
     
    762765    get_cfg_file_from_archive_or_bust();
    763766    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    764     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
     767
     768    tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     769    if (strstr(tmp, "noresize")) {
    765770        log_msg(2, "Not resizing mountlist.");
    766771    } else {
    767772        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    768773    }
     774    mr_free(tmp);
     775
    769776    flaws_str = evaluate_mountlist(mountlist, &res);
    770777    if (!res) {
     
    795802            twenty_seconds_til_yikes();
    796803            g_fprep = fopen("/tmp/prep.sh", "w");
    797             if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "nopart")) {
    798                 log_msg(2,
    799                         "Not partitioning drives due to 'nopart' option.");
     804            tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     805            if (strstr(tmp, "nopart")) {
     806                log_msg(2, "Not partitioning drives due to 'nopart' option.");
    800807                res = 0;
    801808            } else {
    802809                res = partition_everything(mountlist);
    803810                if (res) {
    804                     log_to_screen
    805                         ("Warning. Errors occurred during partitioning.");
     811                    log_to_screen("Warning. Errors occurred during partitioning.");
    806812                    res = 0;
    807813                }
    808814            }
     815            mr_free(tmp);
     816
    809817            retval += res;
    810818            if (!res) {
     
    867875
    868876  after_the_nuke:
     877    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
    869878    if (retval) {
    870879        log_to_screen("Errors occurred during the nuke phase.");
    871     } else if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "RESTORE")) {
    872         log_to_screen
    873             ("PC was restored successfully. Thank you for using Mondo Rescue.");
    874         log_to_screen
    875             ("Please visit our website at http://www.mondorescue.org for more information.");
     880    } else if (tmp1, "RESTORE")) {
     881        log_to_screen("PC was restored successfully. Thank you for using Mondo Rescue.");
     882        log_to_screen("Please visit our website at http://www.mondorescue.org for more information.");
    876883    } else {
    877884        mr_asprintf(tmp,"%s","Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
     
    882889        log_to_screen("Please visit our website at http://www.mondorescue.org for more information.");
    883890    }
     891    mr_free(tmp1);
     892
    884893    g_I_have_just_nuked = TRUE;
    885894    return (retval);
     
    26182627    /* Configure global variables */
    26192628    malloc_libmondo_global_strings();
    2620     if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "textonly"))
    2621     {
     2629    tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
     2630    if (strstr(tmp1, "textonly")) {
    26222631        g_text_mode = TRUE;
    26232632        log_msg(1, "TEXTONLY MODE");
     
    26252634        g_text_mode = FALSE;
    26262635    }                           // newt :-)
     2636    mr_free(tmp1);
    26272637
    26282638    /* Init GUI */
    26292639    setup_newt_stuff();         /* call newtInit and setup screen log */
    26302640
    2631     strcpy(g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore"));
     2641    tmp1 = call_program_and_get_last_line_of_output("which mondorestore");
     2642    strcpy(g_mondo_home, tmp1);
     2643    mr_free(tmp1);
     2644
    26322645    g_current_media_number = 1; // precaution
    26332646
Note: See TracChangeset for help on using the changeset viewer.