Changeset 2322


Ignore:
Timestamp:
Aug 18, 2009, 2:37:58 PM (10 years ago)
Author:
bruno
Message:

r3333@localhost: bruno | 2009-08-08 01:58:31 +0200

  • bkpinfo->prefix is now dynamically assigned
  • Fix newt mondoarchive
Location:
branches/2.2.10/mondo/src
Files:
8 edited

Legend:

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

    r2321 r2322  
    12261226
    12271227    if (flag_set['p']) {
    1228         strncpy(bkpinfo->prefix, flag_val['p'], MAX_STR_LEN / 4);
     1228        mr_free(bkpinfo->prefix);
     1229        mr_asprintf(&tmp1, "%s", flag_val['p']);
     1230        bkpinfo->prefix = tmp1;
    12291231        log_msg(1,"Prefix forced to %s",bkpinfo->prefix);
    12301232    }
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2321 r2322  
    1919#include "libmondo-fork-EXT.h"
    2020#include "libmondo-stream-EXT.h"
     21
     22extern void mr_strip_spaces(char *);
    2123
    2224#include <sys/types.h>
     
    18031805            finish(1);
    18041806        }
     1807        mr_free(bkpinfo->prefix);
     1808        bkpinfo->prefix = p;
    18051809        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    1806         strcpy(bkpinfo->prefix, p);
    1807         mr_free(p);
    18081810
    18091811        log_msg(3, "Just set nfs_remote_dir to %s", bkpinfo->nfs_remote_dir);
     
    18471849            finish(1);
    18481850        }
    1849         strcpy(bkpinfo->prefix, p);
    1850         mr_free(p);
     1851        mr_free(bkpinfo->prefix);
     1852        bkpinfo->prefix = p;
    18511853        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    18521854        break;
     1855
    18531856    default:
    18541857        fatal_error
     
    20172020    log_it("media device = %s", bkpinfo->media_device);
    20182021    log_it("media size = %ld", bkpinfo->media_size[1]);
    2019     log_it("media type = %s",
    2020            bkptype_to_string(bkpinfo->backup_media_type));
     2022    log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    20212023    log_it("prefix = %s", bkpinfo->prefix);
    20222024    log_it("compression = %ld", bkpinfo->compression_level);
     
    20262028    log_it("tmpdir = '%s'", bkpinfo->tmpdir);
    20272029    log_it("image_devs = '%s'", bkpinfo->image_devs);
    2028     log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device,
    2029            bkpinfo->boot_loader);
     2030    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device, bkpinfo->boot_loader);
    20302031    if (bkpinfo->media_size[0] < 0) {
    20312032        if (archiving_to_media) {
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2321 r2322  
    203203    int i;
    204204    char *tmp;
     205    char *tmp1 = NULL;
    205206    char ch;
    206207
     
    224225    tmp[i] = '\0';
    225226    outval = atol(tmp);
     227    paranoid_free(tmp);
    226228    if (ch == 'g' || ch == 'G') {
    227229        outval = outval * 1024;
     
    239241        fatal_error("Integer overflow.");
    240242    } else if (ch != 'm' && ch != 'M') {
    241         sprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')",
    242                 incoming, ch);
    243         fatal_error(tmp);
    244     }
    245     paranoid_free(tmp);
     243        mr_asprintf(&tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     244        fatal_error(tmp1);
     245    }
    246246    return (outval);
    247247}
     
    549549    /*@ buffers **************************************************** */
    550550    static char output[MAX_STR_LEN];
    551     static char suffix[MAX_STR_LEN];
     551    char *suffix = NULL;
    552552
    553553    /*@ end vars *************************************************** */
     
    555555    assert_string_is_neither_NULL_nor_zerolength(path);
    556556    if (s[0] != '\0') {
    557         sprintf(suffix, ".%s", s);
     557        mr_asprintf(&suffix, ".%s", s);
    558558    } else {
    559         suffix[0] = '\0';
    560     }
    561     sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno,
    562             suffix);
     559        mr_asprintf(&suffix, "");
     560    }
     561    sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno, suffix);
     562    mr_free(suffix);
    563563    return (output);
    564564}
     
    925925{
    926926    int sev;
    927     char *reason;
    928     char *filename;
    929 
    930     malloc_string(reason);
    931     malloc_string(filename);
    932    
     927    char *reason = NULL;
     928    char *filename = NULL;
     929
    933930    // out_reason might be null on purpose, so don't bomb if it is :) OK?
    934931    assert_string_is_neither_NULL_nor_zerolength(fn);
    935932    if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) {
    936         strcpy(filename, fn + strlen(MNT_RESTORING));
     933        mr_asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));
    937934    } else if (fn[0] != '/') {
    938         sprintf(filename, "/%s", fn);
     935        mr_asprintf(&filename, "/%s", fn);
    939936    } else {
    940         strcpy(filename, fn);
     937        mr_asprintf(&filename, "%s", fn);
    941938    }
    942939
    943940    sev = 3;
    944     sprintf(reason,
    945             "Changed since backup. Consider running a differential backup in a day or two.");
     941    mr_asprintf(&reason, "Changed since backup. Consider running a differential backup in a day or two.");
     942
    946943    if (!strncmp(filename, "/var/", 5)) {
    947944        sev = 2;
    948         sprintf(reason,
    949                 "/var's contents will change regularly, inevitably.");
     945        mr_free(reason);
     946        mr_asprintf(&reason, "/var's contents will change regularly, inevitably.");
    950947    }
    951948    if (!strncmp(filename, "/home", 5)) {
    952949        sev = 2;
    953         sprintf(reason,
    954                 "It's in your /home directory. Therefore, it is important.");
     950        mr_free(reason);
     951        mr_asprintf(&reason, "It's in your /home directory. Therefore, it is important.");
    955952    }
    956953    if (!strncmp(filename, "/usr/", 5)) {
    957954        sev = 3;
    958         sprintf(reason,
    959                 "You may have installed/removed software during the backup.");
     955        mr_free(reason);
     956        mr_asprintf(&reason, "You may have installed/removed software during the backup.");
    960957    }
    961958    if (!strncmp(filename, "/etc/", 5)) {
    962959        sev = 3;
    963         sprintf(reason,
    964                 "Do not edit config files while backing up your PC.");
     960        mr_free(reason);
     961        mr_asprintf(&reason, "Do not edit config files while backing up your PC.");
    965962    }
    966963    if (!strcmp(filename, "/etc/adjtime")
    967964        || !strcmp(filename, "/etc/mtab")) {
    968965        sev = 1;
    969         sprintf(reason, "This file changes all the time. It's OK.");
     966        mr_free(reason);
     967        mr_asprintf(&reason, "This file changes all the time. It's OK.");
    970968    }
    971969    if (!strncmp(filename, "/root/", 6)) {
    972970        sev = 3;
    973         sprintf(reason, "Were you compiling/editing something in /root?");
     971        mr_free(reason);
     972        mr_asprintf(&reason, "Were you compiling/editing something in /root?");
    974973    }
    975974    if (!strncmp(filename, "/root/.", 7)) {
    976975        sev = 2;
    977         sprintf(reason, "Temp or 'dot' files changed in /root.");
     976        mr_free(reason);
     977        mr_asprintf(&reason, "Temp or 'dot' files changed in /root.");
    978978    }
    979979    if (!strncmp(filename, "/var/lib/", 9)) {
    980980        sev = 2;
    981         sprintf(reason, "Did you add/remove software during backing?");
     981        mr_free(reason);
     982        mr_asprintf(&reason, "Did you add/remove software during backing?");
    982983    }
    983984    if (!strncmp(filename, "/var/lib/rpm", 12)) {
    984985        sev = 3;
    985         sprintf(reason, "Did you add/remove software during backing?");
     986        mr_free(reason);
     987        mr_asprintf(&reason, "Did you add/remove software during backing?");
    986988    }
    987989    if (!strncmp(filename, "/var/lib/slocate", 16)) {
    988990        sev = 1;
    989         sprintf(reason,
    990                 "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
     991        mr_free(reason);
     992        mr_asprintf(&reason, "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
    991993    }
    992994    if (!strncmp(filename, "/var/log/", 9)
     
    994996        || !strcmp(filename + strlen(filename) - 4, ".log")) {
    995997        sev = 1;
    996         sprintf(reason,
    997                 "Log files change frequently as the computer runs. Fret not.");
     998        mr_free(reason);
     999        mr_asprintf(&reason, "Log files change frequently as the computer runs. Fret not.");
    9981000    }
    9991001    if (!strncmp(filename, "/var/spool", 10)) {
    10001002        sev = 1;
    1001         sprintf(reason,
    1002                 "Background processes or printers were active. This does not affect the integrity of your backup.");
     1003        mr_free(reason);
     1004        mr_asprintf(&reason, "Background processes or printers were active. This does not affect the integrity of your backup.");
    10031005    }
    10041006    if (!strncmp(filename, "/var/spool/mail", 10)) {
    10051007        sev = 2;
    1006         sprintf(reason, "Mail was sent/received during backup.");
     1008        mr_free(reason);
     1009        mr_asprintf(&reason, "Mail was sent/received during backup.");
    10071010    }
    10081011    if (filename[strlen(filename) - 1] == '~') {
    10091012        sev = 1;
    1010         sprintf(reason,
    1011                 "Backup copy of another file which was modified recently.");
     1013        mr_free(reason);
     1014        mr_asprintf(&reason, "Backup copy of another file which was modified recently.");
    10121015    }
    10131016    if (strstr(filename, "cache")) {
    10141017        sev = 1;
    1015         sprintf(reason,
    1016                 "Part of a cache of data. Caches change from time to time. Don't worry.");
     1018        mr_free(reason);
     1019        mr_asprintf(&reason, "Part of a cache of data. Caches change from time to time. Don't worry.");
    10171020    }
    10181021    if (!strncmp(filename, "/var/run/", 9)
     
    10211024        || strstr(filename, "/.Xauthority")) {
    10221025        sev = 1;
    1023         sprintf(reason,
    1024                 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
     1026        mr_free(reason);
     1027        mr_asprintf(&reason, "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
    10251028    }
    10261029    if (out_reason) {
    10271030        strcpy(out_reason, reason);
    10281031    }
    1029     paranoid_free(filename);
    1030     paranoid_free(reason);
     1032    mr_free(filename);
     1033    mr_free(reason);
    10311034    return (sev);
    10321035}
     
    10781081    /*@ buffers ******************************************* */
    10791082    char *outstr = NULL;
    1080     char *pos_w_commas, *tmp;
     1083    char *pos_w_commas = NULL;
    10811084    char *mds = NULL;
     1085    char *tmp = NULL;
    10821086
    10831087    assert(bkpinfo != NULL);
    10841088
    10851089    if (bkpinfo->media_size[g_current_media_number] <= 0) {
    1086         malloc_string(pos_w_commas);
    1087         malloc_string(tmp);
    1088         sprintf(tmp, "%lld", g_tape_posK);
    1089         strcpy(pos_w_commas, commarize(tmp));
    1090         paranoid_free(tmp);
     1090        mr_asprintf(&tmp, "%lld", g_tape_posK);
     1091        mr_asprintf(&pos_w_commas, "%s", commarize(tmp));
     1092        mr_free(tmp);
    10911093        mr_asprintf(&outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
    1092         paranoid_free(pos_w_commas);
     1094        mr_free(pos_w_commas);
    10931095        return (outstr);
    10941096    }
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2321 r2322  
    804804{
    805805    int i;
     806    char *p = NULL;
    806807
    807808    log_msg(1, "Hi");
     
    832833        strcpy(bkpinfo->isodir, MONDO_CACHE);
    833834    }
    834     strcpy(bkpinfo->prefix, STD_PREFIX);
     835    mr_asprintf(&p, "%s", STD_PREFIX);
     836    bkpinfo->prefix = p;
    835837    bkpinfo->scratchdir = NULL;
    836838    bkpinfo->tmpdir = NULL;
  • branches/2.2.10/mondo/src/common/mondostructures.h

    r2321 r2322  
    472472   * If backup_media_type is anything else, this is ignored.
    473473   */
    474     char prefix[MAX_STR_LEN / 4];
     474    char *prefix;
    475475
    476476  /**
  • branches/2.2.10/mondo/src/lib/mr_mem.c

    r2320 r2322  
    5757   
    5858    ssize_t ret;
    59     ssize_t n = 0;
     59    size_t n = 0;
    6060
    6161    ret = getline(lineptr,&n,fd);
  • branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c

    r2321 r2322  
    3232
    3333/***************** global vars, used only by main.c ******************/
    34 long diffs;
     34long diffs = 0L;
    3535
    3636extern t_bkptype g_backup_media_type;
     
    167167    char *tmp = NULL;
    168168    char *tmp1 = NULL;
    169     int res, retval;
     169    int res = 0;
     170    int i = 0;
     171    int retval = 0;
    170172    char *say_at_end = NULL;
    171 
    172 /* Initialize variables */
    173 
    174     res = 0;
    175     retval = 0;
    176     diffs = 0;
    177173
    178174    printf("Initializing...\n");
     
    191187    } else {
    192188        g_text_mode = TRUE;
     189        /* newt mode if -g specified on cli */
     190        for (i = 0; i < argc; i++) {
     191            if (!strcmp(argv[i],"-g")) {
     192                g_text_mode = FALSE;
     193            }
     194        }
    193195    }
    194196    setup_newt_stuff();
     
    235237    if (argc == 4 && !strcmp(argv[1], "getfattr")) {
    236238        g_loglevel = 10;
    237         g_text_mode = TRUE;
    238239        if (!strstr(argv[2], "filelist")) {
    239240            printf("Sorry - filelist goes first\n");
     
    438439
    439440    if (!g_text_mode) {
    440         popup_and_OK
    441             ("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
     441        popup_and_OK("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
    442442        log_to_screen("See %s for details of backup run.", MONDO_LOGFILE);
    443443    } else {
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2321 r2322  
    772772        }
    773773    }
     774    mr_free(bkpinfo->prefix);
    774775    if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    775             strcpy(bkpinfo->prefix,value);
     776        mr_asprintf(&tmp1, "%s", value);
    776777    } else {
    777             strcpy(bkpinfo->prefix,STD_PREFIX);
    778     }
     778        mr_asprintf(&tmp1, "%s", STD_PREFIX);
     779    }
     780    bkpinfo->prefix = tmp1;
    779781} else if (!strcmp(value, "nfs")) {
    780782    bkpinfo->backup_media_type = nfs;
    781783    bkpinfo->please_dont_eject = TRUE;
     784    mr_free(bkpinfo->prefix);
    782785    if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    783             strcpy(bkpinfo->prefix,value);
     786        mr_asprintf(&tmp1, "%s", value);
    784787    } else {
    785             strcpy(bkpinfo->prefix,STD_PREFIX);
    786     }
    787     if (strstr(call_program_and_get_last_line_of_output
    788        ("cat /proc/cmdline"), "pxe")) {
     788        mr_asprintf(&tmp1, "%s", STD_PREFIX);
     789    }
     790    bkpinfo->prefix = tmp1;
     791
     792    if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
    789793        /* We need to override prefix value in PXE mode as it's
    790794        * already done in start-nfs */
     
    793797            fatal_error("no imgname variable in environment");
    794798        }
    795         strcpy(bkpinfo->prefix,envtmp1);
     799        mr_free(bkpinfo->prefix);
     800        mr_asprintf(&tmp1, "%s", envtmp1);
     801        bkpinfo->prefix = tmp1;
    796802    }
    797803
Note: See TracChangeset for help on using the changeset viewer.