summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2017-09-28 22:28:36 -0400
committerBrian Evans <grknight@gentoo.org>2017-09-28 22:30:51 -0400
commitb19f6190519f94450e4aa23cde091b8fd24d763d (patch)
treee9798d7e7a4f523701adc6148d822f1b96096a3d
parentdev-db/mariadb: Drop old 10.2 versions (diff)
downloadgentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.zip
gentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.tar.gz
gentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.tar.bz2
mysql*.eclass: Tighten up creation of directories
-rw-r--r--eclass/mysql-cmake.eclass6
-rw-r--r--eclass/mysql-multilib-r1.eclass34
-rw-r--r--eclass/mysql-multilib.eclass23
-rw-r--r--eclass/mysql-v2.eclass23
4 files changed, 33 insertions, 53 deletions
diff --git a/eclass/mysql-cmake.eclass b/eclass/mysql-cmake.eclass
index 25d2c3c..2963a97 100644
--- a/eclass/mysql-cmake.eclass
+++ b/eclass/mysql-cmake.eclass
@@ -338,7 +338,7 @@ mysql-cmake_src_prepare() {
rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
fi
- epatch_user
+ cmake-utils_src_prepare
}
# @FUNCTION: mysql-cmake_src_configure
@@ -511,14 +511,14 @@ mysql-cmake_src_install() {
if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
dodir "${MY_DATADIR#${EPREFIX}}"
keepdir "${MY_DATADIR#${EPREFIX}}"
- chown -R mysql:mysql "${D}/${MY_DATADIR}"
+ nonfatal fowners -R mysql:mysql "${D}/${MY_DATADIR}"
fi
diropts "-m0755"
for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
dodir "${folder}"
keepdir "${folder}"
- chown -R mysql:mysql "${ED}/${folder}"
+ nonfatal fowners -R mysql:mysql "${ED}/${folder}"
done
fi
diff --git a/eclass/mysql-multilib-r1.eclass b/eclass/mysql-multilib-r1.eclass
index 5495491..fcf3b4e 100644
--- a/eclass/mysql-multilib-r1.eclass
+++ b/eclass/mysql-multilib-r1.eclass
@@ -342,11 +342,7 @@ mysql-multilib-r1_src_prepare() {
echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
fi
- if [[ "${EAPI}x" == "5x" ]] ; then
- epatch_user
- else
- default
- fi
+ cmake-utils_src_prepare
}
# @FUNCTION: mysql-multilib-r1_src_configure
@@ -608,14 +604,14 @@ multilib_src_install() {
if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
dodir "${MY_DATADIR#${EPREFIX}}"
keepdir "${MY_DATADIR#${EPREFIX}}"
- chown -R mysql:mysql "${D}/${MY_DATADIR}"
+ nonfatal fowners -R mysql:mysql "${D}/${MY_DATADIR}"
fi
diropts "-m0755"
for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
dodir "${folder}"
keepdir "${folder}"
- chown -R mysql:mysql "${ED}/${folder}"
+ nonfatal fowners -R mysql:mysql "${ED}/${folder}"
done
einfo "Including support files and sample configurations"
@@ -684,15 +680,9 @@ mysql-multilib-r1_pkg_postinst() {
# Make sure the vars are correctly initialized
mysql_init_vars
- # Check FEATURES="collision-protect" before removing this
+ # Create log directory securely if it does not exist
[[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
- # Secure the logfiles
- touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
- chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
- chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
-
- # Minimal builds don't have the MySQL server
if use server ; then
docinto "support-files"
for script in \
@@ -929,12 +919,14 @@ mysql-multilib-r1_pkg_config() {
# Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
PID_DIR="${EROOT}/var/run/mysqld"
if [[ ! -d "${PID_DIR}" ]]; then
- mkdir -p "${PID_DIR}" || die "Could not create pid directory"
- chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
- chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
+ install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
+ fi
+
+ if [[ ! -d "${MY_DATADIR}" ]]; then
+ install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
fi
- pushd "${TMPDIR}" &>/dev/null
+ pushd "${TMPDIR}" &>/dev/null || die
# Filling timezones, see
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html
@@ -957,17 +949,15 @@ mysql-multilib-r1_pkg_config() {
fi
cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" ${initialize_options} )
einfo "Command: ${cmd[*]}"
- "${cmd[@]}" \
+ su -s /bin/sh -c "${cmd[*]}" mysql \
>"${TMPDIR}"/mysql_install_db.log 2>&1
if [ $? -ne 0 ]; then
grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
fi
- popd &>/dev/null
+ popd &>/dev/null || die
[[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
|| die "MySQL databases not installed"
- chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
- chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
diff --git a/eclass/mysql-multilib.eclass b/eclass/mysql-multilib.eclass
index aa0930e..b172bc0 100644
--- a/eclass/mysql-multilib.eclass
+++ b/eclass/mysql-multilib.eclass
@@ -843,14 +843,9 @@ mysql-multilib_pkg_postinst() {
# Make sure the vars are correctly initialized
mysql_init_vars
- # Check FEATURES="collision-protect" before removing this
+ # Create log directory securely if it does not exist
[[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
- # Secure the logfiles
- touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
- chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
- chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
-
# Minimal builds don't have the MySQL server
if use_if_iuse minimal ; then
:
@@ -1070,28 +1065,28 @@ mysql-multilib_pkg_config() {
# Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
PID_DIR="${EROOT}/var/run/mysqld"
if [[ ! -d "${PID_DIR}" ]]; then
- mkdir -p "${PID_DIR}" || die "Could not create pid directory"
- chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
- chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
+ install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
+ fi
+
+ if [[ ! -d "${MY_DATADIR}" ]]; then
+ install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
fi
- pushd "${TMPDIR}" &>/dev/null
+ pushd "${TMPDIR}" &>/dev/null || die
#cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
[[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}'"
einfo "Command: $cmd"
- eval $cmd \
+ su -s /bin/sh -c "${cmd}" mysql \
>"${TMPDIR}"/mysql_install_db.log 2>&1
if [ $? -ne 0 ]; then
grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
fi
- popd &>/dev/null
+ popd &>/dev/null || die
[[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
|| die "MySQL databases not installed"
- chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
- chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
# Filling timezones, see
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html
diff --git a/eclass/mysql-v2.eclass b/eclass/mysql-v2.eclass
index 3734e19..53cba1e 100644
--- a/eclass/mysql-v2.eclass
+++ b/eclass/mysql-v2.eclass
@@ -587,14 +587,9 @@ mysql-v2_pkg_postinst() {
# Make sure the vars are correctly initialized
mysql_init_vars
- # Check FEATURES="collision-protect" before removing this
+ # Create log directory securely if it does not exist
[[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
- # Secure the logfiles
- touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
- chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
- chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
-
# Minimal builds don't have the MySQL server
if ! use minimal ; then
docinto "support-files"
@@ -821,28 +816,28 @@ mysql-v2_pkg_config() {
# Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
PID_DIR="${EROOT}/var/run/mysqld"
if [[ ! -d "${PID_DIR}" ]]; then
- mkdir -p "${PID_DIR}" || die "Could not create pid directory"
- chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
- chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
+ install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
+ fi
+
+ if [[ ! -d "${MY_DATADIR}" ]]; then
+ install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
fi
- pushd "${TMPDIR}" &>/dev/null
+ pushd "${TMPDIR}" &>/dev/null || die
#cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
[[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}'"
einfo "Command: $cmd"
- eval $cmd \
+ su -s /bin/sh -c "${cmd}" mysql \
>"${TMPDIR}"/mysql_install_db.log 2>&1
if [ $? -ne 0 ]; then
grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
fi
- popd &>/dev/null
+ popd &>/dev/null || die
[[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
|| die "MySQL databases not installed"
- chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
- chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
# Filling timezones, see
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html