Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-files.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-files.c
r839 r900 18 18 #include "libmondo-fork-EXT.h" 19 19 #include "libmondo-string-EXT.h" 20 #include "mr_mem.h" 20 21 21 22 /*@unused@*/ … … 59 60 60 61 if (does_file_exist(filename)) { 61 asprintf(&command, "md5sum \"%s\"", filename);62 mr_asprintf(&command, "md5sum \"%s\"", filename); 62 63 fin = popen(command, "r"); 63 paranoid_free(command);64 mr_free(command); 64 65 65 66 if (fin) { 66 (void)getline(&output, &n, fin);67 mr_getline(&output, &n, fin); 67 68 p = strchr(output, ' '); 68 69 paranoid_pclose(fin); 69 70 } 70 71 } else { 71 asprintf(&tmp, "File '%s' not found; cannot calc checksum",72 mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", 72 73 filename); 73 74 log_it(tmp); 74 paranoid_free(tmp);75 mr_free(tmp); 75 76 } 76 77 if (p) { … … 106 107 assert_string_is_neither_NULL_nor_zerolength(filename); 107 108 if (!does_file_exist(filename)) { 108 asprintf(&tmp,109 mr_asprintf(&tmp, 109 110 "%s does not exist, so I cannot found the number of lines in it", 110 111 filename); 111 112 log_it(tmp); 112 paranoid_free(tmp);113 mr_free(tmp); 113 114 return (0); 114 115 } 115 asprintf(&command, "cat %s | wc -l", filename);116 mr_asprintf(&command, "cat %s | wc -l", filename); 116 117 if (!does_file_exist(filename)) { 117 118 return (-1); 118 119 } 119 120 fin = popen(command, "r"); 120 paranoid_free(command);121 mr_free(command); 121 122 122 123 if (fin) { … … 124 125 noof_lines = 0; 125 126 } else { 126 (void)getline(&incoming, &n, fin);127 mr_getline(&incoming, &n, fin); 127 128 while (strlen(incoming) > 0 128 129 && incoming[strlen(incoming) - 1] < 32) { … … 130 131 } 131 132 noof_lines = atol(incoming); 132 paranoid_free(incoming);133 mr_free(incoming); 133 134 } 134 135 paranoid_pclose(fin); … … 189 190 assert_string_is_neither_NULL_nor_zerolength(inout); 190 191 191 asprintf(&infname, "%s.in", inout);192 193 asprintf(&tmp, "cp -f %s %s", inout, infname);192 mr_asprintf(&infname, "%s.in", inout); 193 194 mr_asprintf(&tmp, "cp -f %s %s", inout, infname); 194 195 run_program_and_log_output(tmp, FALSE); 195 paranoid_free(tmp);196 mr_free(tmp); 196 197 197 198 if (!(fin = fopen(infname, "r"))) { 198 199 log_OS_error("Unable to openin infname"); 199 paranoid_free(infname);200 mr_free(infname); 200 201 return; 201 202 } 202 203 203 asprintf(&outfname, "%s", inout);204 mr_asprintf(&outfname, "%s", inout); 204 205 if (!(fout = fopen(outfname, "w"))) { 205 206 log_OS_error("Unable to openout outfname"); 206 paranoid_free(outfname);207 mr_free(outfname); 207 208 return; 208 209 } 209 paranoid_free(outfname);210 211 for ( getline(&incoming, &n, fin); !feof(fin);212 getline(&incoming, &n, fin)) {210 mr_free(outfname); 211 212 for (mr_getline(&incoming, &n, fin); !feof(fin); 213 mr_getline(&incoming, &n, fin)) { 213 214 i = strlen(incoming) - 1; 214 215 if (i >= 0 && incoming[i] < 32) { … … 218 219 fprintf(fout, "%s\n", incoming); 219 220 } else { 220 asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);221 mr_asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming); 221 222 log_it(tmp); 222 paranoid_free(tmp);223 } 224 } 225 paranoid_free(incoming);223 mr_free(tmp); 224 } 225 } 226 mr_free(incoming); 226 227 paranoid_fclose(fout); 227 228 paranoid_fclose(fin); 228 229 unlink(infname); 229 paranoid_free(infname);230 mr_free(infname); 230 231 } 231 232 … … 249 250 // If we didn't get anything back, check whether mindi raised a fatal error 250 251 if (kernel == NULL) { 251 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");252 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 252 253 tmp = call_program_and_get_last_line_of_output(command); 253 254 if (strlen(tmp) > 1) { … … 255 256 fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'."); 256 257 } 257 paranoid_free(command);258 paranoid_free(tmp);258 mr_free(command); 259 mr_free(tmp); 259 260 } 260 261 … … 303 304 assert_string_is_neither_NULL_nor_zerolength(fname); 304 305 305 asprintf(&command, "which %s 2> /dev/null", fname);306 mr_asprintf(&command, "which %s 2> /dev/null", fname); 306 307 incoming = call_program_and_get_last_line_of_output(command); 307 paranoid_free(command);308 mr_free(command); 308 309 309 310 if (incoming == NULL) { … … 311 312 return (NULL); // forget it :) 312 313 } 313 asprintf(&command,314 mr_asprintf(&command, 314 315 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", 315 316 incoming); 316 paranoid_free(incoming);317 mr_free(incoming); 317 318 318 319 incoming = call_program_and_get_last_line_of_output(command); 319 paranoid_free(command);320 mr_free(command); 320 321 } 321 322 if (incoming == NULL) // yes, it is == '\0' twice, not once :) 322 323 { 323 asprintf(&command, "dirname %s 2> /dev/null", incoming);324 paranoid_free(incoming);324 mr_asprintf(&command, "dirname %s 2> /dev/null", incoming); 325 mr_free(incoming); 325 326 326 327 incoming = call_program_and_get_last_line_of_output(command); 327 paranoid_free(command);328 mr_free(command); 328 329 } 329 330 output = incoming; … … 332 333 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output); 333 334 } else { 334 paranoid_free(output);335 mr_free(output); 335 336 log_msg(4, "find_home_of_exe() --- Could not find %s", fname); 336 337 } … … 395 396 && !strstr(err_log_lines[i], "% done"); i--); 396 397 if (i < 0) { 397 asprintf(&command,398 mr_asprintf(&command, 398 399 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", 399 400 filename, '%'); 400 401 lastline = call_program_and_get_last_line_of_output(command); 401 paranoid_free(command);402 mr_free(command); 402 403 if (!lastline) { 403 404 return (0); 404 405 } 405 406 } else { 406 asprintf(&lastline, err_log_lines[i]);407 mr_asprintf(&lastline, err_log_lines[i]); 407 408 } 408 409 … … 412 413 } 413 414 if (!p) { 414 paranoid_free(lastline);415 mr_free(lastline); 415 416 return (0); 416 417 } … … 421 422 } 422 423 i = atoi(p); 423 paranoid_free(lastline);424 mr_free(lastline); 424 425 425 426 return (i); … … 447 448 448 449 if (!does_file_exist(filename)) { 449 asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),450 mr_asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"), 450 451 filename); 451 452 log_it(tmp); 452 paranoid_free(tmp);453 mr_free(tmp); 453 454 return (NULL); 454 455 } 455 asprintf(&command, "tail -n1 %s", filename);456 mr_asprintf(&command, "tail -n1 %s", filename); 456 457 fin = popen(command, "r"); 457 paranoid_free(command);458 459 getline(&output, &n, fin);458 mr_free(command); 459 460 mr_getline(&output, &n, fin); 460 461 paranoid_pclose(fin); 461 462 while (strlen(output) > 0 && output[strlen(output) - 1] < 32) { … … 504 505 505 506 assert_string_is_neither_NULL_nor_zerolength(outdir_fname); 506 asprintf(&tmp, "mkdir -p %s", outdir_fname);507 mr_asprintf(&tmp, "mkdir -p %s", outdir_fname); 507 508 res = system(tmp); 508 paranoid_free(tmp);509 mr_free(tmp); 509 510 return (res); 510 511 } … … 532 533 assert(!strstr(outfile_fname, "/dev/cdrom")); 533 534 534 asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);535 mr_asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname); 535 536 res += system(command); 536 paranoid_free(command);537 538 asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);537 mr_free(command); 538 539 mr_asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname); 539 540 res += system(command); 540 paranoid_free(command);541 542 asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);541 mr_free(command); 542 543 mr_asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname); 543 544 res += system(command); 544 paranoid_free(command);545 mr_free(command); 545 546 unlink(outfile_fname); 546 547 return (0); … … 575 576 return (0); 576 577 } 577 (void)getline(&incoming, &n, fin);578 mr_getline(&incoming, &n, fin); 578 579 while (!feof(fin)) { 579 580 if (strstr(incoming, wildcard)) { 580 581 matches++; 581 582 } 582 (void)getline(&incoming, &n, fin);583 mr_getline(&incoming, &n, fin); 583 584 } 584 585 paranoid_fclose(fin); 585 paranoid_free(incoming);586 mr_free(incoming); 586 587 return (matches); 587 588 } … … 603 604 FILE *fin; 604 605 605 asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);606 mr_asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str); 606 607 if (!pid) { 607 608 log_it("Unregistering PID"); … … 609 610 log_it("Error unregistering PID"); 610 611 } 611 paranoid_free(lockfile_fname);612 mr_free(lockfile_fname); 612 613 return; 613 614 } 614 615 if (does_file_exist(lockfile_fname)) { 615 616 if ((fin = fopen(lockfile_fname, "r"))) { 616 (void)getline(&tmp, &n, fin);617 mr_getline(&tmp, &n, fin); 617 618 paranoid_fclose(fin); 618 619 } else { … … 620 621 } 621 622 pid = (pid_t) atol(tmp); 622 paranoid_free(tmp);623 624 asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);623 mr_free(tmp); 624 625 mr_asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid); 625 626 res = system(tmp); 626 paranoid_free(tmp);627 mr_free(tmp); 627 628 if (!res) { 628 629 log_it … … 631 632 } 632 633 } 633 asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),634 mr_asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(), 634 635 lockfile_fname); 635 paranoid_free(lockfile_fname);636 mr_free(lockfile_fname); 636 637 637 638 if (system(tmp)) { 638 639 fatal_error("Cannot register PID"); 639 640 } 640 paranoid_free(tmp);641 mr_free(tmp); 641 642 return; 642 643 } … … 655 656 long file_len_K = 0L; 656 657 657 asprintf(&command,658 mr_asprintf(&command, 658 659 "grep '%s ' %s/mountlist.txt | head -n1 | awk '{print $4;}'", 659 660 dev, tmpdir); … … 662 663 file_len_K = atol(sz_res); 663 664 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K); 664 paranoid_free(command);665 paranoid_free(sz_res);665 mr_free(command); 666 mr_free(sz_res); 666 667 return (file_len_K); 667 668 } … … 692 693 693 694 log_it("Calculating size of all biggiefiles (in total)"); 694 asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);695 mr_asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir); 695 696 log_it("biggielist = %s", biggielist); 696 697 if (!(fin = fopen(biggielist, "r"))) { … … 699 700 } else { 700 701 log_msg(4, "Reading it..."); 701 for ( getline(&fname, &n, fin); !feof(fin);702 getline(&fname, &n, fin)) {702 for (mr_getline(&fname, &n, fin); !feof(fin); 703 mr_getline(&fname, &n, fin)) { 703 704 if (fname[strlen(fname) - 1] <= 32) { 704 705 fname[strlen(fname) - 1] = '\0'; … … 710 711 fatal_error("ntfsresize not found"); 711 712 } 712 paranoid_free(tmp);713 714 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);713 mr_free(tmp); 714 715 mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 715 716 log_it("command = %s", command); 716 717 tmp = call_program_and_get_last_line_of_output(command); 717 paranoid_free(command);718 mr_free(command); 718 719 719 720 log_it("res of it = %s", tmp); 720 721 file_len_K = atoll(tmp) / 1024L; 721 paranoid_free(tmp);722 mr_free(tmp); 722 723 } else { 723 724 file_len_K = get_phys_size_of_drive(fname) * 1024L; … … 731 732 log_msg(4, "%s --> %ld K", fname, file_len_K); 732 733 } 733 asprintf(&comment,734 mr_asprintf(&comment, 734 735 "After adding %s, scratchL+%ld now equals %ld", fname, 735 736 file_len_K, scratchL); 736 737 log_msg(4, comment); 737 paranoid_free(comment);738 mr_free(comment); 738 739 739 740 if (feof(fin)) { … … 741 742 } 742 743 } 743 paranoid_free(fname);744 } 745 paranoid_free(biggielist);744 mr_free(fname); 745 } 746 mr_free(biggielist); 746 747 747 748 log_it("Closing..."); … … 771 772 /*@ end vars *************************************************** */ 772 773 773 asprintf(&command, "du -sk %s", mountpt);774 mr_asprintf(&command, "du -sk %s", mountpt); 774 775 errno = 0; 775 776 fin = popen(command, "r"); … … 778 779 llres = 0; 779 780 } else { 780 (void)getline(&tmp, &n, fin);781 mr_getline(&tmp, &n, fin); 781 782 paranoid_pclose(fin); 782 783 p = strchr(tmp, '\t'); … … 790 791 } 791 792 792 paranoid_free(command);793 paranoid_free(tmp);793 mr_free(command); 794 mr_free(tmp); 794 795 return (llres); 795 796 } … … 842 843 843 844 844 asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);845 mr_asprintf(&command, "which %s > /dev/null 2> /dev/null", fname); 845 846 res = system(command); 846 paranoid_free(command);847 mr_free(command); 847 848 848 849 if (res) { 849 asprintf(&errorstr,850 mr_asprintf(&errorstr, 850 851 _("Please install '%s'. I cannot find it on your system."), 851 852 fname); 852 853 log_to_screen(errorstr); 853 paranoid_free(errorstr);854 mr_free(errorstr); 854 855 log_to_screen 855 856 (_("There may be an hyperlink at http://www.mondorescue.org which")); … … 949 950 log_msg(4, "g_mondo_home='%s'", g_mondo_home); 950 951 if ((g_mondo_home == NULL) || strlen(g_mondo_home) < 2) { 951 paranoid_free(g_mondo_home);952 mr_free(g_mondo_home); 952 953 g_mondo_home = find_and_store_mondoarchives_home(); 953 954 } 954 asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,955 mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, 955 956 bkpinfo->scratchdir); 956 957 … … 959 960 fatal_error("Failed to copy Mondo's stuff to scratchdir"); 960 961 } 961 paranoid_free(command);962 963 asprintf(&tmp, "%s/payload.tgz", g_mondo_home);962 mr_free(command); 963 964 mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home); 964 965 965 966 /* i18n */ 966 asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);967 mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir); 967 968 log_msg(4, "command = %s", command); 968 969 run_program_and_log_output(command, 1); 969 paranoid_free(command);970 mr_free(command); 970 971 971 972 if (does_file_exist(tmp)) { … … 974 975 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 975 976 chdir(bkpinfo->scratchdir); 976 asprintf(&command, "tar -zxvf %s", tmp);977 mr_asprintf(&command, "tar -zxvf %s", tmp); 977 978 if (run_program_and_log_output(command, FALSE)) { 978 979 fatal_error("Failed to untar payload"); 979 980 } 980 paranoid_free(command);981 mr_free(command); 981 982 chdir(old_pwd); 982 983 } 983 paranoid_free(tmp);984 985 asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,984 mr_free(tmp); 985 986 mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, 986 987 bkpinfo->scratchdir); 987 988 if (run_program_and_log_output(command, FALSE)) { 988 989 fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir"); 989 990 } 990 paranoid_free(command);991 mr_free(command); 991 992 992 993 tmp = call_program_and_get_last_line_of_output("which mondorestore"); … … 995 996 ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?"); 996 997 } 997 asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);998 paranoid_free(tmp);998 mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir); 999 mr_free(tmp); 999 1000 1000 1001 if (run_program_and_log_output(command, FALSE)) { 1001 1002 fatal_error("Failed to copy mondorestore to tmpdir"); 1002 1003 } 1003 paranoid_free(command);1004 1005 asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);1004 mr_free(command); 1005 1006 mr_asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir); 1006 1007 paranoid_system(command); 1007 paranoid_free(command);1008 mr_free(command); 1008 1009 1009 1010 if (bkpinfo->postnuke_tarball) { 1010 asprintf(&command, "cp -f %s %s/post-nuke.tgz",1011 mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", 1011 1012 bkpinfo->postnuke_tarball, bkpinfo->tmpdir); 1012 1013 if (run_program_and_log_output(command, FALSE)) { 1013 1014 fatal_error("Unable to copy post-nuke tarball to tmpdir"); 1014 1015 } 1015 paranoid_free(command);1016 mr_free(command); 1016 1017 } 1017 1018 … … 1047 1048 1048 1049 log_it("Storing NFS configuration"); 1049 asprintf(&tmp, bkpinfo->nfs_mount);1050 mr_asprintf(&tmp, bkpinfo->nfs_mount); 1050 1051 p = strchr(tmp, ':'); 1051 1052 if (!p) { … … 1054 1055 } 1055 1056 *(p++) = '\0'; 1056 asprintf(&nfs_server_ipaddr, tmp);1057 paranoid_free(tmp);1058 1059 asprintf(&nfs_mount, p);1057 mr_asprintf(&nfs_server_ipaddr, tmp); 1058 mr_free(tmp); 1059 1060 mr_asprintf(&nfs_mount, p); 1060 1061 /* BERLIOS : there is a bug #67 here as it only considers the first NIC */ 1061 asprintf(&command,1062 mr_asprintf(&command, 1062 1063 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1063 1064 nfs_dev = call_program_and_get_last_line_of_output(command); 1064 paranoid_free(command);1065 1066 asprintf(&command,1065 mr_free(command); 1066 1067 mr_asprintf(&command, 1067 1068 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1068 1069 nfs_client_ipaddr = call_program_and_get_last_line_of_output(command); 1069 paranoid_free(command);1070 1071 asprintf(&command,1070 mr_free(command); 1071 1072 mr_asprintf(&command, 1072 1073 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1073 1074 nfs_client_netmask = call_program_and_get_last_line_of_output(command); 1074 paranoid_free(command);1075 1076 asprintf(&command,1075 mr_free(command); 1076 1077 mr_asprintf(&command, 1077 1078 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1078 1079 nfs_client_broadcast = call_program_and_get_last_line_of_output(command); 1079 paranoid_free(command);1080 1081 asprintf(&command,1080 mr_free(command); 1081 1082 mr_asprintf(&command, 1082 1083 "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1083 1084 nfs_client_defgw = call_program_and_get_last_line_of_output(command); 1084 paranoid_free(command);1085 1086 asprintf(&tmp,1085 mr_free(command); 1086 1087 mr_asprintf(&tmp, 1087 1088 "nfs_client_ipaddr=%s; nfs_client_netmask=%s; nfs_server_ipaddr=%s; nfs_mount=%s; nfs_client_defgw=%s; ", 1088 1089 nfs_client_ipaddr, nfs_client_netmask, nfs_server_ipaddr, nfs_mount, nfs_client_defgw); 1089 paranoid_free(nfs_mount);1090 mr_free(nfs_mount); 1090 1091 log_it(tmp); 1091 paranoid_free(tmp);1092 mr_free(tmp); 1092 1093 1093 1094 if (strlen(nfs_dev) < 2) { … … 1107 1108 if (!strncmp(nfs_dev, "bond", 4)) { 1108 1109 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev); 1109 asprintf(&command,1110 mr_asprintf(&command, 1110 1111 "ifconfig %s | awk '{print $5}'", nfs_dev); 1111 1112 mac_addr = call_program_and_get_last_line_of_output(command); 1112 asprintf(&command,1113 mr_asprintf(&command, 1113 1114 "ifconfig | grep -E '%s' | head -n1 | cut -d' ' -f1", mac_addr); 1114 paranoid_free(nfs_dev);1115 mr_free(nfs_dev); 1115 1116 nfs_dev = call_program_and_get_last_line_of_output(command); 1116 paranoid_free(command);1117 paranoid_free(mac_addr);1117 mr_free(command); 1118 mr_free(mac_addr); 1118 1119 1119 1120 log_to_screen("Replacing it with %s\n", nfs_dev); 1120 1121 } 1121 1122 1122 asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);1123 mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir); 1123 1124 write_one_liner_data_file(tmp, nfs_dev); 1124 paranoid_free(nfs_dev);1125 paranoid_free(tmp);1126 1127 asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);1125 mr_free(nfs_dev); 1126 mr_free(tmp); 1127 1128 mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir); 1128 1129 write_one_liner_data_file(tmp, nfs_client_ipaddr); 1129 paranoid_free(nfs_client_ipaddr);1130 paranoid_free(tmp);1131 1132 asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);1130 mr_free(nfs_client_ipaddr); 1131 mr_free(tmp); 1132 1133 mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir); 1133 1134 write_one_liner_data_file(tmp, nfs_client_netmask); 1134 paranoid_free(nfs_client_netmask);1135 paranoid_free(tmp);1136 1137 asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);1135 mr_free(nfs_client_netmask); 1136 mr_free(tmp); 1137 1138 mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir); 1138 1139 write_one_liner_data_file(tmp, nfs_client_defgw); 1139 paranoid_free(nfs_client_defgw);1140 paranoid_free(tmp);1141 1142 asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);1140 mr_free(nfs_client_defgw); 1141 mr_free(tmp); 1142 1143 mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir); 1143 1144 write_one_liner_data_file(tmp, nfs_client_broadcast); 1144 paranoid_free(nfs_client_broadcast);1145 paranoid_free(tmp);1146 1147 asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);1145 mr_free(nfs_client_broadcast); 1146 mr_free(tmp); 1147 1148 mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir); 1148 1149 write_one_liner_data_file(tmp, nfs_server_ipaddr); 1149 paranoid_free(nfs_server_ipaddr);1150 paranoid_free(tmp);1151 1152 asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);1150 mr_free(nfs_server_ipaddr); 1151 mr_free(tmp); 1152 1153 mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir); 1153 1154 write_one_liner_data_file(tmp, bkpinfo->nfs_mount); 1154 paranoid_free(tmp);1155 1156 asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);1155 mr_free(tmp); 1156 1157 mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir); 1157 1158 write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir); 1158 paranoid_free(tmp);1159 1160 asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);1159 mr_free(tmp); 1160 1161 mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 1161 1162 write_one_liner_data_file(tmp, bkpinfo->prefix); 1162 paranoid_free(tmp);1163 mr_free(tmp); 1163 1164 1164 1165 log_it("Finished storing NFS configuration"); … … 1211 1212 } 1212 1213 if (scratchLL <= 1) { 1213 asprintf(&tmp,1214 mr_asprintf(&tmp, 1214 1215 _("Your backup will probably occupy a single %s. Maybe two."), 1215 1216 bkpinfo->backup_media_string); 1216 1217 } else { 1217 asprintf(&tmp, _("Your backup will occupy approximately %s media."),1218 mr_asprintf(&tmp, _("Your backup will occupy approximately %s media."), 1218 1219 number_to_text((int) (scratchLL + 1))); 1219 1220 } … … 1221 1222 log_to_screen(tmp); 1222 1223 } 1223 paranoid_free(tmp);1224 mr_free(tmp); 1224 1225 return; 1225 1226 } … … 1238 1239 char *p = NULL; 1239 1240 1240 asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);1241 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 1241 1242 if (!does_file_exist(tmp)) { 1242 paranoid_free(tmp);1243 mr_free(tmp); 1243 1244 return (FALSE); 1244 1245 } 1245 paranoid_free(tmp);1246 mr_free(tmp); 1246 1247 1247 1248 do_not_compress_these = last_line_of_file(tmp); 1248 1249 for (p = do_not_compress_these; p != NULL; p++) { 1249 asprintf(&tmp, p);1250 mr_asprintf(&tmp, p); 1250 1251 if (strchr(tmp, ' ')) { 1251 1252 *(strchr(tmp, ' ')) = '\0'; 1252 1253 } 1253 1254 if (!strcmp(strrchr(filename, '.'), tmp)) { 1254 paranoid_free(do_not_compress_these);1255 paranoid_free(tmp);1255 mr_free(do_not_compress_these); 1256 mr_free(tmp); 1256 1257 return (TRUE); 1257 1258 } 1258 paranoid_free(tmp);1259 mr_free(tmp); 1259 1260 1260 1261 if (!(p = strchr(p, ' '))) { … … 1262 1263 } 1263 1264 } 1264 paranoid_free(do_not_compress_these);1265 mr_free(do_not_compress_these); 1265 1266 return (FALSE); 1266 1267 } … … 1296 1297 paranoid_fclose(fout); 1297 1298 log_msg(2, "Created %s", outfile); 1298 asprintf(&tmp, "chmod +x %s", outfile);1299 mr_asprintf(&tmp, "chmod +x %s", outfile); 1299 1300 paranoid_system(tmp); 1300 paranoid_free(tmp);1301 mr_free(tmp); 1301 1302 1302 1303 retval = 0; … … 1308 1309 1309 1310 /* @} - end fileGroup */ 1310 1311 void paranoid_alloc(char *alloc, char *orig)1312 {1313 paranoid_free(alloc);1314 asprintf(&alloc, orig);1315 }1316
Note:
See TracChangeset
for help on using the changeset viewer.