Ignore:
Timestamp:
Sep 27, 2007, 12:21:18 PM (12 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-devices.c

    r1638 r1663  
    5050extern struct mr_ar_conf *mr_conf;
    5151
     52extern void setup_tmpdir(char *path);
     53
    5254static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
    5355static char g_cdrom_drive_is_here[MAX_STR_LEN / 4] = "";
     
    6365extern t_bkptype g_backup_media_type;   // set by main()
    6466
    65 
    66 
    67 
    68 void set_g_cdrom_and_g_dvd_to_bkpinfo_value(struct s_bkpinfo *bkpinfo)
     67/* Reference to global bkpinfo */
     68extern struct s_bkpinfo *bkpinfo;
     69
     70
     71
     72
     73void set_g_cdrom_and_g_dvd_to_bkpinfo_value()
    6974{
    7075    strcpy(g_cdrom_drive_is_here, bkpinfo->media_device);   // just in case
     
    502507 * @see mount_CDROM_here
    503508 */
    504 int find_and_mount_actual_cd(struct s_bkpinfo *bkpinfo, char *mountpoint)
     509int find_and_mount_actual_cd(char *mountpoint)
    505510{
    506511    /*@ buffers ***************************************************** */
     
    690695    }
    691696
    692     sprintf(mountpoint, "/tmp/cd.%d", (int) (random() % 32767));
     697    sprintf(mountpoint, "%s/cd.mnt", bkpinfo->tmpdir);
    693698    make_hole_for_dir(mountpoint);
    694699
     
    13211326 */
    13221327void
    1323 insist_on_this_cd_number(struct s_bkpinfo *bkpinfo, int cd_number_i_want)
     1328insist_on_this_cd_number(int cd_number_i_want)
    13241329{
    13251330
     
    13551360            run_program_and_log_output("umount " MNT_CDROM, 5);
    13561361        }
    1357         system("mkdir -p /tmp/isodir &> /dev/null");
     1362        sprintf(tmp, "mkdir -p %s/isodir &> /dev/null", bkpinfo->tmpdir);
     1363        system(tmp);
    13581364        mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    13591365                bkpinfo->nfs_remote_dir, bkpinfo->prefix,
     
    13611367        if (!does_file_exist(tmp)) {
    13621368            mr_free(tmp);
    1363             mr_asprintf(&tmp, "/tmp/isodir/%s/%s-%d.iso",
     1369            mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir,
    13641370                    bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    13651371                    cd_number_i_want);
    13661372            if (does_file_exist(tmp)) {
    13671373                mr_msg(1,
    1368                         "FIXME - hacking bkpinfo->isodir from '%s' to /tmp/isodir",
    1369                         bkpinfo->isodir);
    1370                 strcpy(bkpinfo->isodir, "/tmp/isodir");
     1374                        "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir",
     1375                        bkpinfo->isodir, bkpinfo->tmpdir);
     1376                sprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir);
    13711377            }
    13721378        }
     
    13771383        mr_free(tmp);
    13781384    }
    1379     if ((res = what_number_cd_is_this(bkpinfo)) != cd_number_i_want) {
     1385    if ((res = what_number_cd_is_this()) != cd_number_i_want) {
    13801386        mr_msg(3, "Currently, we hold %d but we want %d", res,
    13811387                cd_number_i_want);
     
    13891395        mr_free(tmp);
    13901396
    1391         while (what_number_cd_is_this(bkpinfo) != cd_number_i_want) {
     1397        while (what_number_cd_is_this() != cd_number_i_want) {
    13921398            sync();
    13931399            if (is_this_device_mounted(MNT_CDROM)) {
     
    14321438 * @ingroup archiveGroup
    14331439 */
    1434 int interactively_obtain_media_parameters_from_user(struct s_bkpinfo
    1435                                                     *bkpinfo,
    1436                                                     bool
    1437                                                     archiving_to_media)
     1440int interactively_obtain_media_parameters_from_user(bool archiving_to_media)
    14381441// archiving_to_media is TRUE if I'm being called by mondoarchive
    14391442// archiving_to_media is FALSE if I'm being called by mondorestore
     
    14651468            bkptype_to_string(bkpinfo->backup_media_type));
    14661469    if (archiving_to_media) {
    1467         sensibly_set_tmpdir_and_scratchdir(bkpinfo);
     1470        sensibly_set_tmpdir_and_scratchdir();
    14681471    }
    14691472    bkpinfo->compression_level =
     
    15661569            mr_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
    15671570            mr_asprintf(&comment,
    1568                 _("Please specify your %s drive's /dev entry"), bkpinfo->backup_media_string);
     1571                _("Please specify your %s drive's /dev entry"), media_descriptor_string(bkpinfo->backup_media));
    15691572            mr_asprintf(&tmp,"/dev/cdrom");
    15701573            if (!popup_and_get_string
     
    17311734        }
    17321735        if (bkpinfo->disaster_recovery) {
    1733             system("umount /tmp/isodir 2> /dev/null");
     1736            sprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
     1737            system(command);
    17341738            if (!popup_and_get_string
    17351739                ("NFS share", "Which remote NFS share should I mount?",
     
    17401744        }
    17411745        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
    1742             sprintf(bkpinfo->isodir, "/tmp/isodir.mondo.%d",
    1743                     (int) (random() % 32768));
     1746            sprintf(bkpinfo->isodir, "%s/nfsdir", bkpinfo->tmpdir);
    17441747            mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
    17451748            run_program_and_log_output(command, 5);
     
    20702073 * @ingroup utilityGroup
    20712074 */
    2072 void sensibly_set_tmpdir_and_scratchdir(struct s_bkpinfo *bkpinfo)
     2075void sensibly_set_tmpdir_and_scratchdir()
    20732076{
    20742077    char *tmp = NULL;
     
    20832086    mr_asprintf(&tmp,
    20842087           call_program_and_get_last_line_of_output
    2085            ("df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2088           ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    20862089#else
    20872090    mr_asprintf(&tmp,
    20882091           call_program_and_get_last_line_of_output
    2089            ("df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x ocfs -x ocfs2 -x mvfs | sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2092           ("LANGUAGE=C df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x ocfs -x ocfs2 -x mvfs | sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    20902093#endif
    20912094
     
    20982101        fatal_error("I couldn't figure out the tempdir!");
    20992102    }
    2100     i = (int) (random() % 32768);
    2101     sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%d", tmp, i);
     2103    setup_tmpdir(tmp);
    21022104    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    21032105
    21042106    sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i);
    21052107    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    2106 
    2107     sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
    2108             bkpinfo->scratchdir);
    21092108
    21102109    mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);
     
    21652164 * (and remain mounted after this function returns).
    21662165 */
    2167 int what_number_cd_is_this(struct s_bkpinfo *bkpinfo)
     2166int what_number_cd_is_this()
    21682167{
    21692168    int cd_number = -1;
Note: See TracChangeset for help on using the changeset viewer.