Changeset 3866 in MondoRescue for branches/3.3/mondo/src/mondorestore
- Timestamp:
- Mar 7, 2024, 1:55:18 PM (2 years ago)
- Location:
- branches/3.3/mondo/src/mondorestore
- Files:
-
- 5 edited
-
mondo-prep.c (modified) (2 diffs)
-
mondo-rstr-compare.c (modified) (4 diffs)
-
mondo-rstr-tools.c (modified) (9 diffs)
-
mondo-rstr-tools.h (modified) (1 diff)
-
mondorestore.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/mondorestore/mondo-prep.c
r3859 r3866 201 201 log_it("STARTING"); 202 202 log_msg(1, "OK, opened i-want-my-lvm. Shutting down LVM volumes..."); 203 if ( find_home_of_exe("lvm")) { // found it :) cool204 mr_asprintf(lvscan_sz, " lvm lvscan");205 mr_asprintf(lvremove_sz, " lvm lvremove");206 mr_asprintf(vgscan_sz, " lvm vgscan");207 mr_asprintf(pvscan_sz, " lvm pvscan");208 mr_asprintf(vgchange_sz, " lvm vgchange");209 mr_asprintf(vgremove_sz, " lvm vgremove -f");203 if ((tmp = find_home_of_exe("lvm")) != NULL) { // found it :) cool 204 mr_asprintf(lvscan_sz, "%s lvscan", tmp); 205 mr_asprintf(lvremove_sz, "%s lvremove", tmp); 206 mr_asprintf(vgscan_sz, "%s vgscan", tmp); 207 mr_asprintf(pvscan_sz, "%s pvscan", tmp); 208 mr_asprintf(vgchange_sz, "%s vgchange", tmp); 209 mr_asprintf(vgremove_sz, "%s vgremove -f", tmp); 210 210 } else { 211 211 mr_asprintf(lvscan_sz, "lvscan"); … … 216 216 mr_asprintf(vgremove_sz, "vgremove"); 217 217 } 218 mr_free(tmp); 219 218 220 mr_asprintf(cmd, "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); 219 221 mr_free(lvscan_sz); -
branches/3.3/mondo/src/mondorestore/mondo-rstr-compare.c
r3822 r3866 259 259 260 260 if (compressor_exe) { 261 mr_asprintf(tmp, "%s", compressor_exe); 262 if (!find_home_of_exe(tmp)) { 261 if ((tmp = find_home_of_exe(compressor_exe)) == NULL) { 263 262 mr_free(tmp); 264 263 mr_free(compressor_exe); … … 266 265 fatal_error("(compare_a_tarball) Compression program missing"); 267 266 } 268 mr_free(tmp);269 267 270 268 if (use_star) { … … 278 276 } else { 279 277 // afio 280 mr_asprintf(tmp, "%s", compressor_exe);281 mr_free(compressor_exe);282 278 mr_asprintf(compressor_exe, "-P %s -Z", tmp); 283 mr_free(tmp);284 }279 } 280 mr_free(tmp); 285 281 } 286 282 … … 541 537 if (g_text_mode) { 542 538 save_mountlist_to_disk(mountlist, g_mountlist_fname); 543 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname); 544 res = system(tmp); 539 tmp = find_my_editor(); 540 res = mr_system("%s %s", tmp, g_mountlist_fname); 541 mr_free(tmp); 545 542 load_mountlist(mountlist, g_mountlist_fname); 546 543 } else { -
branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c
r3854 r3866 405 405 /** malloc **/ 406 406 char *tmp = NULL; 407 char *tmp1 = NULL; 407 408 char *command = NULL; 408 409 char *mountdir = NULL; … … 437 438 mr_strcat(additional_parameters, "-o ro"); 438 439 } 439 if ( find_home_of_exe("setfattr")) {440 if ((tmp = find_home_of_exe("setfattr")) != NULL) { 440 441 mr_strcat(additional_parameters, ",user_xattr"); 441 442 } 442 if (find_home_of_exe("setfacl")) { 443 mr_free(tmp); 444 if ((tmp = find_home_of_exe("setfacl")) != NULL) { 443 445 mr_strcat(additional_parameters, ",acl"); 444 446 } 447 mr_free(tmp); 445 448 } 446 449 … … 780 783 read_cfg_var(cfg_file, "acl", value); 781 784 if (strstr(value, "TRUE")) { 782 mr_asprintf(g_getfacl,"setfacl"); 783 log_msg(1, "We will restore ACLs"); 784 if (! find_home_of_exe("setfacl")) { 785 if ((tmp = find_home_of_exe("setfacl")) == NULL) { 785 786 log_msg(1, "Unable to restore ACLs as no setfacl found"); 786 } 787 } else { 788 mr_asprintf(g_getfacl,"%s", tmp); 789 log_msg(1, "We will restore ACLs"); 790 } 791 mr_free(tmp); 787 792 } 788 793 read_cfg_var(cfg_file, "xattr", value); 789 794 if (strstr(value, "TRUE")) { 790 mr_asprintf(g_getfattr,"setfattr"); 791 log_msg(1, "We will restore XATTRs"); 792 if (! find_home_of_exe("setfattr")) { 795 if ((tmp = find_home_of_exe("setfattr")) == NULL) { 793 796 log_msg(1, "Unable to restore XATTRs as no setfattr found"); 794 } 797 } else { 798 mr_asprintf(g_getfattr,"%s", tmp); 799 log_msg(1, "We will restore XATTRs"); 800 } 801 mr_free(tmp); 795 802 } 796 803 … … 1390 1397 * Attempt to find the user's editor. 1391 1398 * @return The editor found ("vi" if none could be found). 1392 * @note The returned string points to static storage that will be overwritten with each call.1399 * @note The returned string points to an allocated storage that needs to be freed by caller 1393 1400 */ 1394 1401 char *find_my_editor(void) { 1395 1402 1396 static char output[MAX_STR_LEN]; 1397 if (find_home_of_exe("pico")) { 1398 strcpy(output, "pico"); 1399 } else if (find_home_of_exe("nano")) { 1400 strcpy(output, "nano"); 1401 } else if (find_home_of_exe("e3em")) { 1402 strcpy(output, "e3em"); 1403 } else if (find_home_of_exe("e3vi")) { 1404 strcpy(output, "e3vi"); 1405 } else { 1406 strcpy(output, "vi"); 1407 } 1408 if (!find_home_of_exe(output)) { 1409 log_msg(2, " (find_my_editor) --- warning - %s not found", output); 1403 char *output = NULL ; 1404 1405 if ((output = find_home_of_exe("pico")) == NULL) { 1406 if ((output = find_home_of_exe("nano")) == NULL) { 1407 if ((output = find_home_of_exe("e3em")) == NULL) { 1408 if ((output = find_home_of_exe("e3vi")) == NULL) { 1409 if ((output = find_home_of_exe("vim")) == NULL) { 1410 output = find_home_of_exe("vi"); 1411 } 1412 } 1413 } 1414 } 1415 } 1416 if (output == NULL) { 1417 log_msg(2, " (find_my_editor) --- warning - no editor found, even vi"); 1410 1418 } 1411 1419 return (output); … … 1459 1467 popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1460 1468 } 1461 if (!g_text_mode) { 1462 newtSuspend(); 1469 editor = find_my_editor()); 1470 if (editor == NULL) { 1471 popup_and_OK("No editor found. You won't be able to edit conf files"); 1472 } else { 1473 if (!g_text_mode) { 1474 newtSuspend(); 1475 } 1476 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1477 paranoid_system(tmp); 1478 mr_free(tmp); 1479 1480 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1481 paranoid_system(tmp); 1482 mr_free(tmp); 1483 1484 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) { 1485 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1486 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1487 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1488 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) { 1489 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor); 1490 } 1491 paranoid_system(tmp); 1492 mr_free(tmp); 1493 1494 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) { 1495 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1496 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) { 1497 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor); 1498 } 1499 paranoid_system(tmp); 1500 mr_free(tmp); 1501 if (!g_text_mode) { 1502 newtResume(); 1503 } 1463 1504 } 1464 mr_asprintf(editor, "%s", find_my_editor());1465 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1466 paranoid_system(tmp);1467 mr_free(tmp);1468 1469 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);1470 paranoid_system(tmp);1471 mr_free(tmp);1472 1473 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {1474 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);1475 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {1476 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);1477 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {1478 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);1479 }1480 paranoid_system(tmp);1481 mr_free(tmp);1482 1483 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {1484 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);1485 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {1486 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);1487 }1488 paranoid_system(tmp);1489 mr_free(tmp);1490 1505 mr_free(editor); 1491 1506 1492 if (!g_text_mode) {1493 newtResume();1494 }1495 1507 mr_asprintf(command, "mr-stabgrub-me %s", boot_device); 1496 1508 res = run_program_and_log_output(command, 1); … … 1587 1599 1588 1600 if (res) { 1589 popup_and_OK 1590 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist."); 1601 popup_and_OK("You will now edit fstab and elilo.conf, to make sure they match your new mountlist."); 1591 1602 for (done = FALSE; !done;) { 1592 if (!g_text_mode) { 1593 newtSuspend(); 1603 editor = find_my_editor(); 1604 if (editor == NULL) { 1605 popup_and_OK("No editor found. You won't be able to edit conf files"); 1606 done = TRUE; 1607 } else { 1608 1609 if (!g_text_mode) { 1610 newtSuspend(); 1611 } 1612 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1613 paranoid_system(tmp); 1614 mr_free(tmp); 1615 1616 mr_asprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor); 1617 paranoid_system(tmp); 1618 mr_free(tmp); 1619 mr_free(editor); 1620 1621 if (!g_text_mode) { 1622 newtResume(); 1623 } 1624 // newtCls(); 1625 if (ask_me_yes_or_no("Edit them again?")) { 1626 continue; 1627 } 1628 done = TRUE; 1594 1629 } 1595 mr_asprintf(editor, "%s", find_my_editor());1596 1597 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);1598 paranoid_system(tmp);1599 mr_free(tmp);1600 1601 mr_asprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);1602 paranoid_system(tmp);1603 mr_free(tmp);1604 1630 mr_free(editor); 1605 1606 if (!g_text_mode) {1607 newtResume();1608 }1609 // newtCls();1610 if (ask_me_yes_or_no("Edit them again?")) {1611 continue;1612 }1613 done = TRUE;1614 1631 } 1615 1632 } else { … … 1666 1683 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."); 1667 1684 for (done = FALSE; !done;) { 1668 if (!g_text_mode) { 1669 newtSuspend(); 1685 editor = find_my_editor(); 1686 if (editor == NULL) { 1687 popup_and_OK("No editor found. You won't be able to edit conf files"); 1688 } else { 1689 if (!g_text_mode) { 1690 newtSuspend(); 1691 } 1692 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1693 paranoid_system(tmp); 1694 mr_free(tmp); 1695 1696 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1697 paranoid_system(tmp); 1698 mr_free(tmp); 1699 mr_free(editor); 1700 1701 if (!g_text_mode) { 1702 newtResume(); 1703 } 1704 // newtCls(); 1705 if (ask_me_yes_or_no("Edit them again?")) { 1706 continue; 1707 } 1670 1708 } 1671 mr_asprintf(editor, "%s", find_my_editor());1672 1673 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1674 paranoid_system(tmp);1675 mr_free(tmp);1676 1677 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);1678 paranoid_system(tmp);1679 mr_free(tmp);1680 1709 mr_free(editor); 1681 1710 1682 if (!g_text_mode) { 1683 newtResume(); 1684 } 1685 // newtCls(); 1686 if (ask_me_yes_or_no("Edit them again?")) { 1687 continue; 1688 } 1689 res = 1690 run_program_and_log_output("chroot " MNT_RESTORING 1691 " lilo -L", 3); 1711 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", 3); 1692 1712 if (res) { 1693 res = 1694 run_program_and_log_output("chroot " MNT_RESTORING 1695 " lilo", 3); 1713 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo", 3); 1696 1714 } 1697 1715 if (res) { 1698 done = 1699 ask_me_yes_or_no 1700 ("LILO failed. Re-edit system files?"); 1716 done = ask_me_yes_or_no("LILO failed. Re-edit system files?"); 1701 1717 } else { 1702 1718 done = TRUE; … … 1768 1784 mvaddstr_and_log_it(g_currentY, 0, "Modifying fstab and restoring MBR... "); 1769 1785 for (done = FALSE; !done;) { 1770 if (!run_program_and_log_output("which vi", FALSE)) { 1771 popup_and_OK("You will now edit fstab"); 1786 popup_and_OK("You will now edit fstab"); 1787 editor = find_my_editor()); 1788 if (editor == NULL) { 1789 popup_and_OK("No editor found. You won't be able to edit conf files"); 1790 } else { 1772 1791 if (!g_text_mode) { 1773 1792 newtSuspend(); 1774 1793 } 1775 mr_asprintf(editor, "%s", find_my_editor());1776 1794 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1777 mr_free(editor);1778 1795 1779 1796 paranoid_system(tmp); … … 1783 1800 } 1784 1801 } 1802 mr_free(editor); 1803 1785 1804 popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device, MAX_STR_LEN / 4); 1786 1805 mr_asprintf(command, "mr-stabraw-me %s", boot_device); -
branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.h
r2682 r3866 20 20 int run_elilo(bool); 21 21 int run_raw_mbr(bool offer_to_hack_scripts, char *bd); 22 char *find_my_editor(void);23 22 void streamline_changes_file(char *, char *); 24 23 void set_signals(int on); -
branches/3.3/mondo/src/mondorestore/mondorestore.c
r3862 r3866 207 207 mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path); 208 208 (void)unlink(tmp1); 209 paranoid_free(tmp1);209 mr_free(tmp1); 210 210 211 211 /* Edit multipath.conf if needed to adapt wwid */ … … 214 214 log_msg(2, "We may need to clean /etc/multipath.conf"); 215 215 } else { 216 paranoid_free(tmp1);216 mr_free(tmp1); 217 217 return; 218 218 } 219 paranoid_free(tmp1);219 mr_free(tmp1); 220 220 221 221 if (bkpinfo->restore_mode != nuke) { 222 mr_asprintf(editor, "%s", find_my_editor());222 editor = find_my_editor(); 223 223 mr_asprintf(tmp1,"chroot %s %s /etc/multipath.conf", MNT_RESTORING, editor); 224 224 popup_and_OK("You will now edit multipath.conf"); … … 230 230 newtResume(); 231 231 } 232 paranoid_free(tmp1);233 paranoid_free(editor);232 mr_free(tmp1); 233 mr_free(editor); 234 234 } else { 235 235 log_to_screen("Non-interactive mode: no way to give you the keyboard so that you edit your multipath.conf. Hope it's OK"); … … 1767 1767 1768 1768 log_msg(1, "restoring everything"); 1769 if ( !find_home_of_exe("petris") && !g_text_mode) {1769 if (((tmp = find_home_of_exe("petris")) != NULL) && !g_text_mode) { 1770 1770 newtDrawRootText(0, g_noof_rows - 2, 1771 1771 "Press ALT-<left cursor> twice to play Petris :-) "); 1772 1772 newtRefresh(); 1773 1773 } 1774 mr_free(tmp); 1774 1775 mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives"); 1775 1776 mount_media(); … … 1842 1843 1843 1844 /** needs malloc **********/ 1845 char *tmp = NULL; 1844 1846 char *tmp1 = NULL; 1845 1847 char *fstab_fname = NULL; … … 1881 1883 if (g_text_mode) { 1882 1884 save_mountlist_to_disk(mountlist, g_mountlist_fname); 1883 mr_asprintf(tmp1, "%s %s", find_my_editor(), g_mountlist_fname); 1885 tmp = find_my_editor(); 1886 mr_asprintf(tmp1, "%s %s", tmp, g_mountlist_fname); 1887 mr_free(tmp); 1884 1888 res = system(tmp1); 1885 1889 mr_free(tmp1);
Note:
See TracChangeset
for help on using the changeset viewer.
