Changeset 94 in MondoRescue
- Timestamp:
- Oct 29, 2005, 1:08:39 AM (20 years ago)
- Location:
- trunk/mondo
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/configure.in
r87 r94 87 87 case "$host_cpu" in 88 88 i?86*) 89 #x86_64*)90 89 ARCH=i386 91 90 CPPFLAGS="$CPPFLAGS -D__IA32__ -Wall" 91 ;; 92 x86_64*) 93 ARCH=x86-64 94 CPPFLAGS="$CPPFLAGS -D__X86_64__ -Wall" 92 95 ;; 93 96 ia64*) … … 96 99 ;; 97 100 *) 98 echo "*** Sorry, only Intel Architectures (ia32, ia64) are supported at this time. Want to help?" 101 echo "*** Sorry, only Intel Architectures (ia32, x86-64, ia64) are supported at this time." 102 echo "If you Want to help send a mail to bcornec@users.berlios.de" 99 103 ;; 100 104 esac -
trunk/mondo/mondo/common/libmondo-files.c
r87 r94 1112 1112 "Copying Mondo's core files to the scratch directory"); 1113 1113 1114 /* BERLIOS: Why do we need to do it here as well ? */ 1114 1115 log_msg(4, "g_mondo_home='%s'", g_mondo_home); 1115 if (strlen(g_mondo_home) < 2) { 1116 find_and_store_mondoarchives_home(g_mondo_home); 1116 if ((g_mondo_home == NULL) || strlen(g_mondo_home) < 2) { 1117 paranoid_free(g_mondo_home); 1118 g_mondo_home = find_and_store_mondoarchives_home(); 1117 1119 } 1118 1120 sprintf(command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, -
trunk/mondo/mondo/common/libmondo-tools-EXT.h
r59 r94 17 17 extern void initialize_raidrec(struct raid_device_record *raidrec); 18 18 #endif 19 extern void log_trace(char *o);20 19 extern int some_basic_system_sanity_checks(); 21 20 … … 25 24 26 25 extern void insmod_crucial_modules(void); 27 extern int find_and_store_mondoarchives_home(char *home_sz);26 extern char *find_and_store_mondoarchives_home(void); 28 27 29 28 extern void unmount_supermounts_if_necessary(void); -
trunk/mondo/mondo/common/libmondo-tools.c
r89 r94 41 41 42 42 /** 43 * The place where /boot is mounted. 44 */ 45 char *g_boot_mountpt = NULL;43 * The place where /boot is mounted. - Used locally only 44 */ 45 static char *g_boot_mountpt = NULL; 46 46 47 47 /** … … 167 167 char *tmp; 168 168 169 malloc_string(tmp); 170 strcpy(tmp, 169 asprintf(&tmp, 171 170 "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \ 172 171 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \ … … 185 184 * @return 0 for success, nonzero for failure. 186 185 */ 187 int find_and_store_mondoarchives_home(char *home_sz) 188 { 189 assert(home_sz != NULL); 190 strcpy(home_sz, 186 char *find_and_store_mondoarchives_home() 187 { 188 char *home_sz = NULL; 189 190 asprintf(&home_sz, 191 191 call_program_and_get_last_line_of_output 192 192 ("find /usr/lib/ /usr/local/ /usr/share/ /usr/local/share/ /opt/ /ramdisk/usr/share/ -type d -maxdepth 2 -name include -prune -o -type d -maxdepth 2 -path '*/mondo/restore-scripts' -printf '%h\n' 2> /dev/null")); 193 193 194 194 if (home_sz[0] == '\0') { 195 strcpy(home_sz, 195 paranoid_free(home_sz); 196 asprintf(&home_sz, 196 197 call_program_and_get_last_line_of_output 197 198 ("find /usr -type d -path '*/mondo/restore-scripts' -follow -maxdepth 3 -printf '%h\n' 2> /dev/null")); 198 199 } 199 200 if (home_sz[0] == '\0') { 200 return (1); 201 paranoid_free(home_sz); 202 home_sz = NULL; 201 203 } else { 202 return (0); 203 } 204 log_it("mondoarchive home found at %s", home_sz); 205 } 206 return (home_sz); 204 207 } 205 208 … … 210 213 return ("i386"); 211 214 #endif 215 #ifdef __X86_64__ 216 return ("x86-64"); 217 #endif 212 218 #ifdef __IA64__ 213 219 return ("ia64"); … … 220 226 double get_kernel_version() 221 227 { 222 char *p, tmp[200];228 char *p, *tmp; 223 229 double d; 224 230 #ifdef __FreeBSD__ … … 226 232 d = 5.2; // :-) 227 233 #else 228 strcpy(tmp, call_program_and_get_last_line_of_output("uname -r"));234 asprintf(&tmp, call_program_and_get_last_line_of_output("uname -r")); 229 235 p = strchr(tmp, '.'); 230 236 if (p) { … … 254 260 long get_time() 255 261 { 256 257 #if 0258 259 /*@ pointers **************************************************** */260 FILE *fin;261 262 /*@ buffers ***************************************************** */263 char incoming[MAX_STR_LEN];264 265 /*@ end vars **************************************************** */266 267 if (!(fin = popen("date +%s", "r"))) {268 log_OS_error("Cannot popen date");269 return (0);270 }271 fgets(incoming, MAX_STR_LEN - 1, fin);272 paranoid_pclose(fin);273 return (atol(incoming));274 #else275 262 return (long) time((void *) 0); 276 #endif277 263 } 278 264 … … 335 321 system("kldstat | grep ext2fs || kldload ext2fs 2> /dev/null"); 336 322 #else 337 system("modprobe dos &> /dev/null"); 338 system("modprobe fat &> /dev/null"); 339 system("modprobe vfat &> /dev/null"); 340 // system("modprobe osst &> /dev/null"); 341 #endif 342 } 343 344 345 /** 346 * Log a trace message to the trace file. 347 * @bug This function seems orphaned. Please remove. 348 */ 349 void log_trace(char *o) 350 { 351 /*@ pointers **************************************************** */ 352 FILE *fout; 353 354 /*@ buffers ***************************************************** */ 355 char output[MAX_STR_LEN]; 356 357 /*@ int ****************************************************** */ 358 int i; 359 360 /*@ end vars *************************************************** */ 361 362 if (o[0] == '\0') { 363 return; 364 } 365 strcpy(output, o); 366 i = (int) strlen(output); 367 if (i <= 0) { 368 return; 369 } 370 if (output[i - 1] < 32) { 371 output[i - 1] = '\0'; 372 } 373 if (g_text_mode 374 /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) { 375 printf("%s\n", output); 376 } 377 378 fout = fopen(MONDO_TRACEFILE, "a"); 379 if (fout) { 380 fprintf(fout, "%s\n", output); 381 paranoid_fclose(fout); 382 } else { 383 log_OS_error("Cannot write to tracefile"); 384 } 385 } 386 387 388 323 system("modprobe -a dos fat vfat loop &> /dev/null"); 324 #endif 325 } 389 326 390 327 … … 422 359 int post_param_configuration(struct s_bkpinfo *bkpinfo) 423 360 { 424 char *extra_cdrom_params ;425 char *mondo_mkisofs_sz ;361 char *extra_cdrom_params = NULL; 362 char *mondo_mkisofs_sz = NULL; 426 363 char *command; 427 char *mtpt;428 364 char *hostname, *ip_address; 429 365 int retval = 0; … … 432 368 char *cdr_exe; 433 369 char *tmp; 370 char *tmp1; 434 371 int rdsiz_MB; 435 char *iso_dev;436 char *iso_mnt;437 char *iso_tmp;438 372 char *iso_path; 439 373 440 374 assert(bkpinfo != NULL); 441 malloc_string(extra_cdrom_params);442 malloc_string(mondo_mkisofs_sz);443 malloc_string(command);444 malloc_string(mtpt);445 malloc_string(hostname);446 malloc_string(ip_address);447 malloc_string(cdr_exe);448 malloc_string(tmp);449 malloc_string(iso_dev);450 malloc_string(iso_mnt);451 malloc_string(iso_tmp);452 malloc_string(iso_path);453 375 bkpinfo->optimal_set_size = 454 376 (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 4 : 8) * … … 458 380 if (bkpinfo->backup_media_type == tape) { 459 381 log_msg(1, "Bar"); 460 sprintf(tmp, "mt -f %s status", bkpinfo->media_device);382 asprintf(&tmp, "mt -f %s status", bkpinfo->media_device); 461 383 log_msg(1, "tmp = '%s'", tmp); 462 384 if (run_program_and_log_output(tmp, 3)) { … … 464 386 ("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."); 465 387 } 388 paranoid_free(tmp); 466 389 } 467 390 make_hole_for_dir(bkpinfo->scratchdir); … … 472 395 run_program_and_log_output("uname -a", 5); 473 396 run_program_and_log_output("cat /etc/*issue*", 5); 474 sprintf(g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir);475 sprintf(command, "mkdir -p %s", g_tmpfs_mountpt);397 asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir); 398 asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt); 476 399 paranoid_system(command); 400 paranoid_free(command); 477 401 rdsiz_MB = PPCFG_RAMDISK_SIZE + g_tape_buffer_size_MB; 478 402 #ifdef __FreeBSD__ 479 strcpy(tmp,403 asprintf(&tmp, 480 404 call_program_and_get_last_line_of_output 481 405 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6")); 482 406 avm += atol(tmp); 483 strcpy(tmp, 407 paranoid_free(tmp); 408 asprintf(&tmp, 484 409 call_program_and_get_last_line_of_output 485 410 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc")); 486 411 avm += atol(tmp); 487 sprintf(command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm', 412 paranoid_free(tmp); 413 asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm', 488 414 g_tmpfs_mountpt); 489 415 #else 490 strcpy(tmp,416 asprintf(&tmp, 491 417 call_program_and_get_last_line_of_output 492 418 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1")); 493 419 avm += atol(tmp); 494 sprintf(command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 420 paranoid_free(tmp); 421 asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 495 422 g_tmpfs_mountpt, rdsiz_MB, 'm'); 496 423 run_program_and_log_output("cat /proc/cpuinfo", 5); 424 /* BERLIOS: rpm is not necessarily there ! */ 497 425 run_program_and_log_output 498 426 ("rpm -q newt newt-devel slang slang-devel ncurses ncurses-devel gcc", … … 510 438 log_it("It doesn't seem you have enough swap to use tmpfs. Fine."); 511 439 } 440 paranoid_free(command); 512 441 513 442 if (bkpinfo->use_lzo) { … … 524 453 525 454 if (bkpinfo->backup_media_type == dvd) { 526 extra_cdrom_params[0] = '\0'; 527 mondo_mkisofs_sz[0] = '\0'; 528 if (find_home_of_exe("growisofs")) { 529 strcpy(cdr_exe, "growisofs"); 530 } // unlikely to be used 531 else { 455 if (! (find_home_of_exe("growisofs"))) { 532 456 fatal_error("Please install growisofs."); 533 457 } 534 458 if (bkpinfo->nonbootable_backup) { 535 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);459 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); 536 460 } else if 537 461 #ifdef __FreeBSD__ … … 542 466 #ifdef __IA64__ 543 467 { 544 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);468 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO); 545 469 } 546 470 #else 547 471 { 548 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);472 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO); 549 473 } 550 474 #endif 551 475 else 552 476 { 553 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);477 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX); 554 478 } 555 479 if (bkpinfo->manual_cd_tray) { … … 560 484 "%s %s -Z %s . 2>> _ERR_", 561 485 mondo_mkisofs_sz, 562 extra_cdrom_params, bkpinfo->media_device); 563 } 486 "", bkpinfo->media_device); 487 } 488 paranoid_free(mondo_mkisofs_sz); 489 564 490 if (getenv("SUDO_COMMAND")) { 565 491 fatal_error … … 573 499 if (bkpinfo->backup_media_type == cdrw 574 500 || bkpinfo->backup_media_type == cdr) { 575 extra_cdrom_params[0] = '\0';576 501 if (!bkpinfo->manual_cd_tray) { 577 strcat(extra_cdrom_params, "-waiti ");502 asprintf(&extra_cdrom_params, "-waiti "); 578 503 } 579 504 if (bkpinfo->backup_media_type == cdrw) { 580 strcat(extra_cdrom_params, "blank=fast "); 505 if (extra_cdrom_params != NULL) { 506 asprintf(&tmp, extra_cdrom_params); 507 paranoid_free(extra_cdrom_params); 508 asprintf(&extra_cdrom_params, "%s blank=fast ", tmp); 509 } else { 510 asprintf(&extra_cdrom_params, "blank=fast "); 511 } 581 512 } 582 513 if (find_home_of_exe("cdrecord")) { 583 strcpy(cdr_exe, "cdrecord");514 asprintf(&cdr_exe, "cdrecord"); 584 515 } else if (find_home_of_exe("dvdrecord")) { 585 strcpy(cdr_exe, "dvdrecord");516 asprintf(&cdr_exe, "dvdrecord"); 586 517 } else { 587 518 fatal_error("Please install either cdrecord or dvdrecord."); 588 519 } 589 520 if (bkpinfo->nonbootable_backup) { 590 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT);521 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT); 591 522 } else if 592 523 #ifdef __FreeBSD__ … … 597 528 #ifdef __IA64__ 598 529 { 599 strcat(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);530 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO); 600 531 } 601 532 #else 602 533 { 603 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);534 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO); 604 535 } 605 536 #endif 606 537 else 607 538 { 608 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);539 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX); 609 540 } 610 541 if (bkpinfo->manual_cd_tray) { … … 625 556 bkpinfo->cdrw_speed); 626 557 } 558 paranoid_free(mondo_mkisofs_sz); 559 paranoid_free(cdr_exe); 560 paranoid_free(extra_cdrom_params); 627 561 } // end of CD code 628 629 /*630 if (bkpinfo->backup_data && bkpinfo->backup_media_type == tape)631 {632 sprintf (tmp,633 "dd if=/dev/zero of=%s bs=%ld count=32 2> /dev/null",634 bkpinfo->media_device, bkpinfo->internal_tape_block_size);635 if (system(tmp))636 {637 retval++;638 fprintf (stderr,639 "Cannot write to tape device. Is the tape set read-only?\n");640 }641 } // end of tape code642 */643 644 562 645 563 if (bkpinfo->backup_media_type == iso) { … … 653 571 654 572 log_it("isodir = %s", bkpinfo->isodir); 655 sprintf(command, "df %s | tail -n1 | cut -d' ' -f1",573 asprintf(&command, "df %s | tail -n1 | cut -d' ' -f1", 656 574 bkpinfo->isodir); 657 575 log_it("command = %s", command); 658 log_it("res of it = %s", 659 call_program_and_get_last_line_of_output(command)); 660 sprintf(iso_dev, "%s", 661 call_program_and_get_last_line_of_output(command)); 662 sprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir); 663 write_one_liner_data_file(tmp, 664 call_program_and_get_last_line_of_output 665 (command)); 666 667 sprintf(command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 668 iso_dev); 576 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 577 paranoid_free(command); 578 log_it("res of it = %s", tmp); 579 asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir); 580 write_one_liner_data_file(tmp1, tmp); 581 paranoid_free(tmp1); 582 583 asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 584 tmp); 585 paranoid_free(tmp); 669 586 log_it("command = %s", command); 670 log_it("res of it = %s", 671 call_program_and_get_last_line_of_output(command)); 672 sprintf(iso_mnt, "%s", 673 call_program_and_get_last_line_of_output(command)); 674 sprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir); 675 write_one_liner_data_file(tmp, 676 call_program_and_get_last_line_of_output 677 (command)); 678 log_it("isomnt: %s, %d", iso_mnt, strlen(iso_mnt)); 679 sprintf(iso_tmp, "%s", bkpinfo->isodir); 680 if (strlen(iso_tmp) < strlen(iso_mnt)) { 681 iso_path[0] = '\0'; 587 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 588 paranoid_free(command); 589 log_it("res of it = %s", tmp); 590 591 asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir); 592 write_one_liner_data_file(tmp1, tmp); 593 paranoid_free(tmp1); 594 595 log_it("isomnt: %s, %d", tmp, strlen(tmp)); 596 if (strlen(bkpinfo->isodir) < strlen(tmp)) { 597 asprintf(&iso_path,""); 682 598 } else { 683 sprintf(iso_path, "%s", iso_tmp + strlen(iso_mnt)); 684 } 685 sprintf(tmp, "%s/ISODIR", bkpinfo->tmpdir); 599 asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp)); 600 } 601 paranoid_free(tmp); 602 603 asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir); 686 604 write_one_liner_data_file(tmp, iso_path); 605 paranoid_free(tmp); 687 606 log_it("isodir: %s", iso_path); 607 paranoid_free(iso_path); 688 608 689 609 /* End patch */ … … 691 611 692 612 if (bkpinfo->backup_media_type == nfs) { 693 strcpy(hostname, bkpinfo->nfs_mount);613 asprintf(&hostname, bkpinfo->nfs_mount); 694 614 colon = strchr(hostname, ':'); 695 615 if (!colon) { … … 706 626 retval++; 707 627 } else { 708 strcpy(ip_address, inet_ntoa((struct in_addr)628 asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr) 709 629 *((struct in_addr *) hent-> 710 h_addr))); 711 strcat(ip_address, strchr(bkpinfo->nfs_mount, ':')); 630 h_addr)), strchr(bkpinfo->nfs_mount, ':')); 712 631 strcpy(bkpinfo->nfs_mount, ip_address); 632 paranoid_free(ip_address); 713 633 } 714 634 } 715 635 store_nfs_config(bkpinfo); 636 paranoid_free(hostname); 716 637 } 717 638 … … 720 641 fprintf(stderr, "Type 'man mondoarchive' for help.\n"); 721 642 } 722 sprintf(tmp, "%s", MONDO_TMPISOS);643 asprintf(&tmp, "%s", MONDO_TMPISOS); 723 644 if (does_file_exist(tmp)) { 724 645 unlink(tmp); 725 646 } 647 paranoid_free(tmp); 648 726 649 if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) { 727 650 log_it("tmpdir or scratchdir are blank/missing"); … … 735 658 chmod(bkpinfo->tmpdir, 0700); 736 659 g_backup_media_type = bkpinfo->backup_media_type; 737 paranoid_free(mtpt);738 paranoid_free(extra_cdrom_params);739 paranoid_free(mondo_mkisofs_sz);740 paranoid_free(command);741 paranoid_free(hostname);742 paranoid_free(ip_address);743 paranoid_free(cdr_exe);744 paranoid_free(tmp);745 paranoid_free(iso_dev);746 paranoid_free(iso_mnt);747 paranoid_free(iso_tmp);748 paranoid_free(iso_path);749 660 return (retval); 750 661 } … … 777 688 unlink(MONDO_TRACEFILE); 778 689 run_program_and_log_output("rm -Rf /tmp/changed.files*", FALSE); 779 if ( find_and_store_mondoarchives_home(g_mondo_home)) {690 if ((g_mondo_home = find_and_store_mondoarchives_home()) == NULL) { 780 691 fprintf(stderr, 781 692 "Cannot find Mondo's homedir. I think you have >1 'mondo' directory on your hard disk. Please delete the superfluous 'mondo' directories and try again\n"); … … 866 777 long free_space_on_given_partition(char *partition) 867 778 { 868 char command[MAX_STR_LEN], out_sz[MAX_STR_LEN];779 char *command, *out_sz; 869 780 long res; 870 781 871 782 assert_string_is_neither_NULL_nor_zerolength(partition); 872 783 873 sprintf(command, "df -m %s &> /dev/null", partition);784 asprintf(&command, "df -m %s &> /dev/null", partition); 874 785 if (system(command)) { 875 786 return (-1); 876 787 } // partition does not exist 877 sprintf(command, "df -m %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 788 paranoid_free(command); 789 790 asprintf(&command, "df -m %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 878 791 partition); 879 strcpy(out_sz, call_program_and_get_last_line_of_output(command)); 792 asprintf(&out_sz, call_program_and_get_last_line_of_output(command)); 793 paranoid_free(command); 880 794 if (strlen(out_sz) == 0) { 881 795 return (-1); 882 796 } // error within df, probably 883 797 res = atol(out_sz); 798 paranoid_free(out_sz); 884 799 return (res); 885 800 } … … 903 818 904 819 /*@ buffers ************ */ 905 char tmp[MAX_STR_LEN]; 906 // char command[MAX_STR_LEN]; 820 char *tmp; 907 821 908 822 /*@ int's *************** */ … … 921 835 ("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE); 922 836 } 923 strcpy(tmp,837 asprintf(&tmp, 924 838 call_program_and_get_last_line_of_output 925 839 ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2")); … … 932 846 ("WARNING! You have very little RAM. Please upgrade to 64MB or more."); 933 847 } 848 paranoid_free(tmp); 934 849 #endif 935 850 … … 1010 925 run_program_and_log_output 1011 926 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 1012 strcpy(tmp,927 asprintf(&tmp, 1013 928 call_program_and_get_last_line_of_output 1014 929 ("mount | grep -E \"cdr(om|w)\"")); … … 1029 944 } 1030 945 } 946 paranoid_free(tmp); 1031 947 #ifndef __FreeBSD__ 1032 948 if (!does_file_exist("/etc/modules.conf")) { … … 1102 1018 { 1103 1019 /*@ buffer ****************************************************** */ 1104 char command[MAX_STR_LEN * 2];1105 char tmp[MAX_STR_LEN];1020 char *command; 1021 char *tmp; 1106 1022 1107 1023 /*@ end vars *************************************************** */ … … 1110 1026 assert_string_is_neither_NULL_nor_zerolength(label); 1111 1027 if (!does_file_exist(config_file)) { 1112 sprintf(tmp, "(read_cfg_var) Cannot find %s config file",1028 asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", 1113 1029 config_file); 1114 1030 log_to_screen(tmp); 1031 paranoid_free(tmp); 1115 1032 value[0] = '\0'; 1116 1033 return (1); … … 1121 1038 return (0); 1122 1039 } else { 1123 sprintf(command, "cat %s | grep \"%s .*\" | cut -d' ' -f2,3,4,5",1040 asprintf(&command, "cat %s | grep \"%s .*\" | cut -d' ' -f2,3,4,5", 1124 1041 config_file, label); 1125 1042 strcpy(value, call_program_and_get_last_line_of_output(command)); 1043 paranoid_free(command); 1126 1044 if (strlen(value) == 0) { 1127 1045 return (1); … … 1189 1107 void stop_autofs_if_necessary() 1190 1108 { 1191 char tmp[MAX_STR_LEN];1109 char *tmp; 1192 1110 1193 1111 g_autofs_exe[0] = '\0'; … … 1203 1121 log_msg(3, "%s --- autofs detected", g_autofs_exe); 1204 1122 // FIXME -- only disable it if it's running --- sprintf(tmp, "%s status", autofs_exe); 1205 sprintf(tmp, "%s stop", g_autofs_exe);1123 asprintf(&tmp, "%s stop", g_autofs_exe); 1206 1124 if (run_program_and_log_output(tmp, 2)) { 1207 1125 log_it("Failed to stop autofs - I assume it wasn't running"); … … 1210 1128 log_it("Stopped autofs OK"); 1211 1129 } 1130 paranoid_free(tmp); 1212 1131 } 1213 1132 } … … 1218 1137 void restart_autofs_if_necessary() 1219 1138 { 1220 char tmp[MAX_STR_LEN];1139 char *tmp; 1221 1140 1222 1141 if (!g_autofs_stopped || !g_autofs_exe[0]) { … … 1224 1143 return; 1225 1144 } 1226 sprintf(tmp, "%s start", g_autofs_exe);1145 asprintf(&tmp, "%s start", g_autofs_exe); 1227 1146 if (run_program_and_log_output(tmp, 2)) { 1228 1147 log_it("Failed to start autofs"); … … 1231 1150 log_it("Started autofs OK"); 1232 1151 } 1152 paranoid_free(tmp); 1233 1153 } 1234 1154 … … 1239 1159 void mount_boot_if_necessary() 1240 1160 { 1241 char tmp[MAX_STR_LEN]; 1242 char command[MAX_STR_LEN]; 1161 char *tmp; 1162 char *tmp1; 1163 char *command; 1243 1164 1244 1165 log_msg(1, "Started sub"); 1245 log_msg(4, "About to set g_boot_mountpt [0] to '\\0'");1246 g_boot_mountpt[0] = '\0';1166 log_msg(4, "About to set g_boot_mountpt to \"\""); 1167 asprintf(&g_boot_mountpt, ""); 1247 1168 log_msg(4, "Done. Great. Seeting command to something"); 1248 strcpy(command,1169 asprintf(&command, 1249 1170 "cat /etc/fstab | grep -v \":\" | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1250 1171 log_msg(4, "Cool. Command = '%s'", command); 1251 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 1172 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 1173 paranoid_free(command); 1174 1252 1175 log_msg(4, "tmp = '%s'", tmp); 1253 1176 if (tmp[0]) { … … 1255 1178 if (strstr(tmp, "LABEL=")) { 1256 1179 if (!run_program_and_log_output("mount /boot", 5)) { 1257 strcpy(g_boot_mountpt, "/boot"); 1180 paranoid_free(g_boot_mountpt); 1181 asprintf(&g_boot_mountpt, "/boot"); 1258 1182 log_msg(1, "Mounted /boot"); 1259 1183 } else { … … 1261 1185 } 1262 1186 } else { 1263 sprintf(command, "mount | grep -w \"%s\"", tmp);1187 asprintf(&command, "mount | grep -w \"%s\"", tmp); 1264 1188 log_msg(3, "command = %s", command); 1265 1189 if (run_program_and_log_output(command, 5)) { 1266 strcpy(g_boot_mountpt, tmp); 1267 sprintf(tmp, 1190 paranoid_free(g_boot_mountpt); 1191 asprintf(&g_boot_mountpt, tmp); 1192 asprintf(&tmp1, 1268 1193 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1269 1194 g_boot_mountpt); 1270 log_it(tmp); 1271 sprintf(tmp, "mount %s", g_boot_mountpt); 1272 if (run_program_and_log_output(tmp, 5)) { 1273 g_boot_mountpt[0] = '\0'; 1195 log_it(tmp1); 1196 paranoid_free(tmp1); 1197 1198 asprintf(&tmp1, "mount %s", g_boot_mountpt); 1199 if (run_program_and_log_output(tmp1, 5)) { 1200 paranoid_free(g_boot_mountpt); 1201 asprintf(&g_boot_mountpt, ""); 1274 1202 log_msg(1, "Plan B"); 1275 1203 if (!run_program_and_log_output("mount /boot", 5)) { 1276 strcpy(g_boot_mountpt, "/boot"); 1204 paranoid_free(g_boot_mountpt); 1205 asprintf(&g_boot_mountpt, "/boot"); 1277 1206 log_msg(1, "Plan B worked"); 1278 1207 } else { … … 1281 1210 } 1282 1211 } 1212 paranoid_free(tmp1); 1283 1213 } 1284 } 1285 } 1214 paranoid_free(command); 1215 } 1216 } 1217 paranoid_free(tmp); 1286 1218 log_msg(1, "Ended sub"); 1287 1219 } … … 1293 1225 void unmount_boot_if_necessary() 1294 1226 { 1295 char tmp[MAX_STR_LEN];1227 char *tmp; 1296 1228 1297 1229 log_msg(3, "starting"); 1298 1230 if (g_boot_mountpt[0]) { 1299 sprintf(tmp, "umount %s", g_boot_mountpt);1231 asprintf(&tmp, "umount %s", g_boot_mountpt); 1300 1232 if (run_program_and_log_output(tmp, 5)) { 1301 1233 log_it("WARNING - unable to unmount /boot"); 1302 1234 } 1235 paranoid_free(tmp); 1303 1236 } 1304 1237 log_msg(3, "leaving"); … … 1318 1251 { 1319 1252 /*@ buffers ***************************************************** */ 1320 char command[MAX_STR_LEN * 2];1321 char tempfile[MAX_STR_LEN];1322 char tmp[MAX_STR_LEN];1253 char *command; 1254 char *tempfile; 1255 char *tmp; 1323 1256 1324 1257 … … 1327 1260 assert_string_is_neither_NULL_nor_zerolength(label); 1328 1261 assert(value != NULL); 1262 1329 1263 if (!does_file_exist(config_file)) { 1330 sprintf(tmp, "(write_cfg_file) Cannot find %s config file",1264 asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", 1331 1265 config_file); 1332 1266 log_to_screen(tmp); 1267 paranoid_free(tmp); 1333 1268 return (1); 1334 1269 } 1335 strcpy(tempfile,1270 asprintf(&tempfile, 1336 1271 call_program_and_get_last_line_of_output 1337 1272 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX")); 1338 1273 if (does_file_exist(config_file)) { 1339 sprintf(command, "cat %s | grep -vx \"%s .*\" > %s", config_file,1274 asprintf(&command, "cat %s | grep -vx \"%s .*\" > %s", config_file, 1340 1275 label, tempfile); 1341 1276 paranoid_system(command); 1342 } 1343 sprintf(command, "echo \"%s %s\" >> %s", label, value, tempfile); 1277 paranoid_free(command); 1278 } 1279 asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile); 1344 1280 paranoid_system(command); 1345 sprintf(command, "mv -f %s %s", tempfile, config_file); 1281 paranoid_free(command); 1282 1283 asprintf(&command, "mv -f %s %s", tempfile, config_file); 1346 1284 paranoid_system(command); 1285 paranoid_free(command); 1347 1286 unlink(tempfile); 1287 paranoid_free(tempfile); 1348 1288 return (0); 1349 1289 } … … 1361 1301 int i; 1362 1302 static int depth = 0; 1363 char *tmp;1364 1303 FILE *fout; 1365 1304 … … 1369 1308 } 1370 1309 depth++; 1371 1372 malloc_string(tmp);1373 1310 1374 1311 if (debug_level <= g_loglevel) { … … 1404 1341 } 1405 1342 depth--; 1406 paranoid_free(tmp);1407 1343 } 1408 1344 … … 1415 1351 1416 1352 /** 1417 * If @p y, malloc @p x, else free @p x.1418 * @bug This function seems orphaned. Please remove.1419 */1420 #define do_alloc_or_free_depending(x,y) { if(y) {x=malloc(MAX_STR_LEN);} else {paranoid_free(x);} }1421 1422 /**1423 1353 * Allocate or free important globals, depending on @p mal. 1424 1354 * @param mal If TRUE, malloc; if FALSE, free. … … 1428 1358 if (mal) { 1429 1359 iamhere("Malloc'ing globals"); 1430 malloc_string(g_boot_mountpt);1431 malloc_string(g_mondo_home);1432 malloc_string(g_tmpfs_mountpt);1433 1360 malloc_string(g_erase_tmpdir_and_scratchdir); 1434 1361 malloc_string(g_serial_string); … … 1443 1370 paranoid_free(g_magicdev_command); 1444 1371 } 1445 1446 /*1447 char**list_of_arrays[] = {1448 &g_boot_mountpt,1449 &g_mondo_home,1450 &g_tmpfs_mountpt,1451 &g_erase_tmpdir_and_scratchdir,1452 &g_serial_string,1453 &g_magicdev_command,1454 NULL};1455 1456 char**ppcurr;1457 int i;1458 1459 for(i=0;list_of_arrays[i];i++)1460 {1461 log_msg(5, "Allocating %d", i);1462 ppcurr = list_of_arrays[i];1463 if (mal)1464 { *ppcurr = malloc(MAX_STR_LEN); }1465 else1466 {1467 if (*ppcurr)1468 {1469 free(*ppcurr);1470 }1471 }1472 }1473 log_msg(5, "Returning");1474 */1475 1372 } 1476 1373 … … 1518 1415 char *tmp; 1519 1416 1520 malloc_string(tmp);1521 1417 if (g_magicdev_command && g_magicdev_command[0]) { 1522 sprintf(tmp, "%s &", g_magicdev_command);1418 asprintf(&tmp, "%s &", g_magicdev_command); 1523 1419 paranoid_system(tmp); 1524 }1525 paranoid_free(tmp);1420 paranoid_free(tmp); 1421 } 1526 1422 } 1527 1423 -
trunk/mondo/mondo/common/libmondo-tools.h
r59 r94 20 20 void initialize_raidrec(struct raid_device_record *raidrec); 21 21 #endif 22 void log_trace(char *o);23 22 int some_basic_system_sanity_checks(); 24 23 25 24 26 25 void insmod_crucial_modules(void); 27 int find_and_store_mondoarchives_home(char *home_sz);26 char *find_and_store_mondoarchives_home(void); 28 27 29 28 -
trunk/mondo/mondo/common/newt-specific.c
r89 r94 33 33 extern pid_t g_mastermind_pid; 34 34 extern char *g_tmpfs_mountpt; 35 extern char *g_boot_mountpt;36 35 extern char *g_mondo_home; 37 36 -
trunk/mondo/mondo/mondoarchive/main.c
r87 r94 135 135 extern int g_currentY; 136 136 extern bool g_text_mode; 137 extern char *g_boot_mountpt;138 137 extern bool g_remount_cdrom_at_end, g_remount_floppy_at_end; 139 138 extern char *g_mondo_home; … … 314 313 set_signals(TRUE); // catch SIGTERM, etc. 315 314 nice(10); 315 run_program_and_log_output("date", 1); 316 316 run_program_and_log_output("dmesg -n1", TRUE); 317 317 … … 564 564 } 565 565 566 run_program_and_log_output("date", 1); 567 566 568 if (!g_text_mode) { 567 569 popup_and_OK -
trunk/mondo/mondo/mondorestore/mondo-restore.c
r87 r94 3247 3247 malloc_libmondo_global_strings(); 3248 3248 3249 strcpy(g_mondo_home, 3250 call_program_and_get_last_line_of_output("which mondorestore")); 3249 asprintf(&g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore")); 3251 3250 sprintf(g_tmpfs_mountpt, "/tmp/tmpfs"); 3252 3251 make_hole_for_dir(g_tmpfs_mountpt); -
trunk/mondo/mondo/mondorestore/mondo-rstr-tools.c
r87 r94 1999 1999 malloc_string(g_mondo_cfg_file); 2000 2000 malloc_string(g_mountlist_fname); 2001 malloc_string(g_mondo_home);2002 2001 malloc_string(g_tmpfs_mountpt); 2003 2002 malloc_string(g_isodir_device); -
trunk/mondo/mondo/xmondo/xmondo.cpp
r30 r94 5 5 copyright : (C) 2003 by Joshua Oreman 6 6 email : oremanj@get-linux.org 7 cvsid : $Id : xmondo.cpp,v 1.1 2004/06/10 16:13:06 hugo Exp$7 cvsid : $Id$ 8 8 ***************************************************************************/ 9 9 … … 57 57 int g_operation_in_progress = 0; 58 58 59 static char cvsid[] = "$Id : xmondo.cpp,v 1.1 2004/06/10 16:13:06 hugo Exp$";59 static char cvsid[] = "$Id$"; 60 60 61 61 QProgressBar *XMondoProgress; … … 230 230 char logo_location[MAX_STR_LEN]; 231 231 232 if ( find_and_store_mondoarchives_home (logo_location) == 0) {232 if ((logo_location = find_and_store_mondoarchives_home()) != NULL) { 233 233 strcat (logo_location, "/mondo.png"); 234 234 if (logo.load (logo_location)) {
Note:
See TracChangeset
for help on using the changeset viewer.