Database administration tool for non-admin users, rewrite of https://git.pvv.ntnu.no/Projects/mysql-admutils
 
 
Go to file
Oystein Kristoffer Tveit 0837ac9fc7
README: add better documentation
2024-05-14 02:21:39 +02:00
src Let mysql connection shut down gracefully 2024-04-26 00:29:39 +02:00
.gitignore Initial commit 2024-04-20 03:38:29 +02:00
Cargo.lock Add TUI stub 2024-04-23 00:47:58 +02:00
Cargo.toml Add TUI stub 2024-04-23 00:47:58 +02:00
LICENSE Initial commit 2024-04-20 03:38:29 +02:00
README.md README: add better documentation 2024-05-14 02:21:39 +02:00
example-config.toml example-config: fix typo 2024-05-14 02:21:23 +02:00
flake.lock Initial commit 2024-04-20 03:38:29 +02:00
flake.nix flake.nix: fix `RUST_SRC_PATH` in devshell 2024-05-14 02:21:06 +02:00

README.md

mysqladm-rs

Work in progress rewrite of https://git.pvv.ntnu.no/Projects/mysql-admutils

Installation

The resulting binary will probably need to be marked as either SUID or SGID to work in a multi-user environment. The UID/GID of the binary should have access to the config file, which contains secrets to log in to an admin-like MySQL user. Preferrably, this UID/GID should not be root, in order to minimize the potential damage that can be done in case of security vulnerabilities in the program.

Development and testing

Ensure you have a rust toolchain installed.

In order to set up a test instance of mariadb in a docker container, run the following command:

docker run --rm --name mariadb -e MYSQL_ROOT_PASSWORD=secret -d mariadb:latest

You should then create a config file, and adjust the hostname to the IP address of the docker container.

cp ./example-config.toml ./config.toml
DOCKER_IP_ADDRESS="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb)"
sed -i "s/host = \"localhost\"/host = \"${DOCKER_IP_ADDRESS}\"/" ./config.toml

You should now be able to connect to the mariadb instance, after building the program and using arguments to specify the config file.

cargo run -- --config-file ./config.toml <args>

# example usage
cargo run -- --config-file ./config.toml db create "${USER}_testdb"
cargo run -- --config-file ./config.toml user create "${USER}_testuser"
cargo run -- --config-file ./config.toml db edit-perm -p "${USER}_testdb:${USER}_testuser:A"
cargo run -- --config-file ./config.toml db show-perm

To stop and remove the container, run the following command:

docker stop mariadb