Changeset 688 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-restore.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-restore.c
r687 r688 1 1 /*************************************************************************** 2 mondo-restore.c - restores mondoarchive data 3 ------------------- 4 begin : Fri May 19 2000 5 copyright : (C) 2000 by Hugo Rabson 6 email : Hugo Rabson <hugorabson@msn.com> 7 cvsid : $Id$ 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * * 12 * This program is free software; you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation; either version 2 of the License, or * 15 * (at your option) any later version. * 16 * * 17 ***************************************************************************/ 18 19 /*************************************************************************** 20 * Change Log * 21 *************************************************************************** 22 . 23 24 25 07/26 26 - workaround - if not /dev then don't call partimagehack 27 28 07/21 29 - if switch to Interactive Mode during nuke then don't nuke twice :) just once 30 31 07/18 32 - better support of users who boot from LVM CD and nuke-restore non-LVM backups 33 34 07/10 35 - when using 'star', exclude all 'not removed.' messages from log (misleading, they are) 36 - try w/ ACLs, then w/o ACLs if star fails w/ ACLs 37 - added ACL, xattr support for afio 38 39 06/26 40 - remove make_relevant_partition_bootable(); roll into mondo-prep.c 41 - changed various newtDrawRootText() calls to use g_noof_rows instead of 42 integers 43 44 06/19 45 - don't try to access biggiestruct before it is populated w/ data relating 46 to biggiefile; instead, use control char to find out if biggiefile is 47 to be restored w/ partimagehack or not 48 - added AUX_VER 49 50 06/15 51 - read_cfg_file_into_bkpinfo() --- use user-supplied 'isodir' instead of 52 archive's 'isodir' if different 53 Conor Daly <conor.daly@met.ie> 54 55 06/17 56 - restore with partimagehack if NTFS device; dd, if non-NTFS device 57 58 06/14 59 - unmount all; remount, run grub-mr; unmount again 60 61 04/09 62 - fixed subset restoration bug introduced when I added 'star' support 63 64 04/04 65 - cleaned up restore_a_tarball_from_stream() 66 67 04/03 68 - added star support 69 - pause for 3s between partitioning and formatting (if in Nuke Mode) 70 71 03/28 72 - check that g_mountlist_fname was correcfly set; abort if it wasn't 73 74 03/25 75 - removed dev_null code 76 77 03/22/04 78 - added mode_of_file() 79 - added code to check for unauthorised modification of /dev/null 80 by afio (for instance) 81 82 12/27/03 83 - check /tmp/cmdline instead of /proc/cmdline if on FreeBSD 84 85 11/15 86 - added g_fprep 87 - "Switch to interactive mode?" msg is now more informative 88 89 11/05 90 - after 'Are you sure?' when user specifies / as restore path, set 91 restore_path[] to "" so that files are restored to [blank]/file/name :) 92 93 10/29 94 - moved "No restoring or comparing will take place today" block 95 up to before iso_fiddly_bits (if iso) is called - fix bug 96 if you're in ISO Mode and you say "exit to shell" 97 98 10/22 99 - swapped calls to chmod() and chown() after restoration 100 of big files (Jens) 101 102 10/21 103 - changed "/mnt/cdrom" to MNT_CDROM 104 105 10/19 106 - restore biggiefiles selectively from CD properly 107 - use find_my_editor() to find pico/vi/whatever 108 - better use of call_program_and_get_last_line_of_output() to 109 scan /proc/cmdline 110 111 10/18 112 - don't report 'missing compressor' if no compressor used at all 113 114 10/14 115 - log afio's error messages to /var/log/mondo-archive.log 116 when restoring :) 117 - call vi if pico is not available 118 119 10/09 120 - better logging if fatal error (cannot openout bigfile) 121 - better GUI feedback when restoring big files 122 - restore_everything() now uses s_node* instead of char* 123 - ditto restore_all_*_from_*() 124 125 10/02 126 - succinct msg instead of pop-ups, if used -H 127 128 09/27 129 - tweaked restore-time gui 130 131 09/26 132 - proper reporting of DVD/CDR/etc. type in displayed dialogs 133 134 09/23 135 - malloc/free global strings in new subroutines - malloc_libmondo_global_strings() 136 and free_libmondo_global_strings() - which are in libmondo-tools.c 137 138 09/21 139 - trying to fix "mondorestore <no params>" segfault 140 141 09/18 142 - better remounting of / 143 - cleaned up run_grub() 144 - sensible command-line handling in Live Mode 145 146 09/17 147 - cleaned up GRUB installer script a bit 148 149 09/15 150 - remount / as r/w if in disaster recovery mode; 151 helps for b0rken distros 152 153 09/13 154 - major NTFS hackage 155 156 09/12 157 - changed some in-sub var decl'ns to malloc()'s 158 159 09/05 160 - don't let me run unless I'm root 161 - finished NTFS/partimagehack support (CD only); working on tape now 162 163 09/01 164 - fixed cosmetic bug in biggiefile restore window 165 166 06/01 - 08/31 167 - added code to main() to make sure NFS 168 (backup) share is mounted in Nuke and Compare Modes 169 - added code to run_grub() to mount /boot before running grub-install 170 - fixed some stray assert()'s in restore_a_biggiefile_from_stream() 171 - fixed bugs in extract_config_file_from_ramdisk() 172 and get_cfg_file_from_archive() which 173 stopped fape+floppy users from being able to 174 boot from floppy and leave floppy in drive :) 175 - added hooks to partimage for doing imagedevs 176 - fixed calls to popup_and_get_string() 177 178 05/01 - 05/31 179 - fixed biggiefile atime/utime dates restoration bug, I think 180 - added misc clean-up (Steve Hindle) 181 - fixed support for subdir-within-NFS-mount 182 - if nuke mode fails & user reverts to interactive mode _and succeeds_, 183 don't claim nuke mode aborted :) 184 - unmount_all_devices() uses mountlist->el[lino].mountpt 185 instead of mountlist->el[lino].device where possible 186 - added Joshua Oreman's FreeBSD patches 187 - copied missing paragraph from 1.6x's read_cfg_file_into_bkpinfo() 188 to 1.7x's; affected tape streamer users (badly!) 189 - cleaned up some paranoid assert()'s 190 - use which("post-nuke") instead of find_home_of_exe("post-nuke") 191 - fixed "Don't eject while restoring" mode 192 - get_cfg_file_from_archive() --- also recovers mountlist.txt now :) 193 - don't eject if 'donteject' is in kernel's command line 194 - added 'don't panic' msg to start of log 195 196 04/01 - 04/30 197 - added text mode (cat /proc/cmdline; if textonly then text mode is on) 198 - delete /var/lock/subsys/ * when nuking 199 - don't resize mountlist if "noresize" present in /proc/cmdline 200 - changed from chmod -R 1777 tmp to chmod 1777 tmp 201 - replace newtFinished() and newtInit() with 202 newtSuspend() and newtResume() 203 - get_cfg_file_from_archive() returns 1 instead of aborting now 204 - read_cfg_file_into_bkpinfo) --- if autorun CD but its config 205 file indicates a non-CD backup media then ask, just in case 206 - sped up restore_a_tarball_from_CD() a bit 207 - line 4469 --- if post-nuke not found then don't run it :) 208 - replaced "/mnt/RESTORING" with MNT_RESTORING (#define'd) 209 - moved compare_*() into mondorestore/mondo-rstr-compare.c 210 - moved some RAID subroutines into common/libmondo-raid.c 211 - fixed some iso live compare problems 212 - replaced FILELIST_FULL with g_filelist_full and FILELIST_FULL_STUB; 213 g_filelist_full being the full path of the filelist.full text file and 214 FILELIST_FULL_STUB being "tmp/filelist.full" (relative path); 215 - ditto BIGGIELIST_TXT, MONDO_CFG_FILE 216 - added lots of assert()'s and log_OS_error()'s 217 - in Nuke Mode, check mountlist's sanity before doing anything else; 218 if it fails sanity test, offer to revert to Interactive Mode (or abort) 219 - copy log to /mnt/RESTORING/root at end 220 - read_cfg_file_into_bkpinfo() --- read iso-dev and isodir if bkptype==iso 221 - line 1701 --- delete ramdisk file after extracting config info 222 - moved call to make_relevant_partitions_bootable() from 223 within run_boot_loader() to within interactive_mode() and 224 nuke_mode(), after unmounting disks 225 - if editing fstab or *.conf, try to use pico if available 226 - better calling of make-me-bootable 227 - don't sort mountlist anywhere anymore except _locally_ in 228 mount_all_devices() and unmount_all_devices() 229 - edit fstab, grub.conf _after_ stabgrub-me if it fails 230 - run_boot_loader() --- backup all crucial files to /etc/ *.pristine first 231 - added iso_fiddly_bits() 232 - fixed ISO mode support 233 - mount_cdrom() only searches for device if NOT in disaster recovery mode 234 - changed lost of system()'s into run_program_and_log_output()'s 235 - don't eject if bkpinfo->please_dont_eject_when_restoring 236 - cleaned up post-nuke handling code 237 - always eject CD at end, unless bkpinfo->please_dont_... 238 - misc clean-up (Tom Mortell) 239 - afio uses -c (1024L*1024L)/TAPE_BLOCK_SIZE now 240 instead of -c 1024 241 242 01/01 - 03/31/2003 243 - commented out sort_... line (BB) 244 - clean-up (Stan Benoit) 245 - added code for LVM and SW Raid (Brian Borgeson) 246 - line 814 - added -p to 'mkdir -p tmp' 247 - mount_cdrom() - calls find_cdrom_device() if 248 bkpinfo->media_device is blank (to fill it) 249 250 11/01 - 12/31/2002 251 - mount_cdrom() better at handling multiple CD drives 252 - minor clean-up in restore_a_tarball_from_CD() 253 - if --live-from-cd then assume restoring live from CD 254 - tweaked it to run better w/ ArkLinux 255 - create /mnt/RESTORING/mnt/.boot.d for Gentoo users 256 after restoring 257 - cleaned up iso_mode(); no longer asks for NFS info 3 times 258 - mount_cdrom() was trying to mount /mnt/isodir/%s/%d.iso; 259 is now just %s/%d.iso 260 - mount/unmount /boot if necessary (Gentoo) 261 - added RAW MBR support; added run_raw_mbr() for the purpose 262 - unmount & remount supermounts at start/end of live restore 263 - copy /tmp/mountlist.txt to /tmp/mountlist.txt.orig at start 264 - cleaned up string-handling in get_cfg_info_from_archives() 265 - fixed run_grub() to call new stabgrub-me script 266 - popup list of changed files after Compare Mode 267 - permit mondorestore --edit-mountlist even if live mode 268 - create a repaired copy of grub-install which is RAID-friendly; 269 use it when initializing boot sector with run_grub() 270 - use grub-MR instead of grub-install 271 - fixed read_cfg_file_into_bkpinfo() to ignore cfg file's backup_media_type 272 if user has already specified a backup media type interactively 273 274 10/01 - 10/31 275 - run_grub() will let you specify the boot device as well as edit the system 276 files, if grub-install fails 277 - fixed bug in fwrite() call in restore_biggiefile_from_CD() 278 - fixed bug affecting restoration of bigfiles from CD's w/0 compression 279 - run_grub() will run 'grub-install {boot device}' instead of 280 'grub-install (hd0)' 281 282 09/01 - 09/30 283 - use /tmp/tmpfs/mondo.tmp instead of /tmp/mondo.tmp 284 - initialize MOUNTLIST_FNAME at start of main() 285 - differential-related cleanup 286 - better handling of CD-ROM drives which aren't /dev/cdrom :) 287 - run_program_and_log_output() now takes boolean operator to specify 288 whether it will log its activities in the event of _success_ 289 - always load config file from archive before operating on it 290 - moved some subroutines around; now closer to alphabetical order 291 - changed mount.mindi to mount.bootisk 292 - mount disks readonly if in Compare Mode 293 - set /dev/null's permissions to 777, just in case it somehow gets mangled 294 ...which apparently happen with some devfs-based Linux distributions 295 - remove /var/run/ *.pid after restoring 296 - move spurious lockfiles from /home/ * to /home/ * /.disabled 297 - if Interactive Mode then ask user which media, etc. (i.e. catchall mode 298 is now same as Interactive Mode) 299 300 08/01 - 08/30 301 - use data structure to store the fname, checksum, mods & perms of each bigfile 302 ... biggiestruct :) 303 - if a filelist is tiny (2 bytes or less) then ignore it 304 - insist_on_this_cd_number() --- now takes 2 params, not 1 305 - re-enabled 'g_current_media_number = 1' in restore_everything() 306 - added same to compare_mode() 307 - replaced lots of global char[]'s with malloc()'s 308 - if differential backup then don't permit formatting or fdisking, 309 whether Interactive or Nuke mode 310 - added call to register_pid() at start of main() 311 - if Nuke Mode & it succeeds then ask user if they have contributed yet 312 - changed tape-size to media-size (config file) 313 - changed using_* to backup_media_type 314 - changed *_from_tape to *_from_stream 315 316 07/01 - 07/31 317 - added find_and_mount_actual_cdrom() 318 - temp dir is always random 319 - skip tarballs if they don't contain files we're looking for 320 (used to read the whole thing & _then_ skip) 321 - use media_size[1] instead of media_size[0] 322 - fixed serious bug in line 1546 - should have been !=, not ==; stopped 323 mondorestore from correctly restoring big files 324 - bigfile piping enhancements (Philippe de Muyter) 325 - unmount CD-ROM after restoring from live filesystem 326 - TAPE_BLOCK_SIZE treated as %ld, not %d 327 328 06/01 - 06/30 329 - added signal-trapping 330 - disabled 'nr-failed-disks' flag 331 - fixed problem w/selective restore 332 - don't change /tmp's permissions unless it doesn't exist & must be created 333 - fixed bug in --mbr 334 - is_file_in_list() enhanced to exclude /mnt/RESTORING or whatever 335 - added support for uncompressed archives 336 - --monitas-live now accepts path-to-restore_to_, not just path to restore 337 - added some debugging/tracking code to the NFS section 338 - various monitas-related enhancements 339 - added --isonuke and --mbr switches 340 - better logging in run_grub() 341 - improved --monitas-live 342 - mkdir -p /mnt/RESTORING/var/run/console just in case user excludes it 343 - afio now uses 16MB buffer instead of 8MB 344 - always use bkpinfo->media_size[0], now that -s has been expanded 345 - popup and ask where to restore data, if restoring selectively 346 347 05/01 - 05/31 348 - add '--monitas' flag 349 - don't run chmod -R 1777 /mnt/RESTORING/tmp before unmounting unless 350 restoring at the time... 351 352 04/01 - 04/30 353 - delete old /tmp/filelist.full,biggielist.txt if found when restoring to 354 live filesystem 355 - replace MONDO_VERSION #define with VERSION from ../config.h 356 - write fname of bigfile to screen when having trouble reading/comparing it 357 - if restoring to live filesystem then wipe /tmp/tmpfs/ * afterwards 358 - removed spurious finish(0) from main() 359 360 03/01 - 03/31/2002 361 - if /tmp/m*ndo-restore.cfg not found then assume live restore; restore 362 to / instead of /mnt/RESTORING 363 - clean up is_file_in_list() to deal with the /mnt/RESTORING/ prefix 364 - exclude leading '/' from filelist.restore-these 365 - if /tmp/fstab.new exists then use _it_ instead of /tmp/fstab to label 366 ext2 or ext3 partitions 367 - improved logging 368 369 [...] 370 371 07/10/2001 --- first incarnation 372 */ 373 2 * $Id$ 3 */ 374 4 375 5 /** … … 381 11 * #include statements * 382 12 **************************************************************************/ 13 #include <unistd.h> 14 383 15 #include "../common/my-stuff.h" 384 16 #include "../common/mondostructures.h" … … 443 75 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode. 444 76 */ 445 char *g_isodir_device ;77 char *g_isodir_device = NULL; 446 78 447 79 /** 448 80 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode. 449 81 */ 450 char *g_isodir_format ;82 char *g_isodir_format = NULL; 451 83 452 84 /** 453 85 * The location of 'biggielist.txt', containing the biggiefiles on the current archive set. 454 86 */ 455 char *g_biggielist_txt ;87 char *g_biggielist_txt = NULL; 456 88 457 89 /** … … 459 91 * the current archive set. 460 92 */ 461 char *g_filelist_full ;93 char *g_filelist_full = NULL; 462 94 463 95 /** … … 465 97 * as images, not as individual files. 466 98 */ 467 char *g_filelist_imagedevs ;99 char *g_filelist_imagedevs = NULL; 468 100 469 101 /** … … 471 103 * @see g_filelist_imagedevs 472 104 */ 473 char *g_imagedevs_restthese ;105 char *g_imagedevs_restthese = NULL; 474 106 475 107 /** … … 477 109 * information for this backup. 478 110 */ 479 char *g_mondo_cfg_file ;111 char *g_mondo_cfg_file = NULL; 480 112 481 113 /** … … 483 115 * user's partitions and hard drives. 484 116 */ 485 char *g_mountlist_fname ;117 char *g_mountlist_fname = NULL; 486 118 487 119 /** … … 489 121 * to avoid link errors. 490 122 */ 491 char *g_mondo_home ;123 char *g_mondo_home = NULL; 492 124 493 125 /* @} - end of "Restore-Time Globals" in globalGroup */ 494 495 496 126 497 127 extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, 498 128 char direction); 499 500 501 129 502 130 /************************************************************************** … … 508 136 */ 509 137 #define COMPAQ_PROLIANTS_SUCK _("Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo CD/floppy in Interactive Mode.") 510 511 512 138 513 139 … … 561 187 562 188 563 564 565 566 189 /** 567 190 * Determine whether @p mountlist contains a Compaq diagnostic partition. … … 604 227 popup_and_OK(COMPAQ_PROLIANTS_SUCK); 605 228 if (ask_me_yes_or_no 606 (_("Would you like to reboot and use your Compaq CD to prep your hard drive?"))) 229 (_ 230 ("Would you like to reboot and use your Compaq CD to prep your hard drive?"))) 607 231 { 608 fatal_error 609 (_("Aborting. Please reboot and prep your hard drive with your Compaq CD."));232 fatal_error(_ 233 ("Aborting. Please reboot and prep your hard drive with your Compaq CD.")); 610 234 } 611 235 } … … 614 238 *END_OFFER_TO_ABORT_BECAUSE_COMPAQ_PROLIANTS_SUCK * 615 239 **************************************************************************/ 616 617 240 618 241 … … 637 260 assert(mountlist != NULL); 638 261 assert(raidlist != NULL); 639 malloc_string(tmp);640 262 iamhere("pre wrm"); 641 263 c = which_restore_mode(); … … 644 266 interactively_obtain_media_parameters_from_user(bkpinfo, FALSE); 645 267 } else { 646 popup_and_OK(_("No restoring or comparing will take place today.")); 268 popup_and_OK(_ 269 ("No restoring or comparing will take place today.")); 647 270 if (is_this_device_mounted("/mnt/cdrom")) { 648 271 run_program_and_log_output("umount /mnt/cdrom", FALSE); 649 272 } 650 273 if (g_ISO_restore_mode) { 651 sprintf(tmp, "umount %s", bkpinfo->isodir);274 asprintf(&tmp, "umount %s", bkpinfo->isodir); 652 275 run_program_and_log_output(tmp, FALSE); 276 paranoid_free(tmp); 653 277 } 654 278 paranoid_MR_finish(0); … … 677 301 retval += compare_mode(bkpinfo, mountlist, raidlist); 678 302 } 679 paranoid_free(tmp);680 303 return (retval); 681 304 } … … 726 349 727 350 728 729 730 351 /** 731 352 * @addtogroup restoreGroup … … 754 375 bool restore_all; 755 376 756 /** needs malloc **********/ 757 char *tmp ;758 char *fstab_fname ;759 char *old_restpath ;760 761 struct s_node *filelist ;377 char *tmp = NULL; 378 char *tmp1 = NULL; 379 char *fstab_fname = NULL; 380 char *old_restpath = NULL; 381 382 struct s_node *filelist = NULL; 762 383 763 384 /* try to partition and format */ … … 765 386 log_msg(2, "interactive_mode --- starting (great, assertions OK)"); 766 387 767 malloc_string(tmp);768 malloc_string(fstab_fname);769 malloc_string(old_restpath);770 388 assert(bkpinfo != NULL); 771 389 assert(mountlist != NULL); … … 776 394 if (g_text_mode) { 777 395 if (!ask_me_yes_or_no 778 (_("Interactive Mode + textonly = experimental! Proceed anyway?"))) 396 (_ 397 ("Interactive Mode + textonly = experimental! Proceed anyway?"))) 779 398 { 780 399 fatal_error("Wise move."); … … 787 406 iamhere("Done loading config file; resizing ML"); 788 407 #ifdef __FreeBSD__ 789 if (strstr 790 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 791 "noresize")) 408 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 792 409 #else 793 if (strstr 794 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 795 "noresize")) 410 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 796 411 #endif 797 {412 if (strstr(tmp,"noresize")) { 798 413 log_msg(1, "Not resizing mountlist."); 799 414 } else { … … 804 419 if (g_text_mode) { 805 420 save_mountlist_to_disk(mountlist, g_mountlist_fname); 806 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname); 421 tmp1 = find_my_editor(); 422 asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname); 423 paranoid_free(tmp1); 424 807 425 res = system(tmp); 426 paranoid_free(tmp); 808 427 load_mountlist(mountlist, g_mountlist_fname); 809 428 } else { … … 819 438 mvaddstr_and_log_it(1, 30, _("Restoring Interactively")); 820 439 if (bkpinfo->differential) { 821 log_to_screen(_("Because this is a differential backup, disk")); 822 log_to_screen 823 (_(" partitioning and formatting will not take place.")); 440 log_to_screen(_ 441 ("Because this is a differential backup, disk")); 442 log_to_screen(_ 443 (" partitioning and formatting will not take place.")); 824 444 done = TRUE; 825 445 } else { 826 446 if (ask_me_yes_or_no 827 (_("Do you want to erase and partition your hard drives?"))) { 447 (_ 448 ("Do you want to erase and partition your hard drives?"))) 449 { 828 450 if (partition_table_contains_Compaq_diagnostic_partition 829 451 (mountlist)) { … … 836 458 if (ptn_errs) { 837 459 log_to_screen 838 (_("Warning. Errors occurred during disk partitioning.")); 460 (_ 461 ("Warning. Errors occurred during disk partitioning.")); 839 462 } 840 463 841 fmt_errs = format_everything(mountlist, FALSE, raidlist); 464 fmt_errs = 465 format_everything(mountlist, FALSE, raidlist); 842 466 if (!fmt_errs) { 843 467 log_to_screen 844 (_("Errors during disk partitioning were handled OK.")); 845 log_to_screen 846 (_("Partitions were formatted OK despite those errors.")); 468 (_ 469 ("Errors during disk partitioning were handled OK.")); 470 log_to_screen(_ 471 ("Partitions were formatted OK despite those errors.")); 847 472 ptn_errs = 0; 848 473 } … … 854 479 } else { 855 480 mvaddstr_and_log_it(g_currentY++, 0, 856 _("User opted not to partition the devices")); 481 _ 482 ("User opted not to partition the devices")); 857 483 if (ask_me_yes_or_no 858 484 (_("Do you want to format your hard drives?"))) { 859 fmt_errs = format_everything(mountlist, TRUE, raidlist); 485 fmt_errs = 486 format_everything(mountlist, TRUE, raidlist); 860 487 if (!fmt_errs) { 861 488 done = TRUE; … … 869 496 mvaddstr_and_log_it(g_currentY++, 870 497 0, 871 _("Errors occurred. Please repartition and format drives manually.")); 498 _ 499 ("Errors occurred. Please repartition and format drives manually.")); 872 500 done = FALSE; 873 501 } … … 875 503 mvaddstr_and_log_it(g_currentY++, 876 504 0, 877 _("Errors occurred during partitioning. Formatting, however, went OK.")); 505 _ 506 ("Errors occurred during partitioning. Formatting, however, went OK.")); 878 507 done = TRUE; 879 508 } … … 881 510 if (!ask_me_yes_or_no(_("Re-edit the mountlist?"))) { 882 511 retval++; 883 goto end_of_func; 512 iamhere("Leaving interactive_mode()"); 513 return (retval); 884 514 } 885 515 } … … 891 521 unmount_all_devices(mountlist); 892 522 retval++; 893 goto end_of_func; 523 iamhere("Leaving interactive_mode()"); 524 return (retval); 894 525 } 895 526 /* restore */ 896 527 if ((restore_all = 897 ask_me_yes_or_no(_("Do you want me to restore all of your data?")))) 528 ask_me_yes_or_no(_ 529 ("Do you want me to restore all of your data?")))) 898 530 { 899 531 log_msg(1, "Restoring all data"); 900 532 retval += restore_everything(bkpinfo, NULL); 901 } else 902 if ((restore_all = 533 } else if ((restore_all = 903 534 ask_me_yes_or_no 904 535 (_("Do you want me to restore _some_ of your data?")))) { 905 strcpy(old_restpath, bkpinfo->restore_path);536 old_restpath = bkpinfo->restore_path; 906 537 for (done = FALSE; !done;) { 907 538 unlink("/tmp/filelist.full"); … … 912 543 if (filelist) { 913 544 gotos_suck: 914 strcpy(tmp, old_restpath);915 545 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING); 916 546 if (popup_and_get_string 917 (_("Restore path"), _("Restore files to where?"), tmp, 918 MAX_STR_LEN / 4)) { 919 if (!strcmp(tmp, "/")) { 547 (_("Restore path"), _("Restore files to where?"), bkpinfo->restore_path)) { 548 if (!strcmp(bkpinfo->restore_path, "/")) { 920 549 if (!ask_me_yes_or_no(_("Are you sure?"))) { 550 paranoid_free(bkpinfo->restore_path); 551 bkpinfo->restore_path = old_restpath; 921 552 goto gotos_suck; 922 553 } 923 tmp[0] = '\0'; // so we restore to [blank]/file/name :)554 paranoid_alloc(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :) 924 555 } 925 strcpy(bkpinfo->restore_path, tmp);926 556 log_msg(1, "Restoring subset"); 927 557 retval += restore_everything(bkpinfo, filelist); 928 558 free_filelist(filelist); 929 559 } else { 930 strcpy(bkpinfo->restore_path, old_restpath);560 bkpinfo->restore_path = old_restpath; 931 561 free_filelist(filelist); 932 562 } … … 939 569 } 940 570 } 941 strcpy(old_restpath, bkpinfo->restore_path);942 571 } else { 943 572 mvaddstr_and_log_it(g_currentY++, 944 573 0, 945 _("User opted not to restore any data. ")); 574 _ 575 ("User opted not to restore any data. ")); 946 576 } 947 577 if (retval) { 948 578 mvaddstr_and_log_it(g_currentY++, 949 579 0, 950 _("Errors occurred during the restore phase. ")); 580 _ 581 ("Errors occurred during the restore phase. ")); 951 582 } 952 583 … … 956 587 mvaddstr_and_log_it(g_currentY++, 957 588 0, 958 _("User opted not to initialize the boot loader.")); 589 _ 590 ("User opted not to initialize the boot loader.")); 959 591 } 960 592 961 593 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1); 962 594 protect_against_braindead_sysadmins(); 963 // modify_rclocal_one_time( MNT_RESTORING "/etc" );964 595 retval += unmount_all_devices(mountlist); 965 596 /* if (restore_some || restore_all || */ … … 967 598 (_("Label your ext2 and ext3 partitions if necessary?"))) { 968 599 mvaddstr_and_log_it(g_currentY, 0, 969 _("Using e2label to label your ext2,3 partitions")); 600 _ 601 ("Using e2label to label your ext2,3 partitions")); 970 602 if (does_file_exist("/tmp/fstab.new")) { 971 strcpy(fstab_fname, "/tmp/fstab.new");603 asprintf(&fstab_fname, "/tmp/fstab.new"); 972 604 } else { 973 strcpy(fstab_fname, "/tmp/fstab");974 } 975 sprintf(tmp,605 asprintf(&fstab_fname, "/tmp/fstab"); 606 } 607 asprintf(&tmp, 976 608 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 977 609 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 978 610 MONDO_LOGFILE); 611 paranoid_free(fstab_fname); 612 979 613 res = system(tmp); 614 paranoid_free(tmp); 980 615 if (res) { 981 616 log_to_screen … … 992 627 mvaddstr_and_log_it(g_currentY++, 993 628 0, 994 _("Warning - errors occurred during the restore phase.")); 995 } 996 end_of_func: 997 paranoid_free(tmp); 998 paranoid_free(fstab_fname); 999 paranoid_free(old_restpath); 1000 iamhere("Leaving interactive_mode()"); 1001 return (retval); 629 _ 630 ("Warning - errors occurred during the restore phase.")); 631 } 1002 632 } 1003 633 … … 1005 635 *END_INTERACTIVE_MODE * 1006 636 **************************************************************************/ 1007 1008 637 1009 638 … … 1054 683 if (system("umount /tmp/isodir 2> /dev/null")) { 1055 684 log_to_screen 1056 (_("WARNING - unable to unmount device where the ISO files are stored.")); 685 (_ 686 ("WARNING - unable to unmount device where the ISO files are stored.")); 1057 687 } 1058 688 // } … … 1065 695 1066 696 1067 /* MONDO - saving your a$$ since Feb 18th, 2000 */ 1068 1069 697 static void call_me_after_the_nuke(int retval) { 698 699 char *tmp = NULL; 700 char *tmp1 = NULL; 701 702 if (retval) { 703 log_to_screen(_("Errors occurred during the nuke phase.")); 704 log_to_screen(_("Please visit our website at http://www.mondorescue.org for more information.")); 705 } else { 706 #ifdef __FreeBSD__ 707 tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 708 #else 709 tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 710 #endif 711 if ((strstr(tmp1,"restore") == NULL) || 712 (strstr(tmp1,"RESTORE") == NULL)) { 713 /* -H option */ 714 asprintf(&tmp, 715 _ 716 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.")); 717 popup_and_OK(tmp); 718 paranoid_free(tmp); 719 } 720 paranoid_free(tmp1); 721 722 log_to_screen(_ 723 ("Mondo has restored your system. Please remove the backup media and reboot.")); 724 log_to_screen(_ 725 ("Thank you for using Mondo Rescue.")); 726 log_to_screen(_ 727 ("Please visit our website at http://www.mondorescue.org for more information.")); 728 } 729 g_I_have_just_nuked = TRUE; 730 return; 731 } 1070 732 1071 733 … … 1087 749 int res = 0; 1088 750 bool boot_loader_installed = FALSE; 1089 /** malloc **/ 1090 char tmp[MAX_STR_LEN], tmpA[MAX_STR_LEN], tmpB[MAX_STR_LEN], 1091 tmpC[MAX_STR_LEN]; 751 char *tmp = NULL; 752 char tmpA[MAX_STR_LEN]; 753 char tmpB[MAX_STR_LEN]; 754 char tmpC[MAX_STR_LEN]; 1092 755 1093 756 assert(bkpinfo != NULL); … … 1100 763 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo updated the mountlist 1101 764 #ifdef __FreeBSD__ 1102 if (strstr 1103 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 1104 "noresize")) 765 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 1105 766 #else 1106 if (strstr 1107 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 1108 "noresize")) 767 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 1109 768 #endif 1110 {769 if (strstr(tmp,"noresize")) { 1111 770 log_msg(2, "Not resizing mountlist."); 1112 771 } else { 1113 772 resize_mountlist_proportionately_to_suit_new_drives(mountlist); 1114 773 } 774 paranoid_free(tmp); 775 1115 776 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 1116 sprintf(tmp, 1117 _("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"), 777 asprintf(&tmp, 778 _ 779 ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"), 1118 780 tmpA, tmpB, tmpC); 1119 781 if (ask_me_yes_or_no(tmp)) { 782 paranoid_free(tmp); 1120 783 retval = interactive_mode(bkpinfo, mountlist, raidlist); 1121 784 finish(retval); 1122 785 } else { 786 paranoid_free(tmp); 1123 787 fatal_error("Nuke Mode aborted. "); 1124 788 } … … 1128 792 if (bkpinfo->differential) { 1129 793 log_to_screen(_("Because this is a differential backup, disk")); 1130 log_to_screen(_("partitioning and formatting will not take place.")); 794 log_to_screen(_ 795 ("partitioning and formatting will not take place.")); 1131 796 res = 0; 1132 797 } else { … … 1138 803 g_fprep = fopen("/tmp/prep.sh", "w"); 1139 804 #ifdef __FreeBSD__ 1140 if (strstr 1141 (call_program_and_get_last_line_of_output 1142 ("cat /tmp/cmdline"), "nopart")) 805 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 1143 806 #else 1144 if (strstr 1145 (call_program_and_get_last_line_of_output 1146 ("cat /proc/cmdline"), "nopart")) 807 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 1147 808 #endif 1148 {809 if (strstr(tmp,,"nopart")) { 1149 810 log_msg(2, 1150 811 "Not partitioning drives due to 'nopart' option."); … … 1154 815 if (res) { 1155 816 log_to_screen 1156 (_("Warning. Errors occurred during partitioning.")); 817 (_ 818 ("Warning. Errors occurred during partitioning.")); 1157 819 res = 0; 1158 820 } 1159 821 } 822 paranoid_free(tmp); 823 1160 824 retval += res; 1161 825 if (!res) { 1162 826 log_to_screen(_("Preparing to format your disk(s)")); 1163 827 sleep(1); 1164 system("sync"); 1165 log_to_screen(_("Please wait. This may take a few minutes.")); 828 sync(); 829 log_to_screen(_ 830 ("Please wait. This may take a few minutes.")); 1166 831 res += format_everything(mountlist, FALSE, raidlist); 1167 832 } … … 1173 838 mvaddstr_and_log_it(g_currentY++, 1174 839 0, 1175 _("Failed to partition and/or format your hard drives.")); 840 _ 841 ("Failed to partition and/or format your hard drives.")); 1176 842 1177 843 if (ask_me_yes_or_no(_("Try in interactive mode instead?"))) { 1178 844 retval = interactive_mode(bkpinfo, mountlist, raidlist); 1179 goto after_the_nuke;845 call_me_after_the_nuke(retval); 1180 846 } else 1181 847 if (!ask_me_yes_or_no 1182 848 (_("Would you like to try to proceed anyway?"))) { 1183 return (retval);1184 }849 } 850 return(retval); 1185 851 } 1186 852 retval = mount_all_devices(mountlist, TRUE); … … 1188 854 unmount_all_devices(mountlist); 1189 855 log_to_screen 1190 (_("Unable to mount all partitions. Sorry, I cannot proceed.")); 856 (_ 857 ("Unable to mount all partitions. Sorry, I cannot proceed.")); 1191 858 return (retval); 1192 859 } … … 1200 867 protect_against_braindead_sysadmins(); 1201 868 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1); 1202 // modify_rclocal_one_time( MNT_RESTORING "/etc" );1203 869 retval += unmount_all_devices(mountlist); 1204 870 mvaddstr_and_log_it(g_currentY, 1205 871 0, 1206 _("Using e2label to label your ext2,3 partitions")); 1207 1208 sprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab", 872 _ 873 ("Using e2label to label your ext2,3 partitions")); 874 875 asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab", 1209 876 g_mountlist_fname); 1210 877 res = run_program_and_log_output(tmp, TRUE); 878 paranoid_free(tmp); 879 1211 880 if (res) { 1212 log_to_screen(_("label-partitions-as-necessary returned an error")); 881 log_to_screen(_ 882 ("label-partitions-as-necessary returned an error")); 1213 883 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 1214 884 } else { … … 1216 886 } 1217 887 retval += res; 1218 1219 after_the_nuke: 1220 if (retval) { 1221 log_to_screen(_("Errors occurred during the nuke phase.")); 1222 } else if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "RESTORE")) // Bruno's thing 1223 { 1224 log_to_screen 1225 (_("PC was restored successfully. Thank you for using Mondo Rescue.")); 1226 log_to_screen 1227 (_("Please visit our website at http://www.mondorescue.org for more information.")); 1228 } else { 1229 strcpy(tmp,_(" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.")); 1230 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "restore") == NULL) { 1231 popup_and_OK(tmp); 1232 } 1233 log_to_screen 1234 (_("Mondo has restored your system. Please remove the backup media and reboot.")); 1235 log_to_screen 1236 (_("Please visit our website at http://www.mondorescue.org for more information.")); 1237 } 1238 g_I_have_just_nuked = TRUE; 1239 /* 1240 if (!boot_loader_installed && !does_file_exist(DO_MBR_PLEASE)) 1241 { 1242 log_to_screen("PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR"); 1243 write_one_liner_data_file(DO_MBR_PLEASE, "mondorestore --mbr"); 1244 } 1245 */ 1246 return (retval); 888 call_me_after_the_nuke(retval); 889 return(retval); 1247 890 } 1248 1249 891 /************************************************************************** 1250 892 *END_NUKE_MODE * 1251 893 **************************************************************************/ 1252 1253 894 1254 895 … … 1263 904 int retval = 0; 1264 905 1265 /** malloc **/ 1266 char *old_restpath; 1267 1268 struct mountlist_itself *mountlist; 1269 // static 1270 struct raidlist_itself *raidlist; 1271 struct s_node *filelist; 906 char *old_restpath = NULL; 907 908 struct mountlist_itself *mountlist = NULL; 909 struct raidlist_itself *raidlist = NULL; 910 struct s_node *filelist = NULL; 1272 911 1273 912 log_msg(1, "restore_to_live_filesystem() - starting"); 1274 913 assert(bkpinfo != NULL); 1275 malloc_string(old_restpath); 914 1276 915 mountlist = malloc(sizeof(struct mountlist_itself)); 1277 916 raidlist = malloc(sizeof(struct raidlist_itself)); 917 1278 918 if (!mountlist || !raidlist) { 1279 919 fatal_error("Cannot malloc() mountlist and/or raidlist"); 1280 920 } 1281 921 1282 strcpy(bkpinfo->restore_path, "/");922 paranoid_alloc(bkpinfo->restore_path, "/"); 1283 923 if (!g_restoring_live_from_cd) { 1284 924 popup_and_OK 1285 (_("Please insert tape/CD/boot floppy, then hit 'OK' to continue.")); 925 (_ 926 ("Please insert tape/CD/boot floppy, then hit 'OK' to continue.")); 1286 927 sleep(1); 1287 928 } … … 1308 949 if (filelist) { 1309 950 save_filelist(filelist, "/tmp/selected-files.txt"); 1310 strcpy(old_restpath, bkpinfo->restore_path);951 old_restpath = bkpinfo->restore_path; 1311 952 if (popup_and_get_string(_("Restore path"), 1312 953 _("Restore files to where? )"), 1313 bkpinfo->restore_path , MAX_STR_LEN / 4)) {954 bkpinfo->restore_path)) { 1314 955 iamhere("Restoring everything"); 1315 956 retval += restore_everything(bkpinfo, filelist); 1316 free_filelist(filelist); 1317 strcpy(bkpinfo->restore_path, old_restpath); 1318 } else { 1319 free_filelist(filelist); 1320 } 1321 strcpy(bkpinfo->restore_path, old_restpath); 957 } 958 free_filelist(filelist); 959 bkpinfo->restore_path = old_restpath; 1322 960 } 1323 961 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1329 967 eject_device(bkpinfo->media_device); 1330 968 } 1331 paranoid_free(old_restpath);1332 969 free(mountlist); 1333 970 free(raidlist); … … 1358 995 * @return 0 for success (or skip), nonzero for failure. 1359 996 */ 1360 int 997 char * 1361 998 restore_a_biggiefile_from_CD(struct s_bkpinfo *bkpinfo, 1362 999 long bigfileno, 1363 struct s_node *filelist, 1364 char *pathname_of_last_file_restored) 1000 struct s_node *filelist) 1365 1001 { 1366 FILE *fin; 1367 FILE *fout; 1368 FILE *fbzip2; 1369 1370 /** malloc ***/ 1371 char *checksum, *outfile_fname, *tmp, *bzip2_command, 1372 *ntfsprog_command, *suffix, *sz_devfile; 1373 char *bigblk; 1374 char *p; 1002 FILE *fin = NULL; 1003 FILE *fout = NULL; 1004 FILE *fbzip2 = NULL; 1005 char *checksum = NULL; 1006 char *outfile_fname = NULL; 1007 char *tmp = NULL; 1008 char *tmp1 = NULL; 1009 char *tmp2 = NULL; 1010 char *tmp3 = NULL; 1011 char *bzip2_command = NULL; 1012 char *bigblk = NULL; 1013 char *pathname_of_last_file_restored = NULL; 1375 1014 int retval = 0; 1376 1015 int finished = FALSE; 1377 1016 long sliceno; 1378 1017 long siz; 1379 char ntfsprog_fifo[MAX_STR_LEN]; 1018 long siz1; 1019 char *ntfsprog_fifo = NULL; 1380 1020 char *file_to_openout = NULL; 1381 1021 struct s_filename_and_lstat_info biggiestruct; 1382 struct utimbuf the_utime_buf, *ubuf ;1022 struct utimbuf the_utime_buf, *ubuf = NULL; 1383 1023 bool use_ntfsprog_hack = FALSE; 1384 1024 pid_t pid; 1385 1025 int res = 0; 1386 1026 int old_loglevel; 1387 char sz_msg[MAX_STR_LEN];1388 struct s_node *node ;1027 char *sz_msg; 1028 struct s_node *node = NULL; 1389 1029 1390 1030 old_loglevel = g_loglevel; … … 1392 1032 assert(bkpinfo != NULL); 1393 1033 1394 malloc_string(checksum);1395 malloc_string(outfile_fname);1396 malloc_string(tmp);1397 malloc_string(bzip2_command);1398 malloc_string(ntfsprog_command);1399 malloc_string(suffix);1400 malloc_string(sz_devfile);1401 1402 pathname_of_last_file_restored[0] = '\0';1403 1034 if (!(bigblk = malloc(TAPE_BLOCK_SIZE))) { 1404 1035 fatal_error("Cannot malloc bigblk"); 1405 1036 } 1406 1037 1407 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 1038 tmp = slice_fname(bigfileno, 0, ARCHIVES_PATH, ""); 1039 if (!(fin = fopen(tmp,"r"))) { 1408 1040 log_to_screen(_("Cannot even open bigfile's info file")); 1409 return (1); 1410 } 1041 paranoid_free(tmp); 1042 return (pathname_of_last_file_restored); 1043 } 1044 paranoid_free(tmp); 1411 1045 1412 1046 memset((void *) &biggiestruct, 0, sizeof(biggiestruct)); … … 1418 1052 paranoid_fclose(fin); 1419 1053 1420 strcpy(checksum, biggiestruct.checksum);1054 asprintf(&checksum, biggiestruct.checksum); 1421 1055 1422 1056 if (!checksum[0]) { 1423 sprintf(tmp, "Warning - bigfile %ld does not have a checksum",1057 asprintf(&tmp, "Warning - bigfile %ld does not have a checksum", 1424 1058 bigfileno + 1); 1425 1059 log_msg(3, tmp); 1060 paranoid_free(tmp); 1061 /* BERLIOS : Useless ??? 1426 1062 p = checksum; 1427 } 1063 */ 1064 } 1065 paranoid_free(checksum); 1428 1066 1429 1067 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) 1430 1068 { 1431 strcpy(outfile_fname, biggiestruct.filename);1069 asprintf(&outfile_fname, biggiestruct.filename); 1432 1070 } else { 1433 sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,1071 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1434 1072 biggiestruct.filename); 1435 1073 } … … 1441 1079 log_msg(0, "Skipping %s (name isn't in filelist)", 1442 1080 biggiestruct.filename); 1443 pathname_of_last_file_restored[0] = '\0'; 1444 return (0); 1081 return (pathname_of_last_file_restored); 1445 1082 } else if (!(node->selected)) { 1446 1083 log_msg(1, "Skipping %s (name isn't in biggielist subset)", 1447 1084 biggiestruct.filename); 1448 pathname_of_last_file_restored[0] = '\0'; 1449 return (0); 1085 return (pathname_of_last_file_restored); 1450 1086 } 1451 1087 } … … 1470 1106 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1471 1107 outfile_fname); 1472 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),1108 asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768), 1473 1109 (int) (random() % 32768)); 1474 mkfifo( sz_devfile, 0x770);1475 strcpy(ntfsprog_fifo, sz_devfile); 1110 mkfifo(ntfsprog_fifo, 0x770); 1111 1476 1112 file_to_openout = ntfsprog_fifo; 1477 1113 switch (pid = fork()) { … … 1484 1120 res = 1485 1121 feed_outfrom_ntfsprog(biggiestruct.filename, 1486 1122 ntfsprog_fifo); 1487 1123 // log_msg(3, "CHILD - fip - exiting"); 1488 1124 exit(res); … … 1493 1129 (long int) (pid)); 1494 1130 } 1131 // BERLIOS: Is it the right place ?? 1132 paranoid_free(ntfsprog_fifo); 1495 1133 } else { 1496 1134 use_ntfsprog_hack = FALSE; 1497 ntfsprog_fifo[0] = '\0';1498 1135 file_to_openout = outfile_fname; 1499 1136 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1503 1140 } 1504 1141 1505 sprintf(tmp, "Reassembling big file %ld (%s)", bigfileno + 1,1142 asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1, 1506 1143 outfile_fname); 1507 1144 log_msg(2, tmp); 1145 paranoid_free(tmp); 1508 1146 1509 1147 /* … … 1513 1151 */ 1514 1152 1515 strncpy(pathname_of_last_file_restored, biggiestruct.filename, 1516 MAX_STR_LEN - 1); 1517 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0'; 1153 asprintf(&pathname_of_last_file_restored, biggiestruct.filename); 1518 1154 1519 1155 log_msg(3, "file_to_openout = %s", file_to_openout); 1520 1156 if (!(fout = fopen(file_to_openout, "w"))) { 1521 1157 log_to_screen(_("Cannot openout outfile_fname - hard disk full?")); 1522 return ( 1);1158 return (pathname_of_last_file_restored); 1523 1159 } 1524 1160 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1525 1161 1526 1162 for (sliceno = 1, finished = FALSE; !finished;) { 1527 if (!does_file_exist 1528 (slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) 1529 && 1530 !does_file_exist(slice_fname 1531 (bigfileno, sliceno, ARCHIVES_PATH, "lzo")) 1532 && 1533 !does_file_exist(slice_fname 1534 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1163 tmp = slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""); 1164 tmp1 = slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"); 1165 tmp2 = slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"); 1166 if (!does_file_exist(tmp) && !does_file_exist(tmp1) && 1167 !does_file_exist(tmp2)) { 1535 1168 log_msg(3, 1536 1169 "Cannot find a data slice or terminator slice on CD %d", 1537 1170 g_current_media_number); 1538 1171 g_current_media_number++; 1539 sprintf(tmp,1172 asprintf(&tmp3, 1540 1173 "Asking for %s #%d so that I may read slice #%ld\n", 1541 1174 media_descriptor_string(bkpinfo->backup_media_type), 1542 1175 g_current_media_number, sliceno); 1543 log_msg(2, tmp); 1544 sprintf(tmp, _("Restoring from %s #%d"), 1176 log_msg(2, tmp3); 1177 paranoid_free(tmp3); 1178 1179 asprintf(&tmp3, _("Restoring from %s #%d"), 1545 1180 media_descriptor_string(bkpinfo->backup_media_type), 1546 1181 g_current_media_number); 1547 log_to_screen(tmp); 1182 log_to_screen(tmp3); 1183 paranoid_free(tmp3); 1184 1548 1185 insist_on_this_cd_number(bkpinfo, g_current_media_number); 1549 1186 log_to_screen(_("Continuing to restore.")); 1550 1187 } else { 1551 strcpy(tmp,1552 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));1553 1188 if (does_file_exist(tmp) && length_of_file(tmp) == 0) { 1554 1189 log_msg(2, … … 1558 1193 continue; 1559 1194 } else { 1560 if (does_file_exist 1561 (slice_fname 1562 (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1563 strcpy(bzip2_command, "lzop"); 1564 strcpy(suffix, "lzo"); 1565 } else 1566 if (does_file_exist 1567 (slice_fname 1568 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1569 strcpy(bzip2_command, "bzip2"); 1570 strcpy(suffix, "bz2"); 1571 } else 1572 if (does_file_exist 1573 (slice_fname 1574 (bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1575 strcpy(bzip2_command, ""); 1576 strcpy(suffix, ""); 1195 if (does_file_exist(tmp1)) { 1196 asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE); 1197 } else if (does_file_exist(tmp2)) { 1198 asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE); 1199 } else if (does_file_exist(tmp)) { 1200 asprintf(&bzip2_command, ""); 1577 1201 } else { 1578 1202 log_to_screen(_("OK, that's pretty fsck0red...")); 1579 return ( 1);1203 return (pathname_of_last_file_restored); 1580 1204 } 1581 1205 } 1582 if (bzip2_command[0] != '\0') { 1583 sprintf(bzip2_command + strlen(bzip2_command), 1584 " -dc %s 2>> %s", 1585 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, 1586 suffix), MONDO_LOGFILE); 1587 } else { 1588 sprintf(bzip2_command, "cat %s 2>> %s", 1589 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, 1590 suffix), MONDO_LOGFILE); 1591 } 1592 sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld ", 1206 1207 if (bzip2_command == NULL) { 1208 asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE); 1209 } 1210 asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ", 1593 1211 media_descriptor_string(bkpinfo->backup_media_type), 1594 1212 g_current_media_number, bigfileno + 1, sliceno); 1595 log_msg(2, tmp); 1596 1213 log_msg(2, tmp3); 1597 1214 if (!g_text_mode) { 1598 newtDrawRootText(0, g_noof_rows - 2, tmp );1215 newtDrawRootText(0, g_noof_rows - 2, tmp3); 1599 1216 newtRefresh(); 1600 strip_spaces(tmp); 1601 update_progress_form(tmp); 1602 } 1217 update_progress_form(tmp3); 1218 } 1219 paranoid_free(tmp3); 1220 1603 1221 if (!(fbzip2 = popen(bzip2_command, "r"))) { 1604 1222 fatal_error("Can't run popen command"); 1605 1223 } 1224 paranoid_free(bzip2_command); 1225 1606 1226 while (!feof(fbzip2)) { 1607 1227 siz = fread(bigblk, 1, TAPE_BLOCK_SIZE, fbzip2); 1608 1228 if (siz > 0) { 1609 sprintf(sz_msg, "Read %ld from fbzip2", siz); 1610 siz = fwrite(bigblk, 1, siz, fout); 1611 sprintf(sz_msg + strlen(sz_msg), 1612 "; written %ld to fout", siz); 1613 // log_msg(2. sz_msg); 1229 siz1 = fwrite(bigblk, 1, siz, fout); 1230 asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1); 1231 log_it(sz_msg); 1232 paranoid_free(sz_msg); 1614 1233 } 1615 1234 } … … 1620 1239 g_current_progress++; 1621 1240 } 1622 } 1623 /* 1624 memset(bigblk, TAPE_BLOCK_SIZE, 1); // This all looks very fishy... 1625 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout); 1626 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout); 1627 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout); 1628 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout); 1629 */ 1241 paranoid_free(tmp); 1242 paranoid_free(tmp1); 1243 paranoid_free(tmp2); 1244 } 1630 1245 paranoid_fclose(fout); 1631 1246 g_loglevel = old_loglevel; … … 1633 1248 if (use_ntfsprog_hack) { 1634 1249 log_msg(3, "Waiting for ntfsclone to finish"); 1635 sprintf(tmp,1250 asprintf(&tmp, 1636 1251 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1637 1252 while (system(tmp) == 0) { 1638 1253 sleep(1); 1639 1254 } 1255 paranoid_free(tmp); 1640 1256 log_it("OK, ntfsclone has really finished"); 1641 1257 } … … 1649 1265 utime(outfile_fname, ubuf); 1650 1266 } 1267 paranoid_free(outfile_fname); 1651 1268 paranoid_free(bigblk); 1652 paranoid_free(checksum); 1653 paranoid_free(outfile_fname); 1654 paranoid_free(tmp); 1655 paranoid_free(bzip2_command); 1656 paranoid_free(ntfsprog_command); 1657 paranoid_free(suffix); 1658 paranoid_free(sz_devfile); 1659 1660 return (retval); 1269 1270 return (pathname_of_last_file_restored); 1661 1271 } 1272 1662 1273 1663 1274 /************************************************************************** 1664 1275 *END_ RESTORE_A_BIGGIEFILE_FROM_CD * 1665 1276 **************************************************************************/ 1666 1667 1277 1668 1278 … … 1674 1284 * @param orig_bf_fname The original filename of the biggiefile. 1675 1285 * @param biggiefile_number The number of the biggiefile (starting from 0). 1676 * @param orig_checksum Unused.1677 * @param biggiefile_size Unused.1678 1286 * @param filelist The node structure containing the list of files to be restored. 1679 1287 * If @p orig_bf_fname is not in the list, it will be ignored. 1680 1288 * @return 0 for success (or skip), nonzero for failure. 1681 * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL). 1682 */ 1683 int restore_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, char *orig_bf_fname, long biggiefile_number, char *orig_checksum, //UNUSED 1684 long long biggiefile_size, //UNUSED 1289 */ 1290 char *restore_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, char *orig_bf_fname, long biggiefile_number, 1685 1291 struct s_node *filelist, 1686 int use_ntfsprog, 1687 char *pathname_of_last_file_restored) 1292 int use_ntfsprog) 1688 1293 { 1689 1294 FILE *pout; … … 1691 1296 1692 1297 /** mallocs ********/ 1693 char *tmp ;1694 char * command;1695 char * outfile_fname;1696 char * ntfsprog_command;1697 char * sz_devfile;1698 char *ntfsprog_fifo ;1298 char *tmp = NULL; 1299 char *tmp1 = NULL; 1300 char *command = NULL; 1301 char *outfile_fname = NULL; 1302 char *ntfsprog_command = NULL; 1303 char *ntfsprog_fifo = NULL; 1699 1304 char *file_to_openout = NULL; 1305 char *pathname_of_last_file_restored = NULL; 1700 1306 1701 1307 struct s_node *node; … … 1714 1320 ubuf = &the_utime_buf; 1715 1321 1716 malloc_string(tmp);1717 malloc_string(ntfsprog_fifo);1718 malloc_string(outfile_fname);1719 malloc_string(command);1720 malloc_string(sz_devfile);1721 malloc_string(ntfsprog_command);1722 1322 old_loglevel = g_loglevel; 1723 1323 assert(bkpinfo != NULL); 1724 1324 assert(orig_bf_fname != NULL); 1725 assert(orig_checksum != NULL); 1726 1727 pathname_of_last_file_restored[0] = '\0'; 1325 1728 1326 if (use_ntfsprog == BLK_START_A_PIHBIGGIE) { 1729 1327 use_ntfsprog = 1; … … 1737 1335 } 1738 1336 1739 strncpy(pathname_of_last_file_restored, orig_bf_fname, 1740 MAX_STR_LEN - 1); 1741 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0'; 1337 asprintf(&pathname_of_last_file_restored, orig_bf_fname); 1742 1338 1743 1339 /* open out to biggiefile to be restored (or /dev/null if biggiefile is not to be restored) */ … … 1750 1346 "Skipping big file %ld (%s) - not in biggielist subset", 1751 1347 biggiefile_number + 1, orig_bf_fname); 1752 pathname_of_last_file_restored [0] = '\0';1348 pathname_of_last_file_restored = NULL; 1753 1349 } else if (!(node->selected)) { 1754 1350 dummy_restore = TRUE; 1755 1351 log_msg(1, "Skipping %s (name isn't in biggielist subset)", 1756 1352 orig_bf_fname); 1757 pathname_of_last_file_restored [0] = '\0';1353 pathname_of_last_file_restored = NULL; 1758 1354 } 1759 1355 } … … 1761 1357 if (use_ntfsprog) { 1762 1358 if (strncmp(orig_bf_fname, "/dev/", 5)) { 1763 log_msg(1, 1764 "I was in error when I set use_ntfsprog to TRUE."); 1359 log_msg(1, "I was in error when I set use_ntfsprog to TRUE."); 1765 1360 log_msg(1, "%s isn't even in /dev", orig_bf_fname); 1766 1361 use_ntfsprog = FALSE; … … 1770 1365 if (use_ntfsprog) { 1771 1366 g_loglevel = 4; 1772 strcpy(outfile_fname, orig_bf_fname);1367 asprintf(&outfile_fname, orig_bf_fname); 1773 1368 use_ntfsprog_hack = TRUE; 1774 1369 log_msg(2, 1775 1370 "Calling ntfsclone in background because %s is a /dev entry", 1776 1371 outfile_fname); 1777 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),1372 asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768), 1778 1373 (int) (random() % 32768)); 1779 mkfifo( sz_devfile, 0x770);1780 strcpy(ntfsprog_fifo, sz_devfile); 1374 mkfifo(ntfsprog_fifo, 0x770); 1375 1781 1376 file_to_openout = ntfsprog_fifo; 1782 1377 switch (pid = fork()) { … … 1787 1382 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1788 1383 outfile_fname, ntfsprog_fifo); 1789 res = 1790 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1384 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1791 1385 // log_msg(3, "CHILD - fip - exiting"); 1792 1386 exit(res); … … 1797 1391 (long int) (pid)); 1798 1392 } 1393 paranoid_free(ntfsprog_fifo); 1799 1394 } else { 1800 1395 if (!strncmp(orig_bf_fname, "/dev/", 5)) // non-NTFS partition 1801 1396 { 1802 strcpy(outfile_fname, orig_bf_fname);1397 asprintf(&outfile_fname, orig_bf_fname); 1803 1398 } else // biggiefile 1804 1399 { 1805 sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,1400 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1806 1401 orig_bf_fname); 1807 1402 } 1808 1403 use_ntfsprog_hack = FALSE; 1809 ntfsprog_fifo[0] = '\0';1810 1404 file_to_openout = outfile_fname; 1811 1405 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1813 1407 make_hole_for_file(outfile_fname); 1814 1408 } 1815 sprintf(tmp, "Reassembling big file %ld (%s)",1409 asprintf(&tmp1, "Reassembling big file %ld (%s)", 1816 1410 biggiefile_number + 1, orig_bf_fname); 1817 log_msg(2, tmp); 1411 log_msg(2, tmp1); 1412 paranoid_free(tmp1); 1818 1413 } 1819 1414 1820 1415 if (dummy_restore) { 1821 sprintf(outfile_fname, "/dev/null"); 1416 paranoid_free(outfile_fname); 1417 asprintf(&outfile_fname, "/dev/null"); 1822 1418 } 1823 1419 1824 1420 if (!bkpinfo->zip_exe[0]) { 1825 sprintf(command, "cat > \"%s\"", file_to_openout);1421 asprintf(&command, "cat > \"%s\"", file_to_openout); 1826 1422 } else { 1827 sprintf(command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,1423 asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, 1828 1424 file_to_openout, MONDO_LOGFILE); 1829 1425 } 1830 sprintf(tmp, "Pipe command = '%s'", command); 1831 log_msg(3, tmp); 1426 asprintf(&tmp1, "Pipe command = '%s'", command); 1427 log_msg(3, tmp1); 1428 paranoid_free(tmp1); 1832 1429 1833 1430 /* restore biggiefile, one slice at a time */ … … 1835 1432 fatal_error("Cannot pipe out"); 1836 1433 } 1434 paranoid_free(command); 1435 1837 1436 for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr); 1838 1437 ctrl_chr != BLK_STOP_A_BIGGIE; … … 1841 1440 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1842 1441 } 1843 sprintf(tmp, "Working on file #%ld, slice #%ld ",1442 asprintf(&tmp1, "Working on file #%ld, slice #%ld ", 1844 1443 biggiefile_number + 1, current_slice_number); 1845 log_msg(2, tmp); 1444 log_msg(2, tmp1); 1445 1846 1446 if (!g_text_mode) { 1847 newtDrawRootText(0, g_noof_rows - 2, tmp );1447 newtDrawRootText(0, g_noof_rows - 2, tmp1); 1848 1448 newtRefresh(); 1849 1449 } 1850 strip_spaces(tmp); 1851 update_progress_form(tmp); 1450 strip_spaces(tmp1); 1451 update_progress_form(tmp1); 1452 paranoid_free(tmp1); 1453 1852 1454 if (current_slice_number == 0) { 1853 1455 res = … … 1879 1481 g_current_progress++; 1880 1482 } 1483 paranoid_free(tmp); 1881 1484 paranoid_pclose(pout); 1882 1485 … … 1886 1489 if (use_ntfsprog_hack) { 1887 1490 log_msg(3, "Waiting for ntfsclone to finish"); 1888 sprintf(tmp,1491 asprintf(&tmp, 1889 1492 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1890 1493 while (system(tmp) == 0) { 1891 1494 sleep(1); 1892 } 1495 } 1496 paranoid_free(tmp); 1893 1497 log_msg(3, "OK, ntfsclone has really finished"); 1894 1498 } … … 1905 1509 } 1906 1510 1907 paranoid_free(tmp);1908 1511 paranoid_free(outfile_fname); 1909 paranoid_free(command);1910 paranoid_free(ntfsprog_command);1911 paranoid_free(sz_devfile);1912 paranoid_free(ntfsprog_fifo);1913 1512 g_loglevel = old_loglevel; 1914 return ( retval);1513 return (pathname_of_last_file_restored); 1915 1514 } 1916 1515 … … 1918 1517 *END_RESTORE_A_BIGGIEFILE_FROM_STREAM * 1919 1518 **************************************************************************/ 1920 1921 1519 1922 1520 … … 1943 1541 /** malloc **/ 1944 1542 char *command; 1945 char *tmp ;1543 char *tmp = NULL; 1946 1544 char *filelist_name; 1947 char *filelist_subset_fname; 1948 char *executable; 1949 char *temp_log; 1950 char screen_message[100]; 1545 char *filelist_subset_fname = NULL; 1546 char *executable = NULL; 1547 char *temp_log = NULL; 1951 1548 long matches = 0; 1952 1549 bool use_star; 1953 char *xattr_fname; 1954 char *acl_fname; 1955 // char files_to_restore_this_time_fname[MAX_STR_LEN]; 1550 char *xattr_fname = NULL; 1551 char *acl_fname = NULL; 1956 1552 1957 1553 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 1958 malloc_string(command);1959 malloc_string(tmp);1960 malloc_string(filelist_name);1961 malloc_string(filelist_subset_fname);1962 malloc_string(executable);1963 malloc_string(temp_log);1964 malloc_string(xattr_fname);1965 malloc_string(acl_fname);1966 1554 1967 1555 log_msg(5, "Entering"); 1968 filelist_subset_fname[0] = '\0';1969 1556 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1970 // sprintf(files_to_restore_this_time_fname, "/tmp/ftrttf.%d.%d", (int)getpid(), (int)random()); 1971 sprintf(command, "mkdir -p %s/tmp", MNT_RESTORING); 1557 asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING); 1972 1558 run_program_and_log_output(command, 9); 1973 sprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1974 (int) (random() % 32768)); 1975 1976 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%ld", 1559 paranoid_free(command); 1560 1561 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld", 1977 1562 current_tarball_number); 1978 1563 if (length_of_file(filelist_name) <= 2) { … … 1984 1569 "but it's non-critical. It's cosmetic. Don't worry about it."); 1985 1570 retval = 0; 1986 goto leave_sub; 1571 log_msg(5, "Leaving"); 1572 return (retval); 1987 1573 } 1988 1574 if (count_lines_in_file(filelist_name) <= 0 … … 1990 1576 log_msg(3, "length_of_file(%s) = %llu", tarball_fname, 1991 1577 length_of_file(tarball_fname)); 1992 sprintf(tmp, "Unable to restore fileset #%ld (CD I/O error)",1578 asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)", 1993 1579 current_tarball_number); 1994 1580 log_to_screen(tmp); 1581 paranoid_free(tmp); 1995 1582 retval = 1; 1996 goto leave_sub; 1583 log_msg(5, "Leaving"); 1584 return (retval); 1997 1585 } 1998 1586 1999 1587 if (filelist) { 2000 sprintf(filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",1588 asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", 2001 1589 current_tarball_number); 2002 1590 if ((matches = … … 2005 1593 use_star)) 2006 1594 <= 0) { 2007 sprintf(tmp, "Skipping fileset %ld", current_tarball_number);1595 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 2008 1596 log_msg(1, tmp); 1597 paranoid_free(tmp); 2009 1598 } else { 2010 1599 log_msg(3, "Saved fileset %ld's subset to %s", 2011 1600 current_tarball_number, filelist_subset_fname); 2012 1601 } 2013 sprintf(screen_message, "Tarball #%ld --- %ld matches",1602 asprintf(&tmp, "Tarball #%ld --- %ld matches", 2014 1603 current_tarball_number, matches); 2015 log_to_screen(screen_message); 1604 log_to_screen(tmp); 1605 paranoid_free(tmp); 2016 1606 } else { 2017 filelist_subset_fname[0] = '\0'; 2018 } 1607 filelist_subset_fname = NULL; 1608 } 1609 paranoid_free(filelist_name); 2019 1610 2020 1611 if (filelist == NULL || matches > 0) { 2021 sprintf(xattr_fname, XATTR_LIST_FNAME_RAW_SZ,1612 asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ, 2022 1613 MNT_CDROM "/archives", current_tarball_number); 2023 sprintf(acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",1614 asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", 2024 1615 current_tarball_number); 2025 1616 if (strstr(tarball_fname, ".bz2")) { 2026 strcpy(executable, "bzip2");1617 asprintf(&executable, "bzip2"); 2027 1618 } else if (strstr(tarball_fname, ".lzo")) { 2028 strcpy(executable, "lzop");1619 asprintf(&executable, "lzop"); 2029 1620 } else { 2030 executable[0] = '\0'; 2031 } 2032 if (executable[0]) { 2033 sprintf(tmp, "which %s > /dev/null 2> /dev/null", executable); 1621 executable = NULL; 1622 } 1623 1624 if (executable == NULL) { 1625 asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable); 2034 1626 if (run_program_and_log_output(tmp, FALSE)) { 2035 1627 log_to_screen 2036 (_("(compare_a_tarball) Compression program not found - oh no!")); 1628 (_ 1629 ("(compare_a_tarball) Compression program not found - oh no!")); 2037 1630 paranoid_MR_finish(1); 2038 1631 } 2039 strcpy(tmp, executable); 2040 sprintf(executable, "-P %s -Z", tmp); 1632 paranoid_free(tmp); 1633 1634 asprintf(&tmp, executable); 1635 asprintf(&executable, "-P %s -Z", tmp); 1636 paranoid_free(tmp); 2041 1637 } 2042 1638 #ifdef __FreeBSD__ … … 2046 1642 #endif 2047 1643 2048 // if (strstr(tarball_fname, ".star.")) 1644 asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1645 (int) (random() % 32768)); 1646 2049 1647 if (use_star) { 2050 sprintf(command, 1648 if (strstr(tarball_fname, ".bz2")) { 1649 asprintf(&tmp, " -bz"); 1650 } else { 1651 asprintf(&tmp, ""); 1652 } 1653 asprintf(&command, 2051 1654 "star -x -force-remove -U " STAR_ACL_SZ 2052 " errctl= file=%s", tarball_fname); 2053 if (strstr(tarball_fname, ".bz2")) { 2054 strcat(command, " -bz"); 2055 } 1655 " errctl= file=%s %s 2>> %s >> %s", tarball_fname, tmp, temp_log, temp_log); 1656 paranoid_free(tmp); 2056 1657 } else { 2057 if (filelist_subset_fname [0] != '\0') {2058 sprintf(command,2059 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s ",1658 if (filelist_subset_fname != NULL) { 1659 asprintf(&command, 1660 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s 2>> %s >> %s", 2060 1661 TAPE_BLOCK_SIZE, 2061 1662 BUFSIZE, executable, filelist_subset_fname, 2062 1663 // files_to_restore_this_time_fname, 2063 tarball_fname );1664 tarball_fname, temp_log, temp_log); 2064 1665 } else { 2065 sprintf(command,2066 "afio -i -b %ld -c %ld -M 8m %s %s ",1666 asprintf(&command, 1667 "afio -i -b %ld -c %ld -M 8m %s %s 2>> %s >> %s", 2067 1668 TAPE_BLOCK_SIZE, 2068 BUFSIZE, executable, tarball_fname); 2069 } 2070 } 1669 BUFSIZE, executable, tarball_fname, temp_log, temp_log); 1670 } 1671 } 1672 paranoid_free(executable); 1673 2071 1674 #undef BUFSIZE 2072 sprintf(command + strlen(command), " 2>> %s >> %s", temp_log,2073 temp_log);2074 1675 log_msg(1, "command = '%s'", command); 2075 1676 unlink(temp_log); … … 2083 1684 } 2084 1685 } 1686 paranoid_free(command); 1687 2085 1688 if (res && length_of_file(temp_log) < 5) { 2086 1689 res = 0; … … 2092 1695 if (res) { 2093 1696 log_to_screen 2094 (_("Errors occurred while setting extended attributes")); 1697 (_ 1698 ("Errors occurred while setting extended attributes")); 2095 1699 } else { 2096 1700 log_msg(1, "I set xattr OK"); … … 2103 1707 if (res) { 2104 1708 log_to_screen 2105 (_("Errors occurred while setting access control lists")); 1709 (_ 1710 ("Errors occurred while setting access control lists")); 2106 1711 } else { 2107 1712 log_msg(1, "I set ACL OK"); … … 2110 1715 } 2111 1716 if (retval) { 2112 sprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);1717 asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 2113 1718 system(command); 1719 paranoid_free(command); 2114 1720 log_msg(2, "Errors occurred while processing fileset #%d", 2115 1721 current_tarball_number); … … 2117 1723 log_msg(2, "Fileset #%d processed OK", current_tarball_number); 2118 1724 } 1725 unlink(xattr_fname); 1726 paranoid_free(xattr_fname); 2119 1727 } 2120 1728 if (does_file_exist("/PAUSE")) { 2121 1729 popup_and_OK 2122 (_("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 1730 (_ 1731 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2123 1732 } 2124 1733 unlink(filelist_subset_fname); 2125 unlink(xattr_fname);2126 1734 unlink(acl_fname); 2127 1735 unlink(temp_log); 2128 1736 2129 leave_sub:2130 paranoid_free(command);2131 paranoid_free(tmp);2132 paranoid_free(filelist_name);2133 1737 paranoid_free(filelist_subset_fname); 2134 paranoid_free( executable);1738 paranoid_free(acl_fname); 2135 1739 paranoid_free(temp_log); 2136 paranoid_free(xattr_fname); 2137 paranoid_free(acl_fname); 1740 2138 1741 log_msg(5, "Leaving"); 2139 1742 return (retval); … … 2172 1775 2173 1776 /** malloc add ***/ 2174 char *tmp ;2175 char *command ;2176 char *afio_fname ;2177 char *filelist_fname ;2178 char *filelist_subset_fname ;2179 char *executable ;1777 char *tmp = NULL; 1778 char *command = NULL; 1779 char *afio_fname = NULL; 1780 char *filelist_fname = NULL; 1781 char *filelist_subset_fname = NULL; 1782 char *executable = NULL; 2180 1783 long matches = 0; 2181 1784 bool restore_this_fileset = FALSE; … … 2184 1787 assert(bkpinfo != NULL); 2185 1788 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 2186 malloc_string(filelist_subset_fname);2187 malloc_string(filelist_fname);2188 malloc_string(afio_fname);2189 malloc_string(executable);2190 malloc_string(command);2191 malloc_string(tmp);2192 filelist_subset_fname[0] = '\0';2193 1789 /* to do it with a file... */ 2194 1790 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 2195 sprintf(tmp,1791 asprintf(&tmp, 2196 1792 "Restoring from fileset #%ld (%ld KB) on %s #%d", 2197 1793 current_tarball_number, (long) size >> 10, … … 2199 1795 g_current_media_number); 2200 1796 log_msg(2, tmp); 1797 paranoid_free(tmp); 2201 1798 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE); 2202 1799 … … 2206 1803 * in afio or someting; oh darn.. OK, use tmpfs :-) * 2207 1804 ****************************************************************************/ 2208 filelist_fname[0] = filelist_subset_fname[0] = '\0'; 2209 sprintf(afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 1805 asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 2210 1806 current_tarball_number); 2211 sprintf(filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,1807 asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, 2212 1808 current_tarball_number); 2213 sprintf(filelist_subset_fname, "%s/filelist-subset-%ld.tmp",1809 asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp", 2214 1810 bkpinfo->tmpdir, current_tarball_number); 2215 // sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number);2216 1811 res = read_file_from_stream_to_file(bkpinfo, afio_fname, size); 2217 1812 if (strstr(tarball_fname, ".star")) { … … 2221 1816 log_msg(1, "Warning - error reading afioball from tape"); 2222 1817 } 2223 if (bkpinfo->compression_level == 0) { 2224 executable[0] = '\0'; 2225 } else { 1818 if (bkpinfo->compression_level != 0) { 2226 1819 if (bkpinfo->use_star) { 2227 strcpy(executable, " -bz");1820 asprintf(&executable, " -bz"); 2228 1821 } else { 2229 sprintf(executable, "-P %s -Z", bkpinfo->zip_exe);1822 asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe); 2230 1823 } 2231 1824 } … … 2238 1831 if (strstr(tarball_fname, ".star.")) { 2239 1832 use_star = TRUE; 2240 sprintf(command, "star -t file=%s %s", afio_fname, executable);1833 asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE); 2241 1834 } else { 2242 1835 use_star = FALSE; 2243 sprintf(command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE, 2244 executable, afio_fname); 2245 } 2246 sprintf(command + strlen(command), " > %s 2>> %s", filelist_fname, 2247 MONDO_LOGFILE); 1836 asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE, 1837 executable, afio_fname, filelist_fname, MONDO_LOGFILE); 1838 } 2248 1839 log_msg(1, "command = %s", command); 2249 1840 if (system(command)) { 2250 1841 log_msg(4, "Warning - error occurred while retrieving TOC"); 2251 1842 } 1843 paranoid_free(command); 2252 1844 if ((matches = 2253 1845 save_filelist_entries_in_common(filelist_fname, filelist, … … 2259 1851 current_tarball_number); 2260 1852 } 2261 sprintf(tmp, "Skipping fileset %ld", current_tarball_number);1853 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 2262 1854 log_msg(2, tmp); 1855 paranoid_free(tmp); 2263 1856 restore_this_fileset = FALSE; 2264 1857 } else { … … 2269 1862 } 2270 1863 } 1864 unlink(filelist_fname); 1865 paranoid_free(filelist_fname); 2271 1866 2272 1867 // Concoct the call to star/afio to restore files 2273 if (strstr(tarball_fname, ".star.")) // star 2274 { 2275 sprintf(command, "star -x file=%s %s", afio_fname, executable); 1868 if (strstr(tarball_fname, ".star.")) { 1869 // star 2276 1870 if (filelist) { 2277 sprintf(command + strlen(command), " list=%s",2278 filelist_subset_fname );2279 } 2280 } else // afio2281 {2282 sprintf(command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE,2283 executable);1871 asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable 1872 filelist_subset_fname,MONDO_LOGFILE); 1873 } else { 1874 asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE); 1875 } 1876 } else { 1877 // afio 2284 1878 if (filelist) { 2285 sprintf(command + strlen(command), " -w %s",2286 filelist_subset_fname);2287 }2288 sprintf(command + strlen(command), " %s", afio_fname);2289 } 2290 sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);2291 2292 // Call if IF there are files to restore (selectively/unconditionally)1879 asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE); 1880 } else { 1881 asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE); 1882 } 1883 } 1884 paranoid_free(executable); 1885 1886 // Call if IF there are files to restore (selectively/unconditionally) 2293 1887 if (restore_this_fileset) { 2294 1888 log_msg(1, "Calling command='%s'", command); … … 2315 1909 log_msg(1, "NOT CALLING '%s'", command); 2316 1910 } 1911 paranoid_free(command); 2317 1912 2318 1913 if (does_file_exist("/PAUSE") && current_tarball_number >= 50) { … … 2322 1917 2323 1918 unlink(filelist_subset_fname); 2324 unlink(filelist_fname);2325 1919 unlink(afio_fname); 2326 1920 2327 1921 paranoid_free(filelist_subset_fname); 2328 paranoid_free(filelist_fname);2329 1922 paranoid_free(afio_fname); 2330 paranoid_free(command);2331 paranoid_free(tmp);2332 1923 return (retval); 2333 1924 } … … 2336 1927 *END_RESTORE_A_TARBALL_FROM_STREAM * 2337 1928 **************************************************************************/ 2338 2339 2340 1929 2341 1930 … … 2354 1943 { 2355 1944 int retval = 0; 2356 int res; 2357 long noof_biggiefiles, bigfileno = 0, total_slices; 2358 /** malloc **/ 2359 char *tmp; 2360 bool just_changed_cds = FALSE, finished; 2361 char *xattr_fname; 2362 char *acl_fname; 2363 char *biggies_whose_EXATs_we_should_set; // EXtended ATtributes 2364 char *pathname_of_last_biggie_restored; 1945 int res = 0; 1946 long noof_biggiefiles = 0L, bigfileno = 0L, total_slices = 0L; 1947 char *tmp = NULL; 1948 bool just_changed_cds = FALSE, finished = FALSE; 1949 char *xattr_fname = NULL; 1950 char *acl_fname = NULL; 1951 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes 1952 char *pathname_of_last_biggie_restored = NULL; 2365 1953 FILE *fbw = NULL; 2366 1954 2367 malloc_string(xattr_fname);2368 malloc_string(acl_fname);2369 malloc_string(tmp);2370 malloc_string(biggies_whose_EXATs_we_should_set);2371 malloc_string(pathname_of_last_biggie_restored);2372 1955 assert(bkpinfo != NULL); 2373 1956 2374 sprintf(biggies_whose_EXATs_we_should_set,1957 asprintf(&biggies_whose_EXATs_we_should_set, 2375 1958 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2376 1959 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2381 1964 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2382 1965 total_slices = atol(tmp); 2383 sprintf(tmp, _("Reassembling large files ")); 1966 paranoid_free(tmp); 1967 1968 asprintf(&tmp, _("Reassembling large files ")); 2384 1969 mvaddstr_and_log_it(g_currentY, 0, tmp); 1970 paranoid_free(tmp); 1971 2385 1972 if (length_of_file(BIGGIELIST) < 6) { 2386 1973 log_msg(1, "OK, no biggielist; not restoring biggiefiles"); … … 2393 1980 return (0); 2394 1981 } 2395 sprintf(tmp, "OK, there are %ld biggiefiles in the archives",1982 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 2396 1983 noof_biggiefiles); 2397 1984 log_msg(2, tmp); 1985 paranoid_free(tmp); 2398 1986 2399 1987 open_progress_form(_("Reassembling large files"), … … 2403 1991 for (bigfileno = 0, finished = FALSE; !finished;) { 2404 1992 log_msg(2, "Thinking about restoring bigfile %ld", bigfileno + 1); 2405 if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) { 1993 tmp = slice_fname(bigfileno, 0, ARCHIVES_PATH, ""); 1994 if (!does_file_exist(tmp)) { 2406 1995 log_msg(3, 2407 1996 "...but its first slice isn't on this CD. Perhaps this was a selective restore?"); … … 2410 1999 media_descriptor_string(bkpinfo->backup_media_type), 2411 2000 g_current_media_number); 2412 log_msg(3, "Slicename would have been %s", 2413 slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, "")); 2001 tmp1 = slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, ""); 2002 log_msg(3, "Slicename would have been %s", tmp1); 2003 paranoid_free(tmp1); 2004 2414 2005 // I'm not positive 'just_changed_cds' is even necessary... 2415 2006 if (just_changed_cds) { … … 2420 2011 insist_on_this_cd_number(bkpinfo, 2421 2012 ++g_current_media_number); 2422 sprintf(tmp, _("Restoring from %s #%d"),2013 asprintf(&tmp, _("Restoring from %s #%d"), 2423 2014 media_descriptor_string(bkpinfo-> 2424 2015 backup_media_type), 2425 2016 g_current_media_number); 2426 2017 log_to_screen(tmp); 2018 paranoid_free(tmp); 2019 2427 2020 just_changed_cds = TRUE; 2428 2021 } else { … … 2434 2027 } else { 2435 2028 just_changed_cds = FALSE; 2436 sprintf(tmp, _("Restoring big file %ld"), bigfileno + 1);2029 asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1); 2437 2030 update_progress_form(tmp); 2438 res = 2439 restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist, 2440 pathname_of_last_biggie_restored); 2031 paranoid_free(tmp); 2032 2033 pathname_of_last_biggie_restored = 2034 restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist); 2441 2035 iamhere(pathname_of_last_biggie_restored); 2442 2036 if (fbw && pathname_of_last_biggie_restored[0]) { 2443 2037 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2444 2038 } 2039 paranoid_free(pathname_of_last_biggie_restored); 2445 2040 retval += res; 2446 2041 bigfileno++; 2447 2042 2448 2043 } 2044 paranoid_free(tmp); 2449 2045 } 2450 2046 2451 2047 if (fbw) { 2452 2048 fclose(fbw); 2453 sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2454 sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2049 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2050 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2455 2051 if (length_of_file(acl_fname) > 0 && find_home_of_exe("setfacl")) { 2456 2052 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname); … … 2460 2056 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname); 2461 2057 } 2462 } 2058 paranoid_free(acl_fname); 2059 paranoid_free(xattr_fname); 2060 } 2061 paranoid_free(biggies_whose_EXATs_we_should_set); 2062 2463 2063 if (does_file_exist("/PAUSE")) { 2464 2064 popup_and_OK 2465 (_("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2065 (_ 2066 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2466 2067 } 2467 2068 close_progress_form(); … … 2471 2072 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2472 2073 } 2473 paranoid_free(xattr_fname);2474 paranoid_free(acl_fname);2475 paranoid_free(tmp);2476 paranoid_free(biggies_whose_EXATs_we_should_set);2477 paranoid_free(pathname_of_last_biggie_restored);2478 2074 return (retval); 2479 2075 } 2480 2481 2076 /************************************************************************** 2482 2077 *END_RESTORE_ALL_BIGGIFILES_FROM_CD * 2483 2078 **************************************************************************/ 2484 2485 2079 2486 2080 … … 2506 2100 /**malloc ***/ 2507 2101 char *tmp; 2102 char *tmp1; 2508 2103 char *tarball_fname; 2509 2104 char *progress_str; 2510 2105 char *comment; 2511 2512 malloc_string(tmp);2513 malloc_string(tarball_fname);2514 malloc_string(progress_str);2515 malloc_string(comment);2516 2106 2517 2107 assert(bkpinfo != NULL); … … 2527 2117 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2528 2118 max_val = atol(tmp) + 1; 2529 sprintf(progress_str, _("Restoring from %s #%d"), 2119 paranoid_free(tmp); 2120 2121 asprintf(&progress_str, _("Restoring from %s #%d"), 2530 2122 media_descriptor_string(bkpinfo->backup_media_type), 2531 2123 g_current_media_number); … … 2538 2130 insist_on_this_cd_number(bkpinfo, g_current_media_number); 2539 2131 update_progress_form(progress_str); 2540 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2132 2133 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2541 2134 current_tarball_number); 2542 2135 if (!does_file_exist(tarball_fname)) { 2543 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2136 paranoid_free(tarball_fname); 2137 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2544 2138 current_tarball_number); 2545 2139 } 2546 2140 if (!does_file_exist(tarball_fname)) { 2547 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2141 paranoid_free(tarball_fname); 2142 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2548 2143 current_tarball_number); 2549 2144 } 2550 2145 if (!does_file_exist(tarball_fname)) { 2551 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2146 paranoid_free(tarball_fname); 2147 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2552 2148 current_tarball_number); 2553 2149 } 2554 2150 if (!does_file_exist(tarball_fname)) { 2555 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.", 2151 paranoid_free(tarball_fname); 2152 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.", 2556 2153 current_tarball_number); 2557 2154 } 2558 2155 if (!does_file_exist(tarball_fname)) { 2156 paranoid_free(tarball_fname); 2559 2157 if (current_tarball_number == 0) { 2560 2158 log_to_screen 2561 (_("No tarballs. Strange. Maybe you only backed up freakin' big files?")); 2159 (_ 2160 ("No tarballs. Strange. Maybe you only backed up freakin' big files?")); 2562 2161 return (0); 2563 2162 } … … 2569 2168 } 2570 2169 g_current_media_number++; 2571 sprintf(progress_str, _("Restoring from %s #%d"), 2170 paranoid_free(progress_str); 2171 asprintf(&progress_str, _("Restoring from %s #%d"), 2572 2172 media_descriptor_string(bkpinfo->backup_media_type), 2573 2173 g_current_media_number); 2574 2174 log_to_screen(progress_str); 2575 2175 } else { 2576 sprintf(progress_str, _("Restoring from fileset #%ld on %s #%d"), 2176 paranoid_free(progress_str); 2177 asprintf(&progress_str, 2178 _("Restoring from fileset #%ld on %s #%d"), 2577 2179 current_tarball_number, 2578 2180 media_descriptor_string(bkpinfo->backup_media_type), … … 2586 2188 filelist); 2587 2189 } 2588 sprintf(tmp, _("%s #%d, fileset #%ld - restore "), 2190 if (res) { 2191 asprintf(&tmp1, _("reported errors")); 2192 } else { 2193 asprintf(&tmp1, _("succeeded")); 2194 } 2195 asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"), 2589 2196 media_descriptor_string(bkpinfo->backup_media_type), 2590 g_current_media_number, current_tarball_number); 2591 if (res) { 2592 strcat(tmp, _("reported errors")); 2593 } else if (attempts > 1) { 2594 strcat(tmp, _("succeeded")); 2595 } else { 2596 strcat(tmp, _("succeeded")); 2597 } 2197 g_current_media_number, current_tarball_number,tmp1); 2198 paranoid_free(tmp1); 2199 2598 2200 if (attempts > 1) { 2599 sprintf(tmp + strlen(tmp), _(" (%d attempts) - review logs"), 2600 attempts); 2601 } 2602 strcpy(comment, tmp); 2201 asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts); 2202 } 2203 asprintf(&comment, "%s%s", tmp, tmp1); 2204 paranoid_free(tmp); 2205 paranoid_free(tmp1); 2603 2206 if (attempts > 1) { 2604 2207 log_to_screen(comment); 2605 2208 } 2209 paranoid_free(comment); 2606 2210 2607 2211 retval += res; … … 2609 2213 g_current_progress++; 2610 2214 } 2611 } 2215 paranoid_free(tarball_fname); 2216 } 2217 paranoid_free(progress_str); 2612 2218 close_progress_form(); 2219 2613 2220 if (retval) { 2614 2221 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); … … 2616 2223 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2617 2224 } 2618 paranoid_free(tmp);2619 paranoid_free(tarball_fname);2620 paranoid_free(progress_str);2621 paranoid_free(comment);2622 2225 2623 2226 return (retval); … … 2627 2230 *END_RESTORE_ALL_TARBALLS_FROM_CD * 2628 2231 **************************************************************************/ 2629 2630 2232 2631 2233 … … 2650 2252 2651 2253 /** malloc add ****/ 2652 char *tmp; 2653 char *biggie_fname; 2654 char *biggie_cksum; 2655 char *xattr_fname; 2656 char *acl_fname; 2657 char *p; 2658 char *pathname_of_last_biggie_restored; 2659 char *biggies_whose_EXATs_we_should_set; // EXtended ATtributes 2660 long long biggie_size; 2254 char *tmp = NULL; 2255 char *biggie_fname = NULL; 2256 char *xattr_fname = NULL; 2257 char *acl_fname = NULL; 2258 char *p = NULL; 2259 char *pathname_of_last_biggie_restored = NULL; 2260 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes 2261 long long biggie_size = NULL; 2661 2262 FILE *fbw = NULL; 2662 2263 2663 malloc_string(tmp);2664 malloc_string(biggie_fname);2665 malloc_string(biggie_cksum);2666 malloc_string(xattr_fname);2667 malloc_string(acl_fname);2668 malloc_string(biggies_whose_EXATs_we_should_set);2669 malloc_string(pathname_of_last_biggie_restored);2670 2264 assert(bkpinfo != NULL); 2671 2265 2672 2266 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2673 2674 2267 total_slices = atol(tmp); 2675 sprintf(tmp, "Reassembling large files "); 2676 sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2677 sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2268 paranoid_free(tmp); 2269 2270 asprintf(&tmp, "Reassembling large files "); 2271 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2272 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2678 2273 mvaddstr_and_log_it(g_currentY, 0, tmp); 2679 sprintf(biggies_whose_EXATs_we_should_set, 2274 paranoid_free(tmp); 2275 2276 asprintf(&biggies_whose_EXATs_we_should_set, 2680 2277 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2681 2278 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2694 2291 2695 2292 noof_biggiefiles = atol(biggie_fname); 2696 sprintf(tmp, "OK, there are %ld biggiefiles in the archives",2293 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 2697 2294 noof_biggiefiles); 2698 2295 log_msg(2, tmp); 2296 paranoid_free(tmp); 2297 2699 2298 open_progress_form(_("Reassembling large files"), 2700 2299 _("I am now reassembling all the large files."), … … 2713 2312 wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr); 2714 2313 } 2314 /* BERLIOS: useless 2715 2315 p = strrchr(biggie_fname, '/'); 2716 2316 if (!p) { … … 2719 2319 p++; 2720 2320 } 2721 sprintf(tmp, _("Restoring big file %ld (%lld K)"), 2321 */ 2322 asprintf(&tmp, _("Restoring big file %ld (%lld K)"), 2722 2323 current_bigfile_number + 1, biggie_size / 1024); 2723 2324 update_progress_form(tmp); 2724 res = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname, 2325 paranoid_free(tmp); 2326 2327 pathname_of_last_biggie_restored = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname, 2725 2328 current_bigfile_number, 2726 biggie_cksum, 2727 biggie_size, 2728 filelist, ctrl_chr, 2729 pathname_of_last_biggie_restored); 2329 filelist, ctrl_chr); 2730 2330 log_msg(1, "I believe I have restored %s", 2731 2331 pathname_of_last_biggie_restored); … … 2733 2333 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2734 2334 } 2335 paranoid_free(pathname_of_last_biggie_restored); 2336 2735 2337 retval += res; 2736 2338 current_bigfile_number++; … … 2739 2341 if (current_bigfile_number != noof_biggiefiles 2740 2342 && noof_biggiefiles != 0) { 2741 sprintf(tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",2343 asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", 2742 2344 current_bigfile_number, noof_biggiefiles); 2743 2345 } else { 2744 sprintf(tmp,2346 asprintf(&tmp, 2745 2347 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2746 2348 noof_biggiefiles, current_bigfile_number); 2747 2349 } 2748 2350 log_msg(1, tmp); 2351 paranoid_free(tmp); 2749 2352 2750 2353 if (fbw) { … … 2768 2371 } 2769 2372 } 2373 paranoid_free(xattr_fname); 2374 paranoid_free(acl_fname); 2375 paranoid_free(biggies_whose_EXATs_we_should_set); 2376 2770 2377 if (does_file_exist("/PAUSE")) { 2771 2378 popup_and_OK 2772 (_("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2379 (_ 2380 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2773 2381 } 2774 2382 … … 2779 2387 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2780 2388 } 2781 paranoid_free(biggies_whose_EXATs_we_should_set);2782 paranoid_free(pathname_of_last_biggie_restored);2783 2389 paranoid_free(biggie_fname); 2784 paranoid_free(biggie_cksum);2785 paranoid_free(xattr_fname);2786 paranoid_free(acl_fname);2787 paranoid_free(tmp);2788 2390 return (retval); 2789 2391 } … … 2792 2394 *END_RESTORE_ALL_BIGGIEFILES_FROM_STREAM * 2793 2395 **************************************************************************/ 2794 2795 2796 2797 2798 2396 2799 2397 … … 2819 2417 2820 2418 /** malloc **/ 2821 char *tmp ;2822 char *progress_str ;2823 char *tmp_fname ;2824 char *xattr_fname ;2825 char *acl_fname ;2419 char *tmp = NULL; 2420 char *progress_str = NULL; 2421 char *tmp_fname = NULL; 2422 char *xattr_fname = NULL; 2423 char *acl_fname = NULL; 2826 2424 2827 2425 long long tmp_size; 2828 2426 2829 malloc_string(tmp);2830 malloc_string(progress_str);2831 malloc_string(tmp_fname);2832 2427 assert(bkpinfo != NULL); 2833 malloc_string(xattr_fname);2834 malloc_string(acl_fname);2835 2428 mvaddstr_and_log_it(g_currentY, 0, _("Restoring from archives")); 2836 2429 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2837 2430 max_val = atol(tmp) + 1; 2431 paranoid_free(tmp); 2838 2432 2839 2433 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ … … 2841 2435 run_program_and_log_output("pwd", 5); 2842 2436 2843 sprintf(progress_str, _("Restoring from media #%d"),2437 asprintf(&progress_str, _("Restoring from media #%d"), 2844 2438 g_current_media_number); 2845 2439 log_to_screen(progress_str); … … 2863 2457 while (ctrl_chr != BLK_STOP_AFIOBALLS) { 2864 2458 update_progress_form(progress_str); 2865 sprintf(xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,2459 asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2866 2460 current_afioball_number); 2867 sprintf(acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,2461 asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, 2868 2462 current_afioball_number); 2869 2463 unlink(xattr_fname); … … 2879 2473 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 2880 2474 } 2881 sprintf(tmp, 2475 /* BERLIOS: useless ? 2476 asprintf(&tmp, 2882 2477 _("Restoring from fileset #%ld (name=%s, size=%ld K)"), 2883 2478 current_afioball_number, tmp_fname, (long) tmp_size >> 10); 2479 */ 2884 2480 res = 2885 2481 restore_a_tarball_from_stream(bkpinfo, tmp_fname, … … 2889 2485 retval += res; 2890 2486 if (res) { 2891 sprintf(tmp, _("Fileset %ld - errors occurred"),2487 asprintf(&tmp, _("Fileset %ld - errors occurred"), 2892 2488 current_afioball_number); 2893 2489 log_to_screen(tmp); 2490 paranoid_free(tmp); 2894 2491 } 2895 2492 res = … … 2901 2498 current_afioball_number++; 2902 2499 g_current_progress++; 2903 sprintf(progress_str, _("Restoring from fileset #%ld on %s #%d"), 2500 2501 paranoid_free(progress_str); 2502 asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"), 2904 2503 current_afioball_number, 2905 2504 media_descriptor_string(bkpinfo->backup_media_type), … … 2909 2508 unlink(xattr_fname); 2910 2509 unlink(acl_fname); 2510 paranoid_free(xattr_fname); 2511 paranoid_free(acl_fname); 2911 2512 } // next 2513 paranoid_free(progress_str); 2514 paranoid_free(tmp_fname); 2515 2912 2516 log_msg(1, "All done with afioballs"); 2913 2517 close_progress_form(); … … 2917 2521 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2918 2522 } 2919 paranoid_free(tmp);2920 paranoid_free(progress_str);2921 paranoid_free(tmp_fname);2922 paranoid_free(xattr_fname);2923 paranoid_free(acl_fname);2924 2523 return (retval); 2925 2524 } … … 2946 2545 2947 2546 /** mallco ***/ 2948 char *cwd ;2949 char *newpath ;2950 char *tmp ;2547 char *cwd = NULL; 2548 char *newpath = NULL; 2549 char *tmp = NULL; 2951 2550 assert(bkpinfo != NULL); 2952 2551 2953 2552 malloc_string(cwd); 2954 2553 malloc_string(newpath); 2955 malloc_string(tmp);2956 2554 log_msg(2, "restore_everything() --- starting"); 2957 2555 g_current_media_number = 1; 2556 /* BERLIOS: should test return value, or better change the function */ 2958 2557 getcwd(cwd, MAX_STR_LEN - 1); 2959 sprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);2558 asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path); 2960 2559 run_program_and_log_output(tmp, FALSE); 2560 paranoid_free(tmp); 2561 2961 2562 log_msg(1, "Changing dir to %s", bkpinfo->restore_path); 2962 2563 chdir(bkpinfo->restore_path); 2564 /* BERLIOS: should test return value, or better change the function */ 2963 2565 getcwd(newpath, MAX_STR_LEN - 1); 2964 2566 log_msg(1, "path is now %s", newpath); … … 2966 2568 if (!find_home_of_exe("petris") && !g_text_mode) { 2967 2569 newtDrawRootText(0, g_noof_rows - 2, 2968 _("Press ALT-<left cursor> twice to play Petris :-) ")); 2570 _ 2571 ("Press ALT-<left cursor> twice to play Petris :-) ")); 2969 2572 newtRefresh(); 2970 2573 } 2971 mvaddstr_and_log_it(g_currentY, 0, _("Preparing to read your archives")); 2574 mvaddstr_and_log_it(g_currentY, 0, 2575 _("Preparing to read your archives")); 2972 2576 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2973 2577 mount_cdrom(bkpinfo); 2974 2578 mvaddstr_and_log_it(g_currentY++, 0, 2975 _("Restoring OS and data from streaming media")); 2579 _ 2580 ("Restoring OS and data from streaming media")); 2976 2581 if (bkpinfo->backup_media_type == cdstream) { 2977 2582 openin_cdstream(bkpinfo); … … 3008 2613 paranoid_free(cwd); 3009 2614 paranoid_free(newpath); 3010 paranoid_free(tmp);3011 2615 return (resA + resB); 3012 2616 } … … 3017 2621 3018 2622 3019 3020 /**3021 * @brief Haha. You wish! (This function is not implemented :-)3022 */3023 int3024 restore_live_from_monitas_server(struct s_bkpinfo *bkpinfo,3025 char *monitas_device,3026 char *restore_this_directory,3027 char *restore_here)3028 /* NB: bkpinfo hasn't been populated yet, except for ->tmp which is "/tmp" */3029 {3030 FILE *fout;3031 int retval = 0;3032 int i;3033 int j;3034 struct mountlist_itself the_mountlist;3035 static struct raidlist_itself the_raidlist;3036 /** malloc **/3037 char tmp[MAX_STR_LEN + 1];3038 char command[MAX_STR_LEN + 1];3039 char datablock[256 * 1024];3040 char datadisks_fname[MAX_STR_LEN + 1];3041 long k;3042 long length;3043 long long llt;3044 struct s_node *filelist = NULL;3045 assert(bkpinfo != NULL);3046 assert_string_is_neither_NULL_nor_zerolength(monitas_device);3047 assert(restore_this_directory != NULL);3048 assert(restore_here != NULL);3049 3050 sprintf(tmp, "restore_here = '%s'", restore_here);3051 3052 log_msg(2, tmp);3053 3054 log_msg(2, "restore_live_from_monitas_server() - starting");3055 unlink("/tmp/mountlist.txt");3056 unlink("/tmp/filelist.full");3057 unlink("/tmp/biggielist.txt");3058 if (restore_here[0] == '\0') {3059 strcpy(bkpinfo->restore_path, MNT_RESTORING);3060 } else {3061 strcpy(bkpinfo->restore_path, restore_here);3062 }3063 log_msg(3, "FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI");3064 sprintf(tmp, "FYI - data will be restored to %s",3065 bkpinfo->restore_path);3066 log_msg(3, tmp);3067 log_msg(3, "FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI FYI");3068 sprintf(datadisks_fname, "/tmp/mondorestore.datadisks.%d",3069 (int) (random() % 32768));3070 chdir(bkpinfo->tmpdir);3071 3072 sprintf(command, "cat %s", monitas_device);3073 g_tape_stream = popen(command, "r"); // for compatibility with openin_tape()3074 if (!(fout = fopen(datadisks_fname, "w"))) {3075 log_OS_error(datadisks_fname);3076 return (1);3077 }3078 for (i = 0; i < 32; i++) {3079 for (j = 0; j < 4; j++) {3080 for (length = k = 0; length < 256 * 1024; length += k) {3081 k = fread(datablock + length, 1, 256 * 1024 - length,3082 g_tape_stream);3083 }3084 fwrite(datablock, 1, length, fout);3085 g_tape_posK += length;3086 }3087 }3088 paranoid_fclose(fout);3089 sprintf(command,3090 "tar -zxvf %s tmp/mondo-restore.cfg tmp/mountlist.txt tmp/filelist.full tmp/biggielist.txt",3091 datadisks_fname);3092 run_program_and_log_output(command, 4);3093 read_header_block_from_stream(&llt, tmp, &i);3094 read_header_block_from_stream(&llt, tmp, &i);3095 3096 unlink(datadisks_fname);3097 read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);3098 retval = load_mountlist(&the_mountlist, g_mountlist_fname);3099 3100 3101 load_raidtab_into_raidlist(&the_raidlist, RAIDTAB_FNAME);3102 iamhere("FIXME");3103 fatal_error("This will fail");3104 sprintf(command,3105 "grep -x \"%s.*\" %s > %s",3106 restore_this_directory, g_filelist_full, g_filelist_full);3107 if (system(command)) {3108 retval++;3109 log_to_screen3110 (_("Error(s) occurred while processing filelist and wildcard"));3111 }3112 iamhere("FIXME");3113 fatal_error("This will fail");3114 sprintf(command,3115 "grep -x \"%s.*\" %s > %s",3116 restore_this_directory, g_biggielist_txt, g_biggielist_txt);3117 if (system(command)) {3118 log_msg(1,3119 "Error(s) occurred while processing biggielist and wildcard");3120 }3121 sprintf(command, "touch %s", g_biggielist_txt);3122 run_program_and_log_output(command, FALSE);3123 // filelist = load_filelist(g_filelist_restthese); // FIXME --- this probably doesn't work because it doesn't include the biggiefiles3124 retval += restore_everything(bkpinfo, filelist);3125 free_filelist(filelist);3126 log_msg(2, "--------End of restore_live_from_monitas_server--------");3127 return (retval);3128 }3129 3130 /**************************************************************************3131 *END_RESTORE_LIVE_FROM_MONITAS_SERVER *3132 **************************************************************************/3133 3134 3135 3136 3137 2623 extern void wait_until_software_raids_are_prepped(char *, int); 3138 3139 2624 3140 2625 char which_restore_mode(void); … … 3146 2631 void welcome_to_mondorestore() 3147 2632 { 3148 log_msg(0, "-------------- Mondo Restore v%s -------------", PACKAGE_VERSION); 2633 log_msg(0, "-------------- Mondo Restore v%s -------------", 2634 PACKAGE_VERSION); 3149 2635 log_msg(0, 3150 2636 "DON'T PANIC! Mondorestore logs almost everything, so please "); … … 3170 2656 "stopped for some reason, chances are it's detailed here. "); 3171 2657 log_msg(0, 3172 "More than likely there's a message at the very end of this");2658 "More than likely there's a message near the end of this "); 3173 2659 log_msg(0, 3174 2660 "log that will tell you what is wrong. Please read it! "); … … 3178 2664 3179 2665 3180 3181 2666 /** 3182 2667 * Restore the user's data. … … 3185 2670 int main(int argc, char *argv[]) 3186 2671 { 3187 FILE *fin ;3188 FILE *fout ;2672 FILE *fin = NULL; 2673 FILE *fout = NULL; 3189 2674 int retval = 0; 3190 int res; 3191 // int c; 3192 char *tmp; 3193 3194 struct mountlist_itself *mountlist; 3195 struct raidlist_itself *raidlist; 3196 struct s_bkpinfo *bkpinfo; 3197 struct s_node *filelist; 3198 char *a, *b; 2675 int res = 0; 2676 char *tmp = NULL; 2677 2678 struct mountlist_itself *mountlist = NULL; 2679 struct raidlist_itself *raidlist = NULL; 2680 struct s_bkpinfo *bkpinfo = NULL; 2681 struct s_node *filelist = NULL; 2682 char *a = NULL, *b = NULL; 3199 2683 3200 2684 /************************************************************************** … … 3215 2699 3216 2700 g_loglevel = DEFAULT_MR_LOGLEVEL; 3217 malloc_string(tmp);3218 2701 3219 2702 /* Configure global variables */ 3220 2703 #ifdef __FreeBSD__ 3221 if (strstr 3222 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 3223 "textonly")) 2704 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 3224 2705 #else 3225 if (strstr 3226 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 3227 "textonly")) 2706 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 3228 2707 #endif 3229 {2708 if (strstr(tmp,"textonly")) { 3230 2709 g_text_mode = TRUE; 3231 2710 log_msg(1, "TEXTONLY MODE"); … … 3233 2712 g_text_mode = FALSE; 3234 2713 } // newt :-) 2714 paranoid_free(tmp); 2715 3235 2716 if (! 3236 2717 (bkpinfo = g_bkpinfo_DONTUSETHIS = … … 3247 2728 malloc_libmondo_global_strings(); 3248 2729 3249 asprintf(&g_mondo_home, 3250 call_program_and_get_last_line_of_output 3251 ("which mondorestore")); 2730 g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore")); 3252 2731 sprintf(g_tmpfs_mountpt, "/tmp/tmpfs"); 3253 2732 make_hole_for_dir(g_tmpfs_mountpt); … … 3257 2736 run_program_and_log_output("mkdir -p /mnt/floppy", FALSE); 3258 2737 3259 malloc_string(tmp);3260 malloc_string(a);3261 malloc_string(b);3262 2738 setup_MR_global_filenames(bkpinfo); // malloc() and set globals, using bkpinfo->tmpdir etc. 3263 2739 reset_bkpinfo(bkpinfo); … … 3281 2757 3282 2758 /* Backup original mountlist.txt */ 3283 sprintf(tmp, "%s.orig", g_mountlist_fname);2759 asprintf(&tmp, "%s.orig", g_mountlist_fname); 3284 2760 if (!does_file_exist(g_mountlist_fname)) { 3285 2761 log_msg(2, … … 3287 2763 __LINE__, g_mountlist_fname); 3288 2764 } else if (!does_file_exist(tmp)) { 3289 sprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname, 2765 paranoid_free(tmp); 2766 asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname, 3290 2767 g_mountlist_fname); 3291 2768 run_program_and_log_output(tmp, FALSE); 3292 2769 } 2770 paranoid_free(tmp); 3293 2771 3294 2772 /* Init directories */ 3295 2773 make_hole_for_dir(bkpinfo->tmpdir); 3296 sprintf(tmp, "mkdir -p %s", bkpinfo->tmpdir);2774 asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir); 3297 2775 run_program_and_log_output(tmp, FALSE); 2776 paranoid_free(tmp); 2777 3298 2778 make_hole_for_dir("/var/log"); 3299 2779 make_hole_for_dir("/tmp/tmpfs"); /* just in case... */ 3300 2780 run_program_and_log_output("umount " MNT_CDROM, FALSE); 3301 2781 run_program_and_log_output 3302 ("ln -sf "MONDO_LOGFILE" /tmp/mondo-restore.log", 3303 FALSE); 2782 ("ln -sf " MONDO_LOGFILE " /tmp/mondo-restore.log", FALSE); 3304 2783 3305 2784 run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE); … … 3361 2840 system("rm -Rf /tmp/*pih*"); 3362 2841 3363 restore_a_biggiefile_from_CD(bkpinfo, 42, NULL, tmp);2842 (void)restore_a_biggiefile_from_CD(bkpinfo, 42, NULL); 3364 2843 } 3365 2844 … … 3378 2857 // finish(0); 3379 2858 // toggle_path_selection (filelist, "/root/stuff", TRUE); 3380 strcpy(a, argv[3]);3381 strcpy(b, argv[4]);2859 asprintf(&a, argv[3]); 2860 asprintf(&b, argv[4]); 3382 2861 3383 2862 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 3384 2863 free_filelist(filelist); 2864 paranoid_free(a); 2865 paranoid_free(b); 3385 2866 printf("res = %d", res); 3386 2867 finish(0); … … 3444 2925 if (argc != 1) { 3445 2926 popup_and_OK 3446 (_("Live mode doesn't support command-line parameters yet.")); 2927 (_ 2928 ("Live mode doesn't support command-line parameters yet.")); 3447 2929 paranoid_MR_finish(1); 3448 2930 // return(1); … … 3454 2936 if (argc > 1 && strcmp(argv[argc - 1], "--live-from-cd") == 0) { 3455 2937 g_restoring_live_from_cd = TRUE; 3456 }3457 if (argc == 5 && strcmp(argv[1], "--monitas-live") == 0) {3458 retval =3459 restore_live_from_monitas_server(bkpinfo,3460 argv[2],3461 argv[3], argv[4]);3462 2938 } else { 3463 2939 log_msg(2, "Calling restore_to_live_filesystem()"); … … 3466 2942 log_msg(2, "Still here. Yay."); 3467 2943 if (strlen(bkpinfo->tmpdir) > 0) { 3468 sprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);2944 asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir); 3469 2945 run_program_and_log_output(tmp, FALSE); 2946 paranoid_free(tmp); 3470 2947 } 3471 2948 unmount_boot_if_necessary(); /* for Gentoo users */ … … 3496 2973 sprintf(bkpinfo->isodir, "/tmp/isodir"); 3497 2974 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 3498 sprintf(tmp, "mount %s -t nfs -o nolock /tmp/isodir",2975 asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir", 3499 2976 bkpinfo->nfs_mount); 3500 2977 run_program_and_log_output(tmp, 1); 2978 paranoid_free(tmp); 3501 2979 } 3502 2980 } … … 3505 2983 if (retval) { 3506 2984 log_to_screen 3507 (_("Warning - load_raidtab_into_raidlist returned an error")); 2985 (_ 2986 ("Warning - load_raidtab_into_raidlist returned an error")); 3508 2987 } 3509 2988 … … 3577 3056 if (does_file_exist("/tmp/changed.files")) { 3578 3057 log_to_screen 3579 (_("See /tmp/changed.files for list of files that have changed.")); 3058 (_ 3059 ("See /tmp/changed.files for list of files that have changed.")); 3580 3060 } 3581 3061 mvaddstr_and_log_it(g_currentY++, 3582 3062 0, 3583 _("Run complete. Errors were reported. Please review the logfile.")); 3063 _ 3064 ("Run complete. Errors were reported. Please review the logfile.")); 3584 3065 } else { 3585 3066 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3586 3067 mvaddstr_and_log_it(g_currentY++, 3587 3068 0, 3588 _("Run complete. Please remove floppy/CD/media and reboot.")); 3069 _ 3070 ("Run complete. Please remove floppy/CD/media and reboot.")); 3589 3071 } else { 3590 3072 run_program_and_log_output("sync", FALSE); … … 3607 3089 mvaddstr_and_log_it(g_currentY++, 3608 3090 0, 3609 _("Run complete. Please remove media and reboot.")); 3091 _ 3092 ("Run complete. Please remove media and reboot.")); 3610 3093 } 3611 3094 } … … 3617 3100 if (mount_all_devices(mountlist, TRUE)) { 3618 3101 log_to_screen 3619 (_("Unable to re-mount partitions for post-nuke stuff")); 3102 (_ 3103 ("Unable to re-mount partitions for post-nuke stuff")); 3620 3104 } else { 3621 3105 log_msg(1, "Re-mounted partitions for post-nuke stuff"); 3622 sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,3106 asprintf(&tmp, "post-nuke %s %d", bkpinfo->restore_path, 3623 3107 retval); 3624 3108 if (!g_text_mode) { … … 3629 3113 log_OS_error(tmp); 3630 3114 } 3115 paranoid_free(tmp); 3631 3116 if (!g_text_mode) { 3632 3117 newtResume(); … … 3647 3132 unlink("/tmp/mondo-run-prog.tmp"); 3648 3133 set_signals(FALSE); 3649 sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);3134 asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir); 3650 3135 run_program_and_log_output(tmp, FALSE); 3136 paranoid_free(tmp); 3137 3651 3138 log_to_screen 3652 (_("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3653 sprintf(tmp, 3654 _("Mondo-restore is exiting (retval=%d) "), 3139 (_ 3140 ("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3141 asprintf(&tmp, 3142 _ 3143 ("Mondo-restore is exiting (retval=%d) "), 3655 3144 retval); 3656 3145 log_to_screen(tmp); 3657 sprintf(tmp, "umount %s", bkpinfo->isodir); 3146 paranoid_free(tmp); 3147 3148 asprintf(&tmp, "umount %s", bkpinfo->isodir); 3658 3149 run_program_and_log_output(tmp, 5); 3150 paranoid_free(tmp); 3151 3659 3152 paranoid_free(mountlist); 3660 3153 paranoid_free(raidlist); … … 3664 3157 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo 3665 3158 free_libmondo_global_strings(); // it's fine to have this here :) really :) 3666 paranoid_free(a);3667 paranoid_free(b);3668 paranoid_free(tmp);3669 3159 3670 3160 unlink("/tmp/filelist.full"); … … 3679 3169 3680 3170 3681 3682 3683 3684 3171 /************************************************************************** 3685 3172 *END_MONDO-RESTORE.C *
Note:
See TracChangeset
for help on using the changeset viewer.