Changeset 3195


Ignore:
Timestamp:
Sep 30, 2013, 9:07:23 AM (5 years ago)
Author:
bruno
Message:
  • Fix tmpdir initialization as mkdtemp modify the existing string so it should not be freed too early.
Location:
branches/3.2/mondo/src/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-fork.c

    r3194 r3195  
    249249    if (!program[0]) {
    250250        log_msg(2, "Warning - asked to run zerolength program");
    251         return (1);
     251        return(1);
    252252    }
    253253
     
    312312        }
    313313    }
    314     return (res);
     314    return(res);
    315315}
    316316
  • branches/3.2/mondo/src/common/libmondo-tools.c

    r3194 r3195  
    707707    char *p = NULL;
    708708
    709     if (bkpinfo->tmpdir != NULL) {
     709    if (bkpinfo->tmpdir[0] != '\0') {
    710710        /* purging a potential old tmpdir */
    711711        if (chdir("/tmp")) {
     
    735735    p = mkdtemp(tmp);
    736736    if (p == NULL) {
    737         log_it("Failed to create global tmp directory %s for Mondo.",tmp);
     737        printf("Failed to create global tmp directory %s for Mondo.",tmp);
    738738        mr_free(tmp);
    739739        finish(-1);
    740740    }
     741    strcpy(bkpinfo->tmpdir,p);
    741742    mr_free(tmp);
    742743
    743     strcpy(bkpinfo->tmpdir,p);
    744744    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    745745
     
    799799void reset_bkpinfo()
    800800{
    801     log_msg(1, "Initializing bkpinfo");
    802 
    803801    assert(bkpinfo != NULL);
    804802    memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo));
     
    822820   
    823821    /*  We need tmpdir as early as possible for further function calls */
    824     bkpinfo->tmpdir[0]= '\0';           // Really setup after
    825     bkpinfo->scratchdir[0]= '\0';           // Really setup after
     822    bkpinfo->tmpdir[0] = '\0';          // Really setup after
     823    bkpinfo->scratchdir[0] = '\0';          // Really setup after
    826824    setup_tmpdir(NULL);
    827825    setup_scratchdir(NULL);
     
    919917    int retval = 0;
    920918
    921     mvaddstr_and_log_it(g_currentY, 0,
    922                         "Checking sanity of your Linux distribution");
     919    mvaddstr_and_log_it(g_currentY, 0, "Checking sanity of your Linux distribution");
    923920#ifndef __FreeBSD__
    924921    if (system("which mkfs.vfat 2> /dev/null 1> /dev/null")
     
    950947        /* Some SuSE have ramdisk as modules, so insert it first, then test again */
    951948        run_program_and_log_output("modprobe brd 2> /dev/null > /dev/null",FALSE);
    952         if (run_program_and_log_output
    953             ("grep ramdisk /proc/devices", FALSE)) {
    954             if (!ask_me_yes_or_no
    955                 ("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?"))
    956             {
     949        if (run_program_and_log_output("grep ramdisk /proc/devices", FALSE)) {
     950            if (!ask_me_yes_or_no("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?")) {
    957951                //          retval++;
    958                 log_to_screen
    959                     ("It looks as if your kernel lacks ramdisk and initrd support.");
    960                 log_to_screen
    961                     ("I'll allow you to proceed but FYI, if I'm right, your kernel is broken.");
     952                log_to_screen("It looks as if your kernel lacks ramdisk and initrd support.");
     953                log_to_screen("I'll allow you to proceed but FYI, if I'm right, your kernel is broken.");
    962954            }
    963955        }
     
    992984    if (strcmp("", tmp)) {
    993985        if (strstr(tmp, "autofs")) {
    994             log_to_screen
    995                 ("Your CD-ROM is mounted via autofs. I therefore cannot tell");
    996             log_to_screen
    997                 ("if a CD actually is inserted. If a CD is inserted, please");
     986            log_to_screen("Your CD-ROM is mounted via autofs. I therefore cannot tell");
     987            log_to_screen("if a CD actually is inserted. If a CD is inserted, please");
    998988            log_to_screen("eject it. Thank you.");
    999             log_it
    1000                 ("Ignoring autofs CD-ROM 'mount' since we hope nothing's in it.");
     989            log_it("Ignoring autofs CD-ROM 'mount' since we hope nothing's in it.");
    1001990        } else
    1002991            if (run_program_and_log_output("uname -a | grep Knoppix", 5)) {
     
    10171006    if (run_program_and_log_output("mindi -V", 1)) {
    10181007        log_to_screen("Could not ascertain mindi's version number.");
    1019         log_to_screen
    1020             ("You have not installed Mondo and/or Mindi properly.");
     1008        log_to_screen("You have not installed Mondo and/or Mindi properly.");
    10211009        log_to_screen("Please uninstall and reinstall them both.");
    10221010        fatal_error("Please reinstall Mondo and Mindi.");
     
    10241012    mr_asprintf(tmp, "mindi --makemountlist %s/mountlist.txt.test", bkpinfo->tmpdir);
    10251013    if (run_program_and_log_output(tmp, 5)) {
     1014        log_to_screen("%s failed for some reason.", tmp);
    10261015        mr_free(tmp);
    1027         mr_asprintf(tmp, "mindi --makemountlist %s/mountlist.txt.test failed for some reason.", bkpinfo->tmpdir);
    1028         log_to_screen(tmp);
    1029         log_to_screen
    1030             ("Please run that command by hand and examine /var/log/mindi.log");
    1031         log_to_screen
    1032             ("for more information. Perhaps your /etc/fstab file is insane.");
    1033         log_to_screen
    1034             ("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see.");
     1016        log_to_screen("Please run that command by hand and examine /var/log/mindi.log");
     1017        log_to_screen("for more information. Perhaps your /etc/fstab file is insane.");
     1018        log_to_screen("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see.");
    10351019        retval++;
    10361020    }
    10371021    mr_free(tmp);
    10381022
    1039     if (!run_program_and_log_output("parted2fdisk -l 2>/dev/null | grep -i raid", 1)
    1040         && !does_file_exist("/etc/raidtab")) {
    1041         log_to_screen
    1042             ("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
     1023    if (!run_program_and_log_output("parted2fdisk -l 2>/dev/null | grep -i raid", 1) && !does_file_exist("/etc/raidtab")) {
     1024        log_to_screen("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
    10431025        create_raidtab_from_mdstat(MDSTAT_FILE,"/etc/raidtab");
    10441026    }
Note: See TracChangeset for help on using the changeset viewer.