source: MondoRescue/branches/3.2/mondo/src/mondorestore/mondo-rstr-tools.c@ 3613

Last change on this file since 3613 was 3613, checked in by Bruno Cornec, 7 years ago

Add function mr_getcwd and use it to allow use o dynamically allocated memory
instead of getcwd

  • Property svn:keywords set to Id
File size: 74.4 KB
Line 
1/***************************************************************************
2$Id: mondo-rstr-tools.c 3613 2016-11-18 16:31:42Z bruno $
3***************************************************************************/
4
5#include <pthread.h>
6#include <linux/fd.h>
7#include "my-stuff.h"
8#include "mr_mem.h"
9#include "mr_str.h"
10#include "mr_file.h"
11#include "../common/mondostructures.h"
12#include "../common/libmondo.h"
13#include "mr-externs.h"
14#include "mondo-rstr-tools.h"
15#include "libmondo-mountlist-EXT.h"
16
17/**
18 * The biggielist stub (appended to the directory where all.tar.gz was unpacked).
19 */
20#define BIGGIELIST_TXT_STUB "tmp/biggielist.txt"
21
22/**
23 * The filelist stub (appended to the directory where all.tar.gz was unpacked).
24 */
25#define FILELIST_FULL_STUB "tmp/filelist.full.gz"
26
27/**
28 * The mountlist stub (appended to the directory where all.tar.gz was unpacked).
29 */
30#define MOUNTLIST_FNAME_STUB "tmp/mountlist.txt"
31
32/**
33 * The mondorestore.cfg stub (appended to the directory where all.tar.gz was unpacked).
34 */
35#define MONDO_CFG_FILE_STUB "tmp/mondorestore.cfg"
36/**
37 * The i-want-my-lvm stub
38 */
39#define IWANTMYLVM_STUB "tmp/i-want-my-lvm"
40
41extern bool g_ISO_restore_mode; /* are we in Iso Mode? */
42extern bool g_I_have_just_nuked;
43/*
44extern char *g_tmpfs_mountpt;
45*/
46
47/**
48 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode.
49 */
50char *g_isodir_device;
51
52
53/**
54 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode.
55 */
56char *g_isodir_format;
57
58extern long g_current_progress, g_maximum_progress;
59extern char *g_biggielist_txt; // where 'biggielist.txt' is stored, on ramdisk / tempdir;
60 // biggielist.txt is the list of big files stored on the
61 // backup media set in question
62extern char *g_filelist_full; // filelist.full.gz is the list of all regular files
63 // (excluding big files) stored on the backup media set
64extern char *g_biggielist_pot; // list of big files which _could_ be restored, if the
65 // user chooses them
66extern char *g_filelist_imagedevs; // list of devices (e.g. /dev/hda1, /dev/sda5) which
67 // were archived as images, not just /dev entries
68 // ... e.g. NTFS, BeOS partitions
69extern char *g_imagedevs_restthese; // of the imagedevs listed in FILELIST_IMAGEDEVS,
70 // restore only these
71extern char *g_mondo_cfg_file; // where mondorestore.cfg (the config file) is stored
72extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored
73extern char *g_mondo_home; // homedir of Mondo; usually /usr/local/share/mondo
74
75extern t_bkptype g_backup_media_type;
76
77extern int g_partition_table_locked_up;
78extern char *MONDO_LOGFILE;
79
80/* Reference to global bkpinfo */
81extern struct s_bkpinfo *bkpinfo;
82
83/* Should we use or not extended attributes and acl when restoring */
84char *g_getfattr = NULL;
85char *g_getfacl = NULL;
86
87extern void kill_anything_like_this(char *str);
88extern int skip_obdr(void);
89extern int mount_media();
90extern int set_tape_block_size_with_mt(long internal_tape_block_size);
91
92/**
93* @addtogroup restoreUtilityGroup
94* @{
95*/
96/**
97* Free the malloc()s for the filename variables.
98*/
99void free_MR_global_filenames(void)
100{
101paranoid_free(g_biggielist_txt);
102paranoid_free(g_filelist_full);
103paranoid_free(g_filelist_imagedevs);
104paranoid_free(g_imagedevs_restthese);
105paranoid_free(g_mondo_cfg_file);
106paranoid_free(g_mountlist_fname);
107paranoid_free(g_mondo_home);
108/*
109paranoid_free(g_tmpfs_mountpt);
110*/
111paranoid_free(g_isodir_device);
112paranoid_free(g_isodir_format);
113
114}
115
116
117
118/**
119* Ask the user which imagedevs from the list contained in @p infname should
120* actually be restored.
121* @param infname The file containing a list of all imagedevs.
122* @param outfname The location of the output file containing the imagedevs the user wanted to restore.
123* @ingroup restoreUtilityGroup
124*/
125void ask_about_these_imagedevs(char *infname, char *outfname) {
126
127FILE *fin;
128FILE *fout;
129char *incoming = NULL;
130char *p = NULL;
131char *question = NULL;
132
133assert_string_is_neither_NULL_nor_zerolength(infname);
134assert_string_is_neither_NULL_nor_zerolength(outfname);
135
136if (!(fin = fopen(infname, "r"))) {
137 fatal_error("Cannot openin infname");
138}
139if (!(fout = fopen(outfname, "w"))) {
140 fatal_error("Cannot openin outfname");
141}
142for (mr_getline(incoming, fin); !feof(fin) && (incoming != NULL); mr_getline(incoming, fin)) {
143 mr_strip_spaces(incoming);
144
145 if (incoming[0] == '\0') {
146 mr_free(incoming);
147 continue;
148 }
149
150 mr_asprintf(question, "Should I restore the image of %s ?", incoming);
151
152 if (ask_me_yes_or_no(question)) {
153 fprintf(fout, "%s\n", incoming);
154 }
155 mr_free(incoming);
156}
157mr_free(incoming);
158mr_free(question);
159paranoid_fclose(fout);
160paranoid_fclose(fin);
161}
162
163/**************************************************************************
164*ASK_ABOUT_THESE_IMAGEDEVS *
165**************************************************************************/
166
167
168
169
170
171
172
173
174/**
175* Extract @c mondorestore.cfg and @c mountlist.txt from @p ramdisk_fname.
176* @param bkpinfo The backup information structure. @c tmpdir is the only field used.
177* @param ramdisk_fname The filename of the @b compressed ramdisk to look in.
178* @param output_cfg_file Where to put the configuration file extracted.
179* @param output_mountlist_file Where to put the mountlist file extracted.
180* @return 0 for success, nonzero for failure.
181* @ingroup restoreUtilityGroup
182*/
183
184/**
185* Keep trying to get mondorestore.cfg from the archive, until the user gives up.
186*/
187void get_cfg_file_from_archive_or_bust()
188{
189while (get_cfg_file_from_archive()) {
190 if (!ask_me_yes_or_no("Failed to find config file/archives. Choose another source?")) {
191 fatal_error("Could not find config file/archives. Aborting.");
192 }
193 interactively_obtain_media_parameters_from_user(FALSE);
194 }
195}
196
197
198/**
199* Determine whether @p list_fname contains a line containing @p f.
200* @param f The line to search for.
201* @param list_fname The file to search in.
202* @param preamble Ignore this beginning part of @p f ("" to disable).
203* @return TRUE if it's in the list, FALSE if it's not.
204*/
205bool is_file_in_list(char *f, char *list_fname, char *preamble)
206{
207
208char *command = NULL;
209char *file = NULL;
210char *tmp = NULL;
211int res;
212
213assert_string_is_neither_NULL_nor_zerolength(f);
214assert_string_is_neither_NULL_nor_zerolength(list_fname);
215assert(preamble != NULL);
216
217if (strncmp(preamble, f, strlen(preamble)) == 0) {
218 mr_asprintf(file, "%s", f + strlen(preamble));
219} else {
220 mr_asprintf(file, "%s", f);
221}
222if (file[0] == '/' && file[1] == '/') {
223 tmp = file;
224
225 mr_asprintf(file, "%s", tmp + 1);
226 mr_free(tmp);
227}
228log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file);
229mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname);
230mr_free(file);
231
232res = run_program_and_log_output(command, FALSE);
233mr_free(command);
234if (res) {
235 return (FALSE);
236} else {
237 return (TRUE);
238}
239}
240
241/**************************************************************************
242*END_IS_FILE_IN_LIST *
243**************************************************************************/
244
245/**
246 * Get information about the location of ISO images from the user.
247 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters.
248 * @param isodir_format Where to put the format (e.g. ext2) the user enters.
249 * @param nuke_me_please Whether we're planning on nuking or not.
250 * @return TRUE if OK was pressed, FALSE otherwise.
251 */
252bool
253get_isodir_info(char *isodir_device, char *isodir_format,
254 struct s_bkpinfo *bkpinfo, bool nuke_me_please)
255{
256
257 bool HDD = FALSE;
258 /** initialize ********************************************************/
259
260 assert(isodir_device != NULL);
261 assert(isodir_format != NULL);
262 assert(bkpinfo->isodir != NULL);
263
264 log_it("bkpinfo->isodir = %s", bkpinfo->isodir);
265 isodir_format[0] = '\0';
266 if (isodir_device[0] == '\0') {
267 strcpy(isodir_device, "/dev/");
268 }
269 if (bkpinfo->isodir[0] == '\0') {
270 strcpy(bkpinfo->isodir, "/");
271 }
272 // TODO: Are we shure it does what it's expected to do here ?
273 if (does_file_exist("/tmp/NETFS-SERVER-MOUNT")) {
274 strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT"));
275 strcpy(isodir_format, "netfs");
276 strcpy(bkpinfo->isodir, last_line_of_file("/tmp/ISO-DIR"));
277 }
278 if (nuke_me_please) {
279 return (TRUE);
280 }
281
282 if (popup_and_get_string("ISO Mode - device", "On what device do the ISO files live?", isodir_device, MAX_STR_LEN / 4)) {
283 if (popup_and_get_string ("ISO Mode - format", "What is the disk format of the device? (Hit ENTER if you don't know.)", isodir_format, 16)) {
284 if (popup_with_buttons("Are you restoring from an external hard drive ?", "Yes", "No")) {
285 HDD = TRUE;
286 }
287 if (popup_and_get_string ("ISO Mode - path", "At what path on this device can the ISO files be found ?", bkpinfo->isodir, MAX_STR_LEN / 4)) {
288 strip_spaces(isodir_device);
289 strip_spaces(isodir_format);
290 strip_spaces(bkpinfo->isodir);
291 log_it("isodir_device = %s - isodir_format = %s - bkpinfo->isodir = %s", isodir_device, isodir_format, bkpinfo->isodir);
292 if (HDD) {
293 /* We need an additional param */
294 mr_asprintf(bkpinfo->subdir, "%s", bkpinfo->isodir);
295 strcpy(bkpinfo->isodir, "/tmp/isodir");
296 log_it("Now bkpinfo->isodir = %s and subdir = ", bkpinfo->isodir, bkpinfo->subdir);
297 }
298 return (TRUE);
299 }
300 }
301 }
302 return (FALSE);
303}
304
305
306/**
307* Set up an ISO backup.
308* @param bkpinfo The backup information structure. Fields used:
309* - @c bkpinfo->backup_media_type
310* - @c bkpinfo->disaster_recovery
311* - @c bkpinfo->isodir
312* @param nuke_me_please If TRUE, we're in nuke mode; if FALSE we're in interactive mode.
313* @return 0 for success, nonzero for failure.
314*/
315int iso_fiddly_bits(bool nuke_me_please) {
316
317char *mount_isodir_command = NULL;
318char *command = NULL;
319char *mds = NULL;
320int retval = 0, i;
321
322g_ISO_restore_mode = TRUE;
323read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
324if (bkpinfo->disaster_recovery) {
325 /* Don't let this clobber an existing bkpinfo->isodir */
326 if (!bkpinfo->isodir[0]) {
327 strcpy(bkpinfo->isodir, "/tmp/isodir");
328 }
329 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
330 run_program_and_log_output(command, 5);
331 mr_free(command);
332 log_msg(2, "Setting isodir to %s", bkpinfo->isodir);
333}
334
335if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo, nuke_me_please)) {
336 return (1);
337}
338paranoid_system("umount -d " MNT_CDROM " 2> /dev/null"); /* just in case */
339
340if (is_this_device_mounted(g_isodir_device)) {
341 log_to_screen("WARNING - isodir is already mounted");
342} else {
343 mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device);
344 if (strlen(g_isodir_format) > 1) {
345 mr_strcat(mount_isodir_command, " -t %s", g_isodir_format);
346 }
347
348 mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir);
349 run_program_and_log_output("df -m -P -T", FALSE);
350 log_msg(1, "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", mount_isodir_command);
351 if (run_program_and_log_output(mount_isodir_command, FALSE)) {
352 popup_and_OK("Cannot mount the device where the ISO files are stored.");
353 return (1);
354 }
355 paranoid_free(mount_isodir_command);
356 log_to_screen("I have mounted the device where the ISO files are stored.");
357}
358if (!IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
359 mount_media();
360}
361i = what_number_cd_is_this(); /* has the side-effect of calling mount_media() */
362mds = media_descriptor_string(bkpinfo->backup_media_type);
363mr_free(mds);
364
365log_msg(1, "%s #%d has been mounted via loopback mount", mds, i);
366if (i < 0) {
367 popup_and_OK("Cannot find ISO images in the directory you specified.");
368 retval = 1;
369}
370log_msg(2, "bkpinfo->isodir is now %s", bkpinfo->isodir);
371return (retval);
372}
373
374
375
376
377/**
378* Kill all Petris processes.
379*/
380void kill_petris(void) {
381 kill_anything_like_this("petris");
382}
383
384/**************************************************************************
385*END_KILL_PETRIS *
386**************************************************************************/
387
388
389/**
390 * Mount @p device at @p mpt as @p format.
391 * @param device The device (/dev entry) to mount.
392 * @param mpt The directory to mount it on.
393 * @param format The filesystem type of @p device.
394 * @param writeable If TRUE, mount read-write; if FALSE, mount read-only.
395 * @return 0 for success, nonzero for failure.
396 */
397int mount_device(char *device, char *mpt, char *format, bool writeable)
398{
399int res = 0;
400
401/** malloc **/
402char *tmp = NULL;
403char *command = NULL;
404char *mountdir = NULL;
405char *mountpoint = NULL;
406char *additional_parameters = NULL;
407
408assert_string_is_neither_NULL_nor_zerolength(device);
409assert_string_is_neither_NULL_nor_zerolength(mpt);
410assert(format != NULL);
411
412 if (!strcmp(mpt, "/1")) {
413 mr_asprintf(mountpoint, "/");
414 log_msg(3, "Mommm! SME is being a dildo!");
415 } else {
416 mr_asprintf(mountpoint, "%s", mpt);
417 }
418
419 if (!strcmp(mountpoint, "lvm")) {
420 return (0);
421 }
422 if (!strcmp(mountpoint, "image")) {
423 return (0);
424 }
425 mr_asprintf(tmp, "Mounting device %s ", device);
426 log_msg(1, tmp);
427 /* Deal with additional params only if not /proc or /sys */
428 mr_asprintf(additional_parameters, "");
429 if (strcmp(format, "proc") && strcmp(format, "sys")) {
430 if (writeable) {
431 mr_strcat(additional_parameters, "-o rw");
432 } else {
433 mr_strcat(additional_parameters, "-o ro");
434 }
435 if (find_home_of_exe("setfattr")) {
436 mr_strcat(additional_parameters, ",user_xattr");
437 }
438 if (find_home_of_exe("setfacl")) {
439 mr_strcat(additional_parameters, ",acl");
440 }
441 }
442
443 if (!strcmp(mountpoint, "swap")) {
444 mr_asprintf(command, "swapon %s", device);
445 mr_asprintf(mountdir, "swap");
446 } else {
447 if (!strcmp(mountpoint, "/")) {
448 mr_asprintf(mountdir, "%s", MNT_RESTORING);
449 } else {
450 mr_asprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);
451 }
452 mr_asprintf(command, "mkdir -p %s", mountdir);
453 run_program_and_log_output(command, FALSE);
454 mr_free(command);
455
456 mr_asprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE);
457 log_msg(2, "command='%s'", command);
458 }
459 mr_free(additional_parameters);
460
461 res = run_program_and_log_output(command, TRUE);
462 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
463 log_msg(1, "Re-trying without the fancy extra parameters");
464 mr_free(command);
465 mr_asprintf(command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE);
466 res = run_program_and_log_output(command, TRUE);
467 }
468 if (res) {
469 log_msg(1, "Unable to mount device %s (type %s) at %s", device, format, mountdir);
470 log_msg(1, "command was '%s'", command);
471 if (!strcmp(mountpoint, "swap")) {
472 log_to_screen(tmp);
473 } else {
474 log_msg(2, "Retrying w/o the '-t' switch");
475 mr_free(command);
476 mr_asprintf(command, "mount %s %s 2>> %s", device, mountdir, MONDO_LOGFILE);
477 log_msg(2, "2nd command = '%s'", command);
478 res = run_program_and_log_output(command, TRUE);
479 if (res == 0) {
480 log_msg(1,
481 "That's OK. I called mount w/o a filesystem type and it worked fine in the end.");
482 } else {
483 log_to_screen(tmp);
484 }
485 }
486 }
487
488 if (res && !strcmp(mountpoint, "swap")) {
489 log_msg(2, "That's ok. It's just a swap partition.");
490 log_msg(2, "Non-fatal error. Returning 0.");
491 res = 0;
492 }
493
494mr_free(tmp);
495mr_free(command);
496mr_free(mountdir);
497mr_free(mountpoint);
498
499return (res);
500}
501/**************************************************************************
502 *END_MOUNT_DEVICE *
503**************************************************************************/
504
505
506/**
507 * Mount all devices in @p p_external_copy_of_mountlist on @p MNT_RESTORING.
508 * @param p_external_copy_of_mountlist The mountlist containing devices to be mounted.
509 * @param writeable If TRUE, then mount read-write; if FALSE mount read-only.
510 * @return The number of errors encountered (0 for success).
511 */
512int mount_all_devices(struct mountlist_itself *p_external_copy_of_mountlist, bool writeable)
513{
514int retval = 0, lino, res;
515char *tmp = NULL;
516char *these_failed = NULL;
517struct mountlist_itself *mountlist = NULL;
518
519assert(p_external_copy_of_mountlist != NULL);
520mountlist = malloc(sizeof(struct mountlist_itself));
521memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist,
522 sizeof(struct mountlist_itself));
523 sort_mountlist_by_mountpoint(mountlist, 0);
524
525
526 mvaddstr_and_log_it(g_currentY, 0, "Mounting devices ");
527 open_progress_form("Mounting devices", "I am now mounting all the drives.", "This should not take long.", "", mountlist->entries);
528
529 mr_asprintf(these_failed, "");
530 for (lino = 0; lino < mountlist->entries; lino++) {
531 if (!strcmp(mountlist->el[lino].device, "/proc")) {
532 log_msg(1, "Again with the /proc - why is this in your mountlist?");
533 } else if (is_this_device_mounted(mountlist->el[lino].device)) {
534 log_to_screen("%s is already mounted", mountlist->el[lino].device);
535 } else if (strcmp(mountlist->el[lino].mountpoint, "none")
536 && strcmp(mountlist->el[lino].mountpoint, "lvm")
537 && strcmp(mountlist->el[lino].mountpoint, "raid")
538 && strcmp(mountlist->el[lino].mountpoint, "image")) {
539 mr_asprintf(tmp, "Mounting %s", mountlist->el[lino].device);
540 update_progress_form(tmp);
541 mr_free(tmp);
542 res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable);
543 retval += res;
544 if (res) {
545 mr_strcat(these_failed, "%s ",mountlist->el[lino].device);
546 }
547 }
548 g_current_progress++;
549 }
550 close_progress_form();
551 if (retval) {
552 if (g_partition_table_locked_up > 0) {
553 log_to_screen("fdisk's ictol() call to refresh its copy of the partition table causes the kernel to");
554 log_to_screen("lock up the partition table. You might have to reboot and use Interactive Mode to");
555 log_to_screen("format and restore *without* partitioning first. Sorry for the inconvenience.");
556 }
557 mr_asprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed);
558
559 if (!ask_me_yes_or_no(tmp)) {
560 retval = 0;
561 log_to_screen("Continuing, although some device(s) failed to be mounted");
562 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
563 } else {
564 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
565 log_to_screen("Unable to mount some or all of your partitions.");
566 }
567 mr_free(tmp);
568 } else {
569 log_to_screen("All partitions were mounted OK.");
570 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
571 }
572 paranoid_free(these_failed);
573
574 /* Also mounting under MNT_RESTORING special FS */
575 (void)mount_device("/proc","/proc","proc",TRUE);
576 (void)mount_device("/sys","/sys","sysfs",TRUE);
577 run_program_and_log_output("df -m -P -T", 3);
578 paranoid_free(mountlist);
579 return (retval);
580}
581/**************************************************************************
582*END_MOUNT_ALL_DEVICES *
583**************************************************************************/
584
585
586/**
587* Fix some miscellaneous things in the filesystem so the system will come
588* up correctly on the first boot.
589*/
590void protect_against_braindead_sysadmins() {
591
592run_program_and_log_output("touch " MNT_RESTORING "/var/log/pacct", 0);
593run_program_and_log_output("touch " MNT_RESTORING "/var/account/pacct", 0);
594
595/* Log the status of the boot area */
596run_program_and_log_output("ls -alR " MNT_RESTORING "/boot", 0);
597
598if (run_program_and_log_output("ls -al " MNT_RESTORING " /tmp", 0)) {
599 run_program_and_log_output("chmod 1777 " MNT_RESTORING "/tmp", 0);
600}
601run_program_and_log_output("mkdir -p " MNT_RESTORING "/var/run/console", 0);
602run_program_and_log_output("chmod 777 " MNT_RESTORING "/dev/null", 0);
603run_program_and_log_output("cd " MNT_RESTORING "; for i in `ls home/`; do echo \"Moving $i's spurious files to $i/.disabled\"; mkdir \"$i\"/.disabled ; mv -f \"$i\"/.DCOP* \"$i\"/.MCOP* \"$i\"/.*authority \"$i\"/.kde/tmp* \"$i\"/.kde/socket* \"$i\"/.disabled/ ; done", 1);
604run_program_and_log_output("rm -f " MNT_RESTORING "/var/run/*.pid", 1);
605run_program_and_log_output("rm -f " MNT_RESTORING "/var/lock/subsys/*", 1);
606}
607
608/**************************************************************************
609*END_PROTECT_AGAINST_BRAINDEAD_SYSADMINS *
610**************************************************************************/
611
612
613
614
615/**
616* Fill out @p bkpinfo based on @p cfg_file.
617* @param cfg_file The mondorestore.cfg file to read into @p bkpinfo.
618* @param bkpinfo The backup information structure to fill out with information
619* from @p cfg_file.
620* @return 0 for success, nonzero for failure.
621*/
622int read_cfg_file_into_bkpinfo(char *cfgf)
623{
624/** add mallocs **/
625char value[MAX_STR_LEN];
626char *tmp1 = NULL;
627char *envtmp1 = NULL;
628char *envtmp2 = NULL;
629char *command = NULL;
630char iso_mnt[MAX_STR_LEN];
631char iso_path[MAX_STR_LEN];
632char *old_isodir = NULL;
633char *cfg_file = NULL;
634t_bkptype media_specified_by_user;
635
636// assert_string_is_neither_NULL_nor_zerolength(cfg_file);
637assert(bkpinfo != NULL);
638assert(cfgf != NULL);
639log_it("Entering read_cfg_file_into_bkpinfo");
640
641if (!cfgf) {
642 mr_asprintf(cfg_file, "%s", g_mondo_cfg_file);
643} else {
644 mr_asprintf(cfg_file, "%s", cfgf);
645}
646
647media_specified_by_user = bkpinfo->backup_media_type; // or 'none', if not specified
648
649if (0 == read_cfg_var(cfg_file, "backup-media-type", value)) {
650 if (!strcmp(value, "cdstream")) {
651 bkpinfo->backup_media_type = cdstream;
652 } else if (!strcmp(value, "cdr")) {
653 bkpinfo->backup_media_type = cdr;
654 } else if (!strcmp(value, "cdrw")) {
655 bkpinfo->backup_media_type = cdrw;
656 } else if (!strcmp(value, "dvd")) {
657 bkpinfo->backup_media_type = dvd;
658 } else if (!strcmp(value, "usb")) {
659 bkpinfo->backup_media_type = usb;
660 bkpinfo->please_dont_eject = TRUE;
661 } else if (!strcmp(value, "iso")) {
662 bkpinfo->backup_media_type = iso;
663 if (am_I_in_disaster_recovery_mode()) {
664 /* Check to see if CD is already mounted before mounting it... */
665 if (!is_this_device_mounted("/dev/cdrom")) {
666 log_msg(2, "NB: CDROM device not mounted, mounting...");
667 run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1);
668 }
669 if (does_file_exist(MNT_CDROM"/archives/filelist.0")) {
670 bkpinfo->backup_media_type = cdr;
671 run_program_and_log_output("umount -d "MNT_CDROM, 1);
672 log_it("Re-jigging configuration AGAIN. CD-R, not ISO.");
673 }
674 }
675 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
676 strcpy(bkpinfo->prefix,value);
677 } else {
678 strcpy(bkpinfo->prefix,STD_PREFIX);
679 }
680 log_it("Setting Prefix to %s", bkpinfo->prefix);
681 } else if ((!strcmp(value, "netfs")) || (!strcmp(value, "nfs"))) {
682 /* Stay compatible with previous versions by allowing nfs as an entry here */
683 bkpinfo->backup_media_type = netfs;
684 bkpinfo->please_dont_eject = TRUE;
685 if (read_cfg_var(cfg_file, "netfs-proto", value) == 0) {
686 mr_asprintf(bkpinfo->netfs_proto,"%s", value);
687 } else {
688 /* For compatibility, force protocol in old nfs case to be transparent */
689 mr_asprintf(bkpinfo->netfs_proto, "nfs");
690 }
691 if (read_cfg_var(cfg_file, "netfs-server-user", value) == 0) {
692 mr_asprintf(bkpinfo->netfs_user,"%s", value);
693 }
694 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
695 strcpy(bkpinfo->prefix,value);
696 } else {
697 strcpy(bkpinfo->prefix,STD_PREFIX);
698 }
699 tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
700 if (strstr(tmp1, "pxe")) {
701 /* We need to override prefix value in PXE mode as it's
702 * already done in start-netfs */
703 envtmp1 = getenv("imgname");
704 if (envtmp1 == NULL) {
705 fatal_error("no imgname variable in environment");
706 }
707 strcpy(bkpinfo->prefix,envtmp1);
708 }
709 mr_free(tmp1);
710 } else if (!strcmp(value, "tape")) {
711 bkpinfo->backup_media_type = tape;
712 } else if (!strcmp(value, "udev")) {
713 bkpinfo->backup_media_type = udev;
714 } else {
715 fatal_error("UNKNOWN bkp-media-type");
716 }
717} else {
718 fatal_error("backup-media-type not specified!");
719}
720
721if (bkpinfo->disaster_recovery) {
722 if (bkpinfo->backup_media_type == cdstream) {
723 sprintf(bkpinfo->media_device, "/dev/cdrom");
724 bkpinfo->media_size = 650; /* good guess */
725 } else if (bkpinfo->backup_media_type == usb) {
726 envtmp1 = getenv("MRUSBDEV");
727 if (envtmp1 == NULL) {
728 if (read_cfg_var(cfg_file, "usb-dev", value)) {
729 fatal_error("Cannot get USB device name from cfg file");
730 }
731 } else {
732 strcpy(value,envtmp1);
733 }
734 sprintf(bkpinfo->media_device, "%s1", value);
735 log_msg(2, "Backup medium is USB --- dev=%s", bkpinfo->media_device);
736 } else if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) {
737 if (read_cfg_var(cfg_file, "media-dev", value)) {
738 fatal_error("Cannot get tape device name from cfg file");
739 }
740 strcpy(bkpinfo->media_device, value);
741 read_cfg_var(cfg_file, "media-size", value);
742 bkpinfo->media_size = atol(value);
743 log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device);
744 } else {
745 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */
746 bkpinfo->media_size = 1999 * 1024; /* 650, probably, but we don't need this var anyway */
747 log_msg(2, "Backup medium is similar to CD-R[W]");
748 }
749} else {
750 log_msg(2, "Not in Disaster Recovery Mode. No need to derive device name from config file.");
751}
752
753read_cfg_var(cfg_file, "use-star", value);
754if (strstr(value, "yes")) {
755 bkpinfo->use_star = TRUE;
756 log_msg(1, "Goody! ... bkpinfo->use_star is now true.");
757}
758
759read_cfg_var(cfg_file, "obdr", value);
760if (strstr(value, "TRUE")) {
761 bkpinfo->use_obdr = TRUE;
762 log_msg(1, "OBDR mode activated");
763}
764
765read_cfg_var(cfg_file, "acl", value);
766if (strstr(value, "TRUE")) {
767 mr_asprintf(g_getfacl,"setfacl");
768 log_msg(1, "We will restore ACLs");
769 if (! find_home_of_exe("setfacl")) {
770 log_msg(1, "Unable to restore ACLs as no setfacl found");
771 }
772}
773read_cfg_var(cfg_file, "xattr", value);
774if (strstr(value, "TRUE")) {
775 mr_asprintf(g_getfattr,"setfattr");
776 log_msg(1, "We will restore XATTRs");
777 if (! find_home_of_exe("setfattr")) {
778 log_msg(1, "Unable to restore XATTRs as no setfattr found");
779 }
780}
781
782if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) {
783 bkpinfo->internal_tape_block_size = atol(value);
784} else {
785 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
786}
787log_msg(1, "Internal tape block size set to %ld", bkpinfo->internal_tape_block_size);
788
789read_cfg_var(cfg_file, "use-lzma", value);
790if (strstr(value, "yes")) {
791 bkpinfo->use_lzma = TRUE;
792 bkpinfo->use_lzo = FALSE;
793 bkpinfo->use_gzip = FALSE;
794 strcpy(bkpinfo->zip_exe, "lzma");
795 strcpy(bkpinfo->zip_suffix, "lzma");
796}
797
798read_cfg_var(cfg_file, "use-lzo", value);
799if (strstr(value, "yes")) {
800 bkpinfo->use_lzma = FALSE;
801 bkpinfo->use_lzo = TRUE;
802 bkpinfo->use_gzip = FALSE;
803 strcpy(bkpinfo->zip_exe, "lzop");
804 strcpy(bkpinfo->zip_suffix, "lzo");
805}
806
807read_cfg_var(cfg_file, "use-gzip", value);
808if (strstr(value, "yes")) {
809 bkpinfo->use_lzma = FALSE;
810 bkpinfo->use_lzo = FALSE;
811 bkpinfo->use_gzip = TRUE;
812 strcpy(bkpinfo->zip_exe, "gzip");
813 strcpy(bkpinfo->zip_suffix, "gz");
814}
815
816read_cfg_var(cfg_file, "use-comp", value);
817if (strstr(value, "yes")) {
818 bkpinfo->use_lzma = FALSE;
819 bkpinfo->use_lzo = FALSE;
820 bkpinfo->use_gzip = FALSE;
821 strcpy(bkpinfo->zip_exe, "bzip2");
822 strcpy(bkpinfo->zip_suffix, "bz2");
823}
824
825value[0] = '\0';
826read_cfg_var(cfg_file, "differential", value);
827if (!strcmp(value, "yes") || !strcmp(value, "1")) {
828 bkpinfo->differential = TRUE;
829}
830log_msg(2, "differential var = '%s'", value);
831if (bkpinfo->differential) {
832 log_msg(2, "THIS IS A DIFFERENTIAL BACKUP");
833} else {
834 log_msg(2, "This is a regular (full) backup");
835}
836
837read_cfg_var(cfg_file, "please-dont-eject", value);
838tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
839if (value[0] || strstr(tmp1, "donteject")) {
840 bkpinfo->please_dont_eject = TRUE;
841 log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
842}
843mr_free(tmp1);
844
845/* TODO: Read here the boot_* variables */
846read_cfg_var(cfg_file, "boot-type", value);
847if (!strcmp(value, "BIOS")) {
848 bkpinfo->boot_type = BIOS;
849} else if (!strcmp(value, "EFI")) {
850 bkpinfo->boot_type = EFI;
851} else if (!strcmp(value, "UEFI")) {
852 bkpinfo->boot_type = UEFI;
853} else {
854 log_msg(1, "No known boot type found");
855}
856log_msg(1, "Found %s boot type",value);
857
858if (bkpinfo->backup_media_type == netfs) {
859 if (!cfgf) {
860 if (bkpinfo->netfs_mount) {
861 log_msg(2, "netfs_mount remains %s", bkpinfo->netfs_mount);
862 }
863 if (bkpinfo->netfs_remote_dir != NULL) {
864 log_msg(2, "netfs_remote_dir remains %s", bkpinfo->netfs_remote_dir);
865 }
866 log_msg(2, "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place");
867 } else {
868 read_cfg_var(cfg_file, "netfs-server-mount", value);
869 mr_free(bkpinfo->netfs_mount);
870 mr_asprintf(bkpinfo->netfs_mount, "%s", value);
871 if (bkpinfo->netfs_mount != NULL) {
872 log_msg(2, "netfs_mount is %s", bkpinfo->netfs_mount);
873 }
874
875 read_cfg_var(cfg_file, "iso-dir", value);
876 mr_free(bkpinfo->netfs_remote_dir);
877 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", value);
878 if (bkpinfo->netfs_remote_dir != NULL) {
879 log_msg(2, "netfs_remote_dir is %s", bkpinfo->netfs_remote_dir);
880 }
881
882 if (bkpinfo->netfs_proto != NULL) {
883 log_msg(2, "netfs_proto is %s", bkpinfo->netfs_proto);
884 }
885 if (bkpinfo->netfs_user != NULL) {
886 log_msg(2, "netfs_user is %s", bkpinfo->netfs_user);
887 }
888 }
889 tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
890 if (strstr(tmp1, "pxe")) {
891 /* We need to override values in PXE mode as it's
892 * already done in start-netfs */
893 envtmp1 = getenv("netfsmount");
894 if (envtmp1 == NULL) {
895 fatal_error("no netfsmount variable in environment");
896 }
897 envtmp2 = getenv("dirimg");
898 if (envtmp2 == NULL) {
899 fatal_error("no dirimg variable in environment");
900 }
901 mr_free(bkpinfo->netfs_mount);
902 mr_asprintf(bkpinfo->netfs_mount, "%s", envtmp1);
903
904 mr_free(bkpinfo->netfs_remote_dir);
905 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2);
906 }
907 mr_free(tmp1);
908} else if (bkpinfo->backup_media_type == iso) {
909 /* Patch by Conor Daly 23-june-2004
910 * to correctly mount iso-dev and set a sensible
911 * isodir in disaster recovery mode
912 */
913 mr_asprintf(old_isodir, "%s", bkpinfo->isodir);
914 read_cfg_var(cfg_file, "iso-mnt", iso_mnt);
915 read_cfg_var(cfg_file, "iso-dir", iso_path);
916 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
917 if (!bkpinfo->isodir[0]) {
918 strcpy(bkpinfo->isodir, old_isodir);
919 }
920 if ((!bkpinfo->disaster_recovery) || (g_isodir_device[0] != '\0')) {
921 if (strcmp(old_isodir, bkpinfo->isodir)) {
922 log_it("user nominated isodir %s differs from archive, keeping user's choice: %s\n", bkpinfo->isodir, old_isodir );
923 strcpy(bkpinfo->isodir, old_isodir);
924 }
925 }
926 mr_free(old_isodir);
927
928 if (g_isodir_device[0] == '\0') {
929 /* We don't want to loose our conf made earlier in iso_fiddly_bits
930 * so go here only if job not done already */
931 read_cfg_var(cfg_file, "iso-dev", g_isodir_device);
932 }
933
934 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
935
936 if (bkpinfo->disaster_recovery) {
937 if (is_this_device_mounted(g_isodir_device)) {
938 log_msg(2, "NB: isodir is already mounted");
939 /* Find out where it's mounted */
940 mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
941 log_it("command = %s", command);
942 tmp1 = call_program_and_get_last_line_of_output(command);
943 log_it("res of it = %s", tmp1);
944 sprintf(iso_mnt, "%s", tmp1);
945 mr_free(command);
946 mr_free(tmp1);
947 } else {
948 sprintf(iso_mnt, "/tmp/isodir");
949 mr_asprintf(tmp1, "mkdir -p %s", iso_mnt);
950 run_program_and_log_output(tmp1, 5);
951 mr_free(tmp1);
952
953 mr_asprintf(tmp1, "mount %s %s", g_isodir_device, iso_mnt);
954 if (run_program_and_log_output(tmp1, 3)) {
955 log_msg(1, "Unable to mount isodir. Perhaps this is really a CD backup?");
956 bkpinfo->backup_media_type = cdr;
957 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */
958 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0';
959 if (mount_media()) {
960 mr_free(tmp1);
961 fatal_error("Unable to mount isodir. Failed to mount CD-ROM as well.");
962 } else {
963 log_msg(1, "You backed up to disk, then burned some CDs.");
964 }
965 }
966 mr_free(tmp1);
967 }
968 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
969 /* except when already done in iso_fiddly_bits */
970 if ((bkpinfo->backup_media_type == iso) && (g_isodir_device[0] == '\0')) {
971 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
972 }
973 }
974}
975mr_free(cfg_file);
976
977if (media_specified_by_user != none) {
978 if (g_restoring_live_from_cd) {
979 if (bkpinfo->backup_media_type != media_specified_by_user) {
980 log_msg(2, "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
981 interactively_obtain_media_parameters_from_user(FALSE);
982 media_specified_by_user = bkpinfo->backup_media_type;
983 get_cfg_file_from_archive();
984 }
985 }
986 bkpinfo->backup_media_type = media_specified_by_user;
987}
988g_backup_media_type = bkpinfo->backup_media_type;
989return (0);
990
991}
992
993/**************************************************************************
994*END_READ_CFG_FILE_INTO_BKPINFO *
995**************************************************************************/
996
997
998
999
1000/**
1001 * Allow the user to edit the filelist and biggielist.
1002 * The filelist is unlinked after it is read.
1003 * @param bkpinfo The backup information structure. Fields used:
1004 * - @c bkpinfo->backup_media_type
1005 * - @c bkpinfo->isodir
1006 * - @c bkpinfo->media_device
1007 * - @c bkpinfo->tmpdir
1008 * @return The filelist structure containing the information read from disk.
1009 */
1010struct
1011s_node *process_filelist_and_biggielist()
1012{
1013struct s_node *filelist;
1014
1015char *command = NULL;
1016char *old_pwd = NULL;
1017char *q;
1018int res = 0;
1019pid_t pid;
1020bool extract_mountlist_stub = FALSE;
1021
1022assert(bkpinfo != NULL);
1023
1024/* If those files already exist, do not overwrite them later on */
1025if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) {
1026 extract_mountlist_stub = FALSE;
1027} else {
1028 extract_mountlist_stub = TRUE;
1029}
1030
1031if (does_file_exist(g_filelist_full)
1032&& does_file_exist(g_biggielist_txt)) {
1033 log_msg(1, "%s exists", g_filelist_full);
1034 log_msg(1, "%s exists", g_biggielist_txt);
1035 log_msg(2,
1036 "Filelist and biggielist already recovered from media. Yay!");
1037} else {
1038 old_pwd = mr_getcwd();
1039 if (chdir(bkpinfo->tmpdir)) {
1040 // FIXME
1041 }
1042 log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
1043 log_to_screen("Extracting filelist and biggielist from media...");
1044 unlink("/tmp/filelist.full");
1045 unlink(FILELIST_FULL_STUB);
1046 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
1047 mr_asprintf(command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
1048 log_msg(1, "tarcommand = %s", command);
1049 run_program_and_log_output(command, 1);
1050 mr_free(command);
1051
1052 if (!does_file_exist(FILELIST_FULL_STUB)) {
1053 /* Doing that allow us to remain compatible with pre-2.2.5 versions */
1054 log_msg(2, "pre-2.2.4 compatible mode on");
1055 mr_asprintf(command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
1056 log_msg(1, "tarcommand = %s", command);
1057 run_program_and_log_output(command, 1);
1058 mr_free(command);
1059 }
1060 } else {
1061 log_msg(2, "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", bkpinfo->isodir);
1062 insist_on_this_cd_number(1);
1063 log_msg(2, "Back from iotcn");
1064 run_program_and_log_output("mount", 1);
1065 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
1066
1067 log_msg(1, "tarcommand = %s", command);
1068 run_program_and_log_output(command, 1);
1069 mr_free(command);
1070
1071 if (!does_file_exist(FILELIST_FULL_STUB)) {
1072 /* Doing that allow us to remain compatible with pre-2.2.5 versions */
1073 log_msg(2, "pre-2.2.4 compatible mode on");
1074 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
1075
1076 log_msg(1, "tarcommand = %s", command);
1077 run_program_and_log_output(command, 1);
1078 mr_free(command);
1079 }
1080 if (!does_file_exist(BIGGIELIST_TXT_STUB)) {
1081 fatal_error("all.tar.gz did not include " BIGGIELIST_TXT_STUB);
1082 }
1083 if (!does_file_exist(FILELIST_FULL_STUB)) {
1084 fatal_error("all.tar.gz did not include " FILELIST_FULL_STUB);
1085 }
1086 }
1087 mr_asprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file);
1088 run_program_and_log_output(command, FALSE);
1089 mr_free(command);
1090
1091 mr_asprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt);
1092 log_msg(1, "command = %s", command);
1093 paranoid_system(command);
1094 mr_free(command);
1095
1096 mr_asprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full);
1097 log_msg(1, "command = %s", command);
1098 paranoid_system(command);
1099 mr_free(command);
1100 }
1101
1102 if (am_I_in_disaster_recovery_mode()
1103 &&
1104 /* If it was there, do not overwrite it */
1105 (extract_mountlist_stub)
1106 &&
1107 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?"))
1108 {
1109 mr_asprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir);
1110 paranoid_system(command);
1111 mr_free(command);
1112 }
1113
1114 if (chdir(old_pwd)) {
1115 // FIXME
1116 }
1117 mr_free(old_pwd);
1118
1119 if (!does_file_exist(g_biggielist_txt)) {
1120 log_msg(1, "Warning - %s not found", g_biggielist_txt);
1121 }
1122 if (!does_file_exist(g_filelist_full)) {
1123 log_msg(1, "Warning - %s does not exist", g_filelist_full);
1124 }
1125
1126 log_msg(2, "Forking");
1127 pid = fork();
1128 switch (pid) {
1129 case -1:
1130 fatal_error("Forking error");
1131 break;
1132
1133 case 0:
1134 log_to_screen("Pre-processing filelist");
1135 if (!does_file_exist(g_biggielist_txt)) {
1136 mr_asprintf(command, "echo -n > %s", g_biggielist_txt);
1137 paranoid_system(command);
1138 mr_free(command);
1139 }
1140 mr_asprintf(command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs);
1141 paranoid_system(command);
1142 mr_free(command);
1143 exit(0);
1144 break;
1145
1146 default:
1147 open_evalcall_form("Pre-processing filelist");
1148 while (!waitpid(pid, (int *) 0, WNOHANG)) {
1149 usleep(100000);
1150 update_evalcall_form(0);
1151 }
1152 }
1153 close_evalcall_form();
1154
1155 log_msg(3, "loading filelist");
1156 filelist = load_filelist(g_filelist_full);
1157 log_msg(3, "deleting original filelist");
1158 unlink(g_filelist_full);
1159 if (g_text_mode) {
1160 q = NULL;
1161 while (q == NULL) {
1162 printf("Restore which directory? --> ");
1163 mr_getline(q, stdin);
1164 }
1165 toggle_path_selection(filelist, q, TRUE);
1166 if (strlen(q) == 0) {
1167 res = 1;
1168 } else {
1169 res = 0;
1170 }
1171 mr_free(q);
1172 } else {
1173 res = edit_filelist(filelist);
1174 }
1175 if (res) {
1176 log_msg(2, "User hit 'cancel'. Freeing filelist and aborting.");
1177 free_filelist(filelist);
1178 return (NULL);
1179 }
1180 ask_about_these_imagedevs(g_filelist_imagedevs, g_imagedevs_restthese);
1181 close_evalcall_form();
1182
1183 // NB: It's not necessary to add g_biggielist_txt to the filelist.full
1184 // file. The filelist.full file already contains the filename of EVERY
1185 // file backed up - regular and biggie files.
1186
1187 // However, we do want to make sure the imagedevs selected by the user
1188 // are flagged for restoring.
1189 if (length_of_file(g_imagedevs_restthese) > 2) {
1190 add_list_of_files_to_filelist(filelist, g_imagedevs_restthese,
1191 TRUE);
1192 }
1193
1194 return (filelist);
1195}
1196
1197/**************************************************************************
1198 *END_ PROCESS_FILELIST_AND_BIGGIELIST *
1199 **************************************************************************/
1200
1201
1202
1203
1204/**
1205 * Make a backup copy of <tt>path_root</tt>/<tt>filename</tt>.
1206 * The backup filename is the filename of the original with ".pristine" added.
1207 * @param path_root The place where the filesystem is mounted (e.g. MNT_RESTORING).
1208 * @param filename The filename (absolute path) within @p path_root.
1209 * @return 0 for success, nonzero for failure.
1210 */
1211int backup_crucial_file(char *path_root, char *filename)
1212{
1213 char *tmp = NULL;
1214 char *command = NULL;
1215 int res;
1216
1217 assert(path_root != NULL);
1218 assert_string_is_neither_NULL_nor_zerolength(filename);
1219
1220 mr_asprintf(tmp, "%s/%s", path_root, filename);
1221 mr_asprintf(command, "cp -f %s %s.pristine", tmp, tmp);
1222 mr_free(tmp);
1223
1224 res = run_program_and_log_output(command, 5);
1225 mr_free(command);
1226 return (res);
1227}
1228
1229void offer_to_make_initrd() {
1230
1231if (bkpinfo->restore_mode != nuke) {
1232 if (ask_me_yes_or_no
1233 ("You will now be able to re-generate your initrd.\nThis is especially useful if you changed of hardware configuration, cloned, made P2V, used multipath...\nDo you need to do it ?")) {
1234 log_msg(1,"Launching shell for manual initrd recreation");
1235 if (does_file_exist(MNT_RESTORING"/etc/arch-release")) {
1236 popup_and_OK("You'll now be chrooted under your future / partition.\nEdit /etc/mkinitcpio.conf if needed and rebuild your initrd with the kernel preset name e.g.\nmkinitcpio -p kernel26\nThen type exit to finish.\n");
1237 } else {
1238 popup_and_OK("You'll now be chrooted under your future / partition.\nGo under /boot and rebuild your init(rd|ramfs) with\nmkinitrd -f -v initrd-2.x.y.img 2.x.y e.g.\nor initramfs, dracut, ... Then type exit to finish.");
1239 }
1240 mvaddstr_and_log_it(g_currentY, 0, "Modifying initrd...");
1241 if (!g_text_mode) {
1242 newtSuspend();
1243 }
1244 paranoid_system("chroot " MNT_RESTORING);
1245 if (!g_text_mode) {
1246 newtResume();
1247 }
1248 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1249 } else {
1250 return;
1251 }
1252} else {
1253 log_to_screen("Non-interactive mode: no way to give you the keyboard so that you re-generate your initrd. Hope it's OK");
1254 log_msg(1,"Non-interactive mode: no way to give you the keyboard so that you re-generate your initrd. Hope it's OK");
1255}
1256}
1257
1258
1259/**
1260 * Install the user's boot loader in the MBR.
1261 * Currently LILO, ELILO, GRUB, RAW (dd of MBR), and the FreeBSD bootloader are supported.
1262 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them.
1263 * @return 0 for success, nonzero for failure.
1264 */
1265int run_boot_loader(bool offer_to_hack_scripts)
1266{
1267 int res;
1268 int retval = 0;
1269
1270 /** malloc *******/
1271 char *device = NULL;
1272 char *name = NULL;
1273 char *cmd = NULL;
1274
1275 malloc_string(device);
1276 malloc_string(name);
1277
1278 /* In order to have a working bootloader, we need to have all devices
1279 * ready in the chroot. If they are not there (udev) then copy them from
1280 * the current /dev location
1281 */
1282 mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);
1283 run_program_and_log_output(cmd, 3);
1284 paranoid_free(cmd);
1285
1286 backup_crucial_file(MNT_RESTORING, "/etc/fstab");
1287 backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst");
1288 backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg");
1289 backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg");
1290 backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");
1291 backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");
1292 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");
1293 backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map");
1294 backup_crucial_file(MNT_RESTORING, "/etc/mtab");
1295 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
1296 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
1297 log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
1298 sync();
1299
1300 offer_to_make_initrd();
1301 if (!strcmp(name, "LILO")) {
1302 res = run_lilo(offer_to_hack_scripts);
1303 } else if (!strcmp(name, "ELILO")) {
1304 res = run_elilo(offer_to_hack_scripts);
1305 } else if (!strcmp(name, "GRUB")) {
1306 res = run_grub(offer_to_hack_scripts, device);
1307 } else if (!strcmp(name, "RAW")) {
1308 res = run_raw_mbr(offer_to_hack_scripts, device);
1309 }
1310#ifdef __FreeBSD__
1311 else if (!strcmp(name, "BOOT0")) {
1312 mr_asprintf(tmp, "boot0cfg -B %s", device);
1313 res = run_program_and_log_output(tmp, FALSE);
1314 paranoid_free(tmp);
1315 } else {
1316 mr_asprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);
1317 if (!system(tmp)) {
1318 mr_free(tmp);
1319 mr_asprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
1320 res = run_program_and_log_output(tmp, 3);
1321 } else {
1322 log_msg(1, "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
1323 }
1324 mr_free(tmp);
1325 }
1326#else
1327 else {
1328 log_to_screen
1329 ("Unable to determine type of boot loader. Defaulting to LILO.");
1330 res = run_lilo(offer_to_hack_scripts);
1331 }
1332#endif
1333 retval += res;
1334 if (res) {
1335 log_to_screen("Your boot loader returned an error");
1336 } else {
1337 log_to_screen("Your boot loader ran OK");
1338 }
1339 paranoid_free(device);
1340 paranoid_free(name);
1341 return (retval);
1342}
1343
1344/**************************************************************************
1345 *END_ RUN_BOOT_LOADER *
1346 **************************************************************************/
1347
1348
1349
1350/**
1351 * Attempt to find the user's editor.
1352 * @return The editor found ("vi" if none could be found).
1353 * @note The returned string points to static storage that will be overwritten with each call.
1354 */
1355char *find_my_editor(void) {
1356
1357 static char output[MAX_STR_LEN];
1358 if (find_home_of_exe("pico")) {
1359 strcpy(output, "pico");
1360 } else if (find_home_of_exe("nano")) {
1361 strcpy(output, "nano");
1362 } else if (find_home_of_exe("e3em")) {
1363 strcpy(output, "e3em");
1364 } else if (find_home_of_exe("e3vi")) {
1365 strcpy(output, "e3vi");
1366 } else {
1367 strcpy(output, "vi");
1368 }
1369 if (!find_home_of_exe(output)) {
1370 log_msg(2, " (find_my_editor) --- warning - %s not found", output);
1371 }
1372 return (output);
1373}
1374
1375
1376/**
1377 * Install GRUB on @p bd.
1378 * @param offer_to_run_stabgrub If TRUE, then offer to hack the user's fstab for them.
1379 * @param bd The boot device where GRUB is installed.
1380 * @return 0 for success, nonzero for failure.
1381 */
1382int run_grub(bool offer_to_run_stabgrub, char *bd)
1383{
1384 /** malloc **/
1385 char *command = NULL;
1386 char *boot_device = NULL;
1387 char *tmp = NULL;
1388 char *editor = NULL;
1389
1390 bool done;
1391 int res = 0; /* FALSE */
1392 bool mntlistchg = FALSE;
1393 FILE *fin = NULL;
1394
1395 malloc_string(boot_device);
1396
1397 assert_string_is_neither_NULL_nor_zerolength(bd);
1398 strcpy(boot_device, bd);
1399
1400 if (offer_to_run_stabgrub && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
1401 /* interactive mode */
1402 mvaddstr_and_log_it(g_currentY, 0, "Modifying fstab, mtab, device.map and menu.lst/grub.cfg, and running GRUB...");
1403 /* Did we changed the mountlist ? If yes, then force editing conf files */
1404 if ((fin = fopen(MONDO_MNTLISTCHG, "r")) != NULL) {
1405 mntlistchg = TRUE;
1406 }
1407 for (done = FALSE; !done;) {
1408 popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/sda", boot_device, MAX_STR_LEN / 4);
1409 /* Only try to adapt grub here first if the mountlist wasn't changed before */
1410 if (! mntlistchg) {
1411 mr_asprintf(command, "mr-stabgrub-me %s", boot_device);
1412 res = run_program_and_log_output(command, 1);
1413 mr_free(command);
1414 }
1415
1416 if ((res) || (mntlistchg)) {
1417 if (res) {
1418 popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
1419 } else {
1420 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");
1421 }
1422 if (!g_text_mode) {
1423 newtSuspend();
1424 }
1425 mr_asprintf(editor, "%s", find_my_editor());
1426 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
1427 paranoid_system(tmp);
1428 mr_free(tmp);
1429
1430 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
1431 paranoid_system(tmp);
1432 mr_free(tmp);
1433
1434 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
1435 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
1436 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
1437 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
1438 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
1439 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
1440 }
1441 paranoid_system(tmp);
1442 mr_free(tmp);
1443
1444 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
1445 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
1446 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
1447 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
1448 }
1449 paranoid_system(tmp);
1450 mr_free(tmp);
1451 mr_free(editor);
1452
1453 if (!g_text_mode) {
1454 newtResume();
1455 }
1456 mr_asprintf(command, "mr-stabgrub-me %s", boot_device);
1457 res = run_program_and_log_output(command, 1);
1458 mr_free(command);
1459
1460 if (res) {
1461 popup_and_OK("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
1462 newtSuspend();
1463 paranoid_system("chroot " MNT_RESTORING);
1464 newtResume();
1465 } else {
1466 popup_and_OK("GRUB is now installed correctly");
1467 done = TRUE;
1468 }
1469 } else {
1470 done = TRUE;
1471 }
1472 }
1473 } else {
1474 /* nuke mode */
1475 if (!run_program_and_log_output("which mr-grub", FALSE)) {
1476 log_msg(1, "Yay! mr-grub found...");
1477 mr_asprintf(command, "mr-grub %s /"MOUNTLIST_FNAME_STUB, boot_device);
1478 log_msg(1, "command = %s", command);
1479 } else {
1480 // Or grub2-install
1481 mr_asprintf(command, "chroot " MNT_RESTORING " grub-install %s", boot_device);
1482 log_msg(1, "WARNING - mr-grub not found; using grub-install");
1483 }
1484 mvaddstr_and_log_it(g_currentY, 0, "Running GRUB... ");
1485 log_it("%s",command);
1486 res = run_program_and_log_output(command, 1);
1487 mr_free(command);
1488
1489 if (res) {
1490 popup_and_OK("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.");
1491 newtSuspend();
1492 paranoid_system("chroot " MNT_RESTORING);
1493 newtResume();
1494 }
1495 }
1496 if (res) {
1497 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
1498 log_to_screen
1499 ("GRUB ran w/error(s). See %s for more info.", MONDO_LOGFILE);
1500 log_msg(1, "Type:-");
1501 log_msg(1, " mr-mount-me");
1502 log_msg(1, " chroot " MNT_RESTORING);
1503 log_msg(1, " mount /boot");
1504 log_msg(1, " grub-install '(hd0)'");
1505 log_msg(1, " exit");
1506 log_msg(1, " mr-unmount-me");
1507 log_msg(1,
1508 "If you're really stuck, please e-mail the mailing list.");
1509 } else {
1510 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1511 }
1512 paranoid_free(boot_device);
1513
1514 return (res);
1515}
1516
1517/**************************************************************************
1518 *END_RUN_GRUB *
1519 **************************************************************************/
1520
1521
1522/**
1523 * Install ELILO on the user's boot drive (determined by elilo.conf).
1524 * @param offer_to_run_stabelilo If TRUE, then offer to hack the user's fstab for them.
1525 * @return 0 for success, nonzero for failure.
1526 */
1527int run_elilo(bool offer_to_run_stabelilo)
1528{
1529 /** malloc **/
1530 char *command = NULL;
1531 char *tmp = NULL;
1532 char *editor = NULL;
1533
1534 int res;
1535 int done;
1536
1537 if (offer_to_run_stabelilo
1538 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
1539
1540 /* interactive mode */
1541 {
1542 mvaddstr_and_log_it(g_currentY,
1543 0,
1544 "Modifying fstab and elilo.conf... ");
1545 mr_asprintf(command, "mr-stabelilo-me");
1546 res = run_program_and_log_output(command, 3);
1547 mr_free(command);
1548
1549 if (res) {
1550 popup_and_OK
1551 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist.");
1552 for (done = FALSE; !done;) {
1553 if (!g_text_mode) {
1554 newtSuspend();
1555 }
1556 mr_asprintf(editor, "%s", find_my_editor());
1557
1558 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
1559 paranoid_system(tmp);
1560 mr_free(tmp);
1561
1562 mr_asprintf(tmp, "chroot %s %s /etc/elilo.conf", MNT_RESTORING, editor);
1563 paranoid_system(tmp);
1564 mr_free(tmp);
1565 mr_free(editor);
1566
1567 if (!g_text_mode) {
1568 newtResume();
1569 }
1570// newtCls();
1571 if (ask_me_yes_or_no("Edit them again?")) {
1572 continue;
1573 }
1574 done = TRUE;
1575 }
1576 } else {
1577 log_to_screen("elilo.conf and fstab were modified OK");
1578 }
1579 } else
1580 /* nuke mode */
1581 {
1582 res = TRUE;
1583 }
1584 return (res);
1585}
1586
1587/**************************************************************************
1588 *END_RUN_ELILO *
1589 **************************************************************************/
1590
1591
1592/**
1593 * Install LILO on the user's boot drive (determined by /etc/lilo.conf).
1594 * @param offer_to_run_stablilo If TRUE, then offer to hack the user's fstab for them.
1595 * @return 0 for success, nonzero for failure.
1596 */
1597int run_lilo(bool offer_to_run_stablilo)
1598{
1599 /** malloc **/
1600 char *command = NULL;
1601 char *tmp = NULL;
1602 char *editor = NULL;
1603
1604 int res;
1605 int done;
1606 bool run_lilo_M = FALSE;
1607
1608 if (!run_program_and_log_output
1609 ("grep \"boot.*=.*/dev/md\" " MNT_RESTORING "/etc/lilo.conf", 1)) {
1610 run_lilo_M = TRUE;
1611 }
1612
1613 if (offer_to_run_stablilo
1614 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
1615
1616 /* interactive mode */
1617 {
1618 mvaddstr_and_log_it(g_currentY,
1619 0,
1620 "Modifying fstab and lilo.conf, and running LILO... ");
1621 mr_asprintf(command, "mr-stablilo-me");
1622 res = run_program_and_log_output(command, 3);
1623 mr_free(command);
1624
1625 if (res) {
1626 popup_and_OK
1627 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist.");
1628 for (done = FALSE; !done;) {
1629 if (!g_text_mode) {
1630 newtSuspend();
1631 }
1632 mr_asprintf(editor, "%s", find_my_editor());
1633
1634 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
1635 paranoid_system(tmp);
1636 mr_free(tmp);
1637
1638 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
1639 paranoid_system(tmp);
1640 mr_free(tmp);
1641 mr_free(editor);
1642
1643 if (!g_text_mode) {
1644 newtResume();
1645 }
1646// newtCls();
1647 if (ask_me_yes_or_no("Edit them again?")) {
1648 continue;
1649 }
1650 res =
1651 run_program_and_log_output("chroot " MNT_RESTORING
1652 " lilo -L", 3);
1653 if (res) {
1654 res =
1655 run_program_and_log_output("chroot " MNT_RESTORING
1656 " lilo", 3);
1657 }
1658 if (res) {
1659 done =
1660 ask_me_yes_or_no
1661 ("LILO failed. Re-edit system files?");
1662 } else {
1663 done = TRUE;
1664 }
1665 }
1666 } else {
1667 log_to_screen("lilo.conf and fstab were modified OK");
1668 }
1669 } else
1670 /* nuke mode */
1671 {
1672 mvaddstr_and_log_it(g_currentY,
1673 0,
1674 "Running LILO... ");
1675 res =
1676 run_program_and_log_output("chroot " MNT_RESTORING " lilo -L",
1677 3);
1678 if (res) {
1679 res =
1680 run_program_and_log_output("chroot " MNT_RESTORING " lilo",
1681 3);
1682 }
1683 if (res) {
1684 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
1685 log_to_screen
1686 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please.");
1687 } else {
1688 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1689 }
1690 }
1691 if (run_lilo_M) {
1692 run_program_and_log_output("chroot " MNT_RESTORING
1693 " lilo -M /dev/hda", 3);
1694 run_program_and_log_output("chroot " MNT_RESTORING
1695 " lilo -M /dev/sda", 3);
1696 }
1697 return (res);
1698}
1699
1700/**************************************************************************
1701 *END_RUN_LILO *
1702 **************************************************************************/
1703
1704
1705/**
1706 * Install a raw MBR onto @p bd.
1707 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them.
1708 * @param bd The device to copy the stored MBR to.
1709 * @return 0 for success, nonzero for failure.
1710 */
1711int run_raw_mbr(bool offer_to_hack_scripts, char *bd)
1712{
1713 /** malloc **/
1714 char *command = NULL;
1715 char *boot_device = NULL;
1716 char *tmp = NULL;
1717 char *editor;
1718 int res;
1719 int done;
1720
1721 malloc_string(boot_device);
1722 assert_string_is_neither_NULL_nor_zerolength(bd);
1723
1724 strcpy(boot_device, bd);
1725
1726 if (offer_to_hack_scripts
1727 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
1728 /* interactive mode */
1729 mvaddstr_and_log_it(g_currentY, 0, "Modifying fstab and restoring MBR... ");
1730 for (done = FALSE; !done;) {
1731 if (!run_program_and_log_output("which vi", FALSE)) {
1732 popup_and_OK("You will now edit fstab");
1733 if (!g_text_mode) {
1734 newtSuspend();
1735 }
1736 mr_asprintf(editor, "%s", find_my_editor());
1737 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
1738 mr_free(editor);
1739
1740 paranoid_system(tmp);
1741 mr_free(tmp);
1742 if (!g_text_mode) {
1743 newtResume();
1744 }
1745 }
1746 popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device, MAX_STR_LEN / 4);
1747 mr_asprintf(command, "mr-stabraw-me %s", boot_device);
1748 res = run_program_and_log_output(command, 3);
1749 mr_free(command);
1750
1751 if (res) {
1752 done = ask_me_yes_or_no("Modifications failed. Re-try?");
1753 } else {
1754 done = TRUE;
1755 }
1756 }
1757 } else {
1758 /* nuke mode */
1759 mr_asprintf(command, "mr-raw %s /"MOUNTLIST_FNAME_STUB, boot_device);
1760 log_msg(2, "run_raw_mbr() --- command='%s'", command);
1761
1762 mvaddstr_and_log_it(g_currentY, 0, "Restoring MBR... ");
1763 res = run_program_and_log_output(command, 3);
1764 mr_free(command);
1765 }
1766 if (res) {
1767 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
1768 log_to_screen("MBR+fstab processed w/error(s). See %s for more info.", MONDO_LOGFILE);
1769 } else {
1770 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1771 }
1772 paranoid_free(boot_device);
1773 return (res);
1774}
1775
1776/**************************************************************************
1777 *END_RUN_RAW_MBR *
1778 **************************************************************************/
1779
1780
1781
1782/**
1783 * malloc() and set sensible defaults for the mondorestore filename variables.
1784 * @param bkpinfo The backup information structure. Fields used:
1785 * - @c bkpinfo->tmpdir
1786 * - @c bkpinfo->disaster_recovery
1787 */
1788void setup_MR_global_filenames()
1789{
1790 char *temppath;
1791
1792 assert(bkpinfo != NULL);
1793
1794 malloc_string(g_biggielist_txt);
1795 malloc_string(g_filelist_full);
1796 malloc_string(g_filelist_imagedevs);
1797 malloc_string(g_imagedevs_restthese);
1798 malloc_string(g_mondo_cfg_file);
1799 malloc_string(g_mountlist_fname);
1800 malloc_string(g_mondo_home);
1801 malloc_string(g_isodir_device);
1802 malloc_string(g_isodir_format);
1803
1804 temppath = bkpinfo->tmpdir;
1805
1806 sprintf(g_biggielist_txt, "%s/%s", temppath, BIGGIELIST_TXT_STUB);
1807 sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
1808 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
1809// sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath);
1810 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
1811 temppath);
1812 if (bkpinfo->disaster_recovery) {
1813 sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
1814 sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
1815 } else {
1816 sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);
1817 sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB);
1818 }
1819}
1820
1821/**************************************************************************
1822 *END_SET_GLOBAL_FILENAME *
1823 **************************************************************************/
1824
1825
1826/**
1827 * Copy @p input_file (containing the result of a compare) to @p output_file,
1828 * deleting spurious "changes" along the way.
1829 * @param output_file The output file to write with spurious changes removed.
1830 * @param input_file The input file, a list of changed files created by a compare.
1831 */
1832void streamline_changes_file(char *output_file, char *input_file)
1833{
1834 FILE *fin;
1835 FILE *fout;
1836 char *incoming = NULL;
1837
1838 assert_string_is_neither_NULL_nor_zerolength(output_file);
1839 assert_string_is_neither_NULL_nor_zerolength(input_file);
1840
1841 if (!(fin = fopen(input_file, "r"))) {
1842 log_OS_error(input_file);
1843 return;
1844 }
1845 if (!(fout = fopen(output_file, "w"))) {
1846 fatal_error("cannot open output_file");
1847 }
1848 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
1849 if (strncmp(incoming, "etc/adjtime", 11)
1850 && strncmp(incoming, "etc/mtab", 8)
1851 && strncmp(incoming, "tmp/", 4)
1852 && strncmp(incoming, "boot/map", 8)
1853 && !strstr(incoming, "incheckentry")
1854 && strncmp(incoming, "etc/mail/statistics", 19)
1855 && strncmp(incoming, "var/", 4))
1856 fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */
1857 mr_free(incoming);
1858 }
1859 mr_free(incoming);
1860 paranoid_fclose(fout);
1861 paranoid_fclose(fin);
1862}
1863
1864/**************************************************************************
1865 *END_STREAMLINE_CHANGES_FILE *
1866 **************************************************************************/
1867
1868
1869/**
1870 * Give the user twenty seconds to press Ctrl-Alt-Del before we nuke their drives.
1871 */
1872void twenty_seconds_til_yikes()
1873{
1874 int i;
1875 /* MALLOC * */
1876 char *tmp = NULL;
1877
1878 if (does_file_exist("/tmp/NOPAUSE")) {
1879 return;
1880 }
1881 open_progress_form("CAUTION",
1882 "Be advised: I am about to ERASE your hard disk(s)!",
1883 "You may press Ctrl+Alt+Del to abort safely.",
1884 "", 20);
1885 for (i = 0; i < 20; i++) {
1886 g_current_progress = i;
1887 mr_asprintf(tmp, "You have %d seconds left to abort.", 20 - i);
1888 update_progress_form(tmp);
1889 mr_free(tmp);
1890 sleep(1);
1891 }
1892 close_progress_form();
1893}
1894
1895/**************************************************************************
1896 *END_TWENTY_SECONDS_TIL_YIKES *
1897 **************************************************************************/
1898
1899
1900/**
1901 * Unmount all devices in @p p_external_copy_of_mountlist.
1902 * @param p_external_copy_of_mountlist The mountlist to guide the devices to unmount.
1903 * @return 0 for success, nonzero for failure.
1904 */
1905int unmount_all_devices(struct mountlist_itself
1906 *p_external_copy_of_mountlist)
1907{
1908 struct mountlist_itself *mountlist;
1909 int retval = 0, lino, res = 0, i;
1910 char *command = NULL;
1911 char *tmp = NULL;
1912
1913 assert(p_external_copy_of_mountlist != NULL);
1914
1915 mountlist = malloc(sizeof(struct mountlist_itself));
1916 memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist, sizeof(struct mountlist_itself));
1917 sort_mountlist_by_mountpoint(mountlist, 0);
1918
1919 run_program_and_log_output("df -m -P -T", 3);
1920 mvaddstr_and_log_it(g_currentY, 0, "Unmounting devices ");
1921 open_progress_form("Unmounting devices", "Unmounting all devices that were mounted,", "in preparation for the post-restoration reboot.", "", mountlist->entries);
1922 if (chdir("/")) {
1923 // FIXME
1924 }
1925 for (i = 0; i < 10 && run_program_and_log_output("ps | grep buffer | grep -v \"grep buffer\"", TRUE) == 0; i++) {
1926 sleep(1);
1927 log_msg(2, "Waiting for buffer() to finish");
1928 }
1929
1930 sync();
1931
1932 /* after that what is logged is not copied on disk, typically the result of labelling */
1933 mr_asprintf(tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);
1934 if (run_program_and_log_output(tmp, FALSE)) {
1935 log_msg(1, "Error. Failed to copy log to PC's /var/log dir. (Mounted read-only?)");
1936 }
1937 paranoid_free(tmp);
1938 if (does_file_exist("/tmp/DUMBASS-GENTOO")) {
1939 run_program_and_log_output("mkdir -p " MNT_RESTORING "/mnt/.boot.d", 5);
1940 }
1941
1942 /* Unmounting the local /proc and /sys first */
1943 run_program_and_log_output("umount -d " MNT_RESTORING "/proc",3);
1944 run_program_and_log_output("umount -d " MNT_RESTORING "/sys",3);
1945
1946 for (lino = mountlist->entries - 1; lino >= 0; lino--) {
1947 if (!strcmp(mountlist->el[lino].mountpoint, "lvm")) {
1948 continue;
1949 }
1950 mr_asprintf(tmp, "Unmounting device %s ", mountlist->el[lino].device);
1951 update_progress_form(tmp);
1952
1953 //TODO: this should be done in a certain order normally if there are cascading mount
1954 if (is_this_device_mounted(mountlist->el[lino].device)) {
1955 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
1956 mr_asprintf(command, "swapoff %s", mountlist->el[lino].device);
1957 } else {
1958 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
1959 mr_asprintf(command, "umount -d %s/", MNT_RESTORING);
1960 log_msg(3,
1961 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
1962 } else {
1963 mr_asprintf(command, "umount -d " MNT_RESTORING "%s", mountlist->el[lino].mountpoint);
1964
1965 /* To support latest Ubuntu where /var is a separate FS
1966 * Cf: http://linux.derkeiler.com/Mailing-Lists/Ubuntu/2007-04/msg01319.html
1967 * we need to create some dirs under the real / before unmounting it */
1968 if (!strcmp(mountlist->el[lino].mountpoint, "/")) {
1969 run_program_and_log_output("mkdir -p " MNT_RESTORING "/var/lock", FALSE);
1970 run_program_and_log_output("mkdir -p " MNT_RESTORING "/var/run", FALSE);
1971 }
1972 }
1973 }
1974 log_msg(10, "The 'umount' command is '%s'", command);
1975 res = run_program_and_log_output(command, 3);
1976 mr_free(command);
1977 } else {
1978 mr_strcat(tmp, "...not mounted anyway :-) OK");
1979 res = 0;
1980 }
1981 g_current_progress++;
1982 if (res) {
1983 mr_strcat(tmp, "...Failed");
1984 retval++;
1985 log_to_screen(tmp);
1986 } else {
1987 log_msg(2, tmp);
1988 }
1989 paranoid_free(tmp);
1990 }
1991 close_progress_form();
1992 if (retval) {
1993 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
1994 } else {
1995 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
1996 }
1997 if (retval) {
1998 log_to_screen("Unable to unmount some of your partitions.");
1999 } else {
2000 log_to_screen("All partitions were unmounted OK.");
2001 }
2002 mr_asprintf(command, "mount");
2003 log_msg(4, "mount result after unmounting all FS", command);
2004 (void)run_program_and_log_output(command, 3);
2005 mr_free(command);
2006 free(mountlist);
2007 return (retval);
2008}
2009
2010/**************************************************************************
2011 *END_UNMOUNT_ALL_DEVICES *
2012 **************************************************************************/
2013
2014/**
2015 * Extract mondorestore.cfg and the mountlist from the tape inserted
2016 * to the ./tmp/ directory.
2017 * @param dev The tape device to read from.
2018 * @return 0 for success, nonzero for failure.
2019 */
2020int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)
2021{
2022 char *command = NULL;
2023 int res = 0;
2024
2025 if (bkpinfo->use_obdr) {
2026 skip_obdr();
2027 } else {
2028 // TODO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0
2029 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size);
2030 }
2031
2032 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
2033 log_msg(2, "command = '%s'", command);
2034 res = run_program_and_log_output(command, -1);
2035 mr_free(command);
2036
2037 if (res != 0) {
2038 if (does_file_exist(MONDO_CFG_FILE_STUB)) {
2039 res = 0;
2040 } else {
2041 /* Doing that allow us to remain compatible with pre-2.2.5 versions */
2042 log_msg(2, "pre-2.2.4 compatible mode on");
2043 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
2044 log_msg(2, "command = '%s'", command);
2045 res = run_program_and_log_output(command, -1);
2046 mr_free(command);
2047 if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) {
2048 res = 0;
2049 }
2050 }
2051 }
2052 paranoid_free(command);
2053 return (res);
2054}
2055
2056
2057/**
2058 * Get the configuration file from the floppy, tape, or CD.
2059 * @param bkpinfo The backup information structure. Fields used:
2060 * - @c bkpinfo->backup_media_type
2061 * - @c bkpinfo->media_device
2062 * - @c bkpinfo->tmpdir
2063 * @return 0 for success, nonzero for failure.
2064 */
2065int get_cfg_file_from_archive()
2066{
2067 int retval = 0;
2068
2069 /** malloc *****/
2070 char *command = NULL;
2071 char *cfg_file = NULL;
2072 char *tmp = NULL;
2073 char *tmp1 = NULL;
2074 char *mountpt = NULL;
2075 char *mountlist_file = NULL;
2076 bool extract_mountlist_stub = FALSE;
2077 bool extract_i_want_my_lvm = FALSE;
2078
2079 bool try_plan_B;
2080
2081 assert(bkpinfo != NULL);
2082 log_msg(2, "gcffa --- starting");
2083 log_to_screen("I'm thinking...");
2084 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
2085 if (chdir(bkpinfo->tmpdir)) {
2086 // FIXME
2087 }
2088 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);
2089 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent
2090 mr_free(cfg_file);
2091
2092 unlink(FILELIST_FULL_STUB);
2093 unlink(BIGGIELIST_TXT_STUB);
2094 mr_asprintf(command, "mkdir -p %s", mountpt);
2095 run_program_and_log_output(command, FALSE);
2096 mr_free(command);
2097
2098 mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
2099 mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
2100 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
2101 mr_free(mountpt);
2102
2103 if (!does_file_exist(cfg_file)) {
2104 log_msg(2, "gcffa --- we don't have cfg file yet.");
2105 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
2106 try_plan_B = TRUE;
2107 } else {
2108 log_msg(2, "gcffa --- calling mount_media now :)");
2109 if (!mount_media()) {
2110 log_msg(2, "gcffa --- managed to mount CD; so, no need for Plan B");
2111 try_plan_B = FALSE;
2112 } else {
2113 try_plan_B = TRUE;
2114 }
2115 if (what_number_cd_is_this() > 1) {
2116 insist_on_this_cd_number((g_current_media_number = 1));
2117 }
2118 }
2119 if (try_plan_B) {
2120 log_msg(2, "gcffa --- OK, switching to Plan B");
2121 if (chdir(bkpinfo->tmpdir)) {
2122 // FIXME
2123 }
2124 run_program_and_log_output("mkdir -p tmp", FALSE);
2125
2126 if (strlen(bkpinfo->media_device) == 0) {
2127 strcpy(bkpinfo->media_device, "/dev/st0");
2128 log_msg(2, "media_device is blank; assuming %s");
2129 }
2130 mr_asprintf(tmp, "%s", bkpinfo->media_device);
2131 if (extract_cfg_file_and_mountlist_from_tape_dev
2132 (bkpinfo->media_device)) {
2133 strcpy(bkpinfo->media_device, "/dev/st0");
2134 if (extract_cfg_file_and_mountlist_from_tape_dev
2135 (bkpinfo->media_device)) {
2136 strcpy(bkpinfo->media_device, "/dev/osst0");
2137 if (extract_cfg_file_and_mountlist_from_tape_dev
2138 (bkpinfo->media_device)) {
2139 strcpy(bkpinfo->media_device, "/dev/ht0");
2140 if (extract_cfg_file_and_mountlist_from_tape_dev
2141 (bkpinfo->media_device)) {
2142 log_msg(3,
2143 "I tried lots of devices but none worked.");
2144 strcpy(bkpinfo->media_device, tmp);
2145 }
2146 }
2147 }
2148 }
2149 mr_free(tmp);
2150
2151 if (!does_file_exist("tmp/mondorestore.cfg")) {
2152 log_to_screen("Cannot find config info on media");
2153 return (1);
2154 }
2155 } else {
2156 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) {
2157 extract_mountlist_stub = FALSE;
2158 } else {
2159 extract_mountlist_stub = TRUE;
2160 }
2161 if (does_file_exist("/"IWANTMYLVM_STUB)) {
2162 extract_i_want_my_lvm = FALSE;
2163 } else {
2164 extract_i_want_my_lvm = TRUE;
2165 }
2166
2167 log_msg(2, "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");
2168 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
2169 run_program_and_log_output(command, TRUE);
2170 mr_free(command);
2171
2172 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
2173 /* Doing that allow us to remain compatible with pre-2.2.5 versions */
2174 log_msg(2, "pre-2.2.4 compatible mode on");
2175 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
2176 run_program_and_log_output(command, TRUE);
2177 mr_free(command);
2178 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
2179 fatal_error
2180 ("Please reinsert the disk/CD and try again.");
2181 }
2182 }
2183 }
2184 }
2185 if (does_file_exist(MONDO_CFG_FILE_STUB)) {
2186 log_msg(1, "gcffa --- great! We've got the config file");
2187 tmp1 = call_program_and_get_last_line_of_output("pwd");
2188 mr_asprintf(tmp, "%s/%s", tmp1, MONDO_CFG_FILE_STUB);
2189 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
2190 log_it("%s",command);
2191 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {
2192 log_msg(1,
2193 "... but an error occurred when I tried to move it to %s",
2194 cfg_file);
2195 } else {
2196 log_msg(1, "... and I moved it successfully to %s", cfg_file);
2197 }
2198 mr_free(command);
2199
2200 mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);
2201 mr_free(tmp1);
2202 log_it("%s",command);
2203 if (extract_mountlist_stub) {
2204 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {
2205 log_msg(1, "Failed to get mountlist");
2206 } else {
2207 log_msg(1, "Got mountlist too");
2208 mr_free(command);
2209 mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname);
2210 if (run_program_and_log_output(command, 1)) {
2211 log_msg(1, "Failed to copy mountlist to /tmp");
2212 } else {
2213 log_msg(1, "Copied mountlist to /tmp as well OK");
2214 mr_free(command);
2215 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
2216 run_program_and_log_output(command, 1);
2217 }
2218 }
2219 }
2220 mr_free(command);
2221 mr_free(tmp);
2222 }
2223
2224 run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
2225 if (!does_file_exist(cfg_file)) {
2226 log_it("%s",cfg_file);
2227 log_msg(1, "%s not found", cfg_file);
2228 log_to_screen("Oh dear. Unable to recover configuration file from boot disk");
2229 return (1);
2230 }
2231
2232 log_to_screen("Recovered mondorestore.cfg");
2233 if (!does_file_exist(MOUNTLIST_FNAME_STUB)) {
2234 log_to_screen("...but not mountlist.txt - a pity, really...");
2235 } else {
2236 /* Is this code really useful ??? */
2237 if (extract_mountlist_stub) {
2238 mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
2239 run_program_and_log_output(command, FALSE);
2240 mr_free(command);
2241 }
2242 }
2243
2244 mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
2245 mr_free(cfg_file);
2246
2247 run_program_and_log_output(command, FALSE);
2248 mr_free(command);
2249
2250 if (extract_mountlist_stub) {
2251 mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
2252 run_program_and_log_output(command, FALSE);
2253 mr_free(command);
2254 }
2255 mr_free(mountlist_file);
2256
2257 mr_asprintf(command, "cp -f etc/raidtab /etc/");
2258 run_program_and_log_output(command, FALSE);
2259 mr_free(command);
2260
2261 if (extract_i_want_my_lvm) {
2262 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);
2263 run_program_and_log_output(command, FALSE);
2264 mr_free(command);
2265 }
2266 g_backup_media_type = bkpinfo->backup_media_type;
2267 return (retval);
2268}
2269
2270/**************************************************************************
2271 *END_GET_CFG_FILE_FROM_ARCHIVE *
2272 **************************************************************************/
2273
2274/* @} - end restoreUtilityGroup */
2275
2276void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage)
2277{
2278 struct raidlist_itself *raidlist;
2279 int unfinished_mdstat_devices = 9999;
2280 int i = 0;
2281 char *screen_message = NULL;
2282
2283 raidlist = malloc(sizeof(struct raidlist_itself));
2284
2285 assert(wait_for_percentage <= 100);
2286 log_it("wait_until_software_raids_are_prepped");
2287 while (unfinished_mdstat_devices > 0) {
2288 // FIXME: Prefix '/dev/' should really be dynamic!
2289 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
2290 log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
2291 log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE);
2292 return;
2293 }
2294 for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) {
2295 if (raidlist->el[i].progress < wait_for_percentage) {
2296 unfinished_mdstat_devices++;
2297 if (raidlist->el[i].progress == -1) // delayed while another partition inits
2298 {
2299 continue;
2300 }
2301 log_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i);
2302 mr_asprintf(screen_message, "Sync'ing %s", raidlist->el[i].raid_device);
2303 open_evalcall_form(screen_message);
2304 mr_free(screen_message);
2305
2306 while (raidlist->el[i].progress < wait_for_percentage) {
2307 log_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress);
2308 update_evalcall_form(raidlist->el[i].progress);
2309 sleep(2);
2310 // FIXME: Prefix '/dev/' should really be dynamic!
2311 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
2312 break;
2313 }
2314 }
2315 close_evalcall_form();
2316 }
2317 }
2318 }
2319 paranoid_free(raidlist);
2320}
Note: See TracBrowser for help on using the repository browser.