Skip to content

Commit

Permalink
MDEV-22569: Run bin/mariadbd instead of bin/mysqld
Browse files Browse the repository at this point in the history
Replace all references to /usr/sbin/mysqld (and bin and libexec) with
mariadbd, so that the binary server will always be 'mariadbd'.

Also update all places that reference the server binary in other ways,
such as AppArmor profiles and scripts that previously expected to find
a 'mysqld' in process lists.
  • Loading branch information
ottok authored and robertbindar committed Jun 16, 2020
1 parent e290e5a commit 7803601
Show file tree
Hide file tree
Showing 22 changed files with 169 additions and 170 deletions.
6 changes: 3 additions & 3 deletions debian/additions/source_mariadb-10.5.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def add_info(report):
report[key] = ""
for line in read_file('/var/log/daemon.log').split('\n'):
try:
if 'mysqld' in line.split()[4]:
if 'mariadbd' in line.split()[4]:
report[key] += line + '\n'
except IndexError:
continue
Expand All @@ -35,8 +35,8 @@ def add_info(report):
report[key] = ""
for line in read_file('/var/log/mysql/error.log').split('\n'):
report[key] += line + '\n'
attach_mac_events(report, '/usr/sbin/mysqld')
attach_file(report,'/etc/apparmor.d/usr.sbin.mysqld')
attach_mac_events(report, '/usr/sbin/mariadbd')
attach_file(report,'/etc/apparmor.d/usr.sbin.mariadbd')
_add_my_conf_files(report, '/etc/mysql/mariadb.cnf')
for f in os.listdir('/etc/mysql/conf.d'):
_add_my_conf_files(report, os.path.join('/etc/mysql/conf.d', f))
Expand Down
4 changes: 2 additions & 2 deletions debian/mariadb-server-10.5.install
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ debian/additions/echo_stderr usr/share/mysql
debian/additions/mariadb.conf.d/50-mysqld_safe.cnf etc/mysql/mariadb.conf.d
debian/additions/mariadb.conf.d/50-server.cnf etc/mysql/mariadb.conf.d
debian/additions/source_mariadb-10.5.py usr/share/apport/package-hooks
etc/apparmor.d/usr.sbin.mysqld
etc/apparmor.d/usr.sbin.mariadbd
etc/security/user_map.conf
lib/*/security/pam_user_map.so
lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
Expand Down Expand Up @@ -61,7 +61,7 @@ usr/lib/mysql/plugin/server_audit.so
usr/lib/mysql/plugin/simple_password_check.so
usr/lib/mysql/plugin/sql_errlog.so
usr/lib/mysql/plugin/wsrep_info.so
usr/share/doc/mariadb-server-10.5/mysqld.sym.gz
usr/share/doc/mariadb-server-10.5/mariadbd.sym.gz
usr/share/man/man1/aria_chk.1
usr/share/man/man1/aria_dump_log.1
usr/share/man/man1/aria_ftdump.1
Expand Down
8 changes: 4 additions & 4 deletions debian/mariadb-server-10.5.logcheck.ignore.paranoid
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/etc/init.d/mariadb\[[0-9]+\]: Check that mysqld is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: '/usr/bin/mysqladmin --defaults-(extra-)?file=/etc/mysql/debian.cnf ping' resulted in$
/etc/mysql/debian-start\[[0-9]+\]: Checking for crashed MySQL tables\.$
mysqld\[[0-9]+\]: $
mysqld\[[0-9]+\]: Version: .* socket: '/run/mysqld/mysqld.sock' port: 3306$
mysqld\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mariadbd\[[0-9]+\]: $
mariadbd\[[0-9]+\]: Version: .* socket: '/run/mysqld/mysqld.sock' port: 3306$
mariadbd\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mysqld_safe\[[0-9]+\]: started$
usermod\[[0-9]+\]: change user `mysql' GID from `([0-9]+)' to `\1'$
usermod\[[0-9]+\]: change user `mysql' shell from `/bin/false' to `/bin/false'$
24 changes: 12 additions & 12 deletions debian/mariadb-server-10.5.logcheck.ignore.server
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/etc/init.d/mariadb\[[0-9]+\]: [0-9]+ processes alive and '/usr/bin/mysqladmin --defaults-(extra-)?file=/etc/mysql/debian.cnf ping' resulted in$
/etc/init.d/mariadb\[[0-9]+\]: Check that mysqld is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: '/usr/bin/mysqladmin --defaults-(extra-)?file=/etc/mysql/debian.cnf ping' resulted in$
/etc/mysql/debian-start\[[0-9]+\]: Checking for crashed MySQL tables\.$
mysqld\[[0-9]+\]: ?$
mysqld\[[0-9]+\]: .*InnoDB: Shutdown completed
mysqld\[[0-9]+\]: .*InnoDB: Started;
mysqld\[[0-9]+\]: .*InnoDB: Starting shutdown\.\.\.$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: Normal shutdown$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: ready for connections\.$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: Shutdown complete$
mysqld\[[0-9]+\]: /usr/sbin/mysqld: ready for connections\.$
mysqld\[[0-9]+\]: .*/usr/sbin/mysqld: Shutdown Complete$
mysqld\[[0-9]+\]: Version: .* socket
mysqld\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mariadbd\[[0-9]+\]: ?$
mariadbd\[[0-9]+\]: .*InnoDB: Shutdown completed
mariadbd\[[0-9]+\]: .*InnoDB: Started;
mariadbd\[[0-9]+\]: .*InnoDB: Starting shutdown\.\.\.$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: Normal shutdown$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: ready for connections\.$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: Shutdown complete$
mariadbd\[[0-9]+\]: /usr/sbin/mariadbd: ready for connections\.$
mariadbd\[[0-9]+\]: .*/usr/sbin/mariadbd: Shutdown Complete$
mariadbd\[[0-9]+\]: Version: .* socket
mariadbd\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mysqld_safe\[[0-9]+\]: ?$
mysqld_safe\[[0-9]+\]: able to use the new GRANT command!$
mysqld_safe\[[0-9]+\]: ended$
Expand Down
24 changes: 12 additions & 12 deletions debian/mariadb-server-10.5.logcheck.ignore.workstation
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/etc/init.d/mariadb\[[0-9]+\]: [0-9]+ processes alive and '/usr/bin/mysqladmin --defaults-(extra-)?file=/etc/mysql/debian.cnf ping' resulted in$
/etc/init.d/mariadb\[[0-9]+\]: Check that mysqld is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists\!$
/etc/init.d/mariadb\[[0-9]+\]: '/usr/bin/mysqladmin --defaults-(extra-)?file=/etc/mysql/debian.cnf ping' resulted in$
/etc/mysql/debian-start\[[0-9]+\]: Checking for crashed MySQL tables\.$
mysqld\[[0-9]+\]: ?$
mysqld\[[0-9]+\]: .*InnoDB: Shutdown completed
mysqld\[[0-9]+\]: .*InnoDB: Started;
mysqld\[[0-9]+\]: .*InnoDB: Starting shutdown\.\.\.$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: Normal shutdown$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: ready for connections\.$
mysqld\[[0-9]+\]: .*\[Note\] /usr/sbin/mysqld: Shutdown complete$
mysqld\[[0-9]+\]: /usr/sbin/mysqld: ready for connections\.$
mysqld\[[0-9]+\]: .*/usr/sbin/mysqld: Shutdown Complete$
mysqld\[[0-9]+\]: Version: .* socket
mysqld\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mariadbd\[[0-9]+\]: ?$
mariadbd\[[0-9]+\]: .*InnoDB: Shutdown completed
mariadbd\[[0-9]+\]: .*InnoDB: Started;
mariadbd\[[0-9]+\]: .*InnoDB: Starting shutdown\.\.\.$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: Normal shutdown$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: ready for connections\.$
mariadbd\[[0-9]+\]: .*\[Note\] /usr/sbin/mariadbd: Shutdown complete$
mariadbd\[[0-9]+\]: /usr/sbin/mariadbd: ready for connections\.$
mariadbd\[[0-9]+\]: .*/usr/sbin/mariadbd: Shutdown Complete$
mariadbd\[[0-9]+\]: Version: .* socket
mariadbd\[[0-9]+\]: Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line$
mysqld_safe\[[0-9]+\]: ?$
mysqld_safe\[[0-9]+\]: able to use the new GRANT command!$
mysqld_safe\[[0-9]+\]: ended$
Expand Down
50 changes: 25 additions & 25 deletions debian/mariadb-server-10.5.mariadb.init
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the mysql database server daemon
# Description: Controls the main MariaDB database server daemon "mysqld"
# Description: Controls the main MariaDB database server daemon "mariadbd"
# and its wrapper script "mysqld_safe".
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}

