Skip to content

Commit 497fa1f

Browse files
committed
Set CAP_IPC_LOCK capability if possible
As done in upstream 8a1904d about MDEV-33301, set the capability CAP_IPC_LOCK when possible to facilitate the mmaping of huge memory pages (see man mmap), like MariaDB uses with --large-pages.
1 parent 1912f99 commit 497fa1f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

debian/mariadb-server-core.postinst

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# shellcheck source=/dev/null
5+
. /usr/share/debconf/confmodule
6+
7+
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
8+
then
9+
set -v -x
10+
DEBIAN_SCRIPT_TRACE=1
11+
fi
12+
13+
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2}
14+
15+
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
16+
17+
# inspired by iputils-ping
18+
#
19+
# cap_ipc_lock is required if a user wants to use --memlock
20+
# and has insufficient RLIMIT_MEMLOCK (MDEV-33301)
21+
22+
PROGRAM=$(dpkg-divert --truename /usr/sbin/mysqld)
23+
24+
case "$1" in
25+
configure)
26+
# If we have setcap installed, try setting
27+
# which allows us to install our binaries without the setuid
28+
# bit.
29+
if command -v setcap > /dev/null
30+
then
31+
if ! setcap cap_ipc_lock+ep "$PROGRAM"
32+
then
33+
echo "Setcap failed on $PROGRAM, required with --memlock if insufficent RLIMIT_MEMLOCK" >&2
34+
fi
35+
fi
36+
;;
37+
38+
abort-upgrade|abort-remove|abort-configure|triggered)
39+
;;
40+
41+
*)
42+
echo "postinst called with unknown argument '$1'" 1>&2
43+
exit 1
44+
;;
45+
esac
46+
47+
db_stop # in case invoke fails
48+
49+
#DEBHELPER#

0 commit comments

Comments
 (0)