Ignore:
Timestamp:
Jul 22, 2009, 2:11:26 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • Fix a printing error in mindi for the tar command
  • Fix all mr_asprintf which had no second param as a string

(report bug fix done originaly in 2.2.9)

File:
1 edited

Legend:

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

    r2286 r2291  
    226226        log_msg(5, "command='%s'", command);
    227227        res = system(command);
    228         mr_asprintf(&tmp, last_line_of_file(MONDO_LOGFILE));
     228        mr_asprintf(&tmp, "%s", last_line_of_file(MONDO_LOGFILE));
    229229        log_msg(1, "res=%d; tmp='%s'", res, tmp);
    230230        if (bkpinfo->use_star && (res == 254 || res == 65024)
     
    541541
    542542    assert(bkpinfo != NULL);
    543     mr_asprintf(&tmp,
    544             "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
     543    mr_asprintf(&tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    545544            bkpinfo->exclude_paths);
    546545    mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp));
     
    624623
    625624#ifdef __FreeBSD__
    626         mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     625        mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    627626               ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
    628627        if (!bootdev[0]) {
    629628            mr_free(bootdev);
    630             mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     629            mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    631630                   ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
    632631        }
     
    634633        /* Linux */
    635634#ifdef __IA64__
    636         mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     635        mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    637636               ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    638637#else
    639         mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     638        mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    640639               ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    641640#endif
     
    643642            mr_free(bootdev);
    644643#ifdef __IA64__
    645             mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     644            mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    646645                   ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    647646#else
    648             mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     647            mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    649648                   ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    650649#endif
     
    652651        if (!bootdev[0]) {
    653652            mr_free(bootdev);
    654             mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     653            mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    655654                   ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    656655            if (strstr(bootdev, "/dev/cciss/")) {
    657656                mr_free(bootdev);
    658                 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output
     657                mr_asprintf(&bootdev, "%s", call_program_and_get_last_line_of_output
    659658                       ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
    660659            }
     
    667666            ch = 'U';
    668667        if (bkpinfo->boot_loader != '\0') {
    669             mr_asprintf(&tmp, "User specified boot loader. It is '%c'.",
    670                     bkpinfo->boot_loader);
     668            mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
    671669            log_msg(2, tmp);
    672670            mr_free(tmp);
     
    675673        }
    676674        if (bkpinfo->boot_device[0] != '\0') {
    677             mr_asprintf(&tmp, "User specified boot device. It is '%s'.",
    678                     bkpinfo->boot_device);
     675            mr_asprintf(&tmp, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    679676            log_msg(2, tmp);
    680677            mr_free(tmp);
     
    761758        mr_asprintf(&bootldr_str, "unknown");
    762759    }
    763     mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s",
    764             bootldr_str, bkpinfo->boot_device);
     760    mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
    765761    log_to_screen(tmp);
    766762    mr_free(tmp);
     
    862858    estimated_total_noof_slices =
    863859        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    864 /* add nfs stuff here? */
     860    /* add nfs stuff here? */
    865861    mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
    866862    if (system(command)) {
     
    14951491                mr_free(media_usage_comment);
    14961492                if (res) {
    1497                     mr_asprintf(&tmp,
    1498                         "Failed to add archive %ld's files to CD dir\n",
     1493                    mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    14991494                        storing_set_no);
    15001495                    log_to_screen(tmp);
     
    17861781                }
    17871782                pause_for_N_seconds(5, "Letting DVD drive settle");
    1788                 mr_asprintf(&sz_blank_disk, "dvd+rw-format -force %s",
    1789                         bkpinfo->media_device);
     1783                mr_asprintf(&sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
    17901784                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
    17911785                res =
     
    19761970    bool ret = TRUE;
    19771971
    1978     mr_asprintf(&command,
    1979             "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1",
    1980             bigfile_fname);
     1972    mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname);
    19811973    log_msg(1, "command = '%s'", command);
    19821974    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     
    20972089                        "Calling ntfsclone in background because %s is an NTFS partition",
    20982090                        bigfile_fname);
    2099                 mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    2100                         bkpinfo->tmpdir,
     2091                mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir,
    21012092                        (int) (random() % 32768),
    21022093                        (int) (random() % 32768));
     
    22252216        log_msg(1, "EXAT'g set %ld", curr_set_no);
    22262217        if (g_getfattr) {
    2227             mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    2228                 bkpinfo->tmpdir, curr_set_no);
     2218            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, curr_set_no);
    22292219            get_fattr_list(curr_filelist_fname, curr_xattr_list_fname);
    22302220        }
    22312221        if (g_getfacl) {
    2232             mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    2233                 bkpinfo->tmpdir, curr_set_no);
     2222            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, curr_set_no);
    22342223            get_acl_list(curr_filelist_fname, curr_acl_list_fname);
    22352224        }
     
    22412230        retval += res;
    22422231        if (res) {
    2243             mr_asprintf(&tmp,
    2244                     "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
    2245                     curr_set_no);
     2232            mr_asprintf(&tmp, "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
    22462233            log_to_screen(tmp);
    22472234            mr_free(tmp);
     
    22952282
    22962283        if (res) {
    2297             mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    2298                     curr_set_no);
     2284            mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", curr_set_no);
    22992285            log_to_screen(tmp);
    23002286            mr_free(tmp);
     
    25052491            continue;
    25062492        }
    2507         mr_asprintf(&curr_file, cf);
     2493        mr_asprintf(&curr_file, "%s", cf);
    25082494        if (!does_file_exist(curr_file)) {
    25092495            log_msg(1,
     
    25342520            continue;
    25352521        }
    2536         mr_asprintf(&curr_file, cf);
     2522        mr_asprintf(&curr_file, "%s", cf);
    25372523
    25382524        mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file, bkpinfo->scratchdir);
     
    26092595            continue;
    26102596        }
    2611         mr_asprintf(&curr_file, cf);
     2597        mr_asprintf(&curr_file, "%s", cf);
    26122598        if (!does_file_exist(curr_file)) {
    26132599            log_msg(1,
     
    26672653    char *cdrecord = NULL;
    26682654
    2669     mr_asprintf(&bkp, cdrw_dev);
     2655    mr_asprintf(&bkp, "%s", cdrw_dev);
    26702656    if (find_cdrw_device(cdrw_dev)) {
    26712657        strcpy(cdrw_dev, bkp);
     
    28262812        eject_device(cdrom_dev);
    28272813        mds = media_descriptor_string(g_backup_media_type);
    2828         mr_asprintf(&tmp,
    2829                 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
     2814        mr_asprintf(&tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    28302815                mds, g_current_media_number, mds);
    28312816        mr_free(mds);
     
    29952980        mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    29962981        log_it("command = %s", command);
    2997         mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));
     2982        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    29982983        mr_free(command);
    29992984        log_it("res of it = %s", tmp);
     
    30283013    strcpy(biggiestruct.checksum, checksum_line);
    30293014
    3030     mr_asprintf(&tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
     3015    mr_asprintf(&tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
    30313016    fout = fopen(tmp, "w");
    30323017    if (fout == NULL) {
     
    30693054    }
    30703055    for (slice_num = 1; !finished; slice_num++) {
    3071         mr_asprintf(&curr_slice_fname_uncompressed, "%s",
    3072                slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir,
    3073                            ""));
    3074         mr_asprintf(&curr_slice_fname_compressed, "%s",
    3075                slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir,
    3076                            suffix));
    3077 
    3078         mr_asprintf(&tmp, percent_media_full_comment());
     3056        mr_asprintf(&curr_slice_fname_uncompressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""));
     3057        mr_asprintf(&curr_slice_fname_compressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix));
     3058
     3059        mr_asprintf(&tmp, "%s", percent_media_full_comment());
    30793060        update_progress_form(tmp);
    30803061        paranoid_free(tmp);
     
    31083089            }
    31093090            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
    3110                 mr_asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,
    3111                         bkpinfo->compression_level,
    3112                         curr_slice_fname_uncompressed);
     3091                mr_asprintf(&command, "%s -%d %s", bkpinfo->zip_exe, bkpinfo->compression_level, curr_slice_fname_uncompressed);
    31133092                log_msg(2, command);
    31143093                if ((res = system(command))) {
     
    31173096                //          did_I_compress_slice = TRUE;
    31183097            } else {
    3119                 mr_asprintf(&command, "mv %s %s 2>> %s",
    3120                         curr_slice_fname_uncompressed,
    3121                         curr_slice_fname_compressed, MONDO_LOGFILE);
     3098                mr_asprintf(&command, "mv %s %s 2>> %s", curr_slice_fname_uncompressed, curr_slice_fname_compressed, MONDO_LOGFILE);
    31223099                res = 0;        // don't do it :)
    31233100                //          did_I_compress_slice = FALSE;
     
    31373114                mr_asprintf(&tmp, "Problem with slice # %ld", slice_num);
    31383115            } else {
    3139                 mr_asprintf(&tmp,
    3140                         "%s - Bigfile #%ld, slice #%ld compressed OK          ",
    3141                         biggie_filename, biggie_file_number + 1,
     3116                mr_asprintf(&tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1,
    31423117                        slice_num);
    31433118            }
     
    31543129            paranoid_free(tmp);
    31553130
    3156             mr_asprintf(&file_to_archive, curr_slice_fname_compressed);
     3131            mr_asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
    31573132            g_current_progress++;
    31583133        } else {                /* if i==0 then ... */
    31593134
    31603135            finished = TRUE;
    3161             mr_asprintf(&file_to_archive, curr_slice_fname_uncompressed);
     3136            mr_asprintf(&file_to_archive, "%s", curr_slice_fname_uncompressed);
    31623137            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    31633138                break;
     
    31803155        retval += res;
    31813156        if (res) {
    3182             mr_asprintf(&tmp,
    3183                     "Failed to add slice %ld of bigfile %ld to scratchdir",
    3184                     slice_num, biggie_file_number + 1);
     3157            mr_asprintf(&tmp, "Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1);
    31853158            log_to_screen(tmp);
    31863159            paranoid_free(tmp);
     
    35293502            if (res) {
    35303503                mds = media_descriptor_string(bkpinfo->backup_media_type);
    3531                 mr_asprintf(&tmp,
    3532                         "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
     3504                mr_asprintf(&tmp, "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
    35333505                mr_free(mds);
    35343506                log_to_screen(tmp);
     
    35373509            }
    35383510        }
    3539         mr_asprintf(&tmp,
    3540                 "grep 'afio: ' %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s/changed.files",
    3541                 MONDO_LOGFILE, MONDO_CACHE);
     3511        mr_asprintf(&tmp, "grep 'afio: ' %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE);
    35423512        (void)system(tmp);
    35433513        mr_free(tmp);
    35443514
    3545         mr_asprintf(&tmp,
    3546                 "grep 'star: ' %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s/changed.files",
    3547                 MONDO_LOGFILE, MONDO_CACHE);
     3515        mr_asprintf(&tmp, "grep 'star: ' %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE);
    35483516        (void)system(tmp);
    35493517        mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.