~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to mysql-test/std_data/checkDBI_DBD-mysql.pl

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 
4
#
 
5
# This program is free software; you can redistribute it and/or
 
6
# modify it under the terms of the GNU Library General Public
 
7
# License as published by the Free Software Foundation; version 2
 
8
# of the License.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
# Library General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
18
 
 
19
 
 
20
################################################################################
 
21
#
 
22
# This perl script checks for availability of the Perl modules DBI and
 
23
# DBD::mysql using the "current" perl interpreter.
 
24
#
 
25
# Useful for test environment checking before testing executable perl scripts
 
26
# in the MySQL Server distribution.
 
27
#
 
28
# NOTE: The "shebang" on the first line of this script should always point to
 
29
#       /usr/bin/perl, so that we can use this script to check whether or not we
 
30
#       support running perl scripts with such a shebang without specifying the
 
31
#       perl interpreter on the command line. Such a script is mysqlhotcopy.
 
32
#
 
33
#       When run as "checkDBI_DBD-mysql.pl" the shebang line will be evaluated
 
34
#       and used. When run as "perl checkDBI_DBD-mysql.pl" the shebang line is
 
35
#       not used.
 
36
#
 
37
# NOTE: This script will create a temporary file in MTR's tmp dir.
 
38
#       If modules are found, a mysql-test statement which sets a special
 
39
#       variable is written to this file. If one of the modules is not found
 
40
#       (or cannot be loaded), the file will remain empty.
 
41
#       A test (or include file) which sources that file can then easily do
 
42
#       an if-check on the special variable to determine success or failure.
 
43
#
 
44
#       Example:
 
45
#
 
46
#         --let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
 
47
#         --let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
 
48
#         --chmod 0755 $perlChecker
 
49
#         --exec $perlChecker
 
50
#         --source $resultFile
 
51
#         if (!$dbidbd) {
 
52
#             --skip Test needs Perl modules DBI and DBD::mysql
 
53
#         } 
 
54
#
 
55
#       The calling script is also responsible for cleaning up after use:
 
56
#
 
57
#         --remove_file $resultFile
 
58
#
 
59
# Windows notes: 
 
60
#   - shebangs may work differently - call this script with "perl " in front.
 
61
#
 
62
# See mysql-test/include/have_dbi_dbd-mysql.inc for example use of this script.
 
63
# This script should be executable for the user running MTR.
 
64
#
 
65
################################################################################
 
66
 
 
67
BEGIN {
 
68
    # By using eval inside BEGIN we can suppress warnings and continue after.
 
69
    # We need to catch "Can't locate" as well as "Can't load" errors.
 
70
    eval{
 
71
        $FOUND_DBI=0;
 
72
        $FOUND_DBD_MYSQL=0;
 
73
 
 
74
        # Check for DBI module:
 
75
        $FOUND_DBI=1 if require DBI;
 
76
 
 
77
        # Check for DBD::mysql module
 
78
        $FOUND_DBD_MYSQL=1 if require DBD::mysql;
 
79
    };
 
80
};
 
81
 
 
82
# Open a file to be used for transfer of result back to mysql-test.
 
83
# The file must be created whether we write to it or not, otherwise mysql-test 
 
84
# will complain if trying to source it. 
 
85
# An empty file indicates failure to load modules.
 
86
open(FILE, ">", $ENV{'MYSQL_TMP_DIR'}.'/dbidbd-mysql.txt');
 
87
 
 
88
if ($FOUND_DBI && $FOUND_DBD_MYSQL) {
 
89
    # write a mysql-test command setting a variable to indicate success
 
90
    print(FILE 'let $dbidbd= FOUND_DBI_DBD-MYSQL;'."\n");
 
91
}
 
92
 
 
93
# close the file.
 
94
close(FILE);
 
95
 
 
96
1;
 
97