fix(mariadb,mysql plugin): ignore /etc/mysql config files, for better isolation (#2904)#2906
Open
jefft wants to merge 1 commit into
Open
fix(mariadb,mysql plugin): ignore /etc/mysql config files, for better isolation (#2904)#2906jefft wants to merge 1 commit into
jefft wants to merge 1 commit into
Conversation
50c5808 to
e4e043f
Compare
… isolation (jetify-com#2904) By default, mariadbd reads /etc/mysql/mariadb.cnf, and if the system has another version of MariaDB installed, those config files can cause the Devbox mariadbd to fail (e.g. requesting loading plugins not available). This commit causes devbox mariadbd (and mysqld) to only read from $MYSQL_CONF (typically devbox.d/mariadb/my.cnf). Additionally, wrap the client/admin binaries (mariadb, mariadb-admin, mariadb-dump, mysqldump, mysql, mysqladmin) with --defaults-file and --socket so they also ignore /etc/mysql and connect to the correct socket. Fixes jetify-com#2904
e4e043f to
a85fad6
Compare
Contributor
Author
|
In testing, I neglected to test In the latest force-push I removed all mysql wrappers of mariadb commands. This leaves symlinks, which the package natively provides: (devbox) jturner@jturner-desktop:/tmp/testmariadb$ ls -la $(which mysql mysqld mysqld_safe mysqldump mysql_install_db)
lrwxrwxrwx root root 7 B Thu Jan 1 10:00:01 1970 /tmp/testmariadb/.devbox/nix/profile/default/bin/mysql ⇒ mariadb
lrwxrwxrwx root root 18 B Thu Jan 1 10:00:01 1970 /tmp/testmariadb/.devbox/nix/profile/default/bin/mysql_install_db ⇒ mariadb-install-db
lrwxrwxrwx root root 8 B Thu Jan 1 10:00:01 1970 /tmp/testmariadb/.devbox/nix/profile/default/bin/mysqld ⇒ mariadbd
lrwxrwxrwx root root 13 B Thu Jan 1 10:00:01 1970 /tmp/testmariadb/.devbox/nix/profile/default/bin/mysqld_safe ⇒ mariadbd-safe
lrwxrwxrwx root root 12 B Thu Jan 1 10:00:01 1970 /tmp/testmariadb/.devbox/nix/profile/default/bin/mysqldump ⇒ mariadb-dumpThe symlinks behave exactly as we want: (devbox) jturner@jturner-desktop:/tmp/testmariadb$ mariadb -sNBe "select 1;"
1
(devbox) jturner@jturner-desktop:/tmp/testmariadb$ mysql -sNBe "select 1;"
/tmp/testmariadb/.devbox/nix/profile/default/bin/mysql: Deprecated program name. It will be removed in a future release, use '/nix/store/s60l117jfi8y1p567im85rykwjarl13q-mariadb-server-11.8.8/bin/mariadb' instead
1
(devbox) jturner@jturner-desktop:/tmp/testmariadb$ mysqldump --all-databases
/tmp/testmariadb/.devbox/nix/profile/default/bin/mysqldump: Deprecated program name. It will be removed in a future release, use '/nix/store/s60l117jfi8y1p567im85rykwjarl13q-mariadb-server-11.8.8/bin/mariadb-dump' instead
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19-11.8.8-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database:
-- ------------------------------------------------------
-- Server version 11.8.8-MariaDB
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2904.
By default, mariadbd reads /etc/mysql/mariadb.cnf, and if the system has another version of MariaDB installed, those config files can cause the Devbox mariadbd to fail (e.g. requesting loading plugins not available).
Devbox services ought to be isolated from their environment. This commit causes devbox mariadbd (and mysqld) to only read from $MYSQL_CONF (typically devbox.d/mariadb/my.cnf).
Additionally, wrap the client/admin binaries (mariadb, mariadb-admin, mariadb-dump, mysqldump, mysql, mysqladmin) with --defaults-file and --socket so they also ignore /etc/mysql and connect to the correct socket.
How was it tested?
Mariadb
Optionally, create a deliberately broken config option in the default
mariadb.cnfas a canary:Then run:
For me the latter prints:
mysql80
For me the latter commands show:
This change (#2904) finishes the job begun by #2524. Also obsoletes (fixes in a nicer way) #2522.
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.