From d7f6cdeda4ea942b556677e1a590edd203c0c646 Mon Sep 17 00:00:00 2001 From: Alexandre Mazari Date: Sat, 9 Mar 2019 16:57:39 +0100 Subject: [PATCH] Fix locally created database (#56889) * zoneminder: fix initial database creation Move initialDatabases directive from the 'ensureUsers' scope to the correct outer 'mysql' one. * zoneminder: Fix mysql username to match unix username When database.createLocally is used, a mysql user is created with the ensureUsers directive. It ensures that the unix user with the name provided exists and can connect to MySQL through socket. Thus, the MySQL username used by php/perl scripts must match the unix user owning the server PID. This patch sets the default mysql user to 'zoneminder' instead of 'zmuser'. --- nixos/modules/services/misc/zoneminder.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/misc/zoneminder.nix b/nixos/modules/services/misc/zoneminder.nix index fb9c4c41ae27..04ddd3ca183a 100644 --- a/nixos/modules/services/misc/zoneminder.nix +++ b/nixos/modules/services/misc/zoneminder.nix @@ -49,7 +49,7 @@ let # Database ZM_DB_TYPE=mysql ZM_DB_HOST=${cfg.database.host} - ZM_DB_NAME=${cfg.database.name} + ZM_DB_NAME=${if cfg.database.createLocally then user else cfg.database.username} ZM_DB_USER=${cfg.database.username} ZM_DB_PASS=${cfg.database.password} @@ -205,12 +205,12 @@ in { mysql = lib.mkIf cfg.database.createLocally { ensureDatabases = [ cfg.database.name ]; + initialDatabases = [{ + inherit (cfg.database) name; schema = "${pkg}/share/zoneminder/db/zm_create.sql"; + }]; ensureUsers = [{ name = cfg.database.username; ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; }; - initialDatabases = [ - { inherit (cfg.database) name; schema = "${pkg}/share/zoneminder/db/zm_create.sql"; } - ]; }]; };