Changeset 3836 in MondoRescue for branches/3.3/mondo/src/mondorestore


Ignore:
Timestamp:
Mar 5, 2024, 2:50:53 AM (18 months ago)
Author:
Bruno Cornec
Message:

manages isodir dynamically

Location:
branches/3.3/mondo/src/mondorestore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c

    r3835 r3836  
    252252 * @return TRUE if OK was pressed, FALSE otherwise.
    253253 */
    254 bool
    255 get_isodir_info(char *isodir_device, char *isodir_format,
     254bool get_isodir_info(char *isodir_device, char *isodir_format,
    256255                struct s_bkpinfo *bkpinfo, bool nuke_me_please)
    257256{
    258257
    259258    bool HDD = FALSE;
     259    char *tmp = NULL;
    260260    /** initialize ********************************************************/
    261261
     
    269269        strcpy(isodir_device, "/dev/");
    270270    }
    271     if (bkpinfo->isodir[0] == '\0') {
    272         strcpy(bkpinfo->isodir, "/");
    273     }
    274     // TODO: Are we shure 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 ?
    275275    if (does_file_exist("/tmp/NETFS-SERVER-MOUNT")) {
    276276        strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT"));
    277277        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"));
    279279    }
    280280    if (nuke_me_please) {
     
    287287                HDD = TRUE;
    288288            }
    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) {
    290291                strip_spaces(isodir_device);
    291292                strip_spaces(isodir_format);
    292                 strip_spaces(bkpinfo->isodir);
     293                bkpinfo->isodir = mr_strip_spaces(tmp);
     294                mr_free(tmp);
    293295                log_it("isodir_device = %s - isodir_format = %s - bkpinfo->isodir = %s", isodir_device, isodir_format, bkpinfo->isodir);
    294296                if (HDD) {
    295297                    /*  We need an additional param */
    296298                    mr_asprintf(bkpinfo->subdir, "%s", bkpinfo->isodir);
    297                     strcpy(bkpinfo->isodir, "/tmp/isodir");
     299                    mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir");
    298300                    log_it("Now bkpinfo->isodir = %s and subdir = ", bkpinfo->isodir, bkpinfo->subdir);
    299301                }
     
    326328if (bkpinfo->disaster_recovery) {
    327329    /* 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");
    330332    }
    331333    mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
     
    925927    */
    926928    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
    933940    if ((!bkpinfo->disaster_recovery) || (g_isodir_device[0] != '\0')) {
    934941        if (strcmp(old_isodir, bkpinfo->isodir)) {
    935942            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);
    937944        }
    938945    }
     
    969976                bkpinfo->backup_media_type = cdr;
    970977                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';
    972980                if (mount_media()) {
    973981                    mr_free(tmp1);
     
    982990        /*  except when already done in iso_fiddly_bits */
    983991        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);
    985993        }
    986994    }
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3833 r3836  
    28432843            if ((bkpinfo->backup_media_type == netfs) && bkpinfo->netfs_mount && !is_this_device_mounted(bkpinfo->netfs_mount)) {
    28442844                log_msg(1, "Mounting remote %s dir", bkpinfo->netfs_proto);
    2845                 sprintf(bkpinfo->isodir, "/tmp/isodir");
     2845                mr_asprintf(bkpinfo->isodir, "%s", "/tmp/isodir");
    28462846                run_program_and_log_output("mkdir -p /tmp/isodir", 5);
    28472847                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
Note: See TracChangeset for help on using the changeset viewer.