Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rabbitmq config decryption #192620

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion nixos/tests/rabbitmq.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# This test runs rabbitmq and checks if rabbitmq is up and running.

import ./make-test-python.nix ({ pkgs, ... }: {
import ./make-test-python.nix ({ pkgs, ... }:
let
# in real life, you would keep this out of your repo and deploy it to a safe
# location using safe means.
configKeyPath = pkgs.writeText "fake-config-key" "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01";
in
{
name = "rabbitmq";
meta = with pkgs.lib.maintainers; {
maintainers = [ eelco offline ];
Expand All @@ -10,6 +16,29 @@ import ./make-test-python.nix ({ pkgs, ... }: {
services.rabbitmq = {
enable = true;
managementPlugin.enable = true;

# To encrypt:
# rabbitmqctl --quiet encode --cipher blowfish_cfb64 --hash sha256 \
# --iterations 10000 '<<"dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw">>' \
# "hOjWzSEn2Z7cHzKOcf6i183O2NdjurSuoMDIIv01" ;
config = ''
[ { rabbit
, [ {default_user, <<"alice">>}
, { default_pass
, {encrypted,<<"oKKxyTze9PYmsEfl6FG1MxIUhxY7WPQL7HBoMPRC/1ZOdOZbtr9+DxjWW3e1D5SL48n3D9QOsGD0cOgYG7Qdvb7Txrepw8w=">>}
}
, {config_entry_decoder
, [ {passphrase, {file, <<"${configKeyPath}">>}}
, {cipher, blowfish_cfb64}
, {hash, sha256}
, {iterations, 10000}
]
}
% , {rabbitmq_management, [{path_prefix, "/_queues"}]}
]
}
].
'';
};
# Ensure there is sufficient extra disk space for rabbitmq to be happy
virtualisation.diskSize = 1024;
Expand All @@ -23,5 +52,10 @@ import ./make-test-python.nix ({ pkgs, ... }: {
'su -s ${pkgs.runtimeShell} rabbitmq -c "rabbitmqctl status"'
)
machine.wait_for_open_port(15672)

# The password is the plaintext that was encrypted with rabbitmqctl encode above.
machine.wait_until_succeeds(
'${pkgs.rabbitmq-java-client}/bin/PerfTest --time 10 --uri amqp://alice:dJT8isYu6t0Xb6u56rPglSj1vK51SlNVlXfwsRxw@localhost'
turion marked this conversation as resolved.
Show resolved Hide resolved
)
'';
})
20 changes: 11 additions & 9 deletions pkgs/servers/amqp/rabbitmq-server/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
, nixosTests
}:

let
runtimePath = lib.makeBinPath ([
erlang
getconf # for getting memory limits
socat
procps
gnused
coreutils # used by helper scripts
] ++ lib.optionals stdenv.isLinux [ systemd ]); # for systemd unit activation check
in

stdenv.mkDerivation rec {
pname = "rabbitmq-server";
version = "3.10.7";
Expand All @@ -48,15 +59,6 @@ stdenv.mkDerivation rec {
export LANG=C.UTF-8 # fix elixir locale warning
'';

runtimePath = lib.makeBinPath ([
erlang
getconf # for getting memory limits
socat
procps
gnused
coreutils # used by helper scripts
] ++ lib.optionals stdenv.isLinux [ systemd ]); # for systemd unit activation check

postInstall = ''
# rabbitmq-env calls to sed/coreutils, so provide everything early
sed -i $out/sbin/rabbitmq-env -e '2s|^|PATH=${runtimePath}\''${PATH:+:}\$PATH/\n|'
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23789,6 +23789,7 @@ with pkgs;
rabbitmq-server = callPackage ../servers/amqp/rabbitmq-server {
inherit (darwin.apple_sdk.frameworks) AppKit Carbon Cocoa;
elixir = elixir_1_12;
erlang = erlang.override { opensslPackage = openssl_1_1; };
};

radicale2 = callPackage ../servers/radicale/2.x.nix { };
Expand Down