Changeset 1999


Ignore:
Timestamp:
Jul 10, 2008, 6:37:04 PM (11 years ago)
Author:
bruno
Message:
  • Protect recursive remove of tempdir with test on the look and feel of that dir to avoid removing blindly useful dir :-(
Location:
branches/2.2.7/mondo/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.7/mondo/src/common/libmondo-fork-EXT.h

    r1689 r1999  
    1010                                 int cd_no, char *logstub,
    1111                                 char *what_i_am_doing);
    12 extern int run_external_binary_with_percentage_indicator_OLD(char *tt,
    13                                                              char *cmd);
    1412extern int run_external_binary_with_percentage_indicator_NEW(char *tt,
    1513                                                             char *cmd);
  • branches/2.2.7/mondo/src/common/libmondo-fork.c

    r1784 r1999  
    701701
    702702
    703 
    704 
    705 
    706 int run_external_binary_with_percentage_indicator_OLD(char *tt, char *cmd)
    707 {
    708 
    709     /*@ int *************************************************************** */
    710     int res = 0;
    711     int percentage = 0;
    712     int maxpc = 0;
    713     int pcno = 0;
    714     int last_pcno = 0;
    715 
    716     /*@ buffers *********************************************************** */
    717     char *command;
    718     char *tempfile;
    719     char *title;
    720     /*@ pointers ********************************************************** */
    721     FILE *pin;
    722 
    723     malloc_string(title);
    724     malloc_string(command);
    725     malloc_string(tempfile);
    726     assert_string_is_neither_NULL_nor_zerolength(cmd);
    727     assert_string_is_neither_NULL_nor_zerolength(title);
    728 
    729     strcpy(title, tt);
    730     sprintf(tempfile, "%s/mondo.binperc", bkpinfo->tmpdir);
    731     sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
    732             tempfile);
    733     log_msg(3, command);
    734     open_evalcall_form(title);
    735     if (!(pin = popen(command, "r"))) {
    736         log_OS_error("fmt err");
    737         return (1);
    738     }
    739     maxpc = 100;
    740 // OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
    741     for (sleep(1); does_file_exist(tempfile); sleep(1)) {
    742         pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
    743         if (pcno < 0 || pcno > 100) {
    744             log_msg(5, "Weird pc#");
    745             continue;
    746         }
    747         percentage = pcno * 100 / maxpc;
    748         if (pcno <= 5 && last_pcno > 40) {
    749             close_evalcall_form();
    750             strcpy(title, "Verifying...");
    751             open_evalcall_form(title);
    752         }
    753         last_pcno = pcno;
    754         update_evalcall_form(percentage);
    755     }
    756 // OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
    757     close_evalcall_form();
    758     if (pclose(pin)) {
    759         res++;
    760         log_OS_error("Unable to pclose");
    761     }
    762     unlink(tempfile);
    763     paranoid_free(command);
    764     paranoid_free(tempfile);
    765     paranoid_free(title);
    766     return (res);
    767 }
    768 
    769 
    770 
    771 
    772703void *run_prog_in_bkgd_then_exit(void *info)
    773704{
  • branches/2.2.7/mondo/src/common/libmondo-fork.h

    r1689 r1999  
    1212                          int cd_no, char *logstub, char *what_i_am_doing);
    1313
    14 int run_external_binary_with_percentage_indicator_OLD(char *tt, char *cmd);
    1514int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd);
    1615int copy_from_src_to_dest(FILE *, FILE *, char);
  • branches/2.2.7/mondo/src/common/libmondo-tools.c

    r1967 r1999  
    810810    char *p = NULL;
    811811
    812     if (bkpinfo->tmpdir != NULL) {
     812    if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    813813        /* purging a potential old tmpdir */
    814814        asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
  • branches/2.2.7/mondo/src/common/newt-specific.c

    r1919 r1999  
    406406        printf("Execution run ended; result=%d\n", signal);
    407407        printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    408         asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    409         system(command);
    410         paranoid_free(command);
     408        if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
     409            asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     410            system(command);
     411            paranoid_free(command);
     412        }
    411413        paranoid_free(bkpinfo);
    412414        free_libmondo_global_strings();
  • branches/2.2.7/mondo/src/mondorestore/mondorestore.c

    r1987 r1999  
    31893189        }
    31903190        log_msg(2, "Still here. Yay.");
    3191         if (strlen(bkpinfo->tmpdir) > 0) {
     3191        if ((strlen(bkpinfo->tmpdir) > 0) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    31923192            sprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
    31933193            run_program_and_log_output(tmp, FALSE);
     
    33533353        run_program_and_log_output("mount / -o remount,rw", 2);
    33543354    }                           // for b0rken distros
    3355     sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
    3356     system(tmp);
     3355    if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
     3356        sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
     3357        system(tmp);
     3358    }
    33573359    paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
    33583360    free_libmondo_global_strings(); // it's fine to have this here :) really :)
  • branches/2.2.7/mondo/src/restore-scripts/mondo/grub-install.patched

    r691 r1999  
    282282
    283283copy_images() {
    284     # Copy the GRUB images to the GRUB directory.
    285 #    for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
    286 #   rm -f $file || exit 1
    287 #    done
    288     for file in \
    289     ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do
    290     cp -f $file ${grubdir} || exit 1
     284    for file in ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do
     285        cp -f $file ${grubdir} || exit 1
    291286    done
    292287}
  • branches/2.2.7/mondo/src/restore-scripts/mondo/mount-subroutine-me

    r567 r1999  
    2424        if [ -e "$mountdir" ] && [ ! -d "$mountdir" ] ; then
    2525            LogIt "$mountdir exists (but not a dir). Deleting..." 2
    26             rm "$mountdir" -f
     26            rm -f "$mountdir"
    2727            mkdir -p "$mountdir"
    2828        else
Note: See TracChangeset for help on using the changeset viewer.