Changeset 2325 in MondoRescue for branches/2.2.10/mondo/src/mondorestore
- Timestamp:
- Aug 18, 2009, 3:19:15 PM (15 years ago)
- Location:
- branches/2.2.10/mondo/src/mondorestore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2324 r2325 448 448 /** buffers **********************************************************/ 449 449 char *incoming; 450 char *tmp = NULL;451 450 452 451 /** pointers *********************************************************/ … … 2330 2329 char *drive_name) 2331 2330 { 2332 /**buffers **********************************************************/2333 char *tmp = NULL;2334 2331 2335 2332 /** int *************************************************************/ -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2324 r2325 360 360 /** needs malloc **********/ 361 361 362 char *tarball_fname = NULL; 363 char *progress_str = NULL; 364 char *tmp = NULL; 362 char *tarball_fname, *progress_str; 363 char *tmp = NULL; 365 364 char *mds = NULL; 366 365 long max_val; 367 366 367 malloc_string(tarball_fname); 368 malloc_string(progress_str); 368 369 369 370 assert(bkpinfo != NULL); 370 371 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives"); 371 372 malloc_string(tmp); 373 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 372 tmp = read_cfg_var(g_mondo_cfg_file, "last-filelist-number"); 374 373 max_val = atol(tmp); 374 mr_free(tmp); 375 375 376 paranoid_free(tmp); 376 377 … … 442 443 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 443 444 } 445 paranoid_free(tarball_fname); 446 paranoid_free(progress_str); 444 447 return (retval); 445 448 } … … 671 674 0, "Verifying archives against filesystem"); 672 675 676 mr_free(bkpinfo->media_device); 673 677 if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 674 strcpy(bkpinfo->media_device, 675 last_line_of_file("/tmp/CDROM-LIVES-HERE")); 676 } else { 677 find_cdrom_device(bkpinfo->media_device, FALSE); 678 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE")); 679 } else { 680 bkpinfo->media_device = find_cdrom_device(FALSE); 678 681 } 679 682 res = verify_tape_backups(); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c
r2323 r2325 2261 2261 /** 2262 2262 * Get information about the location of ISO images from the user. 2263 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters. 2263 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters. Allocted by the function 2264 2264 * @param isodir_format Where to put the format (e.g. ext2) the user enters. 2265 2265 * @param isodir_path Where to put the path (e.g. /var/cache/mondo) the user enters. … … 2267 2267 * @return TRUE if OK was pressed, FALSE otherwise. 2268 2268 */ 2269 bool get_isodir_info(char *isodir_device, char *isodir_format, char *isodir_path, bool nuke_me_please) 2270 { 2269 bool get_isodir_info(char *isodir_device, char *isodir_format, char *isodir_path, bool nuke_me_please) { 2271 2270 2272 2271 char *p = NULL; … … 2278 2277 /** initialize ********************************************************/ 2279 2278 2280 assert(isodir_device != NULL);2281 2279 assert(isodir_path != NULL); 2282 2280 2283 2281 log_it("isodir_path = %s", isodir_path); 2284 if (isodir_device [0] == '\0') {2282 if (isodir_device == NULL) { 2285 2283 mr_asprintf(idev, "/dev/"); 2286 2284 } else { … … 2297 2295 2298 2296 /* modify for the caller */ 2299 strcpy(isodir_device, idev); 2297 mr_free(isodir_device); 2298 isodir_device = idev; 2300 2299 if (nuke_me_please) { 2301 2300 ret = TRUE; … … 2316 2315 2317 2316 /* modify for the caller */ 2318 strcpy(isodir_device, p); 2317 mr_free(isodir_device); 2318 isodir_device = p; 2319 2319 mr_free(isodir_path); 2320 2320 isodir_path = r; … … 2327 2327 mr_free(p); 2328 2328 } 2329 mr_free(idev);2330 2329 mr_free(isodir_format); 2331 2330 return(ret); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2324 r2325 94 94 paranoid_free(g_tmpfs_mountpt); 95 95 */ 96 paranoid_free(g_isodir_device);96 mr_free(g_isodir_device); 97 97 98 98 } … … 260 260 char *command = NULL; 261 261 char *mds = NULL; 262 char *p = NULL;263 262 int retval = 0, i; 264 263 bool already_mounted = FALSE; … … 266 265 267 266 g_ISO_restore_mode = TRUE; 268 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 267 mr_free(g_isodir_device); 268 g_isodir_device = read_cfg_var(g_mondo_cfg_file, "iso-dev"); 269 269 if (bkpinfo->disaster_recovery) { 270 270 /* Patch Conor Daly 26-june-2004 … … 281 281 } 282 282 283 /* g_isodir_device is passed and modified in this function - memory is managed correctly in it */ 283 284 if (!get_isodir_info(g_isodir_device, isodir_format, bkpinfo->isodir, nuke_me_please)) { 284 285 mr_free(isodir_format); … … 570 571 571 572 char *mount_cmd = NULL; 572 char *p = NULL;573 573 int i, res; 574 574 #ifdef __FreeBSD__ … … 585 585 log_msg(2, "mount_media() - media already mounted. Fair enough."); 586 586 return (0); 587 } 588 589 if (bkpinfo->media_device == NULL) { 590 fatal_error("No media device at that point"); 587 591 } 588 592 … … 594 598 mr_asprintf(bkpinfo->isodir, "/tmp/isodir"); 595 599 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 600 } 601 if ((bkpinfo->isodir == NULL) || (bkpinfo->nfs_remote_dir == NULL) || (bkpinfo->prefix == NULL)) { 602 fatal_error("Unable to prepare the iso filename"); 596 603 } 597 604 #ifdef __FreeBSD__ … … 624 631 #endif 625 632 } else { 626 if (bkpinfo->disaster_recovery 627 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 628 strcpy(bkpinfo->media_device, 629 last_line_of_file("/tmp/CDROM-LIVES-HERE")); 633 mr_free(bkpinfo->media_device); 634 if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 635 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE")); 630 636 } else { 631 find_cdrom_device(bkpinfo->media_device,TRUE);637 bkpinfo->media_device = find_cdrom_device(TRUE); 632 638 } 633 639 … … 720 726 t_bkptype media_specified_by_user; 721 727 722 malloc_string(iso_mnt);723 malloc_string(iso_path);724 malloc_string(value);725 728 malloc_string(tmp); 726 729 // assert_string_is_neither_NULL_nor_zerolength(cfg_file); … … 735 738 media_specified_by_user = bkpinfo->backup_media_type; // or 'none', if not specified 736 739 737 if (0 == read_cfg_var(cfg_file, "backup-media-type", value)) { 738 if (!strcmp(value, "cdstream")) { 739 bkpinfo->backup_media_type = cdstream; 740 } else if (!strcmp(value, "cdr")) { 741 bkpinfo->backup_media_type = cdr; 742 } else if (!strcmp(value, "cdrw")) { 743 bkpinfo->backup_media_type = cdrw; 744 } else if (!strcmp(value, "dvd")) { 745 bkpinfo->backup_media_type = dvd; 746 } else if (!strcmp(value, "usb")) { 747 bkpinfo->backup_media_type = usb; 748 bkpinfo->please_dont_eject = TRUE; 749 } else if (!strcmp(value, "iso")) { 750 751 // Patch by Conor Daly - 2004/07/12 752 bkpinfo->backup_media_type = iso; 753 if (am_I_in_disaster_recovery_mode()) { 754 /* Check to see if CD is already mounted before mounting it... */ 755 if (!is_this_device_mounted("/dev/cdrom")) { 756 log_msg(2, 757 "NB: CDROM device not mounted, mounting..."); 758 run_program_and_log_output("mount /dev/cdrom " 759 MNT_CDROM, 1); 760 } 761 if (does_file_exist(MNT_CDROM "/archives/filelist.0")) { 762 bkpinfo->backup_media_type = cdr; 763 run_program_and_log_output("umount " MNT_CDROM, 1); 764 log_it 765 ("Re-jigging configuration AGAIN. CD-R, not ISO."); 766 } 767 } 768 mr_free(bkpinfo->prefix); 769 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 770 mr_asprintf(bkpinfo->prefix, "%s", value); 740 if ((value = read_cfg_var(cfg_file, "backup-media-type")) == 0) { 741 if (!strcmp(value, "cdstream")) { 742 bkpinfo->backup_media_type = cdstream; 743 } else if (!strcmp(value, "cdr")) { 744 bkpinfo->backup_media_type = cdr; 745 } else if (!strcmp(value, "cdrw")) { 746 bkpinfo->backup_media_type = cdrw; 747 } else if (!strcmp(value, "dvd")) { 748 bkpinfo->backup_media_type = dvd; 749 } else if (!strcmp(value, "usb")) { 750 bkpinfo->backup_media_type = usb; 751 bkpinfo->please_dont_eject = TRUE; 752 } else if (!strcmp(value, "iso")) { 753 // Patch by Conor Daly - 2004/07/12 754 bkpinfo->backup_media_type = iso; 755 if (am_I_in_disaster_recovery_mode()) { 756 /* Check to see if CD is already mounted before mounting it... */ 757 if (!is_this_device_mounted("/dev/cdrom")) { 758 log_msg(2, "NB: CDROM device not mounted, mounting..."); 759 run_program_and_log_output("mount /dev/cdrom " MNT_CDROM, 1); 760 } 761 if (does_file_exist(MNT_CDROM "/archives/filelist.0")) { 762 bkpinfo->backup_media_type = cdr; 763 run_program_and_log_output("umount " MNT_CDROM, 1); 764 log_it 765 ("Re-jigging configuration AGAIN. CD-R, not ISO."); 766 } 767 } 768 mr_free(bkpinfo->prefix); 769 mr_free(value); 770 if ((value = read_cfg_var(cfg_file, "iso-prefix")) == 0) { 771 mr_asprintf(bkpinfo->prefix, "%s", value); 772 } else { 773 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 774 } 775 } else if (!strcmp(value, "nfs")) { 776 bkpinfo->backup_media_type = nfs; 777 bkpinfo->please_dont_eject = TRUE; 778 mr_free(bkpinfo->prefix); 779 mr_free(value); 780 if ((value = read_cfg_var(cfg_file, "iso-prefix")) == 0) { 781 mr_asprintf(bkpinfo->prefix, "%s", value); 782 } else { 783 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 784 } 785 786 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) { 787 /* We need to override prefix value in PXE mode as it's 788 * already done in start-nfs */ 789 envtmp1 = getenv("imgname"); 790 if (envtmp1 == NULL) { 791 fatal_error("no imgname variable in environment"); 792 } 793 mr_free(bkpinfo->prefix); 794 mr_asprintf(bkpinfo->prefix, "%s", envtmp1); 795 } 796 797 } else if (!strcmp(value, "tape")) { 798 bkpinfo->backup_media_type = tape; 799 } else if (!strcmp(value, "udev")) { 800 bkpinfo->backup_media_type = udev; 771 801 } else { 772 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 773 } 774 } else if (!strcmp(value, "nfs")) { 775 bkpinfo->backup_media_type = nfs; 776 bkpinfo->please_dont_eject = TRUE; 777 mr_free(bkpinfo->prefix); 778 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 779 mr_asprintf(bkpinfo->prefix, "%s", value); 780 } else { 781 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 782 } 783 784 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) { 785 /* We need to override prefix value in PXE mode as it's 786 * already done in start-nfs */ 787 envtmp1 = getenv("imgname"); 788 if (envtmp1 == NULL) { 789 fatal_error("no imgname variable in environment"); 790 } 791 mr_free(bkpinfo->prefix); 792 mr_asprintf(bkpinfo->prefix, "%s", envtmp1); 793 } 794 795 } else if (!strcmp(value, "tape")) { 796 bkpinfo->backup_media_type = tape; 797 } else if (!strcmp(value, "udev")) { 798 bkpinfo->backup_media_type = udev; 802 fatal_error("UNKNOWN bkp-media-type"); 803 } 799 804 } else { 800 fatal_error("UNKNOWN bkp-media-type"); 801 } 802 } else { 803 fatal_error("backup-media-type not specified!"); 804 } 805 fatal_error("backup-media-type not specified!"); 806 } 807 mr_free(value); 808 805 809 if (bkpinfo->disaster_recovery) { 806 810 if (bkpinfo->backup_media_type == cdstream) { 807 sprintf(bkpinfo->media_device, "/dev/cdrom");808 // bkpinfo->media_size[0] = -1;811 mr_free(bkpinfo->media_device); 812 mr_asprintf(bkpinfo->media_device, "/dev/cdrom"); 809 813 bkpinfo->media_size[0] = 1999 * 1024; 810 814 bkpinfo->media_size[1] = 650; /* good guess */ … … 812 816 envtmp1 = getenv("MRUSBDEV"); 813 817 if (envtmp1 == NULL) { 814 if ( read_cfg_var(cfg_file, "usb-dev", value)) {818 if ((value = read_cfg_var(cfg_file, "usb-dev")) == NULL) { 815 819 fatal_error("Cannot get USB device name from cfg file"); 816 820 } 817 821 } else { 818 strcpy(value,envtmp1); 819 } 820 sprintf(bkpinfo->media_device, "%s1", value); 822 mr_asprintf(value,"%s", envtmp1); 823 } 824 mr_free(bkpinfo->media_device); 825 mr_asprintf(bkpinfo->media_device, "%s1", value); 826 mr_free(value); 821 827 log_msg(2, "Backup medium is USB --- dev=%s", bkpinfo->media_device); 822 } else if (bkpinfo->backup_media_type == tape 823 || bkpinfo->backup_media_type == udev) { 824 if (read_cfg_var(cfg_file, "media-dev", value)) { 828 } else if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) { 829 if ((value = read_cfg_var(cfg_file, "media-dev")) == NULL) { 825 830 fatal_error("Cannot get tape device name from cfg file"); 826 831 } 827 strcpy(bkpinfo->media_device, value); 828 read_cfg_var(cfg_file, "media-size", value); 829 bkpinfo->media_size[1] = atol(value); 832 mr_free(bkpinfo->media_device); 833 bkpinfo->media_device = value; 834 835 value = read_cfg_var(cfg_file, "media-size"); 836 if (value != NULL) { 837 bkpinfo->media_size[1] = atol(value); 838 mr_free(value); 839 } else { 840 bkpinfo->media_size[1] = 0L; 841 } 830 842 log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device); 831 843 } else { 832 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ 844 mr_free(bkpinfo->media_device); 845 mr_asprintf(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ 833 846 bkpinfo->media_size[0] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 834 847 bkpinfo->media_size[1] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ … … 836 849 } 837 850 } else { 838 log_msg(2, 839 "Not in Disaster Recovery Mode. No need to derive device name from config file."); 840 } 841 842 read_cfg_var(cfg_file, "use-star", value); 843 if (strstr(value, "yes")) { 851 log_msg(2, "Not in Disaster Recovery Mode. No need to derive device name from config file."); 852 } 853 854 value = read_cfg_var(cfg_file, "use-star"); 855 if (value && strstr(value, "yes")) { 844 856 bkpinfo->use_star = TRUE; 845 857 log_msg(1, "Goody! ... bkpinfo->use_star is now true."); 846 858 } 847 848 read_cfg_var(cfg_file, "obdr", value); 849 if (strstr(value, "TRUE")) { 859 mr_free(value); 860 861 value = read_cfg_var(cfg_file, "obdr"); 862 if (value && strstr(value, "TRUE")) { 850 863 bkpinfo->use_obdr = TRUE; 851 864 log_msg(1, "OBDR mode activated"); 852 865 } 853 854 read_cfg_var(cfg_file, "acl", value); 855 if (strstr(value, "TRUE")) { 866 mr_free(value); 867 868 value = read_cfg_var(cfg_file, "acl"); 869 if (value && strstr(value, "TRUE")) { 856 870 mr_asprintf(g_getfacl,"setfacl"); 857 871 log_msg(1, "We will restore ACLs"); … … 860 874 } 861 875 } 862 read_cfg_var(cfg_file, "xattr", value); 863 if (strstr(value, "TRUE")) { 876 mr_free(value); 877 878 value = read_cfg_var(cfg_file, "xattr"); 879 if (value && strstr(value, "TRUE")) { 864 880 mr_asprintf(g_getfattr,"setfattr"); 865 881 log_msg(1, "We will restore XATTRs"); … … 868 884 } 869 885 } 870 871 if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) { 872 bkpinfo->internal_tape_block_size = atol(value);873 log_msg(1, "Internal tape block size has been custom-set to %ld", 874 bkpinfo->internal_tape_block_size);886 mr_free(value); 887 888 value = read_cfg_var(cfg_file, "internal-tape-block-size"); 889 if (value != NULL) { 890 bkpinfo->internal_tape_block_size = atol(value); 875 891 } else { 876 bkpinfo->internal_tape_block_size = 877 DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 878 log_msg(1, "Internal tape block size = default (%ld)", 879 DEFAULT_INTERNAL_TAPE_BLOCK_SIZE); 880 } 881 882 read_cfg_var(cfg_file, "use-lzo", value); 883 if (strstr(value, "yes")) { 884 bkpinfo->use_lzo = TRUE; 885 bkpinfo->use_gzip = FALSE; 886 strcpy(bkpinfo->zip_exe, "lzop"); 887 strcpy(bkpinfo->zip_suffix, "lzo"); 888 } else { 889 read_cfg_var(cfg_file, "use-gzip", value); 890 if (strstr(value, "yes")) { 892 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 893 } 894 log_msg(1, "Internal tape block size set to %ld", bkpinfo->internal_tape_block_size); 895 mr_free(value); 896 897 bkpinfo->zip_exe[0] = bkpinfo->zip_suffix[0] = '\0'; 898 value = read_cfg_var(cfg_file, "use-lzo"); 899 if (value && strstr(value, "yes")) { 900 bkpinfo->use_lzo = TRUE; 901 bkpinfo->use_gzip = FALSE; 902 strcpy(bkpinfo->zip_exe, "lzop"); 903 strcpy(bkpinfo->zip_suffix, "lzo"); 904 } 905 mr_free(value); 906 907 value = read_cfg_var(cfg_file, "use-gzip"); 908 if (value && strstr(value, "yes")) { 891 909 bkpinfo->use_lzo = FALSE; 892 910 bkpinfo->use_gzip = TRUE; 893 911 strcpy(bkpinfo->zip_exe, "gzip"); 894 912 strcpy(bkpinfo->zip_suffix, "gz"); 913 } 914 mr_free(value); 915 916 value = read_cfg_var(cfg_file, "use-comp"); 917 if (value && strstr(value, "yes")) { 918 bkpinfo->use_lzo = FALSE; 919 bkpinfo->use_gzip = FALSE; 920 strcpy(bkpinfo->zip_exe, "bzip2"); 921 strcpy(bkpinfo->zip_suffix, "bz2"); 922 } 923 mr_free(value); 924 925 value = read_cfg_var(cfg_file, "differential"); 926 if (value && (!strcmp(value, "yes") || !strcmp(value, "1"))) { 927 bkpinfo->differential = TRUE; 928 } 929 log_msg(2, "differential var = '%s'", value); 930 mr_free(value); 931 if (bkpinfo->differential) { 932 log_msg(2, "THIS IS A DIFFERENTIAL BACKUP"); 895 933 } else { 896 read_cfg_var(cfg_file, "use-comp", value); 897 if (strstr(value, "yes")) { 898 bkpinfo->use_lzo = FALSE; 899 bkpinfo->use_gzip = FALSE; 900 strcpy(bkpinfo->zip_exe, "bzip2"); 901 strcpy(bkpinfo->zip_suffix, "bz2"); 902 } else { 903 bkpinfo->zip_exe[0] = bkpinfo->zip_suffix[0] = '\0'; 904 } 905 } 906 } 907 908 value[0] = '\0'; 909 read_cfg_var(cfg_file, "differential", value); 910 if (!strcmp(value, "yes") || !strcmp(value, "1")) { 911 bkpinfo->differential = TRUE; 912 } 913 log_msg(2, "differential var = '%s'", value); 914 if (bkpinfo->differential) { 915 log_msg(2, "THIS IS A DIFFERENTIAL BACKUP"); 916 } else { 917 log_msg(2, "This is a regular (full) backup"); 918 } 919 920 read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp); 921 if (tmp[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) { 934 log_msg(2, "This is a regular (full) backup"); 935 } 936 937 tmp = read_cfg_var(g_mondo_cfg_file, "please-dont-eject"); 938 if (tmp || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) { 922 939 bkpinfo->please_dont_eject = TRUE; 923 940 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 924 941 } 942 mr_free(tmp); 925 943 926 944 if (bkpinfo->backup_media_type == nfs) { 927 945 if (!cfgf) { 928 log_msg(2, "nfs_mount remains %s", bkpinfo->nfs_mount); 929 log_msg(2, "nfs_remote_dir remains %s", 930 bkpinfo->nfs_remote_dir); 931 log_msg(2, 932 "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place"); 946 if (bkpinfo->nfs_mount) { 947 log_msg(2, "nfs_mount remains %s", bkpinfo->nfs_mount); 948 } 949 if (bkpinfo->nfs_remote_dir) { 950 log_msg(2, "nfs_remote_dir remains %s", bkpinfo->nfs_remote_dir); 951 } 952 log_msg(2, "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place"); 933 953 } else { 934 read_cfg_var(g_mondo_cfg_file, "nfs-server-mount", 935 bkpinfo->nfs_mount); 936 read_cfg_var(g_mondo_cfg_file, "nfs-server-path", 937 bkpinfo->nfs_remote_dir); 938 log_msg(2, "nfs_mount is %s", bkpinfo->nfs_mount); 939 log_msg(2, "nfs_remote_dir is %s", bkpinfo->nfs_remote_dir); 940 } 941 if (strstr(call_program_and_get_last_line_of_output 942 ("cat /proc/cmdline"), "pxe")) { 954 mr_free(bkpinfo->nfs_mount); 955 bkpinfo->nfs_mount = read_cfg_var(g_mondo_cfg_file, "nfs-server-mount"); 956 957 mr_free(bkpinfo->nfs_remote_dir); 958 bkpinfo->nfs_remote_dir = read_cfg_var(g_mondo_cfg_file, "nfs-server-path"); 959 960 if (bkpinfo->nfs_mount != NULL) { 961 log_msg(2, "nfs_mount is %s", bkpinfo->nfs_mount); 962 } 963 if (bkpinfo->nfs_remote_dir != NULL) { 964 log_msg(2, "nfs_remote_dir is %s", bkpinfo->nfs_remote_dir); 965 } 966 } 967 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) { 943 968 /* We need to override values in PXE mode as it's 944 969 * already done in start-nfs */ … … 951 976 fatal_error("no dirimg variable in environment"); 952 977 } 953 strcpy(bkpinfo->nfs_mount,envtmp1); 954 strcpy(bkpinfo->nfs_remote_dir,envtmp2); 978 mr_free(bkpinfo->nfs_mount); 979 mr_asprintf(bkpinfo->nfs_mount, "%s", envtmp1); 980 981 mr_free(bkpinfo->nfs_remote_dir); 982 mr_asprintf(bkpinfo->nfs_remote_dir, "%s", envtmp2); 955 983 } 956 984 } else if (bkpinfo->backup_media_type == iso) { … … 960 988 */ 961 989 mr_asprintf(old_isodir, "%s", bkpinfo->isodir); 962 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt);963 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path);990 iso_mnt = read_cfg_var(g_mondo_cfg_file, "iso-mnt"); 991 iso_path = read_cfg_var(g_mondo_cfg_file, "isodir"); 964 992 mr_free(bkpinfo->isodir); 965 993 mr_asprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 994 mr_free(iso_mnt); 995 966 996 if (!bkpinfo->isodir[0]) { 967 997 mr_free(bkpinfo->isodir); … … 979 1009 } 980 1010 } 981 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 1011 mr_free(g_isodir_device); 1012 g_isodir_device = read_cfg_var(g_mondo_cfg_file, "iso-dev"); 982 1013 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); 983 1014 … … 989 1020 log_it("command = %s", command); 990 1021 log_it("res of it = %s", call_program_and_get_last_line_of_output(command)); 991 sprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));1022 mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command)); 992 1023 mr_free(command); 993 1024 } else { 994 sprintf(iso_mnt, "/tmp/isodir");1025 mr_asprintf(iso_mnt, "/tmp/isodir"); 995 1026 mr_asprintf(tmp1, "mkdir -p %s", iso_mnt); 996 1027 run_program_and_log_output(tmp1, 5); … … 999 1030 mr_asprintf(tmp1, "mount %s %s", g_isodir_device, iso_mnt); 1000 1031 if (run_program_and_log_output(tmp1, 3)) { 1001 log_msg(1, 1002 "Unable to mount isodir. Perhaps this is really a CD backup?"); 1032 log_msg(1, "Unable to mount isodir. Perhaps this is really a CD backup?"); 1003 1033 bkpinfo->backup_media_type = cdr; 1004 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */1005 iso_mnt[0] = iso_path[0] = '\0';1034 mr_free(bkpinfo->media_device); 1035 mr_asprintf(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */ 1006 1036 if (mount_media()) { 1007 1037 mr_free(tmp1); … … 1019 1049 bkpinfo->isodir = tmp1; 1020 1050 } 1021 } 1051 mr_free(iso_mnt); 1052 } 1053 mr_free(iso_path); 1022 1054 } 1023 1055 … … 1041 1073 paranoid_free(value); 1042 1074 paranoid_free(tmp); 1043 paranoid_free(iso_mnt);1044 paranoid_free(iso_path);1045 1075 return (0); 1046 1076 … … 1316 1346 1317 1347 /** malloc *******/ 1318 char *device ;1319 char *name ;1348 char *device = NULL; 1349 char *name = NULL; 1320 1350 char *cmd = NULL; 1321 1322 malloc_string(device);1323 malloc_string(name);1324 1351 1325 1352 /* In order to have a working bootloader, we need to have all devices … … 1337 1364 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map"); 1338 1365 backup_crucial_file(MNT_RESTORING, "/etc/mtab"); 1339 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);1340 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);1366 device = read_cfg_var(g_mondo_cfg_file, "bootloader.device"); 1367 name = read_cfg_var(g_mondo_cfg_file, "bootloader.name"); 1341 1368 log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name); 1342 1369 system("sync"); … … 1375 1402 } 1376 1403 #endif 1404 mr_free(device); 1405 mr_free(name); 1406 1377 1407 retval += res; 1378 1408 if (res) { … … 1381 1411 log_to_screen("Your boot loader ran OK"); 1382 1412 } 1383 paranoid_free(device);1384 paranoid_free(name);1385 1413 return (retval); 1386 1414 } … … 1849 1877 malloc_string(g_mountlist_fname); 1850 1878 malloc_string(g_mondo_home); 1851 malloc_string(g_isodir_device);1852 1879 1853 1880 sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB); … … 2180 2207 run_program_and_log_output("mkdir -p tmp", FALSE); 2181 2208 2182 if ( strlen(bkpinfo->media_device) == 0) {2183 strcpy(bkpinfo->media_device, "/dev/st0");2184 log_msg(2, "media_device is blank; assuming %s" );2209 if (! bkpinfo->media_device) { 2210 mr_asprintf(bkpinfo->media_device, "/dev/st0"); 2211 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device); 2185 2212 } 2186 2213 mr_asprintf(tmp, "%s", bkpinfo->media_device); 2187 2214 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 2188 strcpy(bkpinfo->media_device, "/dev/st0"); 2215 mr_free(bkpinfo->media_device); 2216 mr_asprintf(bkpinfo->media_device, "/dev/st0"); 2189 2217 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 2190 strcpy(bkpinfo->media_device, "/dev/osst0"); 2218 mr_free(bkpinfo->media_device); 2219 mr_asprintf(bkpinfo->media_device, "/dev/osst0"); 2191 2220 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 2192 strcpy(bkpinfo->media_device, "/dev/ht0"); 2221 mr_free(bkpinfo->media_device); 2222 mr_asprintf(bkpinfo->media_device, "/dev/ht0"); 2193 2223 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 2194 2224 log_msg(3, "I tried lots of devices but none worked."); 2195 strcpy(bkpinfo->media_device, tmp); 2225 mr_free(bkpinfo->media_device); 2226 mr_asprintf(bkpinfo->media_device, "%s", tmp); 2196 2227 } 2197 2228 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2324 r2325 969 969 interactively_obtain_media_parameters_from_user(FALSE); 970 970 } 971 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 972 if (!bkpinfo->media_device[0]) { 973 log_msg(2, "Warning - failed to find media dev"); 971 if (!bkpinfo->media_device) { 972 log_msg(2, "WARNING: failed to find media dev"); 973 } else { 974 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 974 975 } 975 976 … … 1999 2000 long noof_biggiefiles, bigfileno = 0, total_slices; 2000 2001 /** malloc **/ 2001 char *tmp;2002 2002 char *tmp1 = NULL; 2003 2003 char *mds = NULL; … … 2009 2009 FILE *fbw = NULL; 2010 2010 2011 malloc_string(tmp);2012 2011 malloc_string(pathname_of_last_biggie_restored); 2013 2012 assert(bkpinfo != NULL); … … 2018 2017 } 2019 2018 2020 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2021 total_slices = atol(tmp); 2019 tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices"); 2020 total_slices = atol(tmp1); 2021 mr_free(tmp1); 2022 2022 2023 mr_asprintf(tmp1, "Reassembling large files "); 2023 2024 mvaddstr_and_log_it(g_currentY, 0, tmp1); … … 2108 2109 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2109 2110 } 2110 paranoid_free(tmp);2111 2111 paranoid_free(pathname_of_last_biggie_restored); 2112 2112 return (retval); … … 2138 2138 long max_val; 2139 2139 /**malloc ***/ 2140 char *tmp = NULL;2141 2140 char *mds = NULL; 2142 2141 char *tmp1 = NULL; … … 2145 2144 char *comment; 2146 2145 2147 malloc_string(tmp);2148 2146 malloc_string(comment); 2149 2147 … … 2157 2155 } 2158 2156 insist_on_this_cd_number(g_current_media_number); 2159 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);2160 max_val = atol(tmp ) + 1;2161 paranoid_free(tmp);2157 tmp1 = read_cfg_var(g_mondo_cfg_file, "last-filelist-number"); 2158 max_val = atol(tmp1) + 1; 2159 mr_free(tmp1); 2162 2160 2163 2161 mds = media_descriptor_string(bkpinfo->backup_media_type); … … 2278 2276 2279 2277 /** malloc add ****/ 2280 char *tmp; 2281 char *tmp1; 2278 char *tmp1 = NULL; 2282 2279 char *biggie_fname; 2283 2280 char *biggie_cksum; … … 2290 2287 FILE *fbw = NULL; 2291 2288 2292 malloc_string(tmp);2293 2289 malloc_string(biggie_fname); 2294 2290 malloc_string(biggie_cksum); … … 2296 2292 assert(bkpinfo != NULL); 2297 2293 2298 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2299 2300 total_slices = atol(tmp); 2294 tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices"); 2295 total_slices = atol(tmp1); 2296 mr_free(tmp1); 2297 2301 2298 if (g_getfattr) { 2302 2299 mr_asprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); … … 2408 2405 paranoid_free(biggie_fname); 2409 2406 paranoid_free(biggie_cksum); 2410 paranoid_free(tmp);2411 2407 return (retval); 2412 2408 } … … 2453 2449 assert(bkpinfo != NULL); 2454 2450 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives"); 2455 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);2451 tmp = read_cfg_var(g_mondo_cfg_file, "last-filelist-number"); 2456 2452 max_val = atol(tmp) + 1; 2453 mr_free(tmp); 2457 2454 2458 2455 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ … … 2595 2592 openin_cdstream(); 2596 2593 } else { 2597 assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device);2598 2594 openin_tape(); 2599 2595 } … … 2933 2929 // BCO:To be reviewed 2934 2930 if ((bkpinfo->restore_mode == compare) || (bkpinfo->restore_mode == nuke)) { 2935 if (bkpinfo->backup_media_type == nfs 2936 && !is_this_device_mounted(bkpinfo->nfs_mount)) { 2931 if (bkpinfo->backup_media_type == nfs && bkpinfo->nfs_mount && !is_this_device_mounted(bkpinfo->nfs_mount)) { 2937 2932 log_msg(1, "Mounting nfs dir"); 2938 2933 mr_free(bkpinfo->isodir); -
branches/2.2.10/mondo/src/mondorestore/mr-externs.h
r2321 r2325 62 62 extern void setup_newt_stuff(void); 63 63 extern void init_bkpinfo(); 64 extern int read_cfg_var(char *,char *, char *);64 extern char *read_cfg_var(char *, char *); 65 65 extern int read_file_from_stream_to_file(char *, 66 66 long long);
Note:
See TracChangeset
for help on using the changeset viewer.