Changeset 146 in MondoRescue for trunk/mondo/mondo/mondoarchive/mondo-cli.c
- Timestamp:
- Dec 1, 2005, 10:00:14 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondoarchive/mondo-cli.c
r142 r146 367 367 368 368 long itbs; 369 370 malloc_string(tmp);371 malloc_string(psz);372 369 373 370 assert(bkpinfo != NULL); … … 532 529 } 533 530 flag_set['d'] = TRUE; 534 sprintf(tmp, 531 paranoid_free(tmp); // allocation from find_tape_device_and_size 532 533 asprintf(&tmp, 535 534 "You didn't specify a tape streamer device. I'm assuming %s", 536 535 flag_val['d']); 537 536 log_to_screen(tmp); 537 paranoid_free(tmp); 538 538 percent = 0; 539 539 } … … 616 616 strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN); 617 617 } 618 sprintf(tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",618 asprintf(&tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3", 619 619 bkpinfo->nfs_mount); 620 620 strncpy(bkpinfo->isodir, 621 621 call_program_and_get_last_line_of_output(tmp), 622 622 MAX_STR_LEN / 4); 623 paranoid_free(tmp); 624 623 625 if (strlen(bkpinfo->isodir) < 3) { 624 626 retval++; … … 670 672 if (flag_set['N']) // exclude NFS mounts & devices 671 673 { 672 // strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN); 673 strncpy(psz, list_of_NFS_mounts_only(), MAX_STR_LEN); 674 psz = list_of_NFS_mounts_only(); 674 675 if (bkpinfo->exclude_paths[0]) { 675 676 strncat(bkpinfo->exclude_paths, " ", MAX_STR_LEN); 676 677 } 677 678 strncat(bkpinfo->exclude_paths, psz, MAX_STR_LEN); 679 paranoid_free(psz); 680 678 681 log_msg(3, "-N means we're now excluding %s", 679 682 bkpinfo->exclude_paths); … … 684 687 } 685 688 if (flag_set['b']) { 686 strcpy(psz, flag_val['b']);689 asprintf(&psz, flag_val['b']); 687 690 log_msg(1, "psz = '%s'", psz); 688 691 if (psz[strlen(psz) - 1] == 'k') { … … 692 695 itbs = atol(psz); 693 696 } 697 paranoid_free(psz); 698 694 699 log_msg(1, "'%s' --> %ld", flag_val['b'], itbs); 695 700 log_msg(1, "Internal tape block size is now %ld bytes", itbs); … … 725 730 && !does_file_exist(bkpinfo->kernel_path)) { 726 731 retval++; 727 sprintf(tmp,732 asprintf(&tmp, 728 733 "You specified kernel '%s', which does not exist\n", 729 734 bkpinfo->kernel_path); 730 735 log_to_screen(tmp); 736 paranoid_free(tmp); 731 737 } 732 738 } … … 739 745 if (flag_set['i']) { 740 746 strncpy(bkpinfo->isodir, flag_val['d'], MAX_STR_LEN / 4); 741 sprintf(tmp, "ls -l %s", bkpinfo->isodir);747 asprintf(&tmp, "ls -l %s", bkpinfo->isodir); 742 748 if (run_program_and_log_output(tmp, FALSE)) { 743 749 fatal_error 744 750 ("output folder does not exist - please create it"); 745 751 } 752 paranoid_free(tmp); 746 753 } else if (flag_set['n']) { 747 754 strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN); … … 753 760 754 761 if (flag_set['n']) { 755 sprintf(tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,762 asprintf(&tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 756 763 bkpinfo->nfs_remote_dir); 757 764 if (run_program_and_log_output(tmp, FALSE)) { 758 765 retval++; 759 sprintf(tmp, 766 paranoid_free(tmp); 767 asprintf(&tmp, 760 768 "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", 761 769 bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); 762 770 log_to_screen(tmp); 763 771 } 772 paranoid_free(tmp); 764 773 } 765 774 … … 802 811 sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'], 803 812 random() % 32768); 804 sprintf(tmp, "touch %s/.foo.dat", flag_val['T']);813 asprintf(&tmp, "touch %s/.foo.dat", flag_val['T']); 805 814 if (run_program_and_log_output(tmp, 1)) { 806 815 retval++; … … 809 818 fatal_error("I cannot write to the tempdir you specified."); 810 819 } 811 sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], 820 paranoid_free(tmp); 821 822 asprintf(&tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], 812 823 flag_val['T']); 813 824 if (run_program_and_log_output(tmp, 1)) { … … 817 828 fatal_error("I cannot write to the tempdir you specified."); 818 829 } 830 paranoid_free(tmp); 819 831 } 820 832 if (flag_set['A']) { … … 851 863 } 852 864 if (flag_set['f']) { 853 strncpy(bkpinfo->boot_device, 854 resolve_softlinks_to_get_to_actual_device_file(flag_val 855 ['f']), 865 tmp = resolve_softlinks_to_get_to_actual_device_file(flag_val['f']); 866 strncpy(bkpinfo->boot_device, tmp, 856 867 MAX_STR_LEN / 4); 857 868 } 858 if (flag_set['P']) {859 strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN);860 }861 869 if (flag_set['Q']) { 870 if (tmp == NULL) { 871 printf("-f option required when using -Q\n"); 872 finish(-1); 873 } 862 874 i = which_boot_loader(tmp); 863 875 log_msg(3, "boot loader is %c, residing at %s", i, tmp); 864 876 printf("boot loader is %c, residing at %s\n", i, tmp); 865 877 finish(0); 878 } 879 paranoid_free(tmp); 880 881 if (flag_set['P']) { 882 strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN); 866 883 } 867 884 if (flag_set['L']) { … … 928 945 /* and finally... */ 929 946 930 paranoid_free(tmp);931 paranoid_free(psz);932 947 return (retval); 933 948 }
Note:
See TracChangeset
for help on using the changeset viewer.