Changeset 2280 in MondoRescue
- Timestamp:
- Jul 20, 2009, 12:27:51 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2242 r2280 117 117 ************************************************************************/ 118 118 char *incoming_ptr; 119 char *question_ptr ;119 char *question_ptr = NULL; 120 120 121 121 char incoming[MAX_STR_LEN] = "\0"; 122 char question[MAX_STR_LEN];123 122 124 123 assert_string_is_neither_NULL_nor_zerolength(infname); … … 131 130 } 132 131 133 question_ptr = malloc(sizeof(question));134 if (question_ptr == NULL) {135 fprintf(stderr, "Out of Memory\n");136 exit(EXIT_FAILURE);137 }138 139 132 memset(incoming_ptr, '\0', sizeof(incoming)); 140 memset(question_ptr, '\0', sizeof(question));141 142 143 133 144 134 if (!(fin = fopen(infname, "r"))) { … … 156 146 } 157 147 158 sprintf(question_ptr, 159 "Should I restore the image of %s ?", incoming_ptr); 148 mr_asprintf(&question_ptr, "Should I restore the image of %s ?", incoming_ptr); 160 149 161 150 if (ask_me_yes_or_no(question_ptr)) { … … 167 156 paranoid_free(incoming_ptr); 168 157 incoming_ptr = NULL; 169 paranoid_free(question_ptr); 170 question_ptr = NULL; 171 172 158 mr_free(question_ptr); 173 159 paranoid_fclose(fout); 174 160 paranoid_fclose(fin); … … 223 209 224 210 /** needs malloc **/ 225 char *command ;211 char *command = NULL; 226 212 char *file; 227 213 char *tmp; 228 214 int res; 229 215 230 malloc_string(command);231 216 malloc_string(file); 232 217 malloc_string(tmp); … … 236 221 237 222 if (strncmp(preamble, f, strlen(preamble)) == 0) { 238 strcpy(file, f + strlen(preamble));223 strcpy(file, f + strlen(preamble)); 239 224 } else { 240 strcpy(file, f);225 strcpy(file, f); 241 226 } 242 227 if (file[0] == '/' && file[1] == '/') { 243 strcpy(tmp, file); 244 strcpy(file, tmp + 1); 245 } 246 sprintf(tmp, 247 "Checking to see if f=%s, file=%s, is in the list of biggiefiles", 248 f, file); 249 log_msg(2, tmp); 250 sprintf(command, "grep -E '^%s$' %s", file, list_fname); 228 strcpy(tmp, file); 229 strcpy(file, tmp + 1); 230 } 231 log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file); 232 mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname); 251 233 res = run_program_and_log_output(command, FALSE); 252 paranoid_free(command);234 mt_free(command); 253 235 paranoid_free(file); 254 paranoid_free(tmp);236 mr_free(tmp); 255 237 if (res) { 256 return (FALSE);238 return (FALSE); 257 239 } else { 258 return (TRUE);240 return (TRUE); 259 241 } 260 242 } … … 277 259 int iso_fiddly_bits(bool nuke_me_please) 278 260 { 279 char *mount_isodir_command = NULL;280 char *tmp, *command;281 char *mds = NULL;282 int retval = 0, i;283 bool already_mounted = FALSE;261 char *mount_isodir_command = NULL; 262 char *command = NULL; 263 char *mds = NULL; 264 int retval = 0, i; 265 bool already_mounted = FALSE; 284 266 285 267 assert(bkpinfo != NULL); 286 malloc_string(tmp);287 malloc_string(command);288 268 g_ISO_restore_mode = TRUE; 289 269 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); … … 295 275 } 296 276 /* End patch */ 297 sprintf(command, "mkdir -p %s", bkpinfo->isodir);277 mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir); 298 278 run_program_and_log_output(command, 5); 279 mr_free(command); 299 280 log_msg(2, "Setting isodir to %s", bkpinfo->isodir); 300 281 } … … 315 296 mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir); 316 297 run_program_and_log_output("df -m", FALSE); 317 sprintf(tmp,298 log_msg(1, 318 299 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 319 300 mount_isodir_command); 320 log_msg(1, tmp);321 301 if (run_program_and_log_output(mount_isodir_command, FALSE)) { 322 302 popup_and_OK … … 333 313 i = what_number_cd_is_this(); /* has the side-effect of calling mount_media() */ 334 314 mds = media_descriptor_string(bkpinfo->backup_media_type); 335 sprintf(tmp, "%s #%d has been mounted via loopback mount", mds, i);336 315 mr_free(mds); 337 316 338 log_msg(1, tmp);317 log_msg(1, "%s #%d has been mounted via loopback mount", mds, i); 339 318 if (i < 0) { 340 319 popup_and_OK … … 344 323 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 345 324 bkpinfo->isodir); 346 paranoid_free(tmp);347 paranoid_free(command);348 325 return (retval); 349 326 } … … 377 354 378 355 /** malloc **/ 379 char *tmp, *command, *mountdir, *mountpoint; 356 char *tmp = NULL; 357 char *command = NULL; 358 char *mountdir = NULL; 359 char *mountpoint = NULL; 380 360 char *additional_parameters = NULL; 381 361 … … 383 363 assert_string_is_neither_NULL_nor_zerolength(mpt); 384 364 assert(format != NULL); 385 malloc_string(tmp);386 malloc_string(command);387 malloc_string(mountdir);388 malloc_string(mountpoint);389 365 390 366 if (!strcmp(mpt, "/1")) { 391 strcpy(mountpoint, "/");367 mr_asprintf(&mountpoint, "/"); 392 368 log_msg(3, "Mommm! SME is being a dildo!"); 393 369 } else { 394 strcpy(mountpoint, mpt);370 mr_asprintf(&mountpoint, mpt); 395 371 } 396 372 … … 401 377 return (0); 402 378 } 403 sprintf(tmp, "Mounting device %s ", device);379 mr_asprintf(&tmp, "Mounting device %s ", device); 404 380 log_msg(1, tmp); 405 381 /* Deal with additional params only if not /proc or /sys */ … … 420 396 421 397 if (!strcmp(mountpoint, "swap")) { 422 sprintf(command, "swapon %s", device); 398 mr_asprintf(&command, "swapon %s", device); 399 mr_asprintf(&mountdir, "swap"); 423 400 } else { 424 401 if (!strcmp(mountpoint, "/")) { 425 strcpy(mountdir, MNT_RESTORING);402 mr_asprintf(&mountdir, "%s", MNT_RESTORING); 426 403 } else { 427 sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);428 } 429 sprintf(command, "mkdir -p %s", mountdir);404 mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint); 405 } 406 mr_asprintf(&command, "mkdir -p %s", mountdir); 430 407 run_program_and_log_output(command, FALSE); 431 sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, 408 mr_free(command); 409 410 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 432 411 additional_parameters, mountdir, MONDO_LOGFILE); 433 412 log_msg(2, "command='%s'", command); 434 413 } 435 paranoid_free(additional_parameters);414 mr_free(additional_parameters); 436 415 437 416 res = run_program_and_log_output(command, TRUE); 438 417 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) { 439 418 log_msg(1, "Re-trying without the fancy extra parameters"); 440 sprintf(command, "mount -t %s %s %s 2>> %s", format, device, 419 mr_free(command); 420 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 441 421 mountdir, MONDO_LOGFILE); 442 422 res = run_program_and_log_output(command, TRUE); … … 450 430 } else { 451 431 log_msg(2, "Retrying w/o the '-t' switch"); 452 sprintf(command, "mount %s %s 2>> %s", device, mountdir,453 432 mr_free(command); 433 mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE); 454 434 log_msg(2, "2nd command = '%s'", command); 455 435 res = run_program_and_log_output(command, TRUE); … … 469 449 } 470 450 471 paranoid_free(tmp);472 paranoid_free(command);473 paranoid_free(mountdir);474 paranoid_free(mountpoint);451 mr_free(tmp); 452 mr_free(command); 453 mr_free(mountdir); 454 mr_free(mountpoint); 475 455 476 456 return (res); … … 491 471 { 492 472 int retval = 0, lino, res; 493 char *tmp ;473 char *tmp = NULL; 494 474 char *these_failed = NULL; 495 475 char *format; 496 476 struct mountlist_itself *mountlist = NULL; 497 477 498 malloc_string(tmp);499 478 malloc_string(format); 500 479 … … 518 497 "Again with the /proc - why is this in your mountlist?"); 519 498 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 520 sprintf(tmp, "%s is already mounted",499 mr_asprintf(&tmp, "%s is already mounted", 521 500 mountlist->el[lino].device); 522 501 log_to_screen(tmp); 502 mr_free(tmp); 523 503 } else if (strcmp(mountlist->el[lino].mountpoint, "none") 524 504 && strcmp(mountlist->el[lino].mountpoint, "lvm") 525 505 && strcmp(mountlist->el[lino].mountpoint, "raid") 526 506 && strcmp(mountlist->el[lino].mountpoint, "image")) { 527 sprintf(tmp, "Mounting %s", mountlist->el[lino].device);507 mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device); 528 508 update_progress_form(tmp); 509 mr_free(tmp); 529 510 strcpy(format, mountlist->el[lino].format); 530 511 res = mount_device(mountlist->el[lino].device, … … 548 529 ("format and restore *without* partitioning first. Sorry for the inconvenience."); 549 530 } 550 sprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed);531 mr_asprintf(&tmp, "Could not mount device(s) %s- shall I abort?", these_failed); 551 532 552 533 if (!ask_me_yes_or_no(tmp)) { … … 560 541 ("Unable to mount some or all of your partitions."); 561 542 } 543 mr_free(tmp); 562 544 } else { 563 545 log_to_screen("All partitions were mounted OK."); … … 571 553 run_program_and_log_output("df -m", 3); 572 554 paranoid_free(mountlist); 573 paranoid_free(tmp);574 555 paranoid_free(format); 575 556 return (retval); … … 591 572 int mount_media() 592 573 { 593 char *mount_cmd ;574 char *mount_cmd = NULL; 594 575 int i, res; 595 576 #ifdef __FreeBSD__ … … 598 579 #endif 599 580 600 malloc_string(mount_cmd);601 581 assert(bkpinfo != NULL); 602 582 … … 604 584 || bkpinfo->backup_media_type == udev) { 605 585 log_msg(8, "Tape/udev. Therefore, no need to mount a media."); 606 paranoid_free(mount_cmd);607 586 return 0; 608 587 } … … 610 589 if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) { 611 590 log_msg(2, "mount_media() - media already mounted. Fair enough."); 612 paranoid_free(mount_cmd);613 591 return (0); 614 592 } … … 623 601 } 624 602 #ifdef __FreeBSD__ 625 sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, 626 bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 603 mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 627 604 mddev = make_vn(mount_cmd); 628 sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 605 mr_free(mount_cmd); 606 607 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 629 608 #else 630 sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", 631 bkpinfo->isodir, bkpinfo->nfs_remote_dir, 609 mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, 632 610 bkpinfo->prefix, g_current_media_number, MNT_CDROM); 633 611 #endif … … 635 613 } else if (bkpinfo->backup_media_type == iso) { 636 614 #ifdef __FreeBSD__ 637 sprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, 638 bkpinfo->prefix, g_current_media_number); 615 mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number); 639 616 mddev = make_vn(mount_cmd); 640 sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 617 mr_free(mount_cmd); 618 619 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 641 620 #else 642 sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",621 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 643 622 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 644 623 #endif 645 624 } else if (bkpinfo->backup_media_type == usb) { 646 sprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);625 mr_asprintf(&mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM); 647 626 } else if (strstr(bkpinfo->media_device, "/dev/")) { 648 627 #ifdef __FreeBSD__ 649 sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 650 MNT_CDROM); 628 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM); 651 629 #else 652 sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", 653 bkpinfo->media_device, MNT_CDROM); 630 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM); 654 631 #endif 655 632 } else { … … 663 640 664 641 #ifdef __FreeBSD__ 665 sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 666 MNT_CDROM); 642 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM); 667 643 #else 668 sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", 669 bkpinfo->media_device, MNT_CDROM); 644 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM); 670 645 #endif 671 646 } … … 682 657 } 683 658 } 659 mr_free(mount_cmd); 684 660 685 661 if (res) { … … 688 664 log_msg(2, "Mounted media drive OK"); 689 665 } 690 paranoid_free(mount_cmd);691 666 return (res); 692 667 } … … 694 669 *END_MOUNT_CDROM * 695 670 **************************************************************************/ 696 697 671 698 672 … … 743 717 char *value = NULL; 744 718 char *tmp = NULL; 719 char *tmp1 = NULL; 745 720 char *envtmp1 = NULL; 746 721 char *envtmp2 = NULL; … … 752 727 t_bkptype media_specified_by_user; 753 728 754 malloc_string(command);755 729 malloc_string(iso_mnt); 756 730 malloc_string(iso_path); … … 850 824 } 851 825 sprintf(bkpinfo->media_device, "%s1", value); 852 sprintf(tmp, "Backup medium is USB --- dev=%s", bkpinfo->media_device); 853 log_msg(2, tmp); 826 log_msg(2, "Backup medium is USB --- dev=%s", bkpinfo->media_device); 854 827 } else if (bkpinfo->backup_media_type == tape 855 828 || bkpinfo->backup_media_type == udev) { … … 860 833 read_cfg_var(cfg_file, "media-size", value); 861 834 bkpinfo->media_size[1] = atol(value); 862 sprintf(tmp, "Backup medium is TAPE --- dev=%s", 863 bkpinfo->media_device); 864 log_msg(2, tmp); 835 log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device); 865 836 } else { 866 837 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ … … 953 924 954 925 read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp); 955 if (tmp[0] 956 || 957 strstr(call_program_and_get_last_line_of_output 958 ("cat /proc/cmdline"), "donteject")) { 959 bkpinfo->please_dont_eject = TRUE; 960 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 926 if (tmp[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) { 927 bkpinfo->please_dont_eject = TRUE; 928 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 961 929 } 962 930 … … 1018 986 log_msg(2, "NB: isodir is already mounted"); 1019 987 /* Find out where it's mounted */ 1020 sprintf(command, 1021 "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", 1022 g_isodir_device); 988 mr_asprintf(&command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device); 1023 989 log_it("command = %s", command); 1024 log_it("res of it = %s", 1025 call_program_and_get_last_line_of_output(command)); 1026 sprintf(iso_mnt, "%s", 1027 call_program_and_get_last_line_of_output(command)); 990 log_it("res of it = %s", call_program_and_get_last_line_of_output(command)); 991 sprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command)); 992 mr_free(command); 1028 993 } else { 1029 994 sprintf(iso_mnt, "/tmp/isodir"); 1030 sprintf(tmp, "mkdir -p %s", iso_mnt); 1031 run_program_and_log_output(tmp, 5); 1032 sprintf(tmp, "mount %s %s", g_isodir_device, iso_mnt); 1033 if (run_program_and_log_output(tmp, 3)) { 995 mr_asprintf(&tmp1, "mkdir -p %s", iso_mnt); 996 run_program_and_log_output(tmp1, 5); 997 mr_free(tmp1); 998 999 mr_asprintf(&tmp1, "mount %s %s", g_isodir_device, iso_mnt); 1000 if (run_program_and_log_output(tmp1, 3)) { 1034 1001 log_msg(1, 1035 1002 "Unable to mount isodir. Perhaps this is really a CD backup?"); … … 1038 1005 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0'; 1039 1006 if (mount_media()) { 1007 mr_free(tmp1); 1040 1008 fatal_error 1041 1009 ("Unable to mount isodir. Failed to mount CD-ROM as well."); … … 1045 1013 } 1046 1014 } 1015 mr_free(tmp1); 1047 1016 } 1048 1017 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ … … 1072 1041 paranoid_free(value); 1073 1042 paranoid_free(tmp); 1074 paranoid_free(command);1075 1043 paranoid_free(iso_mnt); 1076 1044 paranoid_free(iso_path); … … 1103 1071 1104 1072 /** add mallocs**/ 1105 char *command ;1073 char *command = NULL; 1106 1074 char *tmp; 1107 1075 int res = 0; … … 1110 1078 1111 1079 assert(bkpinfo != NULL); 1112 malloc_string(command);1113 1080 malloc_string(tmp); 1114 1081 … … 1134 1101 unlink(FILELIST_FULL_STUB); 1135 1102 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1136 sprintf(command, 1137 "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", 1103 mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", 1138 1104 bkpinfo->internal_tape_block_size, 1139 1105 bkpinfo->media_device, … … 1145 1111 log_msg(1, "tarcommand = %s", command); 1146 1112 run_program_and_log_output(command, 1); 1113 mr_free(command); 1114 1147 1115 if (!does_file_exist(FILELIST_FULL_STUB)) { 1148 1116 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1149 1117 log_msg(2, "pre-2.2.4 compatible mode on"); 1150 sprintf(command,1118 mr_asprintf(&command, 1151 1119 "tar -b %ld -zxf %s %s %s %s %s %s", 1152 1120 bkpinfo->internal_tape_block_size, … … 1159 1127 log_msg(1, "tarcommand = %s", command); 1160 1128 run_program_and_log_output(command, 1); 1129 mr_free(command); 1161 1130 } 1162 1131 } else { … … 1167 1136 log_msg(2, "Back from iotcn"); 1168 1137 run_program_and_log_output("mount", 1); 1169 sprintf(command,1138 mr_asprintf(&command, 1170 1139 "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", 1171 1140 MNT_CDROM, … … 1178 1147 log_msg(1, "tarcommand = %s", command); 1179 1148 run_program_and_log_output(command, 1); 1149 mr_free(command); 1150 1180 1151 if (!does_file_exist(FILELIST_FULL_STUB)) { 1181 1152 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1182 1153 log_msg(2, "pre-2.2.4 compatible mode on"); 1183 sprintf(command,1154 mr_asprintf(&command, 1184 1155 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1185 1156 MNT_CDROM, … … 1192 1163 log_msg(1, "tarcommand = %s", command); 1193 1164 run_program_and_log_output(command, 1); 1165 mr_free(command); 1194 1166 } 1195 1167 if (!does_file_exist(BIGGIELIST_TXT_STUB)) { … … 1202 1174 } 1203 1175 } 1204 sprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB, 1205 g_mondo_cfg_file); 1176 mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file); 1206 1177 run_program_and_log_output(command, FALSE); 1207 1208 sprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, 1209 1178 mr_free(command); 1179 1180 mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt); 1210 1181 log_msg(1, "command = %s", command); 1211 1182 paranoid_system(command); 1212 sprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, 1213 FILELIST_FULL_STUB, g_filelist_full); 1183 mr_free(command); 1184 1185 mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full); 1214 1186 log_msg(1, "command = %s", command); 1215 1187 paranoid_system(command); 1216 } 1217 1218 if (am_I_in_disaster_recovery_mode() 1188 mr_free(command); 1189 } 1190 1191 if (am_I_in_disaster_recovery_mode() 1219 1192 && 1220 1193 /* If it was there, do not overwrite it */ 1221 1194 (extract_mountlist_stub) 1222 1195 && 1223 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) 1224 { 1225 sprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1196 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) { 1197 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1226 1198 bkpinfo->tmpdir); 1227 paranoid_system(command); 1199 paranoid_system(command); 1200 mr_free(command); 1228 1201 } 1229 1202 … … 1248 1221 log_to_screen("Pre-processing filelist"); 1249 1222 if (!does_file_exist(g_biggielist_txt)) { 1250 sprintf(command, "echo -n > %s", g_biggielist_txt);1223 mr_asprintf(&command, "echo -n > %s", g_biggielist_txt); 1251 1224 paranoid_system(command); 1252 } 1253 sprintf(command, "grep -E '^/dev/.*' %s > %s", 1225 mr_free(command); 1226 } 1227 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", 1254 1228 g_biggielist_txt, g_filelist_imagedevs); 1255 1229 paranoid_system(command); 1230 mr_free(command); 1256 1231 exit(0); 1257 1232 break; … … 1301 1276 } 1302 1277 1303 paranoid_free(command);1304 1278 paranoid_free(tmp); 1305 1279 return (filelist); … … 1322 1296 int backup_crucial_file(char *path_root, char *filename) 1323 1297 { 1324 char *tmp ;1325 char *command ;1298 char *tmp = NULL; 1299 char *command = NULL; 1326 1300 int res; 1327 1301 1328 malloc_string(tmp);1329 malloc_string(command);1330 1302 assert(path_root != NULL); 1331 1303 assert_string_is_neither_NULL_nor_zerolength(filename); 1332 1304 1333 sprintf(tmp, "%s/%s", path_root, filename); 1334 sprintf(command, "cp -f %s %s.pristine", tmp, tmp); 1305 mr_asprintf(&tmp, "%s/%s", path_root, filename); 1306 mr_asprintf(&command, "cp -f %s %s.pristine", tmp, tmp); 1307 mr_free(tmp); 1335 1308 1336 1309 res = run_program_and_log_output(command, 5); 1337 paranoid_free(tmp); 1338 paranoid_free(command); 1310 mr_free(command); 1339 1311 return (res); 1340 1312 } … … 1402 1374 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1403 1375 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1404 mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1405 log_msg(2, tmp); 1406 paranoid_free(tmp); 1376 log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name); 1407 1377 system("sync"); 1408 1378 … … 1425 1395 mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device); 1426 1396 if (!system(tmp)) { 1427 paranoid_free(tmp);1397 mr_free(tmp); 1428 1398 mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1429 1399 res = run_program_and_log_output(tmp, 3); 1430 1400 } else { 1431 log_msg(1, 1432 "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 1433 } 1434 paranoid_free(tmp); 1401 log_msg(1, "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 1402 } 1403 mr_free(tmp); 1435 1404 } 1436 1405 #else … … 1493 1462 { 1494 1463 /** malloc **/ 1495 char *command ;1464 char *command = NULL; 1496 1465 char *boot_device; 1497 1466 char *rootdev; 1498 1467 char *rootdrive; 1499 1468 char *conffile; 1500 char *tmp ;1469 char *tmp = NULL; 1501 1470 char *editor; 1502 1471 … … 1504 1473 int done; 1505 1474 1506 malloc_string(command);1507 1475 malloc_string(boot_device); 1508 malloc_string(tmp);1509 1476 malloc_string(editor); 1510 1477 malloc_string(rootdev); … … 1515 1482 strcpy(boot_device, bd); 1516 1483 1517 if (!run_program_and_log_output("which grub-MR", FALSE)) {1518 log_msg(1, "Yay! grub-MR found...");1519 sprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device);1520 log_msg(1, "command = %s", command);1521 } else {1522 sprintf(command, "chroot " MNT_RESTORING " grub-install %s",1523 boot_device);1524 log_msg(1, "WARNING - grub-MR not found; using grub-install");1525 }1526 1484 if (offer_to_run_stabgrub 1527 1485 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) … … 1535 1493 "Please confirm/enter the boot device. If in doubt, try /dev/hda", 1536 1494 boot_device, MAX_STR_LEN / 4); 1537 sprintf(command, "stabgrub-me %s", boot_device);1495 mr_asprintf(&command, "stabgrub-me %s", boot_device); 1538 1496 res = run_program_and_log_output(command, 1); 1497 mr_free(command); 1498 1539 1499 if (res) { 1540 1500 popup_and_OK … … 1551 1511 newtSuspend(); 1552 1512 } 1553 sprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1513 mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1554 1514 paranoid_system(tmp); 1555 sprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1515 mr_free(tmp); 1516 1517 mr_asprintf(&tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1556 1518 paranoid_system(tmp); 1557 sprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1519 mr_free(tmp); 1520 1521 mr_asprintf(&tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1558 1522 paranoid_system(tmp); 1559 sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1523 mr_free(tmp); 1524 1525 mr_asprintf(&tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1560 1526 paranoid_system(tmp); 1527 mr_free(tmp); 1528 1561 1529 if (!g_text_mode) { 1562 1530 newtResume(); … … 1566 1534 /* nuke mode */ 1567 1535 { 1536 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1537 log_msg(1, "Yay! grub-MR found..."); 1538 mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", boot_device); 1539 log_msg(1, "command = %s", command); 1540 } else { 1541 mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", boot_device); 1542 log_msg(1, "WARNING - grub-MR not found; using grub-install"); 1543 } 1568 1544 mvaddstr_and_log_it(g_currentY, 1569 1545 0, … … 1571 1547 log_it("%s",command); 1572 1548 res = run_program_and_log_output(command, 1); 1549 mr_free(command); 1550 1573 1551 if (res) { 1574 1552 popup_and_OK … … 1599 1577 paranoid_free(rootdrive); 1600 1578 paranoid_free(conffile); 1601 paranoid_free(command);1602 1579 paranoid_free(boot_device); 1603 paranoid_free(tmp);1604 1580 paranoid_free(editor); 1605 1581 … … 1620 1596 { 1621 1597 /** malloc **/ 1622 char *command ;1623 char *tmp ;1598 char *command = NULL; 1599 char *tmp = NULL; 1624 1600 char *editor; 1625 1601 … … 1627 1603 int done; 1628 1604 1629 malloc_string(command);1630 malloc_string(tmp);1631 1605 malloc_string(editor); 1632 1606 strcpy(editor, find_my_editor()); … … 1639 1613 0, 1640 1614 "Modifying fstab and elilo.conf... "); 1641 sprintf(command, "stabelilo-me");1615 mr_asprintf(&command, "stabelilo-me"); 1642 1616 res = run_program_and_log_output(command, 3); 1617 mr_free(command); 1618 1643 1619 if (res) { 1644 1620 popup_and_OK … … 1648 1624 newtSuspend(); 1649 1625 } 1650 sprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1626 mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1651 1627 paranoid_system(tmp); 1652 sprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor); 1628 mr_free(tmp); 1629 1630 mr_asprintf(&tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor); 1653 1631 paranoid_system(tmp); 1632 mr_free(tmp); 1633 1654 1634 if (!g_text_mode) { 1655 1635 newtResume(); … … 1669 1649 res = TRUE; 1670 1650 } 1671 paranoid_free(command);1672 paranoid_free(tmp);1673 1651 paranoid_free(editor); 1674 1652 return (res); … … 1688 1666 { 1689 1667 /** malloc **/ 1690 char *command ;1691 char *tmp ;1668 char *command = NULL; 1669 char *tmp = NULL; 1692 1670 char *editor; 1693 1671 … … 1695 1673 int done; 1696 1674 bool run_lilo_M = FALSE; 1697 malloc_string(command);1698 malloc_string(tmp);1699 1675 malloc_string(editor); 1700 1676 … … 1713 1689 0, 1714 1690 "Modifying fstab and lilo.conf, and running LILO... "); 1715 sprintf(command, "stablilo-me");1691 mr_asprintf(&command, "stablilo-me"); 1716 1692 res = run_program_and_log_output(command, 3); 1693 mr_free(command); 1694 1717 1695 if (res) { 1718 1696 popup_and_OK … … 1722 1700 newtSuspend(); 1723 1701 } 1724 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1702 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1725 1703 paranoid_system(tmp); 1726 sprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1704 mr_free(tmp); 1705 1706 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1727 1707 paranoid_system(tmp); 1708 mr_free(tmp); 1709 1728 1710 if (!g_text_mode) { 1729 1711 newtResume(); … … 1780 1762 " lilo -M /dev/sda", 3); 1781 1763 } 1782 paranoid_free(command);1783 paranoid_free(tmp);1784 1764 paranoid_free(editor); 1785 1765 return (res); … … 1800 1780 { 1801 1781 /** malloc **/ 1802 char *command ;1782 char *command = NULL; 1803 1783 char *boot_device; 1804 char *tmp ;1784 char *tmp = NULL; 1805 1785 char *editor; 1806 1786 int res; 1807 1787 int done; 1808 1788 1809 malloc_string(command);1810 1789 malloc_string(boot_device); 1811 malloc_string(tmp);1812 1790 malloc_string(editor); 1813 1791 assert_string_is_neither_NULL_nor_zerolength(bd); … … 1815 1793 strcpy(editor, find_my_editor()); 1816 1794 strcpy(boot_device, bd); 1817 sprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device);1818 log_msg(2, "run_raw_mbr() --- command='%s'", command);1819 1795 1820 1796 if (offer_to_hack_scripts … … 1830 1806 newtSuspend(); 1831 1807 } 1832 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1808 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1833 1809 paranoid_system(tmp); 1810 mr_free(tmp); 1834 1811 if (!g_text_mode) { 1835 1812 newtResume(); 1836 1813 } 1837 // newtCls();1838 1814 } 1839 1815 popup_and_get_string("Boot device", 1840 1816 "Please confirm/enter the boot device. If in doubt, try /dev/hda", 1841 1817 boot_device, MAX_STR_LEN / 4); 1842 sprintf(command, "stabraw-me %s", boot_device);1818 mr_asprintf(&command, "stabraw-me %s", boot_device); 1843 1819 res = run_program_and_log_output(command, 3); 1820 mr_free(command); 1821 1844 1822 if (res) { 1845 1823 done = ask_me_yes_or_no("Modifications failed. Re-try?"); … … 1851 1829 /* nuke mode */ 1852 1830 { 1831 mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device); 1832 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1833 1853 1834 mvaddstr_and_log_it(g_currentY, 0, 1854 1835 "Restoring MBR... "); 1855 1836 res = run_program_and_log_output(command, 3); 1856 } 1837 mr_free(command); 1838 } 1839 1857 1840 if (res) { 1858 1841 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); … … 1862 1845 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1863 1846 } 1864 paranoid_free(command);1865 1847 paranoid_free(boot_device); 1866 paranoid_free(tmp);1867 1848 paranoid_free(editor); 1868 1849 return (res); … … 1894 1875 malloc_string(g_mountlist_fname); 1895 1876 malloc_string(g_mondo_home); 1896 /*1897 malloc_string(g_tmpfs_mountpt);1898 */1899 1877 malloc_string(g_isodir_device); 1900 1878 malloc_string(g_isodir_format); … … 1905 1883 sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB); 1906 1884 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath); 1907 // sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath); 1908 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", 1909 temppath); 1885 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", temppath); 1910 1886 if (bkpinfo->disaster_recovery) { 1911 1887 sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); … … 1913 1889 } else { 1914 1890 sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB); 1915 sprintf(g_mountlist_fname, "%s/%s", temppath, 1916 MOUNTLIST_FNAME_STUB); 1891 sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB); 1917 1892 } 1918 1893 } … … 1975 1950 int i; 1976 1951 /* MALLOC * */ 1977 char *tmp; 1978 1979 malloc_string(tmp); 1952 char *tmp = NULL; 1953 1980 1954 if (does_file_exist("/tmp/NOPAUSE")) { 1981 1955 return; … … 1987 1961 for (i = 0; i < 20; i++) { 1988 1962 g_current_progress = i; 1989 sprintf(tmp, "You have %d seconds left to abort.", 20 - i);1963 mr_asprintf(&tmp, "You have %d seconds left to abort.", 20 - i); 1990 1964 update_progress_form(tmp); 1965 mr_free(tmp); 1991 1966 sleep(1); 1992 1967 } 1993 1968 close_progress_form(); 1994 paranoid_free(tmp);1995 1969 } 1996 1970 … … 2010 1984 struct mountlist_itself *mountlist; 2011 1985 int retval = 0, lino, res = 0, i; 2012 char *command ;1986 char *command = NULL; 2013 1987 char *tmp = NULL; 2014 1988 2015 malloc_string(command);2016 1989 assert(p_external_copy_of_mountlist != NULL); 2017 1990 … … 2065 2038 if (is_this_device_mounted(mountlist->el[lino].device)) { 2066 2039 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { 2067 sprintf(command, "swapoff %s", mountlist->el[lino].device);2040 mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device); 2068 2041 } else { 2069 2042 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) { 2070 sprintf(command, "umount %s/", MNT_RESTORING);2043 mr_asprintf(&command, "umount %s/", MNT_RESTORING); 2071 2044 log_msg(3, 2072 2045 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2073 2046 } else { 2074 sprintf(command, "umount " MNT_RESTORING "%s",2047 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2075 2048 mountlist->el[lino].mountpoint); 2076 2049 … … 2086 2059 log_msg(10, "The 'umount' command is '%s'", command); 2087 2060 res = run_program_and_log_output(command, 3); 2061 mr_free(command); 2088 2062 } else { 2089 2063 mr_strcat(tmp, "...not mounted anyway :-) OK"); … … 2112 2086 } 2113 2087 free(mountlist); 2114 paranoid_free(command);2115 2088 return (retval); 2116 2089 } … … 2130 2103 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev) 2131 2104 { 2132 char *command ;2105 char *command = NULL; 2133 2106 int res = 0; 2134 2135 malloc_string(command);2136 2107 2137 2108 if (bkpinfo->use_obdr) { … … 2142 2113 } 2143 2114 2144 sprintf(command,2115 mr_asprintf(&command, 2145 2116 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", 2146 2117 dev, … … 2151 2122 log_msg(2, "command = '%s'", command); 2152 2123 res = run_program_and_log_output(command, -1); 2124 mr_free(command); 2125 2153 2126 if (res != 0) { 2154 2127 if (does_file_exist(MONDO_CFG_FILE_STUB)) { … … 2157 2130 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2158 2131 log_msg(2, "pre-2.2.4 compatible mode on"); 2159 sprintf(command,2132 mr_asprintf(&command, 2160 2133 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2161 2134 dev, … … 2166 2139 log_msg(2, "command = '%s'", command); 2167 2140 res = run_program_and_log_output(command, -1); 2141 mr_free(command); 2142 2168 2143 if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) { 2169 2144 res = 0; … … 2171 2146 } 2172 2147 } 2173 paranoid_free(command);2174 2148 return (res); 2175 2149 } … … 2191 2165 /** malloc *****/ 2192 2166 char *device; 2193 char *command ;2194 char *cfg_file ;2167 char *command = NULL; 2168 char *cfg_file = NULL; 2195 2169 char *mounted_cfgf_path; 2196 char *tmp ;2197 char *mountpt ;2170 char *tmp = NULL; 2171 char *mountpt = NULL; 2198 2172 char *ramdisk_fname; 2199 char *mountlist_file ;2173 char *mountlist_file = NULL; 2200 2174 bool extract_mountlist_stub = FALSE; 2201 2175 bool extract_i_want_my_lvm = FALSE; … … 2204 2178 2205 2179 assert(bkpinfo != NULL); 2206 malloc_string(cfg_file);2207 2180 malloc_string(mounted_cfgf_path); 2208 malloc_string(mountpt);2209 2181 malloc_string(ramdisk_fname); 2210 malloc_string(mountlist_file);2211 2182 malloc_string(device); 2212 malloc_string(command);2213 malloc_string(tmp);2214 2183 log_msg(2, "gcffa --- starting"); 2215 2184 log_to_screen("I'm thinking..."); 2216 sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2185 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2217 2186 device[0] = '\0'; 2218 2187 chdir(bkpinfo->tmpdir); 2219 strcpy(cfg_file, MONDO_CFG_FILE_STUB);2188 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB); 2220 2189 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent 2190 mr_free(cfg_file); 2191 2221 2192 unlink(FILELIST_FULL_STUB); 2222 2193 unlink(BIGGIELIST_TXT_STUB); 2223 sprintf(command, "mkdir -p %s", mountpt);2194 mr_asprintf(&command, "mkdir -p %s", mountpt); 2224 2195 run_program_and_log_output(command, FALSE); 2225 2226 sprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2227 sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2228 // make_hole_for_file( cfg_file ); 2229 // make_hole_for_file( mountlist_file); 2196 mr_free(command); 2197 2198 mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2199 mr_asprintf(^mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2230 2200 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 2201 mr_free(mountpt); 2231 2202 2232 2203 if (!does_file_exist(cfg_file)) { … … 2256 2227 log_msg(2, "media_device is blank; assuming %s"); 2257 2228 } 2258 strcpy(tmp, bkpinfo->media_device);2229 mr_asprintf(&tmp, bkpinfo->media_device); 2259 2230 if (extract_cfg_file_and_mountlist_from_tape_dev 2260 2231 (bkpinfo->media_device)) { … … 2275 2246 } 2276 2247 } 2248 mr_free(tmp); 2277 2249 2278 2250 if (!does_file_exist("tmp/mondo-restore.cfg")) { … … 2294 2266 log_msg(2, 2295 2267 "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz"); 2296 sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2268 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2297 2269 run_program_and_log_output(command, TRUE); 2270 mr_free(command); 2271 2298 2272 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { 2299 2273 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2300 2274 log_msg(2, "pre-2.2.4 compatible mode on"); 2301 sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2275 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2302 2276 run_program_and_log_output(command, TRUE); 2277 mr_free(command); 2278 2303 2279 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { 2304 2280 fatal_error … … 2310 2286 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2311 2287 log_msg(1, "gcffa --- great! We've got the config file"); 2312 sprintf(tmp, "%s/%s", 2313 call_program_and_get_last_line_of_output("pwd"), 2314 MONDO_CFG_FILE_STUB); 2315 sprintf(command, "cp -f %s %s", tmp, cfg_file); 2288 mr_asprintf(&tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB); 2289 mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file); 2316 2290 log_it("%s",command); 2317 if (strcmp(tmp, cfg_file) 2318 && run_program_and_log_output(command, 1)) { 2319 log_msg(1, 2320 "... but an error occurred when I tried to move it to %s", 2321 cfg_file); 2291 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) { 2292 log_msg(1, "... but an error occurred when I tried to move it to %s", cfg_file); 2322 2293 } else { 2323 2294 log_msg(1, "... and I moved it successfully to %s", cfg_file); 2324 2295 } 2325 sprintf(command, "cp -f %s/%s %s", 2326 call_program_and_get_last_line_of_output("pwd"), 2296 mr_free(command); 2297 2298 mr_asprintf(&command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"), 2327 2299 MOUNTLIST_FNAME_STUB, mountlist_file); 2328 2300 log_it("%s",command); 2329 2301 if (extract_mountlist_stub) { 2330 if (strcmp(tmp, cfg_file) 2331 && run_program_and_log_output(command, 1)) { 2302 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) { 2332 2303 log_msg(1, "Failed to get mountlist"); 2333 2304 } else { 2334 2305 log_msg(1, "Got mountlist too"); 2335 sprintf(command, "cp -f %s %s", mountlist_file, 2336 g_mountlist_fname); 2306 2307 mr_free(command); 2308 mr_asprintf(&command, "cp -f %s %s", mountlist_file, g_mountlist_fname); 2337 2309 if (run_program_and_log_output(command, 1)) { 2338 2310 log_msg(1, "Failed to copy mountlist to /tmp"); 2339 2311 } else { 2340 2312 log_msg(1, "Copied mountlist to /tmp as well OK"); 2341 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2313 mr_free(command); 2314 mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2342 2315 run_program_and_log_output(command, 1); 2343 2316 } 2344 2317 } 2345 2318 } 2319 mr_free(tmp); 2320 mr_free(command); 2346 2321 } 2347 2322 run_program_and_log_output("umount " MNT_CDROM, FALSE); … … 2361 2336 /* Is this code really useful ??? */ 2362 2337 if (extract_mountlist_stub) { 2363 sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,2338 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2364 2339 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2365 2340 run_program_and_log_output(command, FALSE); 2366 } 2367 } 2368 2369 sprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2341 mr_free(command); 2342 } 2343 } 2344 2345 mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2346 mr_free(cfg_file); 2347 2370 2348 run_program_and_log_output(command, FALSE); 2349 mr_free(command); 2350 2371 2351 if (extract_mountlist_stub) { 2372 sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2352 mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2373 2353 run_program_and_log_output(command, FALSE); 2374 } 2375 sprintf(command, "cp -f etc/raidtab /etc/"); 2354 mr_free(command); 2355 } 2356 mr_free(mountlist_file); 2357 2358 mr_asprintf(&command, "cp -f etc/raidtab /etc/"); 2376 2359 run_program_and_log_output(command, FALSE); 2360 mr_free(command); 2361 2377 2362 if (extract_i_want_my_lvm) { 2378 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2363 mr_asprintf(&command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2379 2364 run_program_and_log_output(command, FALSE); 2365 mr_free(command); 2380 2366 } 2381 2367 g_backup_media_type = bkpinfo->backup_media_type; 2382 2368 paranoid_free(device); 2383 paranoid_free(command);2384 paranoid_free(tmp);2385 paranoid_free(cfg_file);2386 2369 paranoid_free(mounted_cfgf_path); 2387 paranoid_free(mountpt);2388 2370 paranoid_free(ramdisk_fname); 2389 paranoid_free(mountlist_file);2390 2371 return (retval); 2391 2372 } … … 2416 2397 struct raidlist_itself *raidlist; 2417 2398 int unfinished_mdstat_devices = 9999, i; 2418 char *screen_message; 2419 2420 malloc_string(screen_message); 2399 char *screen_message = NULL; 2400 2421 2401 raidlist = malloc(sizeof(struct raidlist_itself)); 2422 2402 … … 2438 2418 } 2439 2419 log_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i); 2440 sprintf(screen_message, "Sync'ing %s", 2441 raidlist->el[i].raid_device); 2420 mr_asprintf(&screen_message, "Sync'ing %s", raidlist->el[i].raid_device); 2442 2421 open_evalcall_form(screen_message); 2422 mr_free(screen_message); 2423 2443 2424 while (raidlist->el[i].progress < wait_for_percentage) { 2444 2425 log_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress); … … 2454 2435 } 2455 2436 } 2456 paranoid_free(screen_message);2457 2437 paranoid_free(raidlist); 2458 2438 }
Note:
See TracChangeset
for help on using the changeset viewer.