Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-tools.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-tools.c
r783 r900 21 21 #include <arpa/inet.h> 22 22 #endif 23 #include "mr_mem.h" 23 24 24 25 /*@unused@*/ … … 169 170 char *tmp; 170 171 171 asprintf(&tmp,172 mr_asprintf(&tmp, 172 173 "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \ 173 174 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \ … … 175 176 else { print $0;};}' $file.old > $file ; fi ; done"); 176 177 run_program_and_log_output(tmp, 5); 177 paranoid_free(tmp);178 mr_free(tmp); 178 179 } 179 180 … … 190 191 char *home_sz = NULL; 191 192 192 asprintf(&home_sz, MONDO_SHARE);193 mr_asprintf(&home_sz, MONDO_SHARE); 193 194 return (home_sz); 194 195 } … … 369 370 if (bkpinfo->backup_media_type == tape) { 370 371 log_msg(1, "Bar"); 371 asprintf(&tmp, "mt -f %s status", bkpinfo->media_device);372 mr_asprintf(&tmp, "mt -f %s status", bkpinfo->media_device); 372 373 log_msg(1, "tmp = '%s'", tmp); 373 374 if (run_program_and_log_output(tmp, 3)) { … … 375 376 ("Unable to open tape device. If you haven't specified it with -d, do so. If you already have, check your parameter. I think it's wrong."); 376 377 } 377 paranoid_free(tmp);378 mr_free(tmp); 378 379 } 379 380 make_hole_for_dir(bkpinfo->scratchdir); … … 385 386 run_program_and_log_output("cat /etc/*-release", 5); 386 387 run_program_and_log_output("cat /etc/*issue*", 5); 387 asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir);388 asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt);388 mr_asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir); 389 mr_asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt); 389 390 paranoid_system(command); 390 paranoid_free(command);391 mr_free(command); 391 392 rdsiz_MB = PPCFG_RAMDISK_SIZE + g_tape_buffer_size_MB; 392 393 #ifdef __FreeBSD__ … … 394 395 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6"); 395 396 avm += atol(tmp); 396 paranoid_free(tmp);397 mr_free(tmp); 397 398 tmp = call_program_and_get_last_line_of_output 398 399 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc"); 399 400 avm += atol(tmp); 400 paranoid_free(tmp);401 asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm',401 mr_free(tmp); 402 mr_asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm', 402 403 g_tmpfs_mountpt); 403 404 #else … … 405 406 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1"); 406 407 avm += atol(tmp); 407 paranoid_free(tmp);408 asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c",408 mr_free(tmp); 409 mr_asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 409 410 g_tmpfs_mountpt, rdsiz_MB, 'm'); 410 411 run_program_and_log_output("cat /proc/cpuinfo", 5); … … 416 417 if (avm / 1024 > rdsiz_MB * 3) { 417 418 if (run_program_and_log_output(command, 5)) { 418 paranoid_free(g_tmpfs_mountpt);419 mr_free(g_tmpfs_mountpt); 419 420 log_it("Failed to mount tmpfs"); 420 421 } else { … … 422 423 } 423 424 } else { 424 paranoid_free(g_tmpfs_mountpt);425 mr_free(g_tmpfs_mountpt); 425 426 log_it("It doesn't seem you have enough swap to use tmpfs. Fine."); 426 427 } 427 paranoid_free(command);428 mr_free(command); 428 429 429 430 if (bkpinfo->use_lzo) { 430 paranoid_alloc(bkpinfo->zip_exe, "lzop");431 paranoid_alloc(bkpinfo->zip_suffix, "lzo");431 mr_allocstr(bkpinfo->zip_exe, "lzop"); 432 mr_allocstr(bkpinfo->zip_suffix, "lzo"); 432 433 } else if (bkpinfo->compression_level != 0) { 433 paranoid_alloc(bkpinfo->zip_exe, "bzip2");434 paranoid_alloc(bkpinfo->zip_suffix, "bz2");434 mr_allocstr(bkpinfo->zip_exe, "bzip2"); 435 mr_allocstr(bkpinfo->zip_suffix, "bz2"); 435 436 } else { 436 437 bkpinfo->zip_exe = NULL; … … 445 446 fatal_error("Please install growisofs."); 446 447 } 447 paranoid_free(tmp);448 mr_free(tmp); 448 449 449 450 if (bkpinfo->nonbootable_backup) { 450 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);451 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); 451 452 } else if 452 453 #ifdef __FreeBSD__ … … 457 458 #ifdef __IA64__ 458 459 { 459 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);460 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO); 460 461 } 461 462 #else 462 463 { 463 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);464 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO); 464 465 } 465 466 #endif 466 467 else 467 468 { 468 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);469 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX); 469 470 } 470 471 if (bkpinfo->manual_cd_tray) { … … 472 473 // -m isn't supported by growisofs, BTW... 473 474 } else { 474 asprintf(&bkpinfo->call_make_iso,475 mr_asprintf(&bkpinfo->call_make_iso, 475 476 "%s %s -Z %s . 2>> _ERR_", 476 477 mondo_mkisofs_sz, "", bkpinfo->media_device); 477 478 } 478 paranoid_free(mondo_mkisofs_sz);479 mr_free(mondo_mkisofs_sz); 479 480 480 481 if (getenv ("SUDO_COMMAND")) { 481 asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND");482 mr_asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND"); 482 483 tmp = call_program_and_get_last_line_of_output(command); 483 484 if (!strcmp(tmp, "1")) { … … 485 486 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 486 487 } 487 paranoid_free(tmp);488 paranoid_free(command);488 mr_free(tmp); 489 mr_free(command); 489 490 } 490 491 log_msg(2, "call_make_iso (DVD res) is ... %s", … … 496 497 || bkpinfo->backup_media_type == cdr) { 497 498 if (!bkpinfo->manual_cd_tray) { 498 asprintf(&extra_cdrom_params, "-waiti ");499 mr_asprintf(&extra_cdrom_params, "-waiti "); 499 500 } 500 501 if (bkpinfo->backup_media_type == cdrw) { 501 502 if (extra_cdrom_params != NULL) { 502 asprintf(&tmp, extra_cdrom_params);503 paranoid_free(extra_cdrom_params);504 asprintf(&extra_cdrom_params, "%s blank=fast ", tmp);503 mr_asprintf(&tmp, extra_cdrom_params); 504 mr_free(extra_cdrom_params); 505 mr_asprintf(&extra_cdrom_params, "%s blank=fast ", tmp); 505 506 } else { 506 asprintf(&extra_cdrom_params, "blank=fast ");507 mr_asprintf(&extra_cdrom_params, "blank=fast "); 507 508 } 508 509 } … … 510 511 tmp1 = find_home_of_exe("dvdrecord"); 511 512 if (tmp) { 512 asprintf(&cdr_exe, "cdrecord");513 mr_asprintf(&cdr_exe, "cdrecord"); 513 514 } else if (tmp1) { 514 asprintf(&cdr_exe, "dvdrecord");515 mr_asprintf(&cdr_exe, "dvdrecord"); 515 516 } else { 516 517 fatal_error("Please install either cdrecord or dvdrecord."); 517 518 } 518 paranoid_free(tmp);519 paranoid_free(tmp1);519 mr_free(tmp); 520 mr_free(tmp1); 520 521 521 522 if (bkpinfo->nonbootable_backup) { 522 asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd);523 mr_asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd); 523 524 } else if 524 525 #ifdef __FreeBSD__ … … 529 530 #ifdef __IA64__ 530 531 { 531 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);532 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO); 532 533 } 533 534 #else 534 535 { 535 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);536 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO); 536 537 } 537 538 #endif 538 539 else 539 540 { 540 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);541 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX); 541 542 } 542 543 if (bkpinfo->manual_cd_tray) { 543 544 if (bkpinfo->call_before_iso == NULL) { 544 asprintf(&bkpinfo->call_before_iso,545 mr_asprintf(&bkpinfo->call_before_iso, 545 546 "%s -o %s/temporary.iso . 2>> _ERR_", 546 547 mondo_mkisofs_sz, bkpinfo->tmpdir); 547 548 } else { 548 asprintf(&call_before_iso_user, bkpinfo->call_before_iso);549 asprintf(&bkpinfo->call_before_iso,549 mr_asprintf(&call_before_iso_user, bkpinfo->call_before_iso); 550 mr_asprintf(&bkpinfo->call_before_iso, 550 551 "( %s -o %s/temporary.iso . 2>> _ERR_ ; %s )", 551 552 mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user); 552 paranoid_free(call_before_iso_user);553 mr_free(call_before_iso_user); 553 554 } 554 555 log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso); 555 asprintf(&bkpinfo->call_make_iso,556 mr_asprintf(&bkpinfo->call_make_iso, 556 557 "%s %s -v %s fs=4m dev=%s speed=%d %s/temporary.iso", 557 558 cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", … … 559 560 bkpinfo->cdrw_speed, bkpinfo->tmpdir); 560 561 } else { 561 asprintf(&bkpinfo->call_make_iso,562 mr_asprintf(&bkpinfo->call_make_iso, 562 563 "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", 563 564 mondo_mkisofs_sz, cdr_exe, … … 566 567 bkpinfo->cdrw_speed); 567 568 } 568 paranoid_free(mondo_mkisofs_sz);569 paranoid_free(cdr_exe);570 paranoid_free(extra_cdrom_params);569 mr_free(mondo_mkisofs_sz); 570 mr_free(cdr_exe); 571 mr_free(extra_cdrom_params); 571 572 } // end of CD code 572 573 … … 581 582 582 583 log_it("isodir = %s", bkpinfo->isodir); 583 asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1",584 mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1", 584 585 bkpinfo->isodir); 585 586 log_it("command = %s", command); 586 587 tmp = call_program_and_get_last_line_of_output(command); 587 paranoid_free(command);588 mr_free(command); 588 589 log_it("res of it = %s", tmp); 589 asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir);590 mr_asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir); 590 591 write_one_liner_data_file(tmp1, tmp); 591 paranoid_free(tmp1);592 593 asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3",592 mr_free(tmp1); 593 594 mr_asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 594 595 tmp); 595 paranoid_free(tmp);596 mr_free(tmp); 596 597 log_it("command = %s", command); 597 598 tmp = call_program_and_get_last_line_of_output(command); 598 paranoid_free(command);599 mr_free(command); 599 600 log_it("res of it = %s", tmp); 600 601 601 asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir);602 mr_asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir); 602 603 write_one_liner_data_file(tmp1, tmp); 603 paranoid_free(tmp1);604 mr_free(tmp1); 604 605 605 606 log_it("isomnt: %s, %d", tmp, strlen(tmp)); 606 607 if (strlen(bkpinfo->isodir) < strlen(tmp)) { 607 asprintf(&iso_path, " ");608 mr_asprintf(&iso_path, " "); 608 609 } else { 609 asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp));610 } 611 paranoid_free(tmp);612 613 asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir);610 mr_asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp)); 611 } 612 mr_free(tmp); 613 614 mr_asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir); 614 615 write_one_liner_data_file(tmp, iso_path); 615 paranoid_free(tmp);616 mr_free(tmp); 616 617 log_it("isodir: %s", iso_path); 617 paranoid_free(iso_path);618 asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);618 mr_free(iso_path); 619 mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 619 620 write_one_liner_data_file(tmp, bkpinfo->prefix); 620 621 log_it("iso-prefix: %s", bkpinfo->prefix); 621 paranoid_free(tmp);622 mr_free(tmp); 622 623 /* End patch */ 623 624 } // end of iso code 624 625 625 626 if (bkpinfo->backup_media_type == nfs) { 626 asprintf(&hostname, bkpinfo->nfs_mount);627 mr_asprintf(&hostname, bkpinfo->nfs_mount); 627 628 colon = strchr(hostname, ':'); 628 629 if (!colon) { … … 639 640 retval++; 640 641 } else { 641 asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr)642 mr_asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr) 642 643 *((struct in_addr 643 644 *) hent-> 644 645 h_addr)), 645 646 strchr(bkpinfo->nfs_mount, ':')); 646 paranoid_alloc(bkpinfo->nfs_mount, ip_address);647 paranoid_free(ip_address);647 mr_allocstr(bkpinfo->nfs_mount, ip_address); 648 mr_free(ip_address); 648 649 } 649 650 } 650 651 store_nfs_config(bkpinfo); 651 paranoid_free(hostname);652 mr_free(hostname); 652 653 } 653 654 … … 656 657 fprintf(stderr, "Type 'man mondoarchive' for help.\n"); 657 658 } 658 asprintf(&tmp, "%s", MONDO_TMPISOS);659 mr_asprintf(&tmp, "%s", MONDO_TMPISOS); 659 660 if (does_file_exist(tmp)) { 660 661 unlink(tmp); 661 662 } 662 paranoid_free(tmp);663 mr_free(tmp); 663 664 664 665 if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) { … … 668 669 if (bkpinfo->include_paths == NULL) { 669 670 // fatal_error ("Why no backup path?"); 670 asprintf(&bkpinfo->include_paths, "/");671 mr_asprintf(&bkpinfo->include_paths, "/"); 671 672 } 672 673 chmod(bkpinfo->scratchdir, 0700); 673 674 chmod(bkpinfo->tmpdir, 0700); 674 675 g_backup_media_type = bkpinfo->backup_media_type; 675 paranoid_alloc(g_backup_media_string,bkpinfo->backup_media_string);676 mr_allocstr(g_backup_media_string,bkpinfo->backup_media_string); 676 677 return (retval); 677 678 } … … 716 717 g_current_media_number = 1; 717 718 bkpinfo->postnuke_tarball = NULL; 718 paranoid_free(bkpinfo->nfs_mount);719 mr_free(bkpinfo->nfs_mount); 719 720 return (res); 720 721 } … … 746 747 } 747 748 748 paranoid_free(bkpinfo->media_device);749 paranoid_free(bkpinfo->boot_device);750 paranoid_free(bkpinfo->zip_exe);751 paranoid_free(bkpinfo->zip_suffix);752 paranoid_free(bkpinfo->restore_path);749 mr_free(bkpinfo->media_device); 750 mr_free(bkpinfo->boot_device); 751 mr_free(bkpinfo->zip_exe); 752 mr_free(bkpinfo->zip_suffix); 753 mr_free(bkpinfo->restore_path); 753 754 bkpinfo->use_lzo = FALSE; 754 755 bkpinfo->verify_data = FALSE; … … 758 759 (am_I_in_disaster_recovery_mode()? TRUE : FALSE); 759 760 if (bkpinfo->disaster_recovery) { 760 paranoid_alloc(bkpinfo->isodir, "/");761 mr_allocstr(bkpinfo->isodir, "/"); 761 762 } else { 762 paranoid_alloc(bkpinfo->isodir, "/var/cache/mondo/iso");763 } 764 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);765 766 paranoid_free(bkpinfo->scratchdir);763 mr_allocstr(bkpinfo->isodir, "/var/cache/mondo/iso"); 764 } 765 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 766 767 mr_free(bkpinfo->scratchdir); 767 768 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 768 paranoid_free(bkpinfo->tmpdir);769 asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore769 mr_free(bkpinfo->tmpdir); 770 mr_asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore 770 771 bkpinfo->optimal_set_size = 0; 771 772 bkpinfo->backup_media_type = none; 772 paranoid_free(bkpinfo->backup_media_string);773 paranoid_alloc(bkpinfo->include_paths, "/");774 paranoid_free(bkpinfo->exclude_paths);775 paranoid_free(bkpinfo->call_before_iso);776 paranoid_free(bkpinfo->call_make_iso);777 paranoid_free(bkpinfo->call_burn_iso);778 paranoid_free(bkpinfo->call_after_iso);779 paranoid_free(bkpinfo->image_devs);780 paranoid_free(bkpinfo->postnuke_tarball);781 paranoid_free(bkpinfo->kernel_path);782 paranoid_free(bkpinfo->nfs_mount);783 paranoid_free(bkpinfo->nfs_remote_dir);773 mr_free(bkpinfo->backup_media_string); 774 mr_allocstr(bkpinfo->include_paths, "/"); 775 mr_free(bkpinfo->exclude_paths); 776 mr_free(bkpinfo->call_before_iso); 777 mr_free(bkpinfo->call_make_iso); 778 mr_free(bkpinfo->call_burn_iso); 779 mr_free(bkpinfo->call_after_iso); 780 mr_free(bkpinfo->image_devs); 781 mr_free(bkpinfo->postnuke_tarball); 782 mr_free(bkpinfo->kernel_path); 783 mr_free(bkpinfo->nfs_mount); 784 mr_free(bkpinfo->nfs_remote_dir); 784 785 bkpinfo->wipe_media_first = FALSE; 785 786 bkpinfo->differential = FALSE; … … 805 806 assert_string_is_neither_NULL_nor_zerolength(partition); 806 807 807 asprintf(&command, "df -m -P %s &> /dev/null", partition);808 mr_asprintf(&command, "df -m -P %s &> /dev/null", partition); 808 809 if (system(command)) { 809 810 return (-1); 810 811 } // partition does not exist 811 paranoid_free(command);812 813 asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",812 mr_free(command); 813 814 mr_asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 814 815 partition); 815 816 out_sz = call_program_and_get_last_line_of_output(command); 816 paranoid_free(command);817 mr_free(command); 817 818 if (strlen(out_sz) == 0) { 818 819 return (-1); 819 820 } // error within df, probably 820 821 res = atol(out_sz); 821 paranoid_free(out_sz);822 mr_free(out_sz); 822 823 return (res); 823 824 } … … 868 869 (_("WARNING! You have very little RAM. Please upgrade to 64MB or more.")); 869 870 } 870 paranoid_free(tmp);871 mr_free(tmp); 871 872 #endif 872 873 … … 929 930 log_to_screen(_("Please install ms-sys just in case.")); 930 931 } 931 paranoid_free(tmp);932 mr_free(tmp); 932 933 #endif 933 934 } … … 937 938 whine_if_not_found("cmp"); 938 939 } 939 paranoid_free(tmp);940 mr_free(tmp); 940 941 941 942 run_program_and_log_output … … 958 959 } 959 960 } 960 paranoid_free(tmp);961 mr_free(tmp); 961 962 #ifndef __FreeBSD__ 962 963 if (!does_file_exist("/etc/modules.conf")) { … … 1041 1042 1042 1043 if (!does_file_exist(config_file)) { 1043 asprintf(&tmp, "(read_cfg_var) Cannot find %s config file",1044 mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", 1044 1045 config_file); 1045 1046 log_to_screen(tmp); 1046 paranoid_free(tmp);1047 mr_free(tmp); 1047 1048 value = NULL; 1048 1049 return (1); … … 1054 1055 return (0); 1055 1056 */ } else { 1056 asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",1057 mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", 1057 1058 label, config_file); 1058 1059 value = call_program_and_get_last_line_of_output(command); 1059 paranoid_free(command);1060 mr_free(command); 1060 1061 if (strlen(value) == 0) { 1061 1062 return (1); … … 1108 1109 log_msg(1, "Started sub"); 1109 1110 log_msg(4, "Setting command to something"); 1110 asprintf(&command,1111 mr_asprintf(&command, 1111 1112 "grep -v \":\" /etc/fstab | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1112 1113 log_msg(4, "Cool. Command = '%s'", command); 1113 1114 tmp = call_program_and_get_last_line_of_output(command); 1114 paranoid_free(command);1115 mr_free(command); 1115 1116 1116 1117 log_msg(4, "tmp = '%s'", tmp); … … 1119 1120 if (strstr(tmp, "LABEL=")) { 1120 1121 if (!run_program_and_log_output("mount /boot", 5)) { 1121 paranoid_free(g_boot_mountpt);1122 asprintf(&g_boot_mountpt, "/boot");1122 mr_free(g_boot_mountpt); 1123 mr_asprintf(&g_boot_mountpt, "/boot"); 1123 1124 log_msg(1, "Mounted /boot"); 1124 1125 } else { … … 1126 1127 } 1127 1128 } else { 1128 asprintf(&command, "mount | grep -w \"%s\"", tmp);1129 mr_asprintf(&command, "mount | grep -w \"%s\"", tmp); 1129 1130 log_msg(3, "command = %s", command); 1130 1131 if (run_program_and_log_output(command, 5)) { 1131 paranoid_free(g_boot_mountpt);1132 asprintf(&g_boot_mountpt, tmp);1133 asprintf(&tmp1,1132 mr_free(g_boot_mountpt); 1133 mr_asprintf(&g_boot_mountpt, tmp); 1134 mr_asprintf(&tmp1, 1134 1135 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1135 1136 g_boot_mountpt); 1136 1137 log_it(tmp1); 1137 paranoid_free(tmp1);1138 1139 asprintf(&tmp1, "mount %s", g_boot_mountpt);1138 mr_free(tmp1); 1139 1140 mr_asprintf(&tmp1, "mount %s", g_boot_mountpt); 1140 1141 if (run_program_and_log_output(tmp1, 5)) { 1141 1142 /* BERLIOS: Useless ??? 1142 paranoid_free(g_boot_mountpt);1143 asprintf(&g_boot_mountpt, " ");1143 mr_free(g_boot_mountpt); 1144 mr_asprintf(&g_boot_mountpt, " "); 1144 1145 */ 1145 1146 log_msg(1, "Plan B"); 1146 1147 if (!run_program_and_log_output("mount /boot", 5)) { 1147 paranoid_free(g_boot_mountpt);1148 asprintf(&g_boot_mountpt, "/boot");1148 mr_free(g_boot_mountpt); 1149 mr_asprintf(&g_boot_mountpt, "/boot"); 1149 1150 log_msg(1, "Plan B worked"); 1150 1151 } else { … … 1153 1154 } 1154 1155 } 1155 paranoid_free(tmp1);1156 mr_free(tmp1); 1156 1157 } 1157 paranoid_free(command);1158 } 1159 } 1160 paranoid_free(tmp);1158 mr_free(command); 1159 } 1160 } 1161 mr_free(tmp); 1161 1162 log_msg(1, "Ended sub"); 1162 1163 } … … 1172 1173 log_msg(3, "starting"); 1173 1174 if (g_boot_mountpt != NULL) { 1174 asprintf(&tmp, "umount %s", g_boot_mountpt);1175 mr_asprintf(&tmp, "umount %s", g_boot_mountpt); 1175 1176 if (run_program_and_log_output(tmp, 5)) { 1176 1177 log_it("WARNING - unable to unmount /boot"); 1177 1178 } 1178 paranoid_free(tmp);1179 mr_free(tmp); 1179 1180 } 1180 1181 log_msg(3, "leaving"); … … 1205 1206 1206 1207 if (!does_file_exist(config_file)) { 1207 asprintf(&tmp, "(write_cfg_file) Cannot find %s config file",1208 mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", 1208 1209 config_file); 1209 1210 log_to_screen(tmp); 1210 paranoid_free(tmp);1211 mr_free(tmp); 1211 1212 return (1); 1212 1213 } … … 1214 1215 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX"); 1215 1216 if (does_file_exist(config_file)) { 1216 asprintf(&command, "grep -vx '%s .*' %s > %s",1217 mr_asprintf(&command, "grep -vx '%s .*' %s > %s", 1217 1218 label, config_file, tempfile); 1218 1219 paranoid_system(command); 1219 paranoid_free(command);1220 } 1221 asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile);1220 mr_free(command); 1221 } 1222 mr_asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile); 1222 1223 paranoid_system(command); 1223 paranoid_free(command);1224 1225 asprintf(&command, "mv -f %s %s", tempfile, config_file);1224 mr_free(command); 1225 1226 mr_asprintf(&command, "mv -f %s %s", tempfile, config_file); 1226 1227 paranoid_system(command); 1227 paranoid_free(command);1228 mr_free(command); 1228 1229 unlink(tempfile); 1229 paranoid_free(tempfile);1230 mr_free(tempfile); 1230 1231 return (0); 1231 1232 } … … 1243 1244 } else { 1244 1245 iamhere("Freeing globals"); 1245 paranoid_free(g_boot_mountpt);1246 paranoid_free(g_mondo_home);1247 paranoid_free(g_tmpfs_mountpt);1248 paranoid_free(g_erase_tmpdir_and_scratchdir);1249 paranoid_free(g_serial_string);1250 paranoid_free(g_magicdev_command);1246 mr_free(g_boot_mountpt); 1247 mr_free(g_mondo_home); 1248 mr_free(g_tmpfs_mountpt); 1249 mr_free(g_erase_tmpdir_and_scratchdir); 1250 mr_free(g_serial_string); 1251 mr_free(g_magicdev_command); 1251 1252 } 1252 1253 } … … 1295 1296 1296 1297 if (!g_magicdev_command) { 1297 asprintf(&tmp, "%s &", g_magicdev_command);1298 mr_asprintf(&tmp, "%s &", g_magicdev_command); 1298 1299 paranoid_system(tmp); 1299 paranoid_free(tmp);1300 mr_free(tmp); 1300 1301 } 1301 1302 }
Note:
See TracChangeset
for help on using the changeset viewer.