Ignore:
Timestamp:
Sep 27, 2007, 12:21:18 PM (17 years ago)
Author:
Bruno Cornec
Message:
  • Fix bug #197 (based on an initial patch of Scott Cummings)
  • Fix a bug where df was using locale to print messages and wasn't filtered correctly
  • mkdtemp checked in configure
  • reset_bkpinfo called as early as possible by both main program.
  • It creates a tmpdir cleanly with mkdtemp in setup_tmpdir subfunction, which takes in account TMPIR and TMP env var. Remains to see what tmpfs does and tests
  • configure.in should also be filtered.
  • Remove g_bkpinfo_DONTUSETHIS
  • remove bkpinfo also from header files
  • Render bkpinfo global (potential issue on thread, but should not be a problem as that structure is indeed static during archive)
  • Apply patch from Andree Leidenfrost, modified a bit to use bkpinfo->tmpdir instead of /tmp or MINDI_CACHE when appropriate. Fix security issues in mondo. Thanks al ot Andree for catching all those issues.
  • /tmp => /var/log for mondorestore.log in mindi
  • Update linux terminfo to fix a color issue (Andree Leidenfrost)
  • Removes useless log file (Andree Leidenfrost)
  • replace vi with find_my_editor during restore (Andree Leidenfrost)
  • sync in bg in mindi (VMWare issue to look at)
  • mindi/mindi-busybox have a different version than mondo for pb
  • PB-SUF also added to spec file
  • Fix a bug for pb build (omission of PB-SUF declaration)

(merge -r1631:1662 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-tools.c

    r1639 r1663  
    2323#include <sys/socket.h>
    2424#include <netdb.h>
     25#include <stdlib.h>
    2526#include <netinet/in.h>
    2627#include <arpa/inet.h>
     
    3940
    4041extern struct mr_ar_conf *mr_conf;
     42
     43/* Reference to global bkpinfo */
     44extern struct s_bkpinfo *bkpinfo;
    4145
    4246/**
     
    347351 * do not exist.
    348352 */
    349 int post_param_configuration(struct s_bkpinfo *bkpinfo)
     353int post_param_configuration()
    350354{
    351355    char *extra_cdrom_params = NULL;
     
    383387    }
    384388    make_hole_for_dir(bkpinfo->scratchdir);
    385     make_hole_for_dir(bkpinfo->tmpdir);
    386389    if (bkpinfo->backup_media_type == iso)
    387390        make_hole_for_dir(bkpinfo->isodir);
     
    620623            }
    621624        }
    622         store_nfs_config(bkpinfo);
     625        store_nfs_config();
    623626        mr_free(hostname);
    624627    }
     
    638641    }
    639642    chmod(bkpinfo->scratchdir, 0700);
    640     chmod(bkpinfo->tmpdir, 0700);
    641643    g_backup_media_type = bkpinfo->backup_media_type;
    642644    g_backup_media_string = bkpinfo->backup_media_string;
     
    652654 * @return number of errors (0 for success)
    653655 */
    654 int pre_param_configuration(struct s_bkpinfo *bkpinfo)
     656int pre_param_configuration()
    655657{
    656658    int res = 0;
     659    char *tmp = NULL;
    657660
    658661    make_hole_for_dir(MNT_CDROM);
     
    660663    srandom((unsigned long) (time(NULL)));
    661664    insmod_crucial_modules();
    662     reset_bkpinfo(bkpinfo);     // also sets defaults ('/'=backup path, 3=compression level)
    663665    if (bkpinfo->disaster_recovery) {
    664666        if (!does_nonMS_partition_exist()) {
     
    668670    }
    669671
    670     run_program_and_log_output("rm -Rf /tmp/changed.files*", FALSE);
     672    asprintf(&tmp,"rm -Rf %s/changed.files*",MINDI_CACHE);
     673    run_program_and_log_output(tmp, FALSE);
     674    paranoid_free(tmp);
    671675    res += some_basic_system_sanity_checks();
    672676    if (res) {
     
    678682}
    679683
    680 
     684void setup_tmpdir(char *path) {
     685   
     686    char *tmp = NULL;
     687    char *p = NULL;
     688
     689    if (bkpinfo->tmpdir != NULL) {
     690        /* purging a potential old tmpdir */
     691        asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
     692        system(tmp);
     693        paranoid_free(tmp);
     694    }
     695       
     696    if (path != NULL) {
     697        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
     698    } else if (getenv("TMPDIR")) {
     699        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
     700    } else if (getenv("TMP")) {
     701        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
     702    } else {
     703        asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
     704    }
     705    p = mkdtemp(tmp);
     706    if (p == NULL) {
     707        log_it("Failed to create global tmp directory %s for Mondo.",tmp);
     708        finish(-1);
     709    }
     710    strcpy(bkpinfo->tmpdir,p);
     711    paranoid_free(tmp);
     712
     713    //sprintf(bkpinfo->tmpdir, "%s/tmpfs/mondo.tmp.%d", "/tmp", (int) (random() % 32768));  // for mondorestore
     714}
    681715
    682716
     
    685719 * @param bkpinfo The @c bkpinfo to reset.
    686720 */
    687 void reset_bkpinfo(struct s_bkpinfo *bkpinfo)
     721void reset_bkpinfo()
    688722{
    689723    char *tmp = NULL;
     
    694728    /* BERLIOS : Useless ?? */
    695729    memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo));
     730
     731    /* special case for tmpdir as used eveywhere after */
     732    setup_tmpdir(NULL);
    696733
    697734    bkpinfo->manual_tray = mr_conf->manual_tray;
     
    726763    bkpinfo->scratchdir[0] = '\0';
    727764    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
    728     sprintf(bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768));  // for mondorestore
    729765    bkpinfo->optimal_set_size = 0;
    730766    bkpinfo->backup_media_type = none;
     
    952988        fatal_error("Please reinstall Mondo and Mindi.");
    953989    }
    954     if (run_program_and_log_output
    955         ("mindi --makemountlist /tmp/mountlist.txt.test", 5)) {
     990    mr_asprintf(&tmp, "mindi --makemountlist %s/mountlist.txt.test", bkpinfo->tmpdir);
     991    if (run_program_and_log_output(tmp, 5)) {
     992        log_to_screen(tmp);
    956993        log_to_screen
    957             (_("Mindi --makemountlist /tmp/mountlist.txt.test failed for some reason."));
     994            (_("failed for some reason."));
    958995        log_to_screen
    959996            (_("Please run that command by hand and examine /var/log/mindi.log"));
     
    9641001        retval++;
    9651002    }
     1003    mr_free(tmp);
    9661004
    9671005    if (!run_program_and_log_output("parted2fdisk -l | grep -i raid", 1)
     
    11561194        return (1);
    11571195    }
    1158     mr_asprintf(&tempfile,
    1159            call_program_and_get_last_line_of_output
    1160            ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX"));
     1196    mr_asprintf(&tempfile, "%s/mojo-jojo.blah", bkpinfo->tmpdir);
    11611197    if (does_file_exist(config_file)) {
    11621198        mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s",
     
    11851221{
    11861222    if (mal) {
    1187         iamhere("Malloc'ing globals");
    11881223        malloc_string(g_boot_mountpt);
    11891224        malloc_string(g_tmpfs_mountpt);
     
    11921227        malloc_string(g_magicdev_command);
    11931228    } else {
    1194         iamhere("Freeing globals");
    11951229        mr_free(g_boot_mountpt);
    11961230        mr_free(g_tmpfs_mountpt);
Note: See TracChangeset for help on using the changeset viewer.