Changeset 1663 in MondoRescue for branches/stable/mondo/src/mondoarchive


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)

Location:
branches/stable/mondo/src/mondoarchive
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondoarchive/mondo-cli-EXT.h

    r1264 r1663  
    11/* mondo-cli-EXT.h */
    22
    3 extern int handle_incoming_parameters(int argc, char *argv[],
    4                                       struct s_bkpinfo *bkpinfo);
    5 extern int process_the_s_switch(struct s_bkpinfo *bkpinfo, char *value);
    6 extern int process_switches(struct s_bkpinfo *bkpinfo,
    7                             char flag_val[128][MAX_STR_LEN],
     3extern int handle_incoming_parameters(int argc, char *argv[]);
     4extern int process_the_s_switch(char *value);
     5extern int process_switches(char flag_val[128][MAX_STR_LEN],
    86                            bool flag_set[128]);
    97extern int retrieve_switches_from_command_line(int argc, char *argv[],
  • branches/stable/mondo/src/mondoarchive/mondo-cli.c

    r1639 r1663  
    2525extern bool g_text_mode;
    2626extern char g_startdir[MAX_STR_LEN];    ///< ????? @bug ?????
    27 extern char g_erase_tmpdir_and_scratchdir[MAX_STR_LEN];
    2827extern char g_tmpfs_mountpt[MAX_STR_LEN];
    2928extern bool g_sigpipe;
     
    4443bool g_running_live = FALSE;    ///< ????? @bug ????? @ingroup globalGroup
    4544extern bool g_cd_recovery;
     45
     46extern void setup_tmpdir(char *path);
    4647
    4748/**
     
    6364char *g_getfacl = NULL;
    6465char *g_getfattr = NULL;
     66
     67/* Reference to global bkpinfo */
     68extern struct s_bkpinfo *bkpinfo;
    6569
    6670/**
     
    7680 */
    7781int
    78 handle_incoming_parameters(int argc, char *argv[],
    79                            struct s_bkpinfo *bkpinfo)
     82handle_incoming_parameters(int argc, char *argv[])
    8083{
    8184    /*@ int *** */
     
    8992    bool flag_set[128];
    9093
    91     sensibly_set_tmpdir_and_scratchdir(bkpinfo);
     94    sensibly_set_tmpdir_and_scratchdir();
    9295
    9396    for (i = 0; i < 128; i++) {
     
    99102    retval += res;
    100103    if (!retval) {
    101         res = process_switches(bkpinfo, flag_val, flag_set);
     104        res = process_switches(flag_val, flag_set);
    102105        retval += res;
    103106    }
     
    121124    mr_free(tmp);
    122125
    123     sprintf(bkpinfo->tmpdir + strlen(bkpinfo->tmpdir), "/tmp.mondo.%ld",
    124             random() % 32767);
    125126    sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),
    126127            "/mondo.scratch.%ld", random() % 32767);
     
    144145 * @bug Return code not needed.
    145146 */
    146 int process_the_s_switch(struct s_bkpinfo *bkpinfo, char *value)
     147int process_the_s_switch(char *value)
    147148{
    148149    char *tmp = NULL;
     
    180181 */
    181182int
    182 process_switches(struct s_bkpinfo *bkpinfo,
    183                  char flag_val[128][MAX_STR_LEN], bool flag_set[128])
     183process_switches(char flag_val[128][MAX_STR_LEN], bool flag_set[128])
    184184{
    185185
     
    425425                        ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    426426                }
    427                 if (process_the_s_switch(bkpinfo, flag_val['s'])) {
     427                if (process_the_s_switch(flag_val['s'])) {
    428428                    fatal_error("Bad -s switch");
    429429                }
     
    438438    } else {                    /* CD|USB size */
    439439        if (flag_set['s']) {
    440             if (process_the_s_switch(bkpinfo, flag_val['s'])) {
     440            if (process_the_s_switch(flag_val['s'])) {
    441441                fatal_error("Bad -s switch");
    442442            }
     
    672672    }
    673673    if (flag_set['T']) {
    674         sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'],
    675                 random() % 32768);
     674        setup_tmpdir(flag_val['T']);
    676675        mr_asprintf(&tmp2, "touch %s/.foo.dat", flag_val['T']);
    677676        if (run_program_and_log_output(tmp2, 1)) {
     
    683682        mr_free(tmp2);
    684683
    685         mr_asprintf(&tmp2, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],
    686                 flag_val['T']);
     684        mr_asprintf(&tmp2, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
    687685        if (run_program_and_log_output(tmp2, 1)) {
    688686            retval++;
  • branches/stable/mondo/src/mondoarchive/mondo-cli.h

    r1264 r1663  
    33 */
    44
    5 int handle_incoming_parameters(int argc, char *argv[],
    6                                struct s_bkpinfo *bkpinfo);
    7 int process_the_s_switch(struct s_bkpinfo *bkpinfo, char *value);
    8 int process_switches(struct s_bkpinfo *bkpinfo,
    9                      char flag_val[128][MAX_STR_LEN], bool flag_set[128]);
     5int handle_incoming_parameters(int argc, char *argv[]);
     6int process_the_s_switch(char *value);
     7int process_switches(char flag_val[128][MAX_STR_LEN], bool flag_set[128]);
    108int retrieve_switches_from_command_line(int argc, char *argv[],
    119                                        char flag_val[128][MAX_STR_LEN],
  • branches/stable/mondo/src/mondoarchive/mondoarchive.c

    r1639 r1663  
    6262/****************** subroutines used only here ******************/
    6363
     64/* Reference to global bkpinfo */
     65struct s_bkpinfo *bkpinfo;
     66
     67/****************** subroutines used only by main.c ******************/
    6468
    6569/**
     
    386390int main(int argc, char *argv[])
    387391{
    388     struct s_bkpinfo *bkpinfo = NULL;
    389392    struct stat stbuf;
    390393    char *tmp = NULL;
     
    399402#endif
    400403    printf(_("Initializing...\n"));
     404
     405    bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
     406    reset_bkpinfo();
    401407
    402408    /* Reference a dummy cleanup function for mr_exit temporarily */
     
    463469    malloc_libmondo_global_strings();
    464470    diffs = 0;
    465     bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
    466471    if (stat(MONDO_CACHE, &stbuf) != 0) {
    467472        mr_mkdir(MONDO_CACHE,0x755);
     
    580585    }
    581586
    582     if (pre_param_configuration(bkpinfo)) {
     587    if (pre_param_configuration()) {
    583588        fatal_error
    584589            ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
     
    591596        g_text_mode = FALSE;
    592597        setup_newt_stuff();
    593         res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE);   /* yes, archiving */
     598        res = interactively_obtain_media_parameters_from_user(TRUE);    /* yes, archiving */
    594599        if (res) {
    595600            fatal_error
     
    597602        }
    598603    } else {
    599         res = handle_incoming_parameters(argc, argv, bkpinfo);
     604        res = handle_incoming_parameters(argc, argv);
    600605        if (res) {
    601606            mr_msg(1,
     
    609614
    610615/* Finish configuring global structures */
    611     if (post_param_configuration(bkpinfo)) {
     616    if (post_param_configuration()) {
    612617        fatal_error
    613618            ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
     
    622627    /* If we're meant to backup then backup */
    623628    if (bkpinfo->backup_data) {
    624         res = backup_data(bkpinfo);
     629        res = backup_data();
    625630        retval += res;
    626631        if (res) {
     
    634639    /* If we're meant to verify then verify */
    635640    if (bkpinfo->verify_data) {
    636         res = verify_data(bkpinfo);
     641        res = verify_data();
    637642        if (res < 0) {
    638643            mr_asprintf(&say_at_end2, _("%d difference%c found."), -res,
     
    657662    }
    658663
    659 
    660     if (length_of_file("/tmp/changed.files") > 2) {
     664    if (length_of_file(MINDI_CACHE"/changed.files") > 2) {
    661665        if (g_text_mode) {
    662666            log_to_screen
    663                 (_("Type 'less /tmp/changed.files' to see which files don't match the archives"));
     667                (_("Type 'less "MINDI_CACHE"/changed.files' to see which files don't match the archives"));
    664668        } else {
    665669            mr_msg(1,
    666                     _("Type 'less /tmp/changed.files' to see which files don't match the archives"));
     670                    _("Type 'less "MINDI_CACHE"/changed.files' to see which files don't match the archives"));
    667671            mr_msg(2, "Calling popup_changelist_from_file()");
    668             popup_changelist_from_file("/tmp/changed.files");
     672            popup_changelist_from_file(MINDI_CACHE"/changed.files");
    669673            mr_msg(2, "Returned from popup_changelist_from_file()");
    670674        }
    671675    } else {
    672         unlink("/tmp/changed.files");
     676        unlink(MINDI_CACHE"/changed.files");
    673677    }
    674678    log_to_screen(say_at_end);
     
    687691
    688692    system("rm -f /var/cache/mondo-archive/last-backup.aborted");
    689     system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
    690693    if (!retval) {
    691694        printf(_("Mondoarchive ran OK.\n"));
     
    698701    chdir("/tmp");              // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
    699702    system(g_erase_tmpdir_and_scratchdir);
     703
     704    /* assemble command string for deletion of Mondo's tmp directory */
     705    sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
     706   
    700707    free_libmondo_global_strings();
    701708    mr_free(bkpinfo);
    702 
    703     unlink("/tmp/filelist.full");
    704     unlink("/tmp/filelist.full.gz");
    705709
    706710    if (!g_cdrom_drive_is_here) {
     
    714718    mr_msg(1, "Time finished: %s", mr_date());
    715719    mr_msg_close();
     720
     721    /* remove Mondo's tmp directory */
     722    system(tmp);
     723    paranoid_free(tmp);
    716724
    717725    if (!g_text_mode) {
Note: See TracChangeset for help on using the changeset viewer.