test -x /usr/sbin/mysqld || exit 0
test -x /usr/sbin/mariadbd || exit 0

. /lib/lsb/init-functions

Expand Down Expand Up @@ -50,16 +50,16 @@ export HOME=/etc/mysql/

## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
/usr/sbin/mysqld --print-defaults \
# Usage: void mariadbd_get_param option
mariadbd_get_param() {
/usr/sbin/mariadbd --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}

## Do some sanity checks before even trying to start mysqld.
## Do some sanity checks before even trying to start mariadbd.
sanity_checks() {
# check for config file
if [ ! -r /etc/mysql/my.cnf ]; then
Expand All @@ -68,7 +68,7 @@ sanity_checks() {
fi

# check for diskspace shortage
datadir=`mysqld_get_param datadir`
datadir=`mariadbd_get_param datadir`
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
Expand All @@ -79,14 +79,14 @@ sanity_checks() {
## Checks if there is a server running and if so if it is accessible.
#
# check_alive insists on a pingable server
# check_dead also fails if there is a lost mysqld in the process list
# check_dead also fails if there is a lost mariadbd in the process list
#
# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
mysqld_status () {
# Usage: boolean mariadbd_status [check_alive|check_dead] [warn|nowarn]
mariadbd_status () {
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))

ps_alive=0
pidfile=`mysqld_get_param pid-file`
pidfile=`mariadbd_get_param pid-file`
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi

if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
Expand All @@ -109,8 +109,8 @@ case "${1:-''}" in
'start')
sanity_checks;
# Start daemon
log_daemon_msg "Starting MariaDB database server" "mysqld"
if mysqld_status check_alive nowarn; then
log_daemon_msg "Starting MariaDB database server" "mariadbd"
if mariadbd_status check_alive nowarn; then
log_progress_msg "already running"
log_end_msg 0
else
Expand All @@ -122,10 +122,10 @@ case "${1:-''}" in

for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do
sleep 1
if mysqld_status check_alive nowarn ; then break; fi
if mariadbd_status check_alive nowarn ; then break; fi
log_progress_msg "."
done
if mysqld_status check_alive warn; then
if mariadbd_status check_alive warn; then
log_end_msg 0
# Now start mysqlcheck or whatever the admin wants.
output=$(/etc/mysql/debian-start)
Expand All @@ -144,26 +144,26 @@ case "${1:-''}" in
# at least for cron, we can rely on it here, too. (although we have
# to specify it explicit as e.g. sudo environments points to the normal
# users home and not /root)
log_daemon_msg "Stopping MariaDB database server" "mysqld"
if ! mysqld_status check_dead nowarn; then
log_daemon_msg "Stopping MariaDB database server" "mariadbd"
if ! mariadbd_status check_dead nowarn; then
set +e
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
set -e
if [ "$r" -ne 0 ]; then
log_end_msg 1
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
log_daemon_msg "Killing MariaDB database server by signal" "mysqld"
killall -15 mysqld
log_daemon_msg "Killing MariaDB database server by signal" "mariadbd"
killall -15 mariadbd
server_down=
for i in `seq 1 600`; do
sleep 1
if mysqld_status check_dead nowarn; then server_down=1; break; fi
if mariadbd_status check_dead nowarn; then server_down=1; break; fi
done
if test -z "$server_down"; then killall -9 mysqld; fi
if test -z "$server_down"; then killall -9 mariadbd; fi
fi
fi

if ! mysqld_status check_dead warn; then
if ! mariadbd_status check_dead warn; then
log_end_msg 1
log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.5/README.Debian.gz!"
exit -1
Expand All @@ -179,13 +179,13 @@ case "${1:-''}" in
;;

'reload'|'force-reload')
log_daemon_msg "Reloading MariaDB database server" "mysqld"
log_daemon_msg "Reloading MariaDB database server" "mariadbd"
$MYADMIN reload
log_end_msg 0
;;

'status')
if mysqld_status check_alive nowarn; then
if mariadbd_status check_alive nowarn; then
log_action_msg "$($MYADMIN version)"
else
log_action_msg "MariaDB is stopped."
Expand All @@ -196,7 +196,7 @@ case "${1:-''}" in
'bootstrap')
# Bootstrap the cluster, start the first node
# that initiates the cluster
log_daemon_msg "Bootstrapping the cluster" "mysqld"
log_daemon_msg "Bootstrapping the cluster" "mariadbd"
$SELF start "${@:2}" --wsrep-new-cluster
;;

