Changeset 3836 in MondoRescue for branches/3.3
- Timestamp:
- Mar 5, 2024, 2:50:53 AM (6 months ago)
- Location:
- branches/3.3/mondo/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-cli.c
r3835 r3836 408 408 409 409 if (flag_set['n']) { 410 mr_free(bkpinfo->netfs_mount);411 410 mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']); 412 411 if (!flag_set['d']) { 413 mr_free(bkpinfo->netfs_remote_dir);414 412 mr_asprintf(bkpinfo->netfs_remote_dir, "/"); 415 strncpy(bkpinfo->isodir, ".", MAX_STR_LEN / 4);413 mr_asprintf(bkpinfo->isodir, "%s", "."); 416 414 } 417 415 /* test for protocol */ … … 466 464 mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 467 465 } 468 tmp2 = call_program_and_get_last_line_of_output(tmp1); 466 mr_free(bkpinfo->isodir); 467 bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp1); 469 468 mr_free(tmp1); 470 strncpy(bkpinfo->isodir, tmp2, (MAX_STR_LEN / 4)-1);471 mr_free(tmp2);472 469 473 470 log_msg(3, "proto = %s", bkpinfo->netfs_proto); … … 515 512 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 516 513 } 517 tmp2 = call_program_and_get_last_line_of_output(tmp1); 518 strncpy(bkpinfo->isodir, tmp2,(MAX_STR_LEN / 4)-1); 519 mr_free(tmp2); 514 mr_free(bkpinfo->isodir); 515 bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp1); 520 516 if (strlen(bkpinfo->isodir) < 3) { 521 517 retval++; … … 688 684 if (flag_set['d']) { /* backup directory (if ISO/NETFS) */ 689 685 if (flag_set['i']) { 690 strncpy(bkpinfo->isodir, flag_val['d'],(MAX_STR_LEN / 4)-1);686 mr_asprintf(bkpinfo->isodir, "%s", flag_val['d']); 691 687 sprintf(tmp, "ls -l %s", bkpinfo->isodir); 692 688 if (run_program_and_log_output(tmp, 2)) { -
branches/3.3/mondo/src/common/libmondo-devices.c
r3835 r3836 1354 1354 log_msg(2, "Mounting for Network thingy"); 1355 1355 log_msg(2, "isodir = %s", bkpinfo->isodir); 1356 if (( !bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/")) && am_I_in_disaster_recovery_mode()) {1357 strcpy(bkpinfo->isodir, "/tmp/isodir");1356 if ((bkpinfo->isodir == NULL) || !strcmp(bkpinfo->isodir, "/"))) && am_I_in_disaster_recovery_mode()) { 1357 mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir"); 1358 1358 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 1359 1359 } … … 2499 2499 } 2500 2500 mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1); 2501 tmp = call_program_and_get_last_line_of_output(command); 2502 strcpy(bkpinfo->isodir, tmp); 2503 mr_free(tmp); 2501 mr_free(bkpinfo->isodir); 2502 bkpinfo->isodir = call_program_and_get_last_line_of_output(command); 2504 2503 mr_free(command); 2505 2504 … … 2566 2565 log_msg(3, "Testing mount for %s", bkpinfo->netfs_mount); 2567 2566 if (is_this_device_mounted(bkpinfo->netfs_mount)) { 2568 tmp = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"); 2569 strcpy(bkpinfo->isodir, tmp); 2570 mr_free(tmp); 2567 mr_free(bkpinfo->isodir); 2568 bkpinfo->isodir = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"); 2571 2569 } else { 2572 2570 // Why netfsdir ? 2573 snprintf(bkpinfo->isodir, (MAX_STR_LEN / 4) -1, "%s/netfsdir", bkpinfo->tmpdir);2571 mr_asprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir); 2574 2572 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir); 2575 2573 run_program_and_log_output(command, 5); … … 2639 2637 case iso: 2640 2638 if (!bkpinfo->disaster_recovery) { 2641 if (!popup_and_get_string("Storage dir.", "Please enter the full path name to the directory for your ISO images. Example: /mnt/raid0_0", bkpinfo->isodir,(MAX_STR_LEN / 4)-1)) { 2639 tmp = mr_popup_and_get_string("Storage dir.", "Please enter the full path name to the directory for your ISO images. Example: /mnt/raid0_0", bkpinfo->isodir); 2640 if (tmp == NULL) { 2642 2641 log_to_screen("User has chosen not to backup the machine"); 2643 2642 finish(1); 2643 } else { 2644 mr_free(bkpinfo->isodir); 2645 bkpinfo->isodir = tmp; 2644 2646 } 2645 2647 if (archiving_to_media) { -
branches/3.3/mondo/src/common/libmondo-tools.c
r3834 r3836 832 832 bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode(); 833 833 if (bkpinfo->disaster_recovery) { 834 strcpy(bkpinfo->isodir, "/");834 mr_asprintf(bkpinfo->isodir, "%s", "/"); 835 835 } else { 836 strcpy(bkpinfo->isodir, MONDO_CACHE);837 } 838 strcpy(bkpinfo->prefix, STD_PREFIX);836 mr_asprintf(bkpinfo->isodir, "%s", MONDO_CACHE); 837 } 838 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 839 839 bkpinfo->optimal_set_size = 0L; 840 840 bkpinfo->backup_media_type = none; -
branches/3.3/mondo/src/common/newt-specific.c
r3835 r3836 442 442 mr_free(bkpinfo->scratchdir); 443 443 mr_free(bkpinfo->prefix); 444 mr_free(bkpinfo->isodir); 444 445 /* Then free the structure */ 445 446 paranoid_free(bkpinfo); -
branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c
r3835 r3836 252 252 * @return TRUE if OK was pressed, FALSE otherwise. 253 253 */ 254 bool 255 get_isodir_info(char *isodir_device, char *isodir_format, 254 bool get_isodir_info(char *isodir_device, char *isodir_format, 256 255 struct s_bkpinfo *bkpinfo, bool nuke_me_please) 257 256 { 258 257 259 258 bool HDD = FALSE; 259 char *tmp = NULL; 260 260 /** initialize ********************************************************/ 261 261 … … 269 269 strcpy(isodir_device, "/dev/"); 270 270 } 271 if (bkpinfo->isodir[0] == '\0') {272 strcpy(bkpinfo->isodir, "/");273 } 274 // TODO: Are we s hure it does what it's expected to do here ?271 if (bkpinfo->isodir[0] == NULL) { 272 mr_asprintf(bkpinfo->isodir, "%s", "/"); 273 } 274 // TODO: Are we sure it does what it's expected to do here ? 275 275 if (does_file_exist("/tmp/NETFS-SERVER-MOUNT")) { 276 276 strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT")); 277 277 strcpy(isodir_format, "netfs"); 278 strcpy(bkpinfo->isodir, last_line_of_file("/tmp/ISO-DIR"));278 mr_asprintf(bkpinfo->isodir, "%s", last_line_of_file("/tmp/ISO-DIR")); 279 279 } 280 280 if (nuke_me_please) { … … 287 287 HDD = TRUE; 288 288 } 289 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)) { 289 tmp = mr_popup_and_get_string ("ISO Mode - path", "At what path on this device can the ISO files be found ?", bkpinfo->isodir); 290 if (tmp) { 290 291 strip_spaces(isodir_device); 291 292 strip_spaces(isodir_format); 292 strip_spaces(bkpinfo->isodir); 293 bkpinfo->isodir = mr_strip_spaces(tmp); 294 mr_free(tmp); 293 295 log_it("isodir_device = %s - isodir_format = %s - bkpinfo->isodir = %s", isodir_device, isodir_format, bkpinfo->isodir); 294 296 if (HDD) { 295 297 /* We need an additional param */ 296 298 mr_asprintf(bkpinfo->subdir, "%s", bkpinfo->isodir); 297 strcpy(bkpinfo->isodir, "/tmp/isodir");299 mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir"); 298 300 log_it("Now bkpinfo->isodir = %s and subdir = ", bkpinfo->isodir, bkpinfo->subdir); 299 301 } … … 326 328 if (bkpinfo->disaster_recovery) { 327 329 /* Don't let this clobber an existing bkpinfo->isodir */ 328 if ( !bkpinfo->isodir[0]) {329 strcpy(bkpinfo->isodir, "/tmp/isodir");330 if (bkpinfo->isodir == NULL) { 331 mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir"); 330 332 } 331 333 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir); … … 925 927 */ 926 928 mr_asprintf(old_isodir, "%s", bkpinfo->isodir); 927 read_cfg_var(cfg_file, "iso-mnt", iso_mnt); 928 read_cfg_var(cfg_file, "iso-dir", iso_path); 929 snprintf(bkpinfo->isodir, (MAX_STR_LEN / 4)-1, "%s%s", iso_mnt, iso_path); 930 if (!bkpinfo->isodir[0]) { 931 strcpy(bkpinfo->isodir, old_isodir); 932 } 929 if (read_cfg_var(cfg_file, "iso-mnt", iso_mnt) != 0) { 930 iso_mnt[0] = '\0'; 931 } 932 if (read_cfg_var(cfg_file, "iso-dir", iso_path) != 0) { 933 iso_path[0] = '\0'; 934 } 935 mr_asprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 936 if (!strcmpbkpinfo->isodir,"") { 937 mr_asprintf(bkpinfo->isodir, "%s", old_isodir); 938 } 939 933 940 if ((!bkpinfo->disaster_recovery) || (g_isodir_device[0] != '\0')) { 934 941 if (strcmp(old_isodir, bkpinfo->isodir)) { 935 942 log_it("user nominated isodir %s differs from archive, keeping user's choice: %s\n", bkpinfo->isodir, old_isodir ); 936 strcpy(bkpinfo->isodir, old_isodir);943 mr_asprintf(bkpinfo->isodir, "%s", old_isodir); 937 944 } 938 945 } … … 969 976 bkpinfo->backup_media_type = cdr; 970 977 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); /* superfluous */ 971 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0'; 978 mr_free(bkpinfo->isodir); 979 iso_mnt[0] = iso_path[0] = '\0'; 972 980 if (mount_media()) { 973 981 mr_free(tmp1); … … 982 990 /* except when already done in iso_fiddly_bits */ 983 991 if ((bkpinfo->backup_media_type == iso) && (g_isodir_device[0] == '\0')) { 984 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);992 mr_asprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 985 993 } 986 994 } -
branches/3.3/mondo/src/mondorestore/mondorestore.c
r3833 r3836 2843 2843 if ((bkpinfo->backup_media_type == netfs) && bkpinfo->netfs_mount && !is_this_device_mounted(bkpinfo->netfs_mount)) { 2844 2844 log_msg(1, "Mounting remote %s dir", bkpinfo->netfs_proto); 2845 sprintf(bkpinfo->isodir, "/tmp/isodir");2845 mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir"); 2846 2846 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 2847 2847 if (strstr(bkpinfo->netfs_proto, "sshfs")) {
Note:
See TracChangeset
for help on using the changeset viewer.