Changeset 2328 in MondoRescue


Ignore:
Timestamp:
Aug 18, 2009, 3:20:42 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3339@localhost: bruno | 2009-08-11 23:56:01 +0200
bkpinfo->kernel_path, bkpinfo->call_before_iso, bkpinfo->call_make_iso, bkpinfo->call_burn_iso, bkpinfo->call_after_iso and bkpinfo->postnuke_tarball are now dynamically allocated

Location:
branches/2.2.10/mondo/src/common
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2327 r2328  
    438438    copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists
    439439#if __FreeBSD__ == 5
    440     strcpy(bkpinfo->kernel_path, "/boot/kernel/kernel");
     440    mr_asprintf(bkpinfo->kernel_path, "/boot/kernel/kernel");
    441441#elif __FreeBSD__ == 4
    442     strcpy(bkpinfo->kernel_path, "/kernel");
     442    mr_asprintf(bkpinfo->kernel_path, "/kernel");
    443443#elif linux
    444     if (figure_out_kernel_path_interactively_if_necessary
    445         (bkpinfo->kernel_path)) {
    446         fatal_error
    447             ("Kernel not found. Please specify manually with the '-k' switch.");
     444    if (figure_out_kernel_path_interactively_if_necessary(bkpinfo->kernel_path)) {
     445        fatal_error("Kernel not found. Please specify manually with the '-k' switch.");
    448446    }
    449447#else
     
    16611659    chdir(bkpinfo->scratchdir);
    16621660
    1663     if (bkpinfo->call_before_iso[0] != '\0') {
     1661    if (bkpinfo->call_before_iso) {
    16641662        mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number);
    16651663        res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     
    16751673    }
    16761674
    1677     if (bkpinfo->call_make_iso[0] != '\0') {
     1675    if (bkpinfo->call_make_iso) {
    16781676        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    16791677        mds = media_descriptor_string(bkpinfo->backup_media_type);
     
    17471745                }
    17481746                pause_for_N_seconds(5, "Letting DVD drive settle");
    1749                 res =
    1750                     eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1747                res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17511748                retval += res;
    17521749                if (!bkpinfo->please_dont_eject) {
     
    18461843    }
    18471844
    1848     if (bkpinfo->call_burn_iso[0] != '\0') {
     1845    if (bkpinfo->call_burn_iso) {
    18491846        log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
    18501847        mds = media_descriptor_string(bkpinfo->backup_media_type);
     
    18521849        mr_free(mds);
    18531850        pause_and_ask_for_cdr(2, &cd_is_mountable);
    1854         res =
    1855             eval_call_to_make_ISO(bkpinfo->call_burn_iso,
    1856                                   destfile, g_current_media_number,
    1857                                   MONDO_LOGFILE, message_to_screen);
     1851        res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18581852        if (res) {
    18591853            mr_strcat(message_to_screen, "...failed");
     
    18671861    }
    18681862
    1869     if (bkpinfo->call_after_iso[0] != '\0') {
     1863    if (bkpinfo->call_after_iso) {
    18701864        mds = media_descriptor_string(bkpinfo->backup_media_type);
    18711865        mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
    18721866        mr_free(mds);
    1873         res =
    1874             eval_call_to_make_ISO(bkpinfo->call_after_iso,
    1875                                   destfile, g_current_media_number,
    1876                                   MONDO_LOGFILE, message_to_screen);
     1867        res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18771868        if (res) {
    18781869            mr_strcat(message_to_screen, "...failed");
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2327 r2328  
    11811181
    11821182    if ((flag_set['k']) && (! bkpinfo->restore_data)) {
    1183         strncpy(bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN);
     1183        mr_asprintf(bkpinfo->kernel_path, "%s", flag_val['k']);
    11841184        if (!strcmp(bkpinfo->kernel_path, "failsafe")) {
    1185             strcpy(bkpinfo->kernel_path, "FAILSAFE");
    1186         }
    1187         if (strcmp(bkpinfo->kernel_path, "FAILSAFE")
    1188             && !does_file_exist(bkpinfo->kernel_path)) {
     1185            mr_free(bkpinfo->kernel_path);
     1186            mr_asprintf(bkpinfo->kernel_path, "FAILSAFE");
     1187        }
     1188        if (strcmp(bkpinfo->kernel_path, "FAILSAFE") && !does_file_exist(bkpinfo->kernel_path)) {
    11891189            retval++;
    11901190            log_to_screen("You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
     
    12931293
    12941294    if ((flag_set['A']) && (! bkpinfo->restore_data)) {
    1295         strncpy(bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN);
     1295        mr_asprintf(bkpinfo->call_after_iso, "%s", flag_val['A']);
    12961296    }
    12971297
    12981298    if ((flag_set['B']) && (! bkpinfo->restore_data)) {
    1299         strncpy(bkpinfo->call_before_iso, flag_val['B'], MAX_STR_LEN);
     1299        mr_asprintf(bkpinfo->call_before_iso, "%s", flag_val['B']);
    13001300    }
    13011301
     
    13141314#  endif
    13151315#endif
    1316         if (!strchr
    1317             (BOOT_LOADER_CHARS,
    1318              (bkpinfo->boot_loader = flag_val['l'][0]))) {
    1319             log_msg(1, "%c? WTF is %c? I need G, L, E or R.",
    1320                     bkpinfo->boot_loader, bkpinfo->boot_loader);
    1321             fatal_error
    1322                 ("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
     1316        if (!strchr(BOOT_LOADER_CHARS, (bkpinfo->boot_loader = flag_val['l'][0]))) {
     1317            log_msg(1, "%c? What is %c? I need G, L, E or R.", bkpinfo->boot_loader, bkpinfo->boot_loader);
     1318            fatal_error("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
    13231319        }
    13241320#undef BOOT_LOADER_CHARS
     
    13311327
    13321328    if ((flag_set['P']) && (! bkpinfo->restore_data)) {
    1333         strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN);
     1329        mr_free(bkpinfo->postnuke_tarball);
     1330        mr_asprintf(bkpinfo->postnuke_tarball, "%s", flag_val['P']);
    13341331    }
    13351332
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2327 r2328  
    19391939#endif
    19401940        {
    1941             strcpy(bkpinfo->kernel_path, "FAILSAFE");
     1941            mr_free(bkpinfo->kernel_path);
     1942            mr_asprintf(bkpinfo->kernel_path, "FAILSAFE");
    19421943        }
    19431944
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2327 r2328  
    274274    char *command = NULL;;
    275275
    276     if (!kernel[0]) {
    277         strcpy(kernel,
    278                call_program_and_get_last_line_of_output
    279                ("mindi --findkernel 2> /dev/null"));
     276    if (kernel == NULL) {
     277        mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
    280278    }
    281279    // If we didn't get anything back, check whether mindi raised a fatal error
     
    294292    log_it("Calling Mindi with kernel path of '%s'", kernel);
    295293    while (!kernel[0]) {
    296         if (!ask_me_yes_or_no
    297             ("Kernel not found or invalid. Choose another?")) {
     294        if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?")) {
    298295            return (1);
    299296        }
     
    302299            fatal_error("Kernel not found. Please specify with the '-k' flag.");
    303300        }
    304         strcpy(kernel, tmp);
    305         mr_free(tmp);
     301        mr_free(kernel);
     302        kernel = tmp;
    306303
    307304        log_it("User says kernel is at %s", kernel);
     
    10541051    mr_free(command);
    10551052
    1056     if (bkpinfo->postnuke_tarball[0]) {
     1053    if (bkpinfo->postnuke_tarball) {
    10571054        mr_asprintf(command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    10581055        res = run_program_and_log_output(command, FALSE);
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2327 r2328  
    418418    char *tmp = NULL;
    419419    char *p = NULL;
    420     char call_before_iso_user[MAX_STR_LEN] = "\0";
     420    char call_before_iso_user = NULL;
    421421    char *iso_dev = NULL;
    422422    char *iso_mnt = NULL;
     
    529529                return(1);
    530530            }
    531             sprintf(bkpinfo->call_make_iso,
    532                     "%s %s -Z %s . 2>> _ERR_",
    533                     mondo_mkisofs_sz,
    534                     "", bkpinfo->media_device);
     531            mr_free(bkpinfo->call_make_iso);
     532            mr_asprintf(bkpinfo->call_make_iso, "%s %s -Z %s . 2>> _ERR_", mondo_mkisofs_sz, "", bkpinfo->media_device);
    535533            paranoid_free(mondo_mkisofs_sz);
    536534        }
     
    544542            mr_free(command);
    545543        }
    546         log_msg(2, "call_make_iso (DVD res) is ... %s",
    547                 bkpinfo->call_make_iso);
     544        log_msg(2, "call_make_iso (DVD res) is ... %s", bkpinfo->call_make_iso);
    548545    }                           // end of DVD code
    549546
     
    585582            mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);
    586583        }
     584
     585        mr_free(bkpinfo->call_make_iso);
    587586        if (bkpinfo->manual_cd_tray) {
    588             if (bkpinfo->call_before_iso[0] == '\0') {
    589             sprintf(bkpinfo->call_before_iso,
    590                         "%s -o %s/"MONDO_TMPISOS" . 2>> _ERR_",
    591                         mondo_mkisofs_sz, bkpinfo->tmpdir);
    592                 } else {
    593                 strncpy(call_before_iso_user, bkpinfo->call_before_iso, MAX_STR_LEN);
    594                 sprintf (bkpinfo->call_before_iso,
    595                                     "( %s -o %s/"MONDO_TMPISOS" . 2>> _ERR_ ; %s )",
    596                         mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user);
     587            if (bkpinfo->call_before_iso == NULL) {
     588                mr_asprintf(bkpinfo->call_before_iso, "%s -o %s/"MONDO_TMPISOS" . 2>> _ERR_", mondo_mkisofs_sz, bkpinfo->tmpdir);
     589            } else {
     590                mr_asprintf(call_before_iso_user, "%s", bkpinfo->call_before_iso);
     591                mr_free(bkpinfo->call_before_iso);
     592                mr_asprintf(bkpinfo->call_before_iso, "( %s -o %s/"MONDO_TMPISOS" . 2>> _ERR_ ; %s )", mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user);
     593                mr_free(call_before_iso_user);
    597594            }
    598595            log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso);
     
    600597                return(1);
    601598            }
    602             sprintf(bkpinfo->call_make_iso,
    603                     "%s %s -v %s fs=4m dev=%s speed=%d %s/"MONDO_TMPISOS,
    604                     cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject",
    605                     extra_cdrom_params, bkpinfo->media_device,
    606                     bkpinfo->cdrw_speed, bkpinfo->tmpdir);
     599            mr_asprintf(bkpinfo->call_make_iso, "%s %s -v %s fs=4m dev=%s speed=%d %s/"MONDO_TMPISOS, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed, bkpinfo->tmpdir);
    607600        } else {
    608             sprintf(bkpinfo->call_make_iso,
    609                     "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -",
    610                     mondo_mkisofs_sz, cdr_exe,
    611                     (bkpinfo->please_dont_eject) ? " " : "-eject",
    612                     extra_cdrom_params, bkpinfo->media_device,
    613                     bkpinfo->cdrw_speed);
     601            mr_asprintf(bkpinfo->call_make_iso, "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", mondo_mkisofs_sz, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed);
    614602        }
    615603        paranoid_free(mondo_mkisofs_sz);
     
    810798    mr_free(bkpinfo->exclude_paths);
    811799    mr_free(bkpinfo->restore_path);
     800    mr_free(bkpinfo->call_before_iso);
     801    mr_free(bkpinfo->call_make_iso);
     802    mr_free(bkpinfo->call_burn_iso);
     803    mr_free(bkpinfo->call_after_iso);
     804    mr_free(bkpinfo->kernel_path);
    812805    mr_free(bkpinfo->nfs_mount);
    813806    mr_free(bkpinfo->nfs_remote_dir);
    814807    mr_free(bkpinfo->nfs_user);
     808    mr_free(bkpinfo->postnuke_tarball);
    815809
    816810    /* Then free the structure */
     
    860854    bkpinfo->exclude_paths = NULL;
    861855    bkpinfo->restore_path = NULL;
    862     bkpinfo->call_before_iso[0] = '\0';
    863     bkpinfo->call_make_iso[0] = '\0';
    864     bkpinfo->call_burn_iso[0] = '\0';
    865     bkpinfo->call_after_iso[0] = '\0';
    866     bkpinfo->kernel_path[0] = '\0';
     856    bkpinfo->call_before_iso = NULL;
     857    bkpinfo->call_make_iso = NULL;
     858    bkpinfo->call_burn_iso = NULL;
     859    bkpinfo->call_after_iso = NULL;
     860    bkpinfo->kernel_path = NULL;
    867861    bkpinfo->nfs_mount = NULL;
    868862    bkpinfo->nfs_remote_dir = NULL;
    869863    bkpinfo->nfs_user = NULL;
    870     bkpinfo->postnuke_tarball[0] = '\0';
     864    bkpinfo->postnuke_tarball = NULL;
    871865    bkpinfo->wipe_media_first = FALSE;
    872866    bkpinfo->differential = 0;
  • branches/2.2.10/mondo/src/common/mondostructures.h

    r2327 r2328  
    524524   * A command to call BEFORE making an ISO image.
    525525   */
    526     char call_before_iso[MAX_STR_LEN];
     526    char *call_before_iso;
    527527
    528528  /**
    529529   * A command to call to make an ISO image.
    530530   */
    531     char call_make_iso[MAX_STR_LEN];
     531    char *call_make_iso;
    532532
    533533  /**
    534534   * A command to call to burn the ISO image.
    535535   */
    536     char call_burn_iso[MAX_STR_LEN];
     536    char *call_burn_iso;
    537537
    538538  /**
    539539   * A command to call AFTER making an ISO image.
    540    */
    541     char call_after_iso[MAX_STR_LEN];
     540   * BERLIOS: Never initialized in code !!
     541   */
     542    char *call_after_iso;
    542543
    543544  /**
     
    545546   * included with Mindi.
    546547   */
    547     char kernel_path[MAX_STR_LEN];
     548    char *kernel_path;
    548549
    549550  /**
     
    570571   * after nuking the system. If "", do not use a post-nuke tarball.
    571572   */
    572     char postnuke_tarball[MAX_STR_LEN];
     573    char *postnuke_tarball;
    573574
    574575  /**
Note: See TracChangeset for help on using the changeset viewer.