Expand Down
2 changes: 1 addition & 1 deletion debian/mariadb-server-10.5.mysql-server.logrotate
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
sharedscripts
postrotate
test -x /usr/bin/mysqladmin || exit 0
if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then
if [ -f `my_print_defaults --mariadbd | grep -oP "pid-file=\K[^$]+"` ]; then
# If this fails, check debian.conf!
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log
Expand Down
6 changes: 3 additions & 3 deletions debian/mariadb-server-10.5.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ EOF
# This allows upgrade from old versions (that have an apparmor profile
# on by default) to work both to disable a default profile, and to keep
# any profile installed and maintained by users themselves.
profile="/etc/apparmor.d/usr.sbin.mysqld"
profile="/etc/apparmor.d/usr.sbin.mariadbd"
if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then
if grep -q /usr/sbin/mysqld "$profile" 2>/dev/null ; then
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then
apparmor_parser -r "$profile" || true
else
echo "/usr/sbin/mysqld { }" | apparmor_parser --remove 2>/dev/null || true
echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true
fi
fi

Expand Down
4 changes: 2 additions & 2 deletions debian/mariadb-server-10.5.postrm
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"

# Try to stop the server in a sane way. If it does not success let the admin
# do it himself. No database directories should be removed while the server
# is running! Another mysqld in e.g. a different chroot is fine for us.
# is running! Another mariadbd in e.g. a different chroot is fine for us.
stop_server() {
# Return immediately if there are no mysql processes running
# as there is no point in trying to shutdown in that case.
if ! pgrep -x mysqld > /dev/null; then return; fi
if ! pgrep -x mariadbd > /dev/null; then return; fi

set +e
invoke-rc.d mariadb stop
Expand Down
4 changes: 2 additions & 2 deletions debian/mariadb-server-10.5.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ mysql_upgradedir=/var/lib/mysql-upgrade

# Try to stop the server in a sane way. If it does not success let the admin
# do it himself. No database directories should be removed while the server
# is running! Another mysqld in e.g. a different chroot is fine for us.
# is running! Another mariadbd in e.g. a different chroot is fine for us.
stop_server() {
# Return immediately if there are no mysql processes running
# as there is no point in trying to shutdown in that case.
if ! pgrep -x --ns $$ mysqld > /dev/null; then return; fi
if ! pgrep -x --ns $$ mariadbd > /dev/null; then return; fi

set +e
invoke-rc.d mariadb stop
Expand Down
6 changes: 3 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ifeq (32,$(DEB_HOST_ARCH_BITS))
CMAKEFLAGS += -DWITHOUT_ROCKSDB=true
endif

# Add extra flag to avoid WolfSSL code crashing the entire mysqld on s390x. This
# Add extra flag to avoid WolfSSL code crashing the entire mariadbd on s390x. This
# can be removed once upstream has made the code s390x compatible, see
# https://jira.mariadb.org/browse/MDEV-21705 and
# https://github.com/wolfSSL/wolfssl/issues/2828
Expand Down Expand Up @@ -136,10 +136,10 @@ endif

# nm numeric soft is not enough, therefore extra sort in command
# to satisfy Debian reproducible build requirements
nm --defined-only $(BUILDDIR)/sql/mysqld | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.5/mysqld.sym.gz
nm --defined-only $(BUILDDIR)/sql/mariadbd | LC_ALL=C sort | gzip -n -9 > $(TMP)/usr/share/doc/mariadb-server-10.5/mariadbd.sym.gz

# rename and install AppArmor profile
install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld
install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mariadbd

# Install libmariadbclient18 compatibility links
ln -s libmariadb.so.3 $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadbclient.so
Expand Down
Loading

0 comments on commit 7803601

Please sign in to comment.