Пример #1
0
    def prepare_environment(work_dir):
        """
        Configures the Glastopf work environment.

        If this methods completes without exceptions, the environment will look something like:
        (self.workdir)/
                      glastopf.cfg
                      db/
                      log/
                      data/
                          sandbox.php
                          dork_pages/
                          virtual_docs/
                          (and various other module data directories)
        """
        logger.info('Preparing work environment.')
        if not os.path.isfile(os.path.join(work_dir, 'glastopf.cfg')):
            logger.info('Copying glastopf.cfg to work work_dir.')
            shutil.copyfile(os.path.join(package_directory, 'glastopf.cfg.dist'),
                            os.path.join(work_dir, 'glastopf.cfg'))

        #copy emulator level data
        emulator_data_dir = os.path.join(package_directory, 'modules/handlers/emulators/data/')

        shutil.copytree(emulator_data_dir, os.path.join(work_dir, 'data/'),
                        ignore=GlastopfHoneypot._ignore_copy_files)

        dirs = ('log', 'db', 'data')
        for entry in dirs:
            dir_path = os.path.join(work_dir, entry)
            if not os.path.isdir(dir_path):
                os.mkdir(dir_path)
        # Randomize the files in virtualdocs folder
        vdocs.randomize_vdocs(os.path.join(work_dir, 'data/virtualdocs/'))
        GlastopfHoneypot.prepare_sandbox(work_dir)
Пример #2
0
    def prepare_environment(work_dir):
        """
        Configures the Glastopf work environment.

        If this methods completes without exceptions, the environment will look something like:
        (self.workdir)/
                      glastopf.cfg
                      db/
                      log/
                      data/
                          sandbox.php
                          dork_pages/
                          virtual_docs/
                          (and various other module data directories)
        """
        logger.info('Preparing work environment.')
        if not os.path.isfile(os.path.join(work_dir, 'glastopf.cfg')):
            logger.info('Copying glastopf.cfg to work work_dir.')
            shutil.copyfile(
                os.path.join(package_directory, 'glastopf.cfg.dist'),
                os.path.join(work_dir, 'glastopf.cfg'))

        #copy emulator level data
        emulator_data_dir = os.path.join(package_directory,
                                         'modules/handlers/emulators/data/')

        shutil.copytree(emulator_data_dir,
                        os.path.join(work_dir, 'data/'),
                        ignore=GlastopfHoneypot._ignore_copy_files)

        dirs = ('log', 'db', 'data')
        for entry in dirs:
            dir_path = os.path.join(work_dir, entry)
            if not os.path.isdir(dir_path):
                os.mkdir(dir_path)
        # Randomize the files in virtualdocs folder
        vdocs.randomize_vdocs(os.path.join(work_dir, 'data/virtualdocs/'))
        GlastopfHoneypot.prepare_sandbox(work_dir)