Changeset 2214 in MondoRescue
- Timestamp:
- Jun 3, 2009, 7:10:28 PM (15 years ago)
- Location:
- branches/2.2.9/mondo
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/TODO
r30 r2214 1 NEW TODO 2 3 list_of_NFS_devices_and_mounts should allocate memory 4 5 1 6 MONDO TODO Hugo Rabson <hugorabson@msn.com> 07/04/2004 2 7 -
branches/2.2.9/mondo/src/common/libmondo-archive.c
r2211 r2214 508 508 { 509 509 /*@ buffer ************************************************************ */ 510 char *tmp ;510 char *tmp = NULL; 511 511 char *tmp1 = NULL; 512 512 char *tmp2 = NULL; 513 char *scratchdir;514 513 char *command = NULL; 515 char *use_lzo_sz ;516 char *use_gzip_sz ;517 char *use_comp_sz ;518 char *use_star_sz ;519 char *bootldr_str ;520 char *tape_device ;521 char *last_filelist_number ;522 char *broken_bios_sz ;523 char *cd_recovery_sz ;524 char *tape_size_sz ;525 char *devs_to_exclude ;526 char *use_lilo_sz ;527 char *value ;528 char *bootdev ;514 char *use_lzo_sz = NULL; 515 char *use_gzip_sz = NULL; 516 char *use_comp_sz = NULL; 517 char *use_star_sz = NULL; 518 char *bootldr_str = NULL; 519 char *tape_device = NULL; 520 char *last_filelist_number = NULL; 521 char *broken_bios_sz = NULL; 522 char *cd_recovery_sz = NULL; 523 char *tape_size_sz = NULL; 524 char *devs_to_exclude = NULL; 525 char *use_lilo_sz = NULL; /* BCO: shared between LILO/ELILO */ 526 char *value = NULL; 527 char *bootdev = NULL; 529 528 char *ntapedev = NULL; 530 529 … … 542 541 543 542 assert(bkpinfo != NULL); 544 tmp = malloc(9*MAX_STR_LEN);545 malloc_string(scratchdir);546 malloc_string(use_lzo_sz);547 malloc_string(use_gzip_sz);548 malloc_string(use_star_sz);549 malloc_string(use_comp_sz);550 malloc_string(bootldr_str);551 malloc_string(tape_device);552 543 malloc_string(last_filelist_number); 553 malloc_string(broken_bios_sz); 554 malloc_string(cd_recovery_sz); 555 malloc_string(tape_size_sz); 556 malloc_string(devs_to_exclude); 557 malloc_string(use_lilo_sz); /* BCO: shared between LILO/ELILO */ 558 malloc_string(value); 559 malloc_string(bootdev); 560 561 strcpy(scratchdir, bkpinfo->scratchdir); 562 sprintf(tmp, 544 545 mr_asprintf(&tmp, 563 546 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 564 547 bkpinfo->exclude_paths); 565 strcpy(devs_to_exclude, call_program_and_get_last_line_of_output(tmp)); 566 sprintf(tmp, "devs_to_exclude = '%s'", devs_to_exclude); 548 mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp)); 549 mr_free(tmp); 550 551 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 567 552 log_msg(2, tmp); 553 mr_free(tmp); 554 568 555 mvaddstr_and_log_it(g_currentY, 0, 569 556 "Calling MINDI to create boot+data disks"); 570 sprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);557 mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir); 571 558 if (!does_file_exist(tmp)) { 572 sprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 559 mr_free(tmp); 560 mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 573 561 if (!does_file_exist(tmp)) { 574 562 fatal_error … … 577 565 } 578 566 lines_in_filelist = count_lines_in_file(tmp); 579 sprintf(tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 580 strcpy(last_filelist_number, last_line_of_file(tmp)); 567 mr_free(tmp); 568 569 mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 570 mr_asprintf(&last_filelist_number, "%s", last_line_of_file(tmp)); 571 mr_free(tmp); 572 581 573 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 582 sprintf(tape_size_sz, "%ld", bkpinfo->media_size[1]);574 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]); 583 575 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 584 576 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { … … 590 582 } 591 583 paranoid_free(ntapedev); 592 strcpy(tape_device, bkpinfo->media_device);584 mr_asprintf(&tape_device, "%s", bkpinfo->media_device); 593 585 } else { 594 tape_size_sz[0] = '\0';595 tape_device[0] = '\0';586 mr_asprintf(&tape_size_sz, "%ld", 0L);; 587 mr_asprintf(&tape_device, ""); 596 588 } 597 589 if (bkpinfo->use_lzo) { 598 strcpy(use_lzo_sz, "yes");590 mr_asprintf(&use_lzo_sz, "yes"); 599 591 } else { 600 strcpy(use_lzo_sz, "no");592 mr_asprintf(&use_lzo_sz, "no"); 601 593 } 602 594 if (bkpinfo->use_gzip) { 603 strcpy(use_gzip_sz, "yes");595 mr_asprintf(&use_gzip_sz, "yes"); 604 596 } else { 605 strcpy(use_gzip_sz, "no");597 mr_asprintf(&use_gzip_sz, "no"); 606 598 } 607 599 if (bkpinfo->use_star) { 608 strcpy(use_star_sz, "yes");600 mr_asprintf(&use_star_sz, "yes"); 609 601 } else { 610 strcpy(use_star_sz, "no");602 mr_asprintf(&use_star_sz, "no"); 611 603 } 612 604 613 605 if (bkpinfo->compression_level > 0) { 614 strcpy(use_comp_sz, "yes");606 mr_asprintf(&use_comp_sz, "yes"); 615 607 } else { 616 strcpy(use_comp_sz, "no");617 } 618 619 strcpy(broken_bios_sz, "yes"); /* assume so */608 mr_asprintf(&use_comp_sz, "no"); 609 } 610 611 mr_asprintf(&broken_bios_sz, "yes"); /* assume so */ 620 612 if (g_cd_recovery) { 621 strcpy(cd_recovery_sz, "yes");613 mr_asprintf(&cd_recovery_sz, "yes"); 622 614 } else { 623 strcpy(cd_recovery_sz, "no");615 mr_asprintf(&cd_recovery_sz, "no"); 624 616 } 625 617 if (bkpinfo->make_cd_use_lilo) { 626 strcpy(use_lilo_sz, "yes");618 mr_asprintf(&use_lilo_sz, "yes"); 627 619 } else { 628 strcpy(use_lilo_sz, "no");620 mr_asprintf(&use_lilo_sz, "no"); 629 621 } 630 622 … … 634 626 635 627 #ifdef __FreeBSD__ 636 strcpy(bootdev, call_program_and_get_last_line_of_output628 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 637 629 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 638 630 if (!bootdev[0]) { 639 strcpy(bootdev, call_program_and_get_last_line_of_output 631 mr_free(bootdev); 632 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 640 633 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 641 634 } … … 643 636 /* Linux */ 644 637 #ifdef __IA64__ 645 strcpy(bootdev, call_program_and_get_last_line_of_output638 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 646 639 ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 647 640 #else 648 strcpy(bootdev, call_program_and_get_last_line_of_output641 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 649 642 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 650 643 #endif 651 644 if (strstr(bootdev, "/dev/cciss/")) { 645 mr_free(bootdev); 652 646 #ifdef __IA64__ 653 strcpy(bootdev, call_program_and_get_last_line_of_output647 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 654 648 ("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 655 649 #else 656 strcpy(bootdev, call_program_and_get_last_line_of_output650 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 657 651 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 658 652 #endif 659 653 } 660 654 if (!bootdev[0]) { 661 strcpy(bootdev, call_program_and_get_last_line_of_output 655 mr_free(bootdev); 656 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 662 657 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 663 658 if (strstr(bootdev, "/dev/cciss/")) { 664 strcpy(bootdev, call_program_and_get_last_line_of_output 659 mr_free(bootdev); 660 mr_asprintf(&bootdev, call_program_and_get_last_line_of_output 665 661 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 666 662 } … … 673 669 ch = 'U'; 674 670 if (bkpinfo->boot_loader != '\0') { 675 sprintf(tmp, "User specified boot loader. It is '%c'.",671 mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", 676 672 bkpinfo->boot_loader); 677 673 log_msg(2, tmp); 674 mr_free(tmp); 678 675 } else { 679 676 bkpinfo->boot_loader = ch; 680 677 } 681 678 if (bkpinfo->boot_device[0] != '\0') { 682 sprintf(tmp, "User specified boot device. It is '%s'.",679 mr_asprintf(&tmp, "User specified boot device. It is '%s'.", 683 680 bkpinfo->boot_device); 684 681 log_msg(2, tmp); 682 mr_free(tmp); 685 683 } else { 686 684 strcpy(bkpinfo->boot_device, bootdev); 687 685 } 688 686 } 687 mr_free(bootdev); 689 688 690 689 if ( … … 702 701 } 703 702 if (bkpinfo->boot_loader == 'L') { 704 strcpy(bootldr_str, "LILO");703 mr_asprintf(&bootldr_str, "LILO"); 705 704 if (!does_file_exist("/etc/lilo.conf")) { 706 705 fatal_error … … 708 707 } 709 708 } else if (bkpinfo->boot_loader == 'G') { 710 strcpy(bootldr_str, "GRUB");709 mr_asprintf(&bootldr_str, "GRUB"); 711 710 if (!does_file_exist("/boot/grub/menu.lst") 712 711 && does_file_exist("/boot/grub/grub.conf")) { … … 719 718 } 720 719 } else if (bkpinfo->boot_loader == 'E') { 721 strcpy(bootldr_str, "ELILO");720 mr_asprintf(&bootldr_str, "ELILO"); 722 721 /* BCO: fix it for Debian, Mandrake, ... */ 723 722 if (!does_file_exist("/etc/elilo.conf") … … 750 749 } 751 750 } else if (bkpinfo->boot_loader == 'R') { 752 strcpy(bootldr_str, "RAW");751 mr_asprintf(&bootldr_str, "RAW"); 753 752 } 754 753 #ifdef __FreeBSD__ 755 754 else if (bkpinfo->boot_loader == 'D') { 756 strcpy(bootldr_str, "DD");755 mr_asprintf(&bootldr_str, "DD"); 757 756 } 758 757 759 758 else if (bkpinfo->boot_loader == 'B') { 760 strcpy(bootldr_str, "BOOT0");759 mr_asprintf(&bootldr_str, "BOOT0"); 761 760 } 762 761 #endif 763 762 else { 764 strcpy(bootldr_str, "unknown");765 } 766 sprintf(tmp, "Your boot loader is %s and it boots from %s",763 mr_asprintf(&bootldr_str, "unknown"); 764 } 765 mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", 767 766 bootldr_str, bkpinfo->boot_device); 768 767 log_to_screen(tmp); 769 sprintf(tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 768 mr_free(tmp); 769 770 mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 770 771 if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) { 771 772 log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__); 772 773 } 774 mr_free(tmp); 775 773 776 switch (bkpinfo->backup_media_type) { 774 777 case cdr: 775 strcpy(value, "cdr");778 mr_asprintf(&value, "cdr"); 776 779 break; 777 780 case cdrw: 778 strcpy(value, "cdrw");781 mr_asprintf(&value, "cdrw"); 779 782 break; 780 783 case cdstream: 781 strcpy(value, "cdstream");784 mr_asprintf(&value, "cdstream"); 782 785 break; 783 786 case tape: 784 strcpy(value, "tape");787 mr_asprintf(&value, "tape"); 785 788 break; 786 789 case udev: 787 strcpy(value, "udev");790 mr_asprintf(&value, "udev"); 788 791 break; 789 792 case iso: 790 strcpy(value, "iso");793 mr_asprintf(&value, "iso"); 791 794 break; 792 795 case nfs: 793 strcpy(value, "nfs");796 mr_asprintf(&value, "nfs"); 794 797 break; 795 798 case dvd: 796 strcpy(value, "dvd");799 mr_asprintf(&value, "dvd"); 797 800 break; 798 801 case usb: 799 strcpy(value, "usb");802 mr_asprintf(&value, "usb"); 800 803 break; 801 804 default: … … 808 811 } 809 812 810 sprintf(tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);813 mr_asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir); 811 814 if (write_one_liner_data_file(tmp, value)) { 812 815 res++; … … 814 817 __LINE__); 815 818 } 816 sprintf(tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir); 819 mr_free(value); 820 mr_free(tmp); 821 822 mr_asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir); 817 823 if (write_one_liner_data_file(tmp, bootldr_str)) { 818 824 res++; … … 820 826 __LINE__); 821 827 } 822 sprintf(tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir); 828 mr_free(bootldr_str); 829 mr_free(tmp); 830 831 mr_asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir); 823 832 if (bkpinfo->differential) { 824 833 res += write_one_liner_data_file(tmp, "1"); … … 826 835 res += write_one_liner_data_file(tmp, "0"); 827 836 } 837 mr_free(tmp); 828 838 829 839 if (g_getfattr) { … … 861 871 } 862 872 paranoid_free(command); 863 sprintf(tmp, "BTW, I'm telling Mindi your kernel is '%s'",864 bkpinfo->kernel_path);865 866 873 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 867 874 … … 892 899 use_gzip_sz); // parameter #20 (STRING) 893 900 901 mr_free(devs_to_exclude); 902 mr_free(last_filelist_number); 903 mr_free(tape_device); 904 mr_free(use_lzo_sz); 905 mr_free(use_gzip_sz); 906 mr_free(use_star_sz); 907 mr_free(use_comp_sz); 908 mr_free(broken_bios_sz); 909 mr_free(cd_recovery_sz); 910 mr_free(use_lilo_sz); 911 mr_free(tape_size_sz); 912 894 913 if (bkpinfo->nonbootable_backup) { 895 914 mr_strcat(command, " NONBOOTABLE"); … … 928 947 paranoid_free(command); 929 948 } else { 930 sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,949 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, 931 950 bkpinfo->tmpdir); 932 951 if (system(tmp)) { 933 952 fatal_error("Cannot find all.tar.gz in tmpdir"); 934 953 } 954 mr_free(tmp); 935 955 } 936 956 if (res) { … … 942 962 log_to_screen("Mindi failed to create your boot+data disks."); 943 963 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 944 strcpy(tmp, call_program_and_get_last_line_of_output(command));964 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 945 965 paranoid_free(command); 946 966 … … 948 968 popup_and_OK(tmp); 949 969 } 950 } 951 paranoid_free(tmp); 952 paranoid_free(use_lzo_sz); 953 paranoid_free(use_gzip_sz); 954 paranoid_free(scratchdir); 955 paranoid_free(use_comp_sz); 956 paranoid_free(bootldr_str); 957 paranoid_free(tape_device); 958 paranoid_free(last_filelist_number); 959 paranoid_free(broken_bios_sz); 960 paranoid_free(cd_recovery_sz); 961 paranoid_free(tape_size_sz); 962 paranoid_free(devs_to_exclude); 963 paranoid_free(use_lilo_sz); 964 paranoid_free(value); 965 paranoid_free(bootdev); 966 paranoid_free(use_star_sz); 970 mr_free(tmp); 971 } 967 972 return (res); 968 973 } … … 1352 1357 char *storing_afioball_fname; 1353 1358 char *tmp = NULL; 1354 char *media_usage_comment ;1359 char *media_usage_comment = NULL; 1355 1360 pthread_t archival_thread[ARCH_THREADS]; 1356 1361 char *p_list_of_fileset_flags; … … 1370 1375 malloc_string(curr_acl_list_fname); 1371 1376 malloc_string(storing_filelist_fname); 1372 malloc_string(media_usage_comment);1373 1377 malloc_string(storing_afioball_fname); 1374 1378 transfer_block = … … 1434 1438 misc_counter_that_is_not_important = 1435 1439 (misc_counter_that_is_not_important + 1) % 5; 1440 /* BCO the media_usage_comment is not really initialized there ! 1436 1441 if (!misc_counter_that_is_not_important) { 1437 1442 update_progress_form(media_usage_comment); 1443 */ 1438 1444 } 1439 1445 sleep(1); … … 1462 1468 sleep(5); 1463 1469 } 1464 strcpy(media_usage_comment, percent_media_full_comment());1470 mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment()); 1465 1471 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 1466 1472 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1503 1509 g_current_progress++; 1504 1510 update_progress_form(media_usage_comment); 1511 mr_free(media_usage_comment); 1505 1512 if (res) { 1506 1513 mr_asprintf(&tmp, … … 1537 1544 paranoid_free(result_str); 1538 1545 paranoid_free(storing_filelist_fname); 1539 paranoid_free(media_usage_comment);1540 1546 paranoid_free(storing_afioball_fname); 1541 1547 paranoid_free(curr_xattr_list_fname); … … 1980 1986 bool is_dev_an_NTFS_dev(char *bigfile_fname) 1981 1987 { 1982 char *tmp ;1983 char *command ;1984 malloc_string(tmp);1985 malloc_string(command); 1986 sprintf(command,1988 char *tmp = NULL; 1989 char *command = NULL; 1990 bool ret = TRUE; 1991 1992 mr_asprintf(&command, 1987 1993 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1988 1994 bigfile_fname); 1989 1995 log_msg(1, "command = '%s'", command); 1990 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 1996 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1997 mr_free(command); 1998 1991 1999 log_msg(1, "--> tmp = '%s'", tmp); 1992 2000 if (strstr(tmp, "NTFS")) { 1993 2001 iamhere("TRUE"); 1994 ret urn (TRUE);2002 ret = TRUE; 1995 2003 } else { 1996 2004 iamhere("FALSE"); 1997 return (FALSE); 1998 } 2005 ret = FALSE; 2006 } 2007 mr_free(tmp); 2008 return(ret); 1999 2009 } 2000 2010 … … 2203 2213 char *curr_acl_list_fname; 2204 2214 char *tmp = NULL; 2205 char *media_usage_comment ;2215 char *media_usage_comment = NULL; 2206 2216 2207 2217 malloc_string(curr_afioball_fname); 2208 malloc_string(media_usage_comment);2209 2218 malloc_string(curr_filelist_fname); 2210 2219 malloc_string(curr_xattr_list_fname); … … 2256 2265 } 2257 2266 2258 strcpy(media_usage_comment, percent_media_full_comment());2267 mr_asprintf(&media_usage_comment, "%s", percent_media_full_comment()); 2259 2268 2260 2269 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ … … 2294 2303 g_current_progress++; 2295 2304 update_progress_form(media_usage_comment); 2305 mr_free(media_usage_comment); 2296 2306 2297 2307 if (res) { … … 2315 2325 paranoid_free(curr_filelist_fname); 2316 2326 paranoid_free(curr_afioball_fname); 2317 paranoid_free(media_usage_comment);2318 2327 paranoid_free(curr_xattr_list_fname); 2319 2328 paranoid_free(curr_acl_list_fname); … … 2500 2509 2501 2510 /*@ buffers ******************************************************** */ 2502 char *tmp, *curr_file, *cf; 2511 char *tmp = NULL; 2512 char *curr_file = NULL 2513 char *cf; 2503 2514 2504 2515 /*@ long ************************************************************ */ … … 2507 2518 2508 2519 assert(bkpinfo != NULL); 2509 malloc_string(curr_file);2510 tmp = malloc(1200);2511 2520 would_occupy = space_occupied_by_cd(bkpinfo->scratchdir); 2512 2521 va_start(ap, files_to_add); // initialize the variable arguments … … 2515 2524 continue; 2516 2525 } 2517 strcpy(curr_file, cf);2526 mr_asprintf(&curr_file, cf); 2518 2527 if (!does_file_exist(curr_file)) { 2519 2528 log_msg(1, … … 2524 2533 would_occupy += length_of_file(curr_file) / 1024; 2525 2534 } 2535 mr_free(curr_file); 2526 2536 } 2527 2537 va_end(ap); … … 2543 2553 continue; 2544 2554 } 2545 strcpy(curr_file, cf);2546 2547 sprintf(tmp, "mv -f %s %s/archives/", curr_file,2548 bkpinfo->scratchdir);2555 mr_asprintf(&curr_file, cf); 2556 2557 mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file, bkpinfo->scratchdir); 2558 mr_free(curr_file); 2549 2559 res = run_program_and_log_output(tmp, 5); 2550 2560 retval += res; … … 2554 2564 log_msg(8, "Moved %s to CD OK", tmp); 2555 2565 } 2556 // unlink (curr_file);2566 mr_free(tmp); 2557 2567 } 2558 2568 va_end(ap); … … 2562 2572 "Warning - errors occurred while I was adding files to CD dir"); 2563 2573 } 2564 paranoid_free(tmp);2565 paranoid_free(curr_file);2566 2574 return (retval); 2567 2575 } … … 2609 2617 char start_chr; 2610 2618 char stop_chr; 2611 char *curr_file, *cf; 2619 char *curr_file = NULL 2620 char *cf; 2612 2621 /*@ long long ****************************************************** */ 2613 2622 off_t length_of_incoming_file = (off_t)0; … … 2616 2625 2617 2626 assert(bkpinfo != NULL); 2618 malloc_string(curr_file);2619 2627 va_start(ap, files_to_add); 2620 2628 for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) { … … 2622 2630 continue; 2623 2631 } 2624 strcpy(curr_file, cf);2632 mr_asprintf(&curr_file, cf); 2625 2633 if (!does_file_exist(curr_file)) { 2626 2634 log_msg(1, … … 2628 2636 curr_file); 2629 2637 } 2630 /* create header chars */2638 /* create header chars */ 2631 2639 start_chr = BLK_START_AN_AFIO_OR_SLICE; 2632 2640 stop_chr = BLK_STOP_AN_AFIO_OR_SLICE; 2633 /* ask for new tape if necessary */2641 /* ask for new tape if necessary */ 2634 2642 length_of_incoming_file = length_of_file(curr_file); 2635 2643 write_header_block_to_stream(length_of_incoming_file, curr_file, … … 2645 2653 retval += res; 2646 2654 unlink(curr_file); 2647 /* write closing header */ 2655 mr_free(curr_file); 2656 /* write closing header */ 2648 2657 write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr); 2649 2658 } … … 2654 2663 "Warning - errors occurred while I was adding file to tape"); 2655 2664 } 2656 paranoid_free(curr_file);2657 2665 return (retval); 2658 2666 } … … 2678 2686 char *tmp; 2679 2687 int res = 0; 2680 char *bkp ;2688 char *bkp = NULL; 2681 2689 char *cdrecord; 2682 2690 2683 2691 malloc_string(tmp); 2684 malloc_string(bkp);2685 2692 malloc_string(cdrecord); 2686 strcpy(bkp, cdrw_dev);2693 mr_asprintf(&bkp, cdrw_dev); 2687 2694 if (find_cdrw_device(cdrw_dev)) { 2688 2695 strcpy(cdrw_dev, bkp); … … 2713 2720 } 2714 2721 } 2722 mr_free(bkp); 2723 2715 2724 // retract_CD_tray_and_defeat_autorun(); 2716 2725 paranoid_free(tmp); 2717 2726 paranoid_free(cdrecord); 2718 paranoid_free(bkp);2719 2727 return (res); 2720 2728 } … … 2742 2750 char *cdrom_dev; 2743 2751 char *cdrw_dev; 2744 char *our_serial_str ;2752 char *our_serial_str = NULL; 2745 2753 bool ok_go_ahead_burn_it; 2746 2754 int cd_number = -1; … … 2758 2766 malloc_string(szcdno); 2759 2767 malloc_string(szserfname); 2760 malloc_string(our_serial_str);2761 2768 malloc_string(szunmount); 2762 2769 … … 2785 2792 sprintf(szunmount, "umount %s", mtpt); 2786 2793 cd_number = -1; 2787 our_serial_str[0] = '\0';2788 2794 sprintf(tmp, "mount %s %s", cdrom_dev, mtpt); 2795 mr_asprintf(&our_serial_str, "%s", ""); 2789 2796 if ((attempt_to_mount_returned_this = 2790 2797 run_program_and_log_output(tmp, 1))) { … … 2812 2819 cd_number = atoi(last_line_of_file(szcdno)); 2813 2820 sprintf(tmp, "cat %s 2> /dev/null", szserfname); 2814 strcpy(our_serial_str, 2821 mr_free(our_serial_str); 2822 mr_asprintf(&our_serial_str, "%s", 2815 2823 call_program_and_get_last_line_of_output(tmp)); 2816 2824 // FIXME - should be able to use last_line_of_file(), surely? … … 2836 2844 log_to_screen("...but not part of _our_ backup set."); 2837 2845 } 2846 mr_free(our_serial_str); 2838 2847 } else { 2839 2848 log_msg(2, … … 2883 2892 paranoid_free(szcdno); 2884 2893 paranoid_free(szserfname); 2885 paranoid_free(our_serial_str);2886 2894 paranoid_free(szunmount); 2887 2895 if (pmountable) { … … 2966 2974 char *checksum_line, *command; 2967 2975 char *tempblock; 2968 char *curr_slice_fname_uncompressed ;2969 char *curr_slice_fname_compressed ;2970 char *file_to_archive ;2976 char *curr_slice_fname_uncompressed = NULL; 2977 char *curr_slice_fname_compressed = NULL; 2978 char *file_to_archive = NULL; 2971 2979 char *file_to_openin; 2972 2980 /*@ pointers ************************************************** */ … … 2983 2991 long optimal_set_size; 2984 2992 bool should_I_compress_slices; 2985 char *suffix ; // for compressed slices2993 char *suffix = NULL; // for compressed slices 2986 2994 2987 2995 /*@ long long ************************************************** */ … … 3001 3009 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 3002 3010 malloc_string(checksum_line); 3003 malloc_string(curr_slice_fname_uncompressed);3004 malloc_string(curr_slice_fname_compressed);3005 malloc_string(file_to_archive);3006 malloc_string(suffix);3007 3011 command = malloc(MAX_STR_LEN * 8); 3008 3012 … … 3015 3019 if (is_this_file_compressed(biggie_filename) 3016 3020 || bkpinfo->compression_level == 0) { 3017 suffix[0] = '\0';3021 mr_asprintf(&suffix, "%s", ""); 3018 3022 // log_it("%s is indeed compressed :-)", filename); 3019 3023 should_I_compress_slices = FALSE; 3020 3024 } else { 3021 strcpy(suffix, bkpinfo->zip_suffix);3025 mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix); 3022 3026 should_I_compress_slices = TRUE; 3023 3027 } … … 3050 3054 if (!(fin = popen(command, "r"))) { 3051 3055 log_OS_error("Unable to popen-in command"); 3056 mr_free(suffix); 3052 3057 return (1); 3053 3058 } … … 3072 3077 log_msg(1, "Unable to open and write to %s\n", tmp); 3073 3078 paranoid_free(tmp); 3074 paranoid_free(suffix);3079 mr_free(suffix); 3075 3080 return (1); 3076 3081 } … … 3093 3098 paranoid_free(checksum_line); 3094 3099 paranoid_free(command); 3100 mr_free(suffix); 3095 3101 return (1); 3096 3102 } … … 3106 3112 i = bkpinfo->optimal_set_size / 256; 3107 3113 for (slice_num = 1; !finished; slice_num++) { 3108 strcpy(curr_slice_fname_uncompressed,3114 mr_asprintf(&curr_slice_fname_uncompressed, "%s", 3109 3115 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, 3110 3116 "")); 3111 strcpy(curr_slice_fname_compressed,3117 mr_asprintf(&curr_slice_fname_compressed, "%s", 3112 3118 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, 3113 3119 suffix)); … … 3119 3125 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { 3120 3126 log_OS_error(curr_slice_fname_uncompressed); 3127 mr_free(suffix); 3121 3128 return (1); 3122 3129 } … … 3188 3195 paranoid_free(tmp); 3189 3196 3190 strcpy(file_to_archive, curr_slice_fname_compressed);3197 mr_asprintf(&file_to_archive, curr_slice_fname_compressed); 3191 3198 g_current_progress++; 3192 3199 } else { /* if i==0 then ... */ 3193 3200 3194 3201 finished = TRUE; 3195 strcpy(file_to_archive, curr_slice_fname_uncompressed);3202 mr_asprintf(&file_to_archive, curr_slice_fname_uncompressed); 3196 3203 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3197 3204 break; 3198 3205 } 3199 3206 } 3207 mr_free(curr_slice_fname_uncompressed); 3208 mr_free(curr_slice_fname_compressed); 3200 3209 3201 3210 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 3208 3217 res = move_files_to_cd(file_to_archive, NULL); 3209 3218 } 3219 mr_free(file_to_archive); 3220 3210 3221 retval += res; 3211 3222 if (res) { … … 3219 3230 } 3220 3231 } 3232 mr_free(suffix); 3221 3233 paranoid_fclose(fin); 3222 3234 mr_asprintf(&tmp, "Sliced bigfile #%ld", biggie_file_number + 1); … … 3232 3244 paranoid_free(checksum_line); 3233 3245 paranoid_free(command); 3234 paranoid_free(curr_slice_fname_uncompressed);3235 paranoid_free(curr_slice_fname_compressed);3236 paranoid_free(file_to_archive);3237 paranoid_free(suffix);3238 3246 return (retval); 3239 3247 } -
branches/2.2.9/mondo/src/common/libmondo-cli.c
r2211 r2214 98 98 flag_set[i] = FALSE; 99 99 } 100 // strcpy (bkpinfo->scratchdir, "/home");101 100 for (j = 1; j <= MAX_NOOF_MEDIA; j++) { 102 101 bkpinfo->media_size[j] = 650; … … 669 668 670 669 malloc_string(tmp); 671 malloc_string(psz);672 670 673 671 assert(bkpinfo != NULL); … … 1124 1122 { 1125 1123 // strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN); 1126 strncpy(psz, list_of_NFS_mounts_only(), MAX_STR_LEN);1124 asprintf(&psz, "%s", list_of_NFS_mounts_only()); 1127 1125 if (bkpinfo->exclude_paths[0]) { 1128 1126 strncat(bkpinfo->exclude_paths, " ", 4*MAX_STR_LEN); 1129 1127 } 1130 1128 strncat(bkpinfo->exclude_paths, psz, 4*MAX_STR_LEN); 1129 mr_free(psz); 1130 1131 1131 log_msg(3, "-N means we're now excluding %s", 1132 1132 bkpinfo->exclude_paths); … … 1139 1139 1140 1140 if (flag_set['b']) { 1141 strcpy(psz, flag_val['b']);1141 mr_asprintf(&psz, flag_val['b']); 1142 1142 log_msg(1, "psz = '%s'", psz); 1143 1143 if (psz[strlen(psz) - 1] == 'k') { … … 1147 1147 itbs = atol(psz); 1148 1148 } 1149 mr_free(psz); 1149 1150 log_msg(1, "'%s' --> %ld", flag_val['b'], itbs); 1150 1151 log_msg(1, "Internal tape block size is now %ld bytes", itbs); … … 1421 1422 1422 1423 paranoid_free(tmp); 1423 paranoid_free(psz);1424 1424 return (retval); 1425 1425 } -
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2211 r2214 107 107 bool am_I_in_disaster_recovery_mode(void) 108 108 { 109 char *tmp, *comment; 109 char *tmp = NULL; 110 char *comment; 110 111 bool is_this_a_ramdisk = FALSE; 111 112 112 malloc_string(tmp);113 113 malloc_string(comment); 114 strcpy(tmp, where_is_root_mounted());114 mr_asprintf(&tmp, "%s", where_is_root_mounted()); 115 115 sprintf(comment, "root is mounted at %s\n", tmp); 116 116 log_msg(0, comment); … … 133 133 } 134 134 #endif 135 mr_free(tmp); 135 136 136 137 if (is_this_a_ramdisk) { … … 144 145 is_this_a_ramdisk = TRUE; 145 146 } 146 paranoid_free(tmp);147 147 paranoid_free(comment); 148 148 log_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk); … … 513 513 /*@ buffers ************************ */ 514 514 char *comment; 515 char *tmp ;516 char *cdr_exe ;515 char *tmp = NULL; 516 char *cdr_exe = NULL; 517 517 char *command; 518 518 519 519 malloc_string(comment); 520 malloc_string(tmp);521 malloc_string(cdr_exe);522 520 malloc_string(command); 523 521 if (g_cdrw_drive_is_here[0]) { … … 525 523 log_msg(3, "Been there, done that. Returning %s", cdrw_device); 526 524 paranoid_free(comment); 527 paranoid_free(tmp);528 paranoid_free(cdr_exe);529 525 paranoid_free(command); 530 526 return (0); … … 534 530 "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?"); 535 531 paranoid_free(comment); 536 paranoid_free(tmp);537 paranoid_free(cdr_exe);538 532 paranoid_free(command); 539 533 return (1); … … 541 535 run_program_and_log_output("insmod ide-scsi", -1); 542 536 if (find_home_of_exe("cdrecord")) { 543 strcpy(cdr_exe, "cdrecord");537 mr_asprintf(&cdr_exe, "cdrecord"); 544 538 } else { 545 strcpy(cdr_exe, "dvdrecord"); 546 } 547 tmp[0] = '\0'; 539 mr_asprintf(&cdr_exe, "dvdrecord"); 540 } 548 541 if (find_home_of_exe(cdr_exe)) { 549 542 sprintf(command, 550 543 "%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", 551 544 cdr_exe); 552 strcpy(tmp, call_program_and_get_last_line_of_output(command));553 } 554 if ( strlen(tmp) < 2) {545 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 546 } 547 if ((tmp == NULL) || (strlen(tmp) < 2)) { 555 548 paranoid_free(comment); 556 paranoid_free(tmp);557 paranoid_free(cdr_exe);549 mr_free(tmp); 550 mr_free(cdr_exe); 558 551 paranoid_free(command); 559 552 return 1; … … 564 557 strcpy(g_cdrw_drive_is_here, cdrw_device); 565 558 paranoid_free(comment); 566 paranoid_free(tmp);567 paranoid_free(cdr_exe);559 mr_free(tmp); 560 mr_free(cdr_exe); 568 561 paranoid_free(command); 569 562 return (0); … … 597 590 /*@ buffers ***************************************************** */ 598 591 char *tmp; 599 char *cdr_exe; 592 char *tmp1 = NULL; 593 char *cdr_exe = NULL; 600 594 char *phrase_one; 601 595 char *phrase_two; … … 607 601 /*@ intialize *************************************************** */ 608 602 malloc_string(tmp); 609 malloc_string(cdr_exe);610 603 malloc_string(phrase_one); 611 604 malloc_string(phrase_two); … … 640 633 641 634 if (find_home_of_exe("cdrecord")) { 642 strcpy(cdr_exe, "cdrecord");635 mr_asprintf(&cdr_exe, "cdrecord"); 643 636 } else { 644 strcpy(cdr_exe, "dvdrecord");637 mr_asprintf(&cdr_exe, "dvdrecord"); 645 638 } 646 639 tmp[0] = '\0'; … … 663 656 log_msg(4, "command=%s", command); 664 657 log_OS_error("Cannot popen command"); 658 mr_free(cdr_exe); 665 659 return (1); 666 660 } … … 862 856 cdr_exe, g_cdrw_drive_is_here); 863 857 log_msg(1, "command=%s", command); 864 strcpy(tmp, call_program_and_get_last_line_of_output(command));865 if ( tmp[0]) {866 strcpy(output, tmp );858 mr_asprintf(&tmp1, "%s", call_program_and_get_last_line_of_output(command)); 859 if (strlen(tmp1) > 0) { 860 strcpy(output, tmp1); 867 861 log_msg(4, "Finally found it at %s", output); 868 862 retval = 0; 869 goto end_of_find_cdrom_device;870 863 } else { 871 864 log_msg(4, "Still couldn't find it."); 872 865 retval = 1; 873 goto end_of_find_cdrom_device; 874 } 866 } 867 mr_free(tmp1); 868 875 869 end_of_find_cdrom_device: 876 870 paranoid_free(tmp); 877 paranoid_free(cdr_exe);871 mr_free(cdr_exe); 878 872 paranoid_free(phrase_one); 879 873 paranoid_free(phrase_two); … … 1103 1097 /*@ buffers ***************************************************** */ 1104 1098 char *incoming; 1105 char *device_with_tab ;1106 char *device_with_space ;1107 char *tmp ;1108 int retval = 0;1099 char *device_with_tab = NULL; 1100 char *device_with_space = NULL; 1101 char *tmp = NULL; 1102 bool retval = FALSE; 1109 1103 1110 1104 #ifdef __FreeBSD__ … … 1117 1111 1118 1112 malloc_string(incoming); 1119 malloc_string(device_with_tab);1120 malloc_string(device_with_space);1121 malloc_string(tmp);1122 1113 assert(device_raw != NULL); 1123 1114 // assert_string_is_neither_NULL_nor_zerolength(device_raw); … … 1125 1116 log_msg(1, "%s needs to have a '/' prefixed - I'll do it", 1126 1117 device_raw); 1127 sprintf(tmp, "/%s", device_raw);1118 mr_asprintf(&tmp, "/%s", device_raw); 1128 1119 } else { 1129 strcpy(tmp, device_raw);1120 mr_asprintf(&tmp, "%s", device_raw); 1130 1121 } 1131 1122 log_msg(1, "Is %s mounted?", tmp); … … 1133 1124 log_msg(1, 1134 1125 "I don't know how the heck /proc made it into the mountlist. I'll ignore it."); 1135 return (0); 1136 } 1137 sprintf(device_with_tab, "%s\t", tmp); 1138 sprintf(device_with_space, "%s ", tmp); 1126 mr_free(tmp); 1127 return(FALSE); 1128 } 1129 mr_asprintf(&device_with_tab, "%s\t", tmp); 1130 mr_asprintf(&device_with_space, "%s ", tmp); 1131 mr_free(tmp); 1139 1132 1140 1133 if (!(fin = popen("mount", "r"))) { 1141 1134 log_OS_error("Cannot popen 'mount'"); 1142 return 1135 return(FALSE); 1143 1136 } 1144 1137 for ((void)fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); … … 1148 1141 { 1149 1142 paranoid_pclose(fin); 1150 retval = 1; 1151 goto end_of_func; 1152 } 1153 } 1143 paranoid_free(incoming); 1144 return(TRUE); 1145 } 1146 } 1147 mr_free(device_with_tab); 1148 mr_free(device_with_space); 1154 1149 paranoid_pclose(fin); 1155 sprintf(tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null",1150 mr_asprintf(&tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null", 1156 1151 SWAPLIST_COMMAND, device_with_space); 1157 1152 log_msg(4, "tmp (command) = '%s'", tmp); 1158 1153 if (!system(tmp)) { 1159 retval = 1; 1160 goto end_of_func; 1161 } 1162 end_of_func: 1154 retval = TRUE; 1155 } 1156 mr_free(tmp); 1163 1157 paranoid_free(incoming); 1164 paranoid_free(device_with_tab); 1165 paranoid_free(device_with_space); 1166 paranoid_free(tmp); 1167 return (retval); 1158 return(retval); 1168 1159 } 1169 1160 … … 1245 1236 /*@ buffer ****************************************************** */ 1246 1237 char *command; 1247 char *dev;1248 1238 int retval; 1249 1239 1250 1240 malloc_string(command); 1251 malloc_string(dev);1252 1241 assert_string_is_neither_NULL_nor_zerolength(device); 1253 1242 assert_string_is_neither_NULL_nor_zerolength(mountpoint); … … 1256 1245 if (isdigit(device[0])) { 1257 1246 return(1); 1258 } else {1259 strcpy(dev, device);1260 1247 } 1261 1248 log_msg(4, "(mount_USB_here --- device=%s, mountpoint=%s", device, … … 1276 1263 1277 1264 paranoid_free(command); 1278 paranoid_free(dev);1279 1265 return (retval); 1280 1266 } … … 1482 1468 // archiving_to_media is FALSE if I'm being called by mondorestore 1483 1469 { 1484 char *tmp ;1470 char *tmp = NULL; 1485 1471 char *tmp1 = NULL; 1486 1472 char *sz_size; … … 1491 1477 FILE *fin; 1492 1478 1493 malloc_string(tmp);1494 1479 malloc_string(sz_size); 1495 1480 malloc_string(command); … … 1553 1538 if (bkpinfo->backup_media_type == dvd) { 1554 1539 find_dvd_device(bkpinfo->media_device, FALSE); 1555 strcpy(tmp, "1");1540 mr_asprintf(&tmp, "1"); 1556 1541 sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB 1557 1542 log_msg(1, "Setting to DVD defaults"); 1558 1543 } else { 1559 1544 strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM); 1560 strcpy(tmp, "4");1545 mr_asprintf(&tmp, "4"); 1561 1546 strcpy(sz_size, "650"); 1562 1547 log_msg(1, "Setting to CD defaults"); … … 1569 1554 } 1570 1555 bkpinfo->cdrw_speed = atoi(tmp); // if DVD then this shouldn't ever be used anyway :) 1556 mr_free(tmp); 1557 1571 1558 sprintf(comment, 1572 1559 "How much data (in Megabytes) will each %s store?", … … 1620 1607 if (bkpinfo->media_device[0]) { 1621 1608 if (bkpinfo->backup_media_type == usb) { 1622 sprintf(tmp,1609 mr_asprintf(&tmp, 1623 1610 "I think your %s media corresponds to %s. Is this correct?", 1624 1611 media_descriptor_string(bkpinfo->backup_media_type), 1625 1612 bkpinfo->media_device); 1626 1613 } else { 1627 sprintf(tmp,1614 mr_asprintf(&tmp, 1628 1615 "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", 1629 1616 media_descriptor_string(bkpinfo->backup_media_type), … … 1633 1620 bkpinfo->media_device[0] = '\0'; 1634 1621 } 1622 mr_free(tmp); 1635 1623 } 1636 1624 if (!bkpinfo->media_device[0]) { … … 1691 1679 } 1692 1680 } 1693 sprintf(tmp,1694 "I think I've found your tape streamer at %s; am I right on the money?",1695 bkpinfo->media_device);1696 1681 } 1697 1682 if (bkpinfo->media_device[0]) { 1698 sprintf(tmp,1683 mr_asprintf(&tmp, 1699 1684 "I think I've found your tape streamer at %s; am I right on the money?", 1700 1685 bkpinfo->media_device); … … 1702 1687 bkpinfo->media_device[0] = '\0'; 1703 1688 } 1689 mr_free(tmp); 1704 1690 } 1705 1691 if (!bkpinfo->media_device[0]) { … … 1712 1698 } 1713 1699 } 1714 sprintf(tmp, "ls -l %s", bkpinfo->media_device);1700 mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device); 1715 1701 if (run_program_and_log_output(tmp, FALSE)) { 1716 1702 log_to_screen("User has not specified a valid /dev entry"); 1717 1703 finish(1); 1718 1704 } 1705 mr_free(tmp); 1719 1706 log_msg(4, "sz_size = %s", sz_size); 1720 1707 sz_size[0] = '\0'; 1721 /* 1722 if ((size_sz[0]=='\0' || atol(size_sz)==0) && archiving_to_media) 1723 { 1724 if (!popup_and_get_string("Tape size", "How much COMPRESSED data will one of your tape cartridges hold? (e.g. 4GB for 4 gigabytes)", size_sz, 16)) 1725 { log_to_screen("User has chosen not to backup the PC"); finish(1); } 1726 } 1727 */ 1708 1728 1709 bkpinfo->use_obdr = ask_me_yes_or_no 1729 1710 ("Do you want to activate OBDR support for your tapes ?"); … … 1829 1810 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 1830 1811 run_program_and_log_output(command, 5); 1831 sprintf(tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount,1812 mr_asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, 1832 1813 bkpinfo->isodir); 1833 1814 run_program_and_log_output(tmp, 3); 1815 mr_free(tmp); 1816 1834 1817 malloc_string(g_selfmounted_isodir); 1835 1818 strcpy(g_selfmounted_isodir, bkpinfo->isodir); … … 1840 1823 finish(1); 1841 1824 } 1842 strcpy(tmp, bkpinfo->nfs_remote_dir);1825 mr_asprintf(&tmp, bkpinfo->nfs_remote_dir); 1843 1826 if (!popup_and_get_string 1844 1827 ("Directory", "Which directory within that mountpoint?", tmp, … … 1848 1831 } 1849 1832 strcpy(bkpinfo->nfs_remote_dir, tmp); 1833 mr_free(tmp); 1834 1850 1835 // check whether writable - we better remove surrounding spaces for this 1851 1836 strip_spaces(bkpinfo->nfs_remote_dir); … … 1981 1966 finish(1); 1982 1967 } 1983 strcpy(tmp, list_of_NFS_mounts_only());1968 mr_asprintf(&tmp, "%s", list_of_NFS_mounts_only()); 1984 1969 if (strlen(tmp) > 2) { 1985 1970 if (bkpinfo->exclude_paths[0]) { … … 1988 1973 strncpy(bkpinfo->exclude_paths, tmp, MAX_STR_LEN); 1989 1974 } 1975 mr_free(tmp); 1990 1976 // NTFS 1991 strcpy(tmp,1977 mr_asprintf(&tmp, "%s", 1992 1978 call_program_and_get_last_line_of_output 1993 1979 ("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'")); … … 2002 1988 strncpy(bkpinfo->image_devs, tmp, MAX_STR_LEN / 4); 2003 1989 } 1990 mr_free(tmp); 2004 1991 2005 1992 … … 2047 2034 #else 2048 2035 if (bkpinfo->backup_media_type == nfs) { 2049 sprintf(tmp, "mount | grep \"%s\" | cut -d' ' -f3",2050 bkpinfo->nfs_mount);2051 // strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp));2052 2036 log_msg(3, "I think the NFS mount is mounted at %s", 2053 2037 bkpinfo->isodir); … … 2078 2062 } 2079 2063 } 2080 paranoid_free(tmp);2081 2064 paranoid_free(sz_size); 2082 2065 paranoid_free(command); … … 2100 2083 char *list_of_NFS_devices_and_mounts(void) 2101 2084 { 2102 char *exclude_these_devices ;2103 char *exclude_these_directories ;2085 char *exclude_these_devices = NULL; 2086 char *exclude_these_directories = NULL; 2104 2087 static char result_sz[1024]; 2105 2088 2106 malloc_string(exclude_these_devices); 2107 malloc_string(exclude_these_directories); 2108 strcpy(exclude_these_directories,list_of_NFS_mounts_only()); 2109 strcpy(exclude_these_devices, 2089 mr_asprintf(exclude_these_directories,"%s",list_of_NFS_mounts_only()); 2090 mr_asprintf(exclude_these_devices,"%s", 2110 2091 call_program_and_get_last_line_of_output 2111 2092 ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2112 s printf(result_sz, "%s %s", exclude_these_directories,2113 exclude_these_devices );2114 paranoid_free(exclude_these_devices);2115 paranoid_free(exclude_these_directories);2093 snprintf(result_sz, "%s %s", exclude_these_directories, 2094 exclude_these_devices, 1023); 2095 mr_free(exclude_these_devices); 2096 mr_free(exclude_these_directories); 2116 2097 return (result_sz); 2117 2098 } … … 2128 2109 char *list_of_NFS_mounts_only(void) 2129 2110 { 2130 char *exclude_these_directories ;2111 char *exclude_these_directories = NULL; 2131 2112 static char result_sz[512]; 2132 2113 2133 malloc_string(exclude_these_directories); 2134 strcpy(exclude_these_directories, 2114 mr_asprintf(&exclude_these_directories,"%s", 2135 2115 call_program_and_get_last_line_of_output 2136 2116 ("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2137 s printf(result_sz, "%s", exclude_these_directories);2138 paranoid_free(exclude_these_directories);2117 snprintf(result_sz, "%s", exclude_these_directories, 511); 2118 mr_free(exclude_these_directories); 2139 2119 return (result_sz); 2140 2120 } … … 2183 2163 { 2184 2164 char *tmp = NULL; 2185 char *command, *sz; 2186 2187 malloc_string(command); 2188 malloc_string(sz); 2165 char *command = NULL; 2166 char *sz = NULL; 2167 2189 2168 assert(bkpinfo != NULL); 2190 2169 … … 2200 2179 2201 2180 if (tmp[0] != '/') { 2202 strcpy(sz, tmp);2181 mr_asprintf(&sz, tmp); 2203 2182 paranoid_free(tmp); 2204 2183 mr_asprintf(&tmp, "/%s", sz); 2184 mr_free(sz); 2205 2185 } 2206 2186 if (!tmp[0]) { … … 2214 2194 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2215 2195 2216 sprintf(command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);2196 mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp); 2217 2197 paranoid_free(tmp); 2218 2198 2219 2199 paranoid_system(command); 2220 paranoid_free(command); 2221 paranoid_free(sz); 2200 mr_free(command); 2222 2201 } 2223 2202 … … 2559 2538 char *command; 2560 2539 char *curr_fname; 2561 char *scratch ;2562 char *tmp ;2540 char *scratch = NULL; 2541 char *tmp = NULL; 2563 2542 char *p; 2564 2543 2565 2544 struct stat statbuf; 2566 2545 command = malloc(1000); 2567 malloc_string(tmp);2568 malloc_string(scratch);2569 2546 malloc_string(curr_fname); 2570 2547 if (!does_file_exist(incoming)) { … … 2578 2555 log_msg(1, "curr_fname = %s", curr_fname); 2579 2556 sprintf(command, "file %s", curr_fname); 2580 strcpy(tmp, call_program_and_get_last_line_of_output(command));2557 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 2581 2558 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; 2582 2559 p--); 2583 2560 p++; 2584 strcpy(scratch, p);2561 mr_asprintf(&scratch, p); 2585 2562 for (p = scratch; *p != '\0' && *p != '\''; p++); 2586 2563 *p = '\0'; 2587 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, 2588 scratch); 2564 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch); 2565 mr_free(tmp); 2566 2589 2567 if (scratch[0] == '/') { 2590 2568 strcpy(curr_fname, scratch); // copy whole thing because it's an absolute softlink … … 2599 2577 strcpy(p, scratch); 2600 2578 } 2579 mr_free(scratch); 2601 2580 lstat(curr_fname, &statbuf); 2602 2581 } … … 2606 2585 paranoid_free(command); 2607 2586 paranoid_free(curr_fname); 2608 paranoid_free(tmp);2609 2587 return (output); 2610 2588 } … … 2619 2597 { 2620 2598 static char output[4]; 2621 char *tmp ;2599 char *tmp = NULL; 2622 2600 char *command; 2623 2601 char *fdisk; … … 2625 2603 struct stat buf; 2626 2604 #endif 2627 malloc_string(tmp);2628 2605 malloc_string(command); 2629 2606 malloc_string(fdisk); … … 2632 2609 log_msg(1, "Using %s", fdisk); 2633 2610 sprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2634 strcpy(tmp, call_program_and_get_last_line_of_output(command));2611 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 2635 2612 if (strstr(tmp, "GPT") == NULL) { 2636 2613 strcpy(output, "MBR"); … … 2638 2615 strcpy(output, "GPT"); 2639 2616 } 2617 mr_free(tmp); 2618 2640 2619 log_msg(0, "Found %s partition table format type", output); 2641 2620 paranoid_free(command); 2642 paranoid_free(tmp);2643 2621 paranoid_free(fdisk); 2644 2622 return (output); -
branches/2.2.9/mondo/src/common/libmondo-fifo.c
r2049 r2214 155 155 void kill_buffer() 156 156 { 157 char *tmp ;158 char *command ;157 char *tmp = NULL; 158 char *command = NULL; 159 159 160 160 if (g_sz_call_to_buffer == NULL) { … … 164 164 return; 165 165 } 166 malloc_string(tmp);167 malloc_string(command);168 166 paranoid_system("sync"); 169 sprintf(command,167 mr_asprintf(&command, 170 168 "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $2;}' | grep -v PID | head -1", ps_options, g_sz_call_to_buffer); 171 169 log_msg(2, "kill_buffer() --- command = %s", command); 172 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 173 sprintf(command, "kill %s", tmp); 170 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 171 mr_free(command); 172 173 mr_asprintf(&command, "kill %s", tmp); 174 174 log_msg(2, "kill_buffer() --- command = %s", command); 175 175 if (strlen(tmp) > 0) { 176 176 run_program_and_log_output(command, TRUE); 177 177 } 178 paranoid_free(tmp);179 paranoid_free(command);178 mr_free(tmp); 179 mr_free(command); 180 180 } 181 181
Note:
See TracChangeset
for help on using the changeset viewer.