Commit 8a1904d7 authored by Daniel Black's avatar Daniel Black

MDEV-33301 memlock with systemd still not working

CapabilityBoundingSet included CAP_IPC_LOCK in MDEV-9095, however
it requires that the executable has the capability marked in extended
attributes also.

The alternate to this is raising the RLIMIT_MEMLOCK for the service/
process to be able to complete the mlockall system call. This needs to
be adjusted to whatever the MariaDB server was going to allocate.
Rather than leave the non-obvious mapping of settings and tuning,
add the capability so its easier for the user.

We set the capability, if possible, but may never be used depending
on user settings. As such in the Debian postinst script, don't
complain if this fails.

The CAP_IPC_LOCK also facilitates the mmaping of huge memory pages.
(see man mmap), like mariadb uses with --large-pages.
parent 0185ac64
......@@ -163,6 +163,7 @@ SET(CPACK_RPM_server_USER_FILELIST
${ignored}
"%config(noreplace) ${INSTALL_SYSCONF2DIR}/*"
"%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql"
"%caps(cap_ipc_lock=pe) %{_sbindir}/mysqld"
)
SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf")
SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
......
#!/bin/sh
set -e
# inspired by iputils-ping
#
# cap_ipc_lock is required if a user wants to use --memlock
# and has insufficient RLIMIT_MEMLOCK (MDEV-33301)
PROGRAM=$(dpkg-divert --truename /usr/sbin/mysqld)
if [ "$1" = configure ]; then
# If we have setcap installed, try setting
# which allows us to install our binaries without the setuid
# bit.
if command -v setcap > /dev/null; then
if ! setcap cap_ipc_lock+ep "$PROGRAM"; then
echo "Setcap failed on $PROGRAM, required with --memlock if insufficent RLIMIT_MEMLOCK" >&2
fi
fi
fi
#DEBHELPER#
exit 0
......@@ -14,6 +14,7 @@
capability chown,
capability dac_override,
capability ipc_lock,
capability setgid,
capability setuid,
capability sys_rawio,
......
......@@ -25,7 +25,7 @@ require {
class lnk_file read;
class process { getattr signull };
class unix_stream_socket connectto;
class capability { sys_resource sys_nice };
class capability { ipc_lock sys_resource sys_nice };
class tcp_socket { name_bind name_connect };
class file { execute setattr read create getattr execute_no_trans write ioctl open append unlink };
class sock_file { create unlink getattr };
......@@ -87,6 +87,8 @@ allow mysqld_t bin_t:file { getattr read execute open execute_no_trans ioctl };
# MariaDB additions
allow mysqld_t self:process setpgid;
allow mysqld_t self:capability { ipc_lock };
# This rule allows port tcp/4444
allow mysqld_t kerberos_port_t:tcp_socket { name_bind name_connect };
# This rule allows port tcp/4567 (tram_port_t may not be available on
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment