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 /eclass/mysql-multilib.eclass
parentdev-db/mariadb: Drop old 10.2 versions (diff)
downloadgentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.tar.gz
gentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.tar.bz2
gentoo-b19f6190519f94450e4aa23cde091b8fd24d763d.zip
mysql*.eclass: Tighten up creation of directories
Diffstat (limited to 'eclass/mysql-multilib.eclass')
-rw-r--r--eclass/mysql-multilib.eclass23
1 files changed, 9 insertions, 14 deletions
diff --git a/eclass/mysql-multilib.eclass b/eclass/mysql-multilib.eclass
index aa0930e44758..b172bc0c40a0 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