Rename project to muscl
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1086,7 +1086,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mysqladm-rs"
|
||||
name = "muscl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
||||
16
Cargo.toml
16
Cargo.toml
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "mysqladm-rs"
|
||||
name = "muscl"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "BSD-3-Clause"
|
||||
@@ -7,8 +7,8 @@ authors = [
|
||||
"oysteikt@pvv.ntnu.no",
|
||||
"felixalb@pvv.ntnu.no",
|
||||
]
|
||||
repository = "https://git.pvv.ntnu.no/Projects/mysqladm-rs"
|
||||
documentation = "https://pages.pvv.ntnu.no/Projects/mysqladm-rs/main/docs/mysqladm/"
|
||||
repository = "https://git.pvv.ntnu.no/Projects/muscl"
|
||||
documentation = "https://pages.pvv.ntnu.no/Projects/muscl/main/docs/muscl/"
|
||||
description = "A command-line utility for MySQL administration for non-admin users"
|
||||
categories = ["command-line-interface", "command-line-utilities"]
|
||||
keywords = ["mysql", "cli", "administration"]
|
||||
@@ -51,7 +51,7 @@ mysql-admutils-compatibility = []
|
||||
suid-sgid-mode = []
|
||||
|
||||
[[bin]]
|
||||
name = "mysqladm"
|
||||
name = "muscl"
|
||||
bench = false
|
||||
path = "src/main.rs"
|
||||
|
||||
@@ -67,7 +67,7 @@ anyhow = "1.0.100"
|
||||
regex = "1.12.2"
|
||||
|
||||
[package.metadata.deb]
|
||||
name = "mysqladm-rs"
|
||||
name = "muscl"
|
||||
priority = "optional"
|
||||
section = "databases"
|
||||
depends = "$auto"
|
||||
@@ -76,13 +76,13 @@ maintainer = "Programvareverkstedet <projects@pvv.ntnu.no>"
|
||||
copyright = "Copyright (c) 2025, Programvareverkstedet"
|
||||
assets = [
|
||||
[
|
||||
"target/release/mysqladm",
|
||||
"target/release/muscl",
|
||||
"usr/bin/",
|
||||
"755",
|
||||
],
|
||||
[
|
||||
"example-config.toml",
|
||||
"etc/mysqladm/config.toml",
|
||||
"etc/muscl/config.toml",
|
||||
"600",
|
||||
],
|
||||
[
|
||||
@@ -107,5 +107,5 @@ assets = [
|
||||
],
|
||||
]
|
||||
systemd-units = [
|
||||
{ unit-name = "mysqladm", unit-scripts = "assets/systemd", enable = true },
|
||||
{ unit-name = "muscl", unit-scripts = "assets/systemd", enable = true },
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[](https://pages.pvv.ntnu.no/Projects/mysqladm-rs/main/coverage/)
|
||||
[](https://pages.pvv.ntnu.no/Projects/mysqladm-rs/main/docs/mysqladm/)
|
||||
[](https://pages.pvv.ntnu.no/Projects/muscl/main/coverage/)
|
||||
[](https://pages.pvv.ntnu.no/Projects/muscl/main/docs/muscl/)
|
||||
|
||||
# mysqladm-rs
|
||||
# muscl
|
||||
|
||||
Healing mysql spasms since 2024
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
[Unit]
|
||||
Description=MySQL administration tool for non-admin users
|
||||
Requires=mysqladm.socket
|
||||
Requires=muscl.socket
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
ExecStart=/usr/bin/mysqladm-rs server --systemd socket-activate
|
||||
ExecStart=/usr/bin/muscl server --systemd socket-activate
|
||||
|
||||
WatchdogSec=15
|
||||
|
||||
User=mysqladm
|
||||
Group=mysqladm
|
||||
User=muscl
|
||||
Group=muscl
|
||||
DynamicUser=yes
|
||||
|
||||
ConfigurationDirectory=mysqladm
|
||||
RuntimeDirectory=mysqladm
|
||||
ConfigurationDirectory=muscl
|
||||
RuntimeDirectory=muscl
|
||||
|
||||
# This is required to read unix user/group details.
|
||||
PrivateUsers=false
|
||||
@@ -3,6 +3,6 @@ Description=MySQL administration tool for non-admin users
|
||||
WantedBy=sockets.target
|
||||
|
||||
[Socket]
|
||||
ListenStream=/run/mysqladm/mysqladm.sock
|
||||
ListenStream=/run/muscl/muscl.sock
|
||||
Accept=no
|
||||
PassCredentials=true
|
||||
4
build.rs
4
build.rs
@@ -21,7 +21,7 @@ fn generate_mysql_admutils_symlinks() -> anyhow::Result<()> {
|
||||
|
||||
if !target_profile_dir.join("mysql-useradm").exists() {
|
||||
symlink(
|
||||
target_profile_dir.join("mysqladm"),
|
||||
target_profile_dir.join("muscl"),
|
||||
target_profile_dir.join("mysql-useradm"),
|
||||
)
|
||||
.ok();
|
||||
@@ -29,7 +29,7 @@ fn generate_mysql_admutils_symlinks() -> anyhow::Result<()> {
|
||||
|
||||
if !target_profile_dir.join("mysql-dbadm").exists() {
|
||||
symlink(
|
||||
target_profile_dir.join("mysqladm"),
|
||||
target_profile_dir.join("muscl"),
|
||||
target_profile_dir.join("mysql-dbadm"),
|
||||
)
|
||||
.ok();
|
||||
|
||||
@@ -4,16 +4,16 @@ cargo build --release
|
||||
|
||||
mkdir -p assets/completions
|
||||
|
||||
./target/release/mysqladm generate-completions --shell bash > assets/completions/mysqladm.bash
|
||||
./target/release/mysqladm generate-completions --shell zsh > assets/completions/_mysqladm
|
||||
./target/release/mysqladm generate-completions --shell fish > assets/completions/mysqladm.fish
|
||||
./target/release/muscl generate-completions --shell bash > assets/completions/muscl.bash
|
||||
./target/release/muscl generate-completions --shell zsh > assets/completions/_muscl
|
||||
./target/release/muscl generate-completions --shell fish > assets/completions/muscl.fish
|
||||
|
||||
./target/release/mysqladm generate-completions --shell bash --command mysql-dbadm > assets/completions/mysql-dbadm.bash
|
||||
./target/release/mysqladm generate-completions --shell zsh --command mysql-dbadm > assets/completions/_mysql-dbadm
|
||||
./target/release/mysqladm generate-completions --shell fish --command mysql-dbadm > assets/completions/mysql-dbadm.fish
|
||||
./target/release/muscl generate-completions --shell bash --command mysql-dbadm > assets/completions/mysql-dbadm.bash
|
||||
./target/release/muscl generate-completions --shell zsh --command mysql-dbadm > assets/completions/_mysql-dbadm
|
||||
./target/release/muscl generate-completions --shell fish --command mysql-dbadm > assets/completions/mysql-dbadm.fish
|
||||
|
||||
./target/release/mysqladm generate-completions --shell bash --command mysql-useradm > assets/completions/mysql-useradm.bash
|
||||
./target/release/mysqladm generate-completions --shell zsh --command mysql-useradm > assets/completions/_mysql-useradm
|
||||
./target/release/mysqladm generate-completions --shell fish --command mysql-useradm > assets/completions/mysql-useradm.fish
|
||||
./target/release/muscl generate-completions --shell bash --command mysql-useradm > assets/completions/mysql-useradm.bash
|
||||
./target/release/muscl generate-completions --shell zsh --command mysql-useradm > assets/completions/_mysql-useradm
|
||||
./target/release/muscl generate-completions --shell fish --command mysql-useradm > assets/completions/mysql-useradm.fish
|
||||
|
||||
cargo deb
|
||||
cargo deb
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# This should go to `/etc/mysqladm/config.toml`
|
||||
# This should go to `/etc/muscl/config.toml`
|
||||
|
||||
[server]
|
||||
# The path to the socket where users can connect to the daemon.
|
||||
#
|
||||
# Note that this options gets ignored if you are using systemd socket activation
|
||||
# (see `systemctl status mysqladm.socket`)
|
||||
socket_path = "/run/mysqladm/mysqladm.sock"
|
||||
# (see `systemctl status muscl.socket`)
|
||||
socket_path = "/run/muscl/muscl.sock"
|
||||
|
||||
[mysql]
|
||||
|
||||
|
||||
34
flake.nix
34
flake.nix
@@ -37,8 +37,8 @@
|
||||
apps = let
|
||||
mkApp = program: { type = "app"; program = toString program; };
|
||||
in forAllSystems (system: pkgs: _: {
|
||||
mysqladm-rs = mkApp (lib.getExe self.packages.${system}.mysqladm-rs);
|
||||
coverage = mkApp (pkgs.writeScript "mysqladm-rs-coverage" ''
|
||||
muscl = mkApp (lib.getExe self.packages.${system}.muscl);
|
||||
coverage = mkApp (pkgs.writeScript "muscl-coverage" ''
|
||||
${lib.getExe pkgs.python3} -m http.server -d "${self.packages.${system}.coverage}/html/src"
|
||||
'');
|
||||
vm = mkApp "${self.nixosConfigurations.vm.config.system.build.vm}/bin/run-nixos-vm";
|
||||
@@ -59,18 +59,18 @@
|
||||
});
|
||||
|
||||
overlays = {
|
||||
default = self.overlays.mysqladm-rs;
|
||||
mysqladm-rs = final: prev: {
|
||||
inherit (self.packages.${prev.stdenv.hostPlatform.system}) mysqladm-rs;
|
||||
default = self.overlays.muscl;
|
||||
muscl = final: prev: {
|
||||
inherit (self.packages.${prev.stdenv.hostPlatform.system}) muscl;
|
||||
};
|
||||
mysqladm-rs-crane = final: prev: {
|
||||
mysqladm-rs = self.packages.${prev.stdenv.hostPlatform.system}.mysqladm-rs-crane;
|
||||
muscl-crane = final: prev: {
|
||||
muscl = self.packages.${prev.stdenv.hostPlatform.system}.muscl-crane;
|
||||
};
|
||||
};
|
||||
|
||||
nixosModules = {
|
||||
default = self.nixosModules.mysqladm-rs;
|
||||
mysqladm-rs = import ./nix/module.nix;
|
||||
default = self.nixosModules.muscl;
|
||||
muscl = import ./nix/module.nix;
|
||||
};
|
||||
|
||||
packages = forAllSystems (system: pkgs: _:
|
||||
@@ -85,9 +85,9 @@
|
||||
];
|
||||
};
|
||||
in {
|
||||
default = self.packages.${system}.mysqladm-rs-crane;
|
||||
mysqladm-rs = pkgs.callPackage ./nix/default.nix { inherit cargoToml cargoLock src; };
|
||||
mysqladm-rs-crane = pkgs.callPackage ./nix/default.nix {
|
||||
default = self.packages.${system}.muscl-crane;
|
||||
muscl = pkgs.callPackage ./nix/default.nix { inherit cargoToml cargoLock src; };
|
||||
muscl-crane = pkgs.callPackage ./nix/default.nix {
|
||||
useCrane = true;
|
||||
inherit cargoToml cargoLock src craneLib;
|
||||
};
|
||||
@@ -102,7 +102,7 @@
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
overlays = [
|
||||
self.overlays.mysqladm-rs-crane
|
||||
self.overlays.muscl-crane
|
||||
];
|
||||
};
|
||||
modules = [
|
||||
@@ -133,10 +133,10 @@
|
||||
|
||||
users.motd = ''
|
||||
=================================
|
||||
Welcome to the mysqladm-rs vm!
|
||||
Welcome to the muscl vm!
|
||||
|
||||
Try running:
|
||||
${config.services.mysqladm-rs.package.meta.mainProgram}
|
||||
${config.services.muscl.package.meta.mainProgram}
|
||||
|
||||
Password for alice is 'foobar'
|
||||
Password for root is 'root'
|
||||
@@ -149,12 +149,12 @@
|
||||
enable = true;
|
||||
package = pkgs.mariadb;
|
||||
};
|
||||
services.mysqladm-rs = {
|
||||
services.muscl = {
|
||||
enable = true;
|
||||
createLocalDatabaseUser = true;
|
||||
};
|
||||
|
||||
systemd.services."mysqladm@".environment.RUST_LOG = "debug";
|
||||
systemd.services."muscl".environment.RUST_LOG = "debug";
|
||||
|
||||
programs.vim = {
|
||||
enable = true;
|
||||
|
||||
@@ -25,11 +25,11 @@ buildFunction {
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
postInstall = let
|
||||
commands = lib.mapCartesianProduct ({ shell, command }: ''
|
||||
"$out/bin/${mainProgram}" generate-completions --shell "${shell}" --command "${command}" > "$TMP/mysqladm.${shell}"
|
||||
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/mysqladm.${shell}"
|
||||
"$out/bin/${mainProgram}" generate-completions --shell "${shell}" --command "${command}" > "$TMP/muscl.${shell}"
|
||||
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/muscl.${shell}"
|
||||
'') {
|
||||
shell = [ "bash" "zsh" "fish" ];
|
||||
command = [ "mysqladm" "mysql-dbadm" "mysql-useradm" ];
|
||||
command = [ "muscl" "mysql-dbadm" "mysql-useradm" ];
|
||||
};
|
||||
in lib.concatStringsSep "\n" commands;
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.services.mysqladm-rs;
|
||||
cfg = config.services.muscl;
|
||||
format = pkgs.formats.toml { };
|
||||
in
|
||||
{
|
||||
options.services.mysqladm-rs = {
|
||||
enable = lib.mkEnableOption "Enable mysqladm-rs";
|
||||
options.services.muscl = {
|
||||
enable = lib.mkEnableOption "Enable muscl";
|
||||
|
||||
package = lib.mkPackageOption pkgs "mysqladm-rs" { };
|
||||
package = lib.mkPackageOption pkgs "muscl" { };
|
||||
|
||||
createLocalDatabaseUser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Create a local database user for mysqladm-rs";
|
||||
description = "Create a local database user for muscl";
|
||||
};
|
||||
|
||||
logLevel = lib.mkOption {
|
||||
type = lib.types.enum [ "quiet" "error" "warn" "info" "debug" "trace" ];
|
||||
default = "debug";
|
||||
description = "Log level for mysqladm-rs";
|
||||
description = "Log level for muscl";
|
||||
apply = level: {
|
||||
"quiet" = "-q";
|
||||
"error" = "";
|
||||
@@ -37,8 +37,8 @@ in
|
||||
server = {
|
||||
socket_path = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/run/mysqladm/mysqladm.sock";
|
||||
description = "Path to the mysqladm socket";
|
||||
default = "/run/muscl/muscl.sock";
|
||||
description = "Path to the muscl socket";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ in
|
||||
};
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "mysqladm";
|
||||
default = "muscl";
|
||||
description = "MySQL username";
|
||||
};
|
||||
passwordFile = lib.mkOption {
|
||||
@@ -79,12 +79,12 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.services.mysqladm-rs.enable {
|
||||
config = lib.mkIf config.services.muscl.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
environment.etc."mysqladm/config.toml".source = let
|
||||
environment.etc."muscl/config.toml".source = let
|
||||
nullStrippedConfig = lib.filterAttrsRecursive (_: v: v != null) cfg.settings;
|
||||
in format.generate "mysqladm-rs.conf" nullStrippedConfig;
|
||||
in format.generate "muscl.conf" nullStrippedConfig;
|
||||
|
||||
services.mysql.ensureUsers = lib.mkIf cfg.createLocalDatabaseUser [
|
||||
{
|
||||
@@ -96,10 +96,10 @@ in
|
||||
}
|
||||
];
|
||||
|
||||
systemd.services."mysqladm" = {
|
||||
systemd.services."muscl" = {
|
||||
description = "MySQL administration tool for non-admin users";
|
||||
restartTriggers = [ config.environment.etc."mysqladm/config.toml".source ];
|
||||
requires = [ "mysqladm.socket" ];
|
||||
restartTriggers = [ config.environment.etc."muscl/config.toml".source ];
|
||||
requires = [ "muscl.socket" ];
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
ExecStart = "${lib.getExe cfg.package} ${cfg.logLevel} server --systemd socket-activate";
|
||||
@@ -108,12 +108,12 @@ in
|
||||
|
||||
# Although this is a multi-instance unit, the constant `User` field is needed
|
||||
# for authentication via mysql's auth_socket plugin to work.
|
||||
User = "mysqladm";
|
||||
Group = "mysqladm";
|
||||
User = "muscl";
|
||||
Group = "muscl";
|
||||
DynamicUser = true;
|
||||
|
||||
ConfigurationDirectory = "mysqladm";
|
||||
RuntimeDirectory = "mysqladm";
|
||||
ConfigurationDirectory = "muscl";
|
||||
RuntimeDirectory = "muscl";
|
||||
|
||||
# This is required to read unix user/group details.
|
||||
PrivateUsers = false;
|
||||
@@ -166,7 +166,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
systemd.sockets."mysqladm" = {
|
||||
systemd.sockets."muscl" = {
|
||||
description = "MySQL administration tool for non-admin users";
|
||||
wantedBy = [ "sockets.target" ];
|
||||
socketConfig = {
|
||||
|
||||
@@ -88,15 +88,15 @@ pub enum ClientCommand {
|
||||
///
|
||||
/// Enable privileges `SELECT`, `INSERT`, and `UPDATE` for user `my_user` on database `my_db`:
|
||||
///
|
||||
/// `mysqladm edit-db-privs -p my_db:my_user:siu`
|
||||
/// `muscl edit-db-privs -p my_db:my_user:siu`
|
||||
///
|
||||
/// Enable all privileges for user `my_other_user` on database `my_other_db`:
|
||||
///
|
||||
/// `mysqladm edit-db-privs -p my_other_db:my_other_user:A`
|
||||
/// `muscl edit-db-privs -p my_other_db:my_other_user:A`
|
||||
///
|
||||
/// Set miscellaneous privileges for multiple users on database `my_db`:
|
||||
///
|
||||
/// `mysqladm edit-db-privs my_db -p my_user:siu my_other_user:ct``
|
||||
/// `muscl edit-db-privs my_db -p my_user:siu my_other_user:ct``
|
||||
///
|
||||
#[command(verbatim_doc_comment)]
|
||||
EditDbPrivs(EditDbPrivsArgs),
|
||||
|
||||
@@ -52,8 +52,8 @@ The Y/N-values corresponds to the following mysql privileges:
|
||||
/// Create, drop or edit permissions for the DATABASE(s),
|
||||
/// as determined by the COMMAND.
|
||||
///
|
||||
/// This is a compatibility layer for the mysql-dbadm command.
|
||||
/// Please consider using the newer mysqladm command instead.
|
||||
/// This is a compatibility layer for the 'mysql-dbadm' command.
|
||||
/// Please consider using the newer 'muscl' command instead.
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
bin_name = "mysql-dbadm",
|
||||
@@ -93,7 +93,7 @@ pub struct Args {
|
||||
|
||||
// NOTE: mysql-dbadm explicitly calls privileges "permissions".
|
||||
// This is something we're trying to move away from.
|
||||
// See https://git.pvv.ntnu.no/Projects/mysqladm-rs/issues/29
|
||||
// See https://git.pvv.ntnu.no/Projects/muscl/issues/29
|
||||
#[derive(Parser)]
|
||||
pub enum Command {
|
||||
/// create the DATABASE(s).
|
||||
|
||||
@@ -28,8 +28,8 @@ use crate::{
|
||||
/// Create, delete or change password for the USER(s),
|
||||
/// as determined by the COMMAND.
|
||||
///
|
||||
/// This is a compatibility layer for the mysql-useradm command.
|
||||
/// Please consider using the newer mysqladm command instead.
|
||||
/// This is a compatibility layer for the 'mysql-useradm' command.
|
||||
/// Please consider using the newer 'muscl' command instead.
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
bin_name = "mysql-useradm",
|
||||
|
||||
@@ -4,8 +4,8 @@ use nix::unistd::{Group as LibcGroup, User as LibcUser};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use std::ffi::CString;
|
||||
|
||||
pub const DEFAULT_CONFIG_PATH: &str = "/etc/mysqladm/config.toml";
|
||||
pub const DEFAULT_SOCKET_PATH: &str = "/run/mysqladm/mysqladm.sock";
|
||||
pub const DEFAULT_CONFIG_PATH: &str = "/etc/muscl/config.toml";
|
||||
pub const DEFAULT_SOCKET_PATH: &str = "/run/muscl/muscl.sock";
|
||||
|
||||
pub struct UnixUser {
|
||||
pub username: String,
|
||||
|
||||
@@ -37,7 +37,7 @@ mod core;
|
||||
/// You are only allowed to manage databases and users that are prefixed with
|
||||
/// either your username, or a group that you are a member of.
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(bin_name = "mysqladm", version, about, disable_help_subcommand = true)]
|
||||
#[command(bin_name = "muscl", version, about, disable_help_subcommand = true)]
|
||||
struct Args {
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
@@ -83,14 +83,14 @@ struct GenerateCompletionArgs {
|
||||
#[arg(long, default_value = "bash")]
|
||||
shell: Shell,
|
||||
|
||||
#[arg(long, default_value = "mysqladm")]
|
||||
#[arg(long, default_value = "muscl")]
|
||||
command: ToplevelCommands,
|
||||
}
|
||||
|
||||
#[cfg(feature = "mysql-admutils-compatibility")]
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
enum ToplevelCommands {
|
||||
Mysqladm,
|
||||
Muscl,
|
||||
MysqlDbadm,
|
||||
MysqlUseradm,
|
||||
}
|
||||
@@ -167,7 +167,7 @@ fn handle_generate_completions_command(args: &Args) -> anyhow::Result<Option<()>
|
||||
"The executable should not be SUID or SGID when generating completions"
|
||||
);
|
||||
let mut cmd = match completion_args.command {
|
||||
ToplevelCommands::Mysqladm => Args::command(),
|
||||
ToplevelCommands::Muscl => Args::command(),
|
||||
#[cfg(feature = "mysql-admutils-compatibility")]
|
||||
ToplevelCommands::MysqlDbadm => mysql_dbadm::Args::command(),
|
||||
#[cfg(feature = "mysql-admutils-compatibility")]
|
||||
|
||||
Reference in New Issue
Block a user