/[gentoo-x86]/eclass/mysql_fx.eclass
Gentoo

Contents of /eclass/mysql_fx.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Mon Apr 10 21:35:55 2006 UTC (11 years, 9 months ago) by vivo
Branch: MAIN
Changes since 1.11: +3 -1 lines
fix Bug #128713 dev-db/mysql: Query Logging Bypass Vulnerability (CVE-2006-0903)
Raphael Marichez has ported the upstream patch to 4.1.14, thanks!

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4 # $ID: $
5
6
7 # Author: Francesco Riosa <vivo at gentoo.org>
8 # Maintainer: Francesco Riosa <vivo at gentoo.org>
9
10 inherit multilib
11
12 # helper function, version (integer) may have section separated by dots
13 # for readbility
14 stripdots() {
15 local dotver=${1:-"0"}
16 while [[ "${dotver/./}" != "${dotver}" ]] ; do dotver="${dotver/./}" ; done
17 echo "${dotver:-"0"}"
18 }
19
20 # bool mysql_check_version_range(char * range, int ver=MYSQL_VERSION_ID, int die_on_err=MYSQL_DIE_ON_RANGE_ERROR)
21 #
22 # Check if a version number fall inside a range.
23 # the range include the extremes and must be specified as
24 # "low_version to hi_version" i.e. "4.00.00.00 to 5.01.99.99"
25 # Return true if inside the range
26 # 2005-11-19 <vivo at gentoo.org>
27 mysql_check_version_range() {
28 local lbound="${1%% to *}" ; lbound=$(stripdots "${lbound}")
29 local rbound="${1#* to }" ; rbound=$(stripdots "${rbound}")
30 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
31 [[ $lbound -le $my_ver && $my_ver -le $rbound ]] && return 0
32 return 1
33 }
34
35 # private bool _mysql_test_patch_easy( int flags, char * pname )
36 #
37 # true if found at least one appliable range
38 # 2005-11-19 <vivo at gentoo.org>
39 _mysql_test_patch_easy() {
40 local filesdir="${WORKDIR}/mysql-extras"
41 [[ -d "${filesdir}" ]] || die 'sourcedir must be a directory'
42 local flags=$1 pname=$2
43 if [[ $(( $flags & 5 )) -eq 5 ]] ; then
44 einfo "using \"${pname}\""
45 mv "${filesdir}/${pname}" "${EPATCH_SOURCE}" || die "cannot move ${pname}"
46 return 0
47 fi
48 return 1
49 }
50
51 # void mysql_mv_patches(char * index_file, char * filesdir, int my_ver)
52 #
53 # parse a "index_file" looking for patches to apply to current
54 # version.
55 # If the patch apply then print it's description
56 # 2005-11-19 <vivo at gentoo.org>
57 mysql_mv_patches() {
58 local index_file="${1:-"${WORKDIR}/mysql-extras/index.txt"}"
59 local my_ver="${2:-"${MYSQL_VERSION_ID}"}"
60 local my_test_fx=${3:-"_mysql_test_patch_easy"}
61 local dsc ndsc=0 i
62 dsc=( )
63
64 # values for flags are (2^x):
65 # 1 - one patch found
66 # 2 - at least one version range is wrong
67 # 4 - at least one version range is _good_
68 local flags=0 pname='' comments=''
69 while read row; do
70 case "${row}" in
71 @patch\ *)
72 ${my_test_fx} $flags "${pname}" \
73 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
74 flags=1 ; ndsc=0 ; dsc=( )
75 pname=${row#"@patch "}
76 ;;
77 @ver\ *)
78 if mysql_check_version_range "${row#"@ver "}" "${my_ver}" ; then
79 flags=$(( $flags | 4 ))
80 else
81 flags=$(( $flags | 2 ))
82 fi
83 ;;
84 # @use\ *) ;;
85 @@\ *)
86 dsc[$ndsc]="${row#"@@ "}"
87 (( ++ndsc ))
88 ;;
89 esac
90 done < "${index_file}"
91 ${my_test_fx} $flags "${pname}" \
92 && for (( i=0 ; $i < $ndsc ; i++ )) ; do einfo "> ${dsc[$i]}" ; done
93 }
94
95 # * char mysql_strip_double_slash()
96 #
97 # initialize global variables
98 # 2005-11-19 <vivo at gentoo.org>
99 mysql_strip_double_slash() {
100 local path="${1}"
101 local newpath="${path/\/\///}"
102 while [[ ${path} != ${newpath} ]]; do
103 path=${newpath}
104 newpath="${path/\/\///}"
105 done
106 echo "${newpath}"
107 }
108
109 # Is $2 (defaults to $MYSQL_VERSION_ID) at least version $1?
110 # (nice) idea from versionator.eclass
111 mysql_version_is_at_least() {
112 local want_s=$(stripdots "$1") have_s=$( stripdots "${2:-${MYSQL_VERSION_ID}}")
113 [[ -z "${want_s}" ]] && die "mysql_version_is_at_least missing value"
114 [[ ${want_s} -le ${have_s} ]] && return 0 || return 1
115 }
116
117 # void mysql_lib_symlinks()
118 #
119 # To be called on the live filesystem, reassign symlinks to each mysql
120 # library to the best version available
121 # 2005-12-30 <vivo at gentoo.org>
122 mysql_lib_symlinks() {
123 local d dirlist maxdots soname sonameln other better
124 pushd "${ROOT}/usr/$(get_libdir)" &> /dev/null
125 # dirlist must contain the less significative directory left
126 dirlist="mysql"
127
128 # waste some time in removing and recreating symlinks
129 for d in $dirlist ; do
130 for soname in $(find "${d}" -name "*.so*" -and -not -type "l") ; do
131 # maxdot is a limit versus infinite loop
132 maxdots=0
133 sonameln=${soname##*/}
134 # loop in version of the library to link it, similar to the
135 # libtool work
136 while [[ ${sonameln:0-3} != '.so' ]] && [[ ${maxdots} -lt 6 ]]
137 do
138 rm -f "${sonameln}"
139 ln -s "${soname}" "${sonameln}"
140 (( ++maxdots ))
141 sonameln="${sonameln%.*}"
142 done
143 rm -f "${sonameln}"
144 ln -s "${soname}" "${sonameln}"
145 done
146 done
147 popd &> /dev/null
148 }

  ViewVC Help
Powered by ViewVC 1.1.20