- Timestamp:
- Aug 18, 2009, 3:25:29 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2330 r2331 404 404 if (bkpinfo->backup_media_type == dvd) { 405 405 #ifdef DVDRWFORMAT 406 if (!find_home_of_exe("dvd+rw-format")) { 407 fatal_error 408 ("Cannot find dvd+rw-format. Please install it or fix your PATH."); 409 } 406 tmp = find_home_of_exe("dvd+rw-format"); 407 if (!tmp) { 408 mr_free(tmp); 409 fatal_error("Cannot find dvd+rw-format. Please install it or fix your PATH."); 410 } 411 mr_free(tmp); 410 412 #endif 411 if (!find_home_of_exe("growisofs")) { 412 fatal_error 413 ("Cannot find growisofs. Please install it or fix your PATH."); 414 } 413 tmp = find_home_of_exe("growisofs"); 414 if (!tmp) { 415 mr_free(tmp); 416 fatal_error("Cannot find growisofs. Please install it or fix your PATH."); 417 } 418 mr_free(tmp); 415 419 } 416 420 … … 2877 2881 mr_asprintf(checksum_line, "IGNORE"); 2878 2882 log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename); 2879 if ( !find_home_of_exe("ntfsresize")) { 2883 tmp = find_home_of_exe("ntfsresize"); 2884 if (!tmp) { 2885 mr_free(tmp); 2880 2886 fatal_error("ntfsresize not found"); 2881 2887 } 2888 mr_free(tmp); 2889 2882 2890 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 2883 2891 log_it("command = %s", command); -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2330 r2331 709 709 } 710 710 711 if (!find_home_of_exe("afio")) { 712 if (find_home_of_exe("star")) { 711 tmp1 = find_home_of_exe("afio"); 712 if (!tmp1) { 713 mr_free(tmp1); 714 tmp1 = find_home_of_exe("star"); 715 if (tmp1) { 716 mr_free(tmp1); 713 717 flag_set['R'] = TRUE; 714 718 log_msg(1, "Using star instead of afio"); 715 719 } else { 716 fatal_error 717 ("Neither afio nor star is installed. Please install at least one."); 718 } 719 } 720 mr_free(tmp1); 721 fatal_error("Neither afio nor star is installed. Please install at least one."); 722 } 723 } 724 mr_free(tmp1); 720 725 721 726 if (flag_set['R']) { … … 724 729 fatal_error("You may not use star and lzop at the same time."); 725 730 } 726 if (!find_home_of_exe("star")) { 727 fatal_error 728 ("Please install 'star' RPM or tarball if you are going to use -R. Thanks."); 729 } 731 tmp1 = find_home_of_exe("star"); 732 if (!tmp1) { 733 mr_free(tmp1); 734 fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks."); 735 } 736 mr_free(tmp1); 730 737 } 731 738 … … 919 926 } 920 927 if (! bkpinfo->restore_data) { 921 if (!find_home_of_exe("growisofs")) { 928 tmp1 = find_home_of_exe("growisofs"); 929 if (!tmp1) { 930 mr_free(tmp1); 922 931 fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it."); 923 932 } 924 if (!find_home_of_exe("dvd+rw-format")) { 933 mr_free(tmp1); 934 935 tmp1 = find_home_of_exe("dvd+rw-format"); 936 if (!tmp1) { 937 mr_free(tmp1); 925 938 fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it."); 926 939 } 940 mr_free(tmp1); 941 927 942 if (!flag_set['s']) { 928 943 sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB … … 1046 1061 } 1047 1062 if (flag_set['z']) { 1048 if (find_home_of_exe("getfattr")) { 1063 tmp1 = find_home_of_exe("getfattr"); 1064 if (tmp1) { 1049 1065 mr_asprintf(g_getfattr,"getfattr"); 1050 1066 } 1051 if (find_home_of_exe("getfacl")) { 1067 mr_free(tmp1); 1068 1069 tmp1 = find_home_of_exe("getfacl"); 1070 if (tmp1) { 1052 1071 mr_asprintf(g_getfacl,"getfacl"); 1053 1072 } 1073 mr_free(tmp1); 1054 1074 } 1055 1075 … … 1332 1352 1333 1353 if (flag_set['Q']) { 1334 i = which_boot_loader(tmp1); 1335 log_msg(3, "boot loader is %c, residing at %s", i, tmp1); 1336 printf("boot loader is %c, residing at %s\n", i, tmp1); 1337 mr_free(tmp1); 1354 i = which_boot_loader(NULL); 1355 log_msg(3, "boot loader is %c", i); 1356 printf("boot loader is %c\n", i); 1338 1357 finish(0); 1339 1358 } -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2330 r2331 509 509 /*@ buffers ************************ */ 510 510 char *tmp = NULL; 511 char *tmp1 = NULL; 511 512 char *cdr_exe = NULL; 512 513 char *command = NULL; … … 523 524 } 524 525 run_program_and_log_output("insmod ide-scsi", -1); 525 if (find_home_of_exe("cdrecord")) { 526 tmp = find_home_of_exe("cdrecord"); 527 if (tmp) { 526 528 mr_asprintf(cdr_exe, "cdrecord"); 527 529 } else { 528 530 mr_asprintf(cdr_exe, "dvdrecord"); 529 531 } 530 if (find_home_of_exe(cdr_exe)) { 532 mr_free(tmp); 533 534 tmp1 = find_home_of_exe(cdr_exe); 535 if (tmp1) { 531 536 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe); 532 537 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 533 538 mr_free(command); 534 539 } 540 mr_free(tmp1); 541 535 542 if ((tmp == NULL) || (strlen(tmp) < 2)) { 536 543 mr_free(tmp); … … 603 610 make_hole_for_dir(mountpoint); 604 611 605 if (find_home_of_exe("cdrecord")) { 612 tmp = find_home_of_exe("cdrecord"); 613 if (tmp) { 606 614 mr_asprintf(cdr_exe, "cdrecord"); 607 615 } else { 608 616 mr_asprintf(cdr_exe, "dvdrecord"); 609 617 } 610 611 if (!find_home_of_exe(cdr_exe)) { 618 mr_free(tmp); 619 620 tmp = find_home_of_exe(cdr_exe); 621 if (!tmp) { 612 622 mr_asprintf(output, "/dev/cdrom"); 613 623 log_msg(4, "Can't find cdrecord; assuming %s", output); … … 616 626 log_msg(4, "That didn't work. Sorry."); 617 627 mr_free(output); 618 return(output);619 } else {620 621 622 }628 } 629 mr_free(tmp); 630 return(output); 631 } 632 mr_free(tmp); 623 633 624 634 mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe); … … 992 1002 retval = 0; 993 1003 } else { 994 mr_getline( &good_formats, pin);1004 mr_getline(good_formats, pin); 995 1005 if (pclose(pin)) { 996 1006 log_OS_error("Cannot pclose good formats"); … … 2344 2354 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 2345 2355 count_grubs++; 2356 /* BERLIOS : removed as I don't think it's mandatory here 2346 2357 mr_free(which_device); 2347 2358 mr_asprintf(which_device, "%s", current_drive); 2359 */ 2348 2360 break; 2349 2361 } 2350 2362 if (does_string_exist_in_boot_block(current_drive, "LILO")) { 2351 2363 count_lilos++; 2364 /* BERLIOS : removed as I don't think it's mandatory here 2352 2365 mr_free(which_device); 2353 2366 mr_asprintf(which_device, "%s", current_drive); 2367 */ 2354 2368 break; 2355 2369 } … … 2388 2402 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 2389 2403 count_grubs++; 2404 /* BERLIOS : removed as I don't think it's mandatory here 2390 2405 mr_free(which_device); 2391 2406 mr_asprintf(which_device, "%s", current_drive); 2407 */ 2392 2408 break; 2393 2409 } 2394 2410 if (does_string_exist_in_boot_block(current_drive, "LILO")) { 2395 2411 count_lilos++; 2412 /* BERLIOS : removed as I don't think it's mandatory here 2396 2413 mr_free(which_device); 2397 2414 mr_asprintf(which_device, "%s", current_drive); 2415 */ 2398 2416 break; 2399 2417 } -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2327 r2331 527 527 char *syscall_pout = NULL; 528 528 char *incoming; 529 char *current_subset_file, *current_master_file; 529 char *current_subset_file; 530 char *current_master_file = NULL; 530 531 char *masklist = NULL; 531 532 int retval = 0; … … 551 552 malloc_string(incoming); 552 553 malloc_string(current_subset_file); 553 malloc_string(current_master_file);554 554 mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir); 555 555 mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist); … … 558 558 559 559 sort_file(masklist); 560 current_subset_file[0] = current_master_file[0] ='\0';560 current_subset_file[0] = '\0'; 561 561 562 562 mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE); … … 594 594 (void)fgets(incoming, MAX_STR_LEN, pin); 595 595 while (!feof(pin) && !feof(faclin)) { 596 // printf("incoming = %s", incoming); 597 598 strcpy(current_master_file, incoming + 8); 596 mr_asprintf(current_master_file, "%s", incoming + 8); 599 597 600 598 p = current_subset_file; … … 635 633 log_msg(my_depth, "Copying master %s", q); 636 634 } 637 // if (!i) { printf("Match --- %s\n", q); }638 635 639 636 while (!feof(pin) && strncmp(incoming, "# file: ", 8)) { 640 637 if (!i) { 641 642 // printf("%s", incoming);643 644 638 fputs(incoming, pout); 645 639 } … … 649 643 (void)fgets(current_subset_file, MAX_STR_LEN, faclin); 650 644 } 645 mr_free(current_master_file); 651 646 } 652 647 while (!feof(pin)) { … … 663 658 664 659 paranoid_free(current_subset_file); 665 paranoid_free(current_master_file);666 660 paranoid_free(incoming); 667 661 return (retval); … … 669 663 670 664 671 int set_fattr_list(char *masklist, char *fattr_fname) 672 { 673 if (find_home_of_exe("setfattr")) { 665 int set_fattr_list(char *masklist, char *fattr_fname) { 666 667 char *tmp = NULL; 668 669 tmp = find_home_of_exe("setfattr"); 670 if (tmp) { 671 mr_free(tmp); 674 672 return (set_EXAT_list(masklist, fattr_fname, "setfattr")); 675 673 } else { 674 mr_free(tmp); 676 675 log_msg(1, "ERROR: set_EXAT_list: setfattr doesn't exist"); 677 676 return(0); … … 681 680 682 681 683 int set_acl_list(char *masklist, char *acl_fname) 684 { 685 if (find_home_of_exe("setfacl")) { 682 int set_acl_list(char *masklist, char *acl_fname) { 683 684 char *tmp = NULL; 685 686 tmp = find_home_of_exe("setfacl"); 687 if (tmp) { 688 mr_free(tmp); 686 689 return (set_EXAT_list(masklist, acl_fname, "setfacl")); 687 690 } else { 691 mr_free(tmp); 688 692 log_msg(1, "ERROR: set_EXAT_list: setfacl doesn't exist"); 689 693 return(0); … … 1770 1774 char *fname; 1771 1775 char *tmp; 1772 size_t len = 0; // Scrub's patch doesn't work without that 1773 1774 // log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE"); 1776 size_t len = 0; 1777 1775 1778 malloc_string(fname); 1776 1779 malloc_string(tmp); -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2328 r2331 317 317 * @return The full path to the executable, or "" if it does not exist, or NULL if @c file could not be found. 318 318 * @note The returned string points to static storage that will be overwritten with each call. 319 * @bug The checks with @c file and @c dirname seem pointless. If @c incomingis "", then you're calling319 * @bug The checks with @c file and @c dirname seem pointless. If @c output is "", then you're calling 320 320 * <tt>dirname 2\>/dev/null</tt> or <tt>file 2\>/dev/null | cut -d':' -f1 2\>/dev/null</tt>, which basically amounts 321 321 * to nothing. … … 324 324 { 325 325 /*@ buffers ********************* */ 326 static char output[MAX_STR_LEN]; 327 char *incoming; 326 char *output = NULL; 328 327 char *command = NULL; 329 328 330 malloc_string(incoming);331 incoming[0] = '\0';332 329 /*@******************************* */ 333 330 334 331 assert_string_is_neither_NULL_nor_zerolength(fname); 335 332 mr_asprintf(command, "which %s 2> /dev/null", fname); 336 strcpy(incoming, call_program_and_get_last_line_of_output(command));337 mr_free(command); 338 if ( incoming[0] == '\0') {333 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command)); 334 mr_free(command); 335 if (output[0] == '\0') { 339 336 if (system("which file > /dev/null 2> /dev/null")) { 340 paranoid_free(incoming); 341 output[0] = '\0'; 337 mr_free(output); 342 338 return (NULL); // forget it :) 343 339 } 344 mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming); 345 strcpy(incoming, call_program_and_get_last_line_of_output(command)); 340 mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", output); 341 mr_free(output); 342 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command)); 346 343 mr_free(command); 347 344 } 348 if ( incoming[0] == '\0') // yes, it is == '\0' twice, not once :)349 {350 mr_ asprintf(command, "dirname %s 2> /dev/null", incoming);351 strcpy(incoming, call_program_and_get_last_line_of_output(command));345 if (output[0] == '\0') { 346 mr_asprintf(command, "dirname %s 2> /dev/null", output); 347 mr_free(output); 348 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command)); 352 349 mr_free(command); 353 350 } 354 strcpy(output, incoming); 351 355 352 if (output[0] != '\0' && does_file_exist(output)) { 356 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, 357 incoming); 353 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output); 358 354 } else { 359 output[0] = '\0';355 mr_free(output); 360 356 log_msg(4, "find_home_of_exe() --- Could not find %s", fname); 361 357 } 362 paranoid_free(incoming); 363 if (!output[0]) { 364 return (NULL); 365 } else { 366 return (output); 367 } 358 return (output); 368 359 } 369 360 … … 427 418 428 419 /*@ buffers ***************************************************** */ 429 char lastline[MAX_STR_LEN];420 char *lastline = NULL; 430 421 char *command = NULL; 431 422 /*@ pointers **************************************************** */ … … 440 431 if (i < 0) { 441 432 mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%'); 442 strcpy(lastline, call_program_and_get_last_line_of_output(command));433 mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command)); 443 434 mr_free(command); 444 435 if (!lastline[0]) { 436 mr_free(lastline); 445 437 return (0); 446 438 } 447 439 } else { 448 strcpy(lastline, err_log_lines[i]);440 mr_asprintf(lastline, "%s", err_log_lines[i]); 449 441 } 450 442 … … 454 446 } 455 447 if (!p) { 448 mr_free(lastline); 456 449 return (0); 457 450 } … … 461 454 p++; 462 455 } 456 mr_free(lastline); 457 463 458 i = atoi(p); 464 465 459 return (i); 466 460 } … … 550 544 char stub_fname[1000]; 551 545 char curr_fname[1000]; 552 char curr_cksum[1000];546 char *curr_cksum = NULL; 553 547 char *tmp = NULL; 554 548 … … 589 583 mr_free(tmp); 590 584 591 strcpy(curr_cksum, calc_file_ugly_minichecksum(curr_fname));585 mr_asprintf(curr_cksum, "%s", calc_file_ugly_minichecksum(curr_fname)); 592 586 fprintf(fout, "%s\t%s\n", curr_fname, curr_cksum); 587 mr_free(curr_cksum); 588 593 589 if (counter++ > 12) { 594 590 current_time = get_time(); … … 719 715 char *command = NULL; 720 716 char *mountlist = NULL; 721 char sz_res[MAX_STR_LEN];717 char *sz_res = NULL; 722 718 long file_len_K; 723 719 … … 727 723 728 724 log_it(command); 729 strcpy(sz_res, call_program_and_get_last_line_of_output(command));725 mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command)); 730 726 file_len_K = atol(sz_res); 731 727 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K); 728 mr_free(sz_res); 732 729 mr_free(command); 733 730 … … 745 742 char *fname; 746 743 char *biggielist = NULL; 747 char *comment = NULL;748 744 char *tmp = NULL; 749 745 char *command = NULL; … … 752 748 long scratchL = 0; 753 749 long file_len_K; 754 755 int res = 0;756 750 757 751 /*@ pointers *************************************************** */ … … 778 772 if (0 == strncmp(fname, "/dev/", 5)) { 779 773 if (is_dev_an_NTFS_dev(fname)) { 780 if ( !find_home_of_exe("ntfsresize")) { 774 tmp = find_home_of_exe("ntfsresize"); 775 if (!tmp) { 776 mr_free(tmp); 781 777 fatal_error("ntfsresize not found"); 782 778 } 779 mr_free(tmp); 780 783 781 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 784 782 log_it("command = %s", command); … … 1005 1003 /*@ Char buffers ** */ 1006 1004 char *command = NULL; 1007 char tmp[MAX_STR_LEN];1005 char *tmp = NULL; 1008 1006 int res = 0; 1009 1007 1010 mvaddstr_and_log_it(g_currentY, 0, 1011 "Copying Mondo's core files to the scratch directory"); 1008 mvaddstr_and_log_it(g_currentY, 0, "Copying Mondo's core files to the scratch directory"); 1012 1009 1013 1010 log_msg(4, "g_mondo_home='%s'", g_mondo_home); … … 1033 1030 } 1034 1031 1035 strcpy(tmp, 1036 call_program_and_get_last_line_of_output("which mondorestore")); 1032 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore")); 1037 1033 if (!tmp[0]) { 1038 fatal_error1039 1034 mr_free(tmp); 1035 fatal_error("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?"); 1040 1036 } 1041 1037 mr_asprintf(command, "cp -f %s %s", tmp, bkpinfo->tmpdir); 1038 mr_free(tmp); 1039 1042 1040 res = run_program_and_log_output(command, FALSE); 1043 1041 mr_free(command); … … 1270 1268 1271 1269 /** 1272 * Get the last suffix of @p instr.1273 * If @p instr was "httpd.log.gz", we would return "gz".1274 * @param instr The filename to get the suffix of.1275 * @return The suffix (without a dot), or "" if none.1276 * @note The returned string points to static storage that will be overwritten with each call.1277 */1278 char *sz_last_suffix(char *instr)1279 {1280 static char outstr[MAX_STR_LEN];1281 char *p;1282 1283 p = strrchr(instr, '.');1284 if (!p) {1285 outstr[0] = '\0';1286 } else {1287 strcpy(outstr, p);1288 }1289 return (outstr);1290 }1291 1292 1293 /**1294 1270 * Determine whether a file is compressed. This is done 1295 1271 * by reading through the "do-not-compress-these" file distributed with Mondo. … … 1299 1275 bool is_this_file_compressed(char *filename) 1300 1276 { 1301 char do_not_compress_these[MAX_STR_LEN];1277 char *do_not_compress_these = NULL; 1302 1278 char *tmp = NULL; 1303 1279 char *p; … … 1315 1291 } 1316 1292 /* BERLIOS: This is just plain WRONG !! */ 1317 strcpy(do_not_compress_these,last_line_of_file(tmp));1293 mr_asprintf(do_not_compress_these, "%s", last_line_of_file(tmp)); 1318 1294 mr_free(tmp); 1319 1295 … … 1325 1301 if (!strcmp(q, tmp)) { 1326 1302 mr_free(tmp); 1303 mr_free(do_not_compress_these); 1327 1304 return (TRUE); 1328 1305 } … … 1332 1309 mr_free(tmp); 1333 1310 } 1311 mr_free(do_not_compress_these); 1334 1312 return (FALSE); 1335 1313 } -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2325 r2331 589 589 // BACKUP 590 590 int res = -1; 591 char *command = NULL;591 char *command = NULL; 592 592 593 593 if (!does_file_exist(input_device)) { 594 594 fatal_error("input device does not exist"); 595 595 } 596 if ( !find_home_of_exe("ntfsclone")) { 596 command = find_home_of_exe("ntfsclone"); 597 if (!command) { 598 mr_free(command); 597 599 fatal_error("ntfsclone not found"); 598 600 } 601 mr_free(command); 602 599 603 mr_asprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 600 604 res = run_program_and_log_output(command, 5); … … 639 643 /*@ buffers *********************************************************** */ 640 644 char *command = NULL; 641 char *title ;645 char *title = NULL; 642 646 /*@ pointers ********************************************************** */ 643 647 static int chldres = 0; … … 650 654 *pchild_result = 999; 651 655 652 malloc_string(title);653 strcpy(title, tt);654 656 mr_asprintf(command, "%s 2>> %s", cmd, MONDO_LOGFILE); 655 657 log_msg(3, "command = '%s'", command); … … 659 661 660 662 log_msg(8, "Parent running"); 663 mr_asprintf(title, "%s", tt); 661 664 open_evalcall_form(title); 665 mr_free(title); 666 662 667 for (sleep(1); command[0] != '\0'; sleep(1)) { 663 668 pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE); … … 669 674 if (pcno <= 5 && last_pcno >= 40) { 670 675 close_evalcall_form(); 671 strcpy(title, "Verifying...");676 mr_asprintf(title, "Verifying..."); 672 677 open_evalcall_form(title); 678 mr_free(title); 673 679 } 674 680 if (counter++ >= 5) { … … 690 696 } 691 697 log_msg(3, "Parent res = %d", res); 692 paranoid_free(title);693 698 return (res); 694 699 } 695 696 697 700 698 701 … … 709 712 char *command = NULL; 710 713 711 if ( !find_home_of_exe("ntfsclone")) { 714 command = find_home_of_exe("ntfsclone"); 715 if (!command) { 716 mr_free(command); 712 717 fatal_error("ntfsclone not found"); 713 718 } 719 mr_free(command); 720 714 721 mr_asprintf(command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo); 715 722 res = run_program_and_log_output(command, 5); -
branches/2.2.10/mondo/src/common/libmondo-mountlist.c
r2330 r2331 60 60 char tmp = NULL; 61 61 char *device = NULL; 62 char mountpoint[MAX_STR_LEN];63 62 64 63 char *flaws_str = NULL; … … 104 103 continue; 105 104 } 106 strcpy(mountpoint, mountlist->el[pos].mountpoint);107 105 /* is it too big? */ 108 106 if (curr_part_no > 'h') { … … 186 184 187 185 device = build_partition_name(drive, curr_part_no); 188 strcpy(mountpoint, mountlist->el[pos].mountpoint);189 186 if (pos > 0 && !npos) { 190 187 /* gap in the partition list? */ … … 271 268 continue; 272 269 } 273 strcpy(mountpoint, mountlist->el[pos].mountpoint);274 270 /* is it too big? */ 275 271 if (curr_part_no > 'h') { -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2325 r2331 256 256 257 257 log_to_screen("I am looking for your tape streamer. Please wait."); 258 if (find_home_of_exe("cdrecord")) { 259 mr_asprintf(&cdr_exe, "cdrecord"); 260 } else { 261 mr_asprintf(&cdr_exe, "dvdrecord"); 262 } 258 tmp = find_home_of_exe("cdrecord"); 259 if (tmp) { 260 mr_asprintf(cdr_exe, "cdrecord"); 261 } else { 262 mr_asprintf(cdr_exe, "dvdrecord"); 263 } 264 mr_free(tmp); 265 263 266 mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe); 264 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));267 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 265 268 mr_free(command); 266 269 … … 269 272 mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE); 270 273 mr_free(tmp); 274 mr_free(tmp); 271 275 return(dev); 272 276 } … … 274 278 275 279 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe); 276 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));280 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 277 281 mr_free(command); 278 282 … … 280 284 log_it("Could not find tape device"); 281 285 mr_free(tmp); 282 return( dev);286 return(NULL); 283 287 } 284 288 mr_free(tmp); 289 285 290 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe); 286 291 mr_free(cdr_exe); 287 292 288 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));293 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 289 294 mr_free(command); 290 291 295 292 296 mr_asprintf(dev, "%s", "/dev/st"); 293 297 mr_strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 294 298 mr_free(tmp); 299 295 300 res = 0; 296 301 if (!mt_says_tape_exists(dev)) { … … 321 326 } 322 327 323 mr_asprintf( &tmp, call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE |awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));328 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(" cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'")); 324 329 325 330 if (mt_says_tape_exists(dev)) { … … 328 333 log_it("Turning %s", dev); 329 334 mr_free(tmp); 330 mr_asprintf( &tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);335 mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 331 336 mr_free(dev); 332 337 mr_asprintf(&dev, "/dev/os%s", tmp); … … 342 347 log_it("res=%d; dev=%s", res, dev); 343 348 344 if (res) { 349 if (dev) { 350 log_it("At this new point, dev = %s and res = %d", dev, res); 351 } else { 352 log_it("At this new point, dev is NULL and res = %d", dev, res); 345 353 mr_free(tmp); 346 return (dev);354 return(NULL); 347 355 } 348 356 … … 351 359 } 352 360 mr_free(tmp); 353 return (NULL);361 return(dev); 354 362 } 355 363 -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2329 r2331 418 418 char *tmp = NULL; 419 419 char *p = NULL; 420 char call_before_iso_user = NULL;420 char *call_before_iso_user = NULL; 421 421 char *iso_dev = NULL; 422 422 char *iso_mnt = NULL; … … 494 494 495 495 if (bkpinfo->backup_media_type == dvd) { 496 if (find_home_of_exe("growisofs")) { 496 tmp = find_home_of_exe("growisofs"); 497 if (tmp) { 497 498 strcpy(cdr_exe, "growisofs"); 498 499 } // unlikely to be used 499 500 else { 501 mr_free(tmp); 500 502 fatal_error("Please install growisofs."); 501 503 } 504 mr_free(tmp); 505 502 506 if (bkpinfo->nonbootable_backup) { 503 507 mr_asprintf(mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); … … 554 558 mr_asprintf(extra_cdrom_params, "blank=fast "); 555 559 } 556 if (find_home_of_exe("cdrecord")) { 560 tmp = find_home_of_exe("cdrecord"); 561 if (tmp) { 557 562 strcpy(cdr_exe, "cdrecord"); 558 } else if (find_home_of_exe("dvdrecord")) {559 strcpy(cdr_exe, "dvdrecord");560 563 } else { 561 fatal_error("Please install either cdrecord or dvdrecord."); 562 } 564 mr_free(tmp); 565 tmp = find_home_of_exe("dvdrecord"); 566 if (tmp) { 567 strcpy(cdr_exe, "dvdrecord"); 568 } else { 569 mr_free(tmp); 570 fatal_error("Please install either cdrecord or dvdrecord."); 571 } 572 } 573 mr_free(tmp); 574 563 575 if (bkpinfo->nonbootable_backup) { 564 576 mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT); … … 1000 1012 } 1001 1013 1002 if (!find_home_of_exe("cmp")) { 1003 if (!find_home_of_exe("true")) { 1004 whine_if_not_found("cmp"); 1014 tmp = find_home_of_exe("cmp"); 1015 if (!tmp) { 1016 mr_free(tmp); 1017 tmp = find_home_of_exe("true"); 1018 if (!tmp) { 1019 retval += whine_if_not_found("cmp"); 1005 1020 } else { 1006 log_to_screen 1007 ("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."); 1008 if (run_program_and_log_output 1009 ("cp -f `which true` /usr/bin/cmp", 0)) { 1021 log_to_screen("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."); 1022 if (run_program_and_log_output("cp -f `which true` /usr/bin/cmp", 0)) { 1023 mr_free(tmp); 1010 1024 fatal_error("Failed to create dummy 'cmp' file."); 1011 1025 } 1012 1026 } 1013 1027 } 1014 run_program_and_log_output 1015 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 1028 mr_free(tmp); 1029 1030 run_program_and_log_output("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 1016 1031 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\"")); 1017 1032 if (strcmp("", tmp)) { -
branches/2.2.10/mondo/src/common/newt-specific.c
r2324 r2331 750 750 if (g_text_mode) { 751 751 printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q--- [%s]\n--> ", title, b, input); 752 mr_getline( &output, stdin);752 mr_getline(output, stdin); 753 753 if (! strcmp(output,"\n")) { 754 754 /* take default if ENTER was typed */ -
branches/2.2.10/mondo/src/include/mr_mem.h
r2323 r2331 20 20 #define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__) 21 21 #define mr_asprintf(x,y,args...) mr_asprintf_int((char **)&x,__LINE__,__FILE__,y,## args) 22 #define mr_getline(x,y) mr_getline_int( x,y,__LINE__,__FILE__)22 #define mr_getline(x,y) mr_getline_int((char **)&x,y,__LINE__,__FILE__) 23 23 #define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__) 24 24 #define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__) -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2330 r2331 240 240 log_it("STARTING"); 241 241 log_msg(1, "OK, opened i-want-my-lvm. Shutting down LVM volumes..."); 242 if (find_home_of_exe("lvm")) // found it :) cool 242 tmp1 = find_home_of_exe("lvm"); 243 if (tmp1) // found it :) cool 243 244 { 244 245 strcpy(lvscan_sz, "lvm lvscan"); … … 258 259 strcpy(vgremove_sz, "vgremove"); 259 260 } 261 mr_free(tmp1); 262 260 263 mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 261 264 run_program_and_log_output(tmp1, 5); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2329 r2331 390 390 mr_strcat(additional_parameters, "-o ro"); 391 391 } 392 if (find_home_of_exe("setfattr")) { 392 tmp = find_home_of_exe("setfattr"); 393 if (tmp) { 393 394 mr_strcat(additional_parameters, ",user_xattr"); 394 395 } 395 if (find_home_of_exe("setfacl")) { 396 mr_free(tmp); 397 398 tmp = find_home_of_exe("setfacl"); 399 if (tmp) { 396 400 mr_strcat(additional_parameters, ",acl"); 397 401 } 402 mr_free(tmp); 398 403 } 399 404 … … 870 875 mr_asprintf(g_getfacl,"setfacl"); 871 876 log_msg(1, "We will restore ACLs"); 872 if (! find_home_of_exe("setfacl")) { 877 tmp = find_home_of_exe("setfacl"); 878 if (!tmp) { 873 879 log_msg(1, "Unable to restore ACLs as no setfacl found"); 874 880 } 881 mr_free(tmp); 875 882 } 876 883 mr_free(value); … … 880 887 mr_asprintf(g_getfattr,"setfattr"); 881 888 log_msg(1, "We will restore XATTRs"); 882 if (! find_home_of_exe("setfattr")) { 889 tmp = find_home_of_exe("setfattr"); 890 if (!tmp) { 883 891 log_msg(1, "Unable to restore XATTRs as no setfattr found"); 884 892 } 893 mr_free(tmp); 885 894 } 886 895 mr_free(value); … … 1437 1446 * @note The returned string points to static storage that will be overwritten with each call. 1438 1447 */ 1439 char *find_my_editor(void) 1440 { 1448 char *find_my_editor(void) { 1449 1450 char *tmp = NULL; 1441 1451 static char output[MAX_STR_LEN]; 1442 if (find_home_of_exe("pico")) { 1452 1453 tmp = find_home_of_exe("pico"); 1454 if (tmp) { 1443 1455 strcpy(output, "pico"); 1444 } else if (find_home_of_exe("nano")) { 1445 strcpy(output, "nano"); 1446 } else if (find_home_of_exe("e3em")) { 1447 strcpy(output, "e3em"); 1448 } else if (find_home_of_exe("e3vi")) { 1449 strcpy(output, "e3vi"); 1450 } else { 1451 strcpy(output, "vi"); 1452 } 1453 if (!find_home_of_exe(output)) { 1456 } else { 1457 mr_free(tmp); 1458 tmp = find_home_of_exe("nano"); 1459 if (tmp) { 1460 strcpy(output, "nano"); 1461 } else { 1462 mr_free(tmp); 1463 tmp = find_home_of_exe("joe"); 1464 if (tmp) { 1465 strcpy(output, "joe"); 1466 } else { 1467 strcpy(output, "vi"); 1468 } 1469 } 1470 } 1471 mr_free(tmp); 1472 1473 tmp = find_home_of_exe(output); 1474 if (!tmp) { 1454 1475 log_msg(2, " (find_my_editor) --- warning - %s not found", output); 1455 1476 } 1477 mr_free(tmp); 1456 1478 return (output); 1457 1479 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2329 r2331 2535 2535 log_msg(1, "path is now %s", newpath); 2536 2536 log_msg(1, "restoring everything"); 2537 if (!find_home_of_exe("petris") && !g_text_mode) { 2537 tmp = find_home_of_exe("petris"); 2538 if (!tmp && !g_text_mode) { 2538 2539 newtDrawRootText(0, g_noof_rows - 2, 2539 2540 "Press ALT-<left cursor> twice to play Petris :-) "); 2540 2541 newtRefresh(); 2541 2542 } 2543 mr_free(tmp); 2544 2542 2545 mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives"); 2543 2546 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
Note:
See TracChangeset
for help on using the changeset viewer.