Changeset 3836 in MondoRescue


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

manages isodir dynamically

Location:
branches/3.3/mondo/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3835 r3836  
    408408
    409409    if (flag_set['n']) {
    410         mr_free(bkpinfo->netfs_mount);
    411410        mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']);
    412411        if (!flag_set['d']) {
    413             mr_free(bkpinfo->netfs_remote_dir);
    414412            mr_asprintf(bkpinfo->netfs_remote_dir, "/");
    415             strncpy(bkpinfo->isodir, ".", MAX_STR_LEN / 4);
     413            mr_asprintf(bkpinfo->isodir, "%s", ".");
    416414        }
    417415        /* test for protocol */
     
    466464            mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    467465        }
    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);
    469468        mr_free(tmp1);
    470         strncpy(bkpinfo->isodir, tmp2, (MAX_STR_LEN / 4)-1);
    471         mr_free(tmp2);
    472469
    473470        log_msg(3, "proto = %s", bkpinfo->netfs_proto);
     
    515512                    mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    516513                }
    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);
    520516                if (strlen(bkpinfo->isodir) < 3) {
    521517                    retval++;
     
    688684    if (flag_set['d']) {        /* backup directory (if ISO/NETFS) */
    689685        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']);
    691687            sprintf(tmp, "ls -l %s", bkpinfo->isodir);
    692688            if (run_program_and_log_output(tmp, 2)) {
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3835 r3836  
    13541354        log_msg(2, "Mounting for Network thingy");
    13551355        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");
    13581358            log_msg(1, "isodir is being set to %s", bkpinfo->isodir);
    13591359        }
     
    24992499            }
    25002500            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);
    25042503            mr_free(command);
    25052504
     
    25662565        log_msg(3, "Testing mount for %s", bkpinfo->netfs_mount);
    25672566        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");
    25712569        } else {
    25722570            // Why netfsdir ?
    2573             snprintf(bkpinfo->isodir, (MAX_STR_LEN / 4) -1, "%s/netfsdir", bkpinfo->tmpdir);
     2571            mr_asprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir);
    25742572            mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
    25752573            run_program_and_log_output(command, 5);
     
    26392637    case iso:
    26402638        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) {
    26422641                log_to_screen("User has chosen not to backup the machine");
    26432642                finish(1);
     2643            } else {
     2644                mr_free(bkpinfo->isodir);
     2645                bkpinfo->isodir = tmp;
    26442646            }
    26452647            if (archiving_to_media) {
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3834 r3836  
    832832    bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode();
    833833    if (bkpinfo->disaster_recovery) {
    834         strcpy(bkpinfo->isodir, "/");
     834        mr_asprintf(bkpinfo->isodir, "%s", "/");
    835835    } 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);
    839839    bkpinfo->optimal_set_size = 0L;
    840840    bkpinfo->backup_media_type = none;
  • branches/3.3/mondo/src/common/newt-specific.c

    r3835 r3836  
    442442        mr_free(bkpinfo->scratchdir);
    443443        mr_free(bkpinfo->prefix);
     444        mr_free(bkpinfo->isodir);
    444445        /* Then free the structure */
    445446        paranoid_free(bkpinfo);
  • 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.