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 locally created database #56889

Merged
merged 3 commits into from
Mar 9, 2019
Merged

Conversation

amazari
Copy link
Contributor

@amazari amazari commented Mar 5, 2019

Motivation for this change

In its current form the database.createLocally flag is broken. Those patches try to fix it.

Things done
  • mysql user auth: ensure that the mysql and the unix user running zonminder share the same name in order to allow unix socket mysql connection as enforced by the 'ensureUsers' directive
  • move the initial db creation and population to the right scope
    Ping @peterhoeg
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

amazari added 2 commits March 5, 2019 16:36
Move initialDatabases directive from the 'ensureUsers' scope to the correct outer 'mysql' one.
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 to 'zoneminder' instead of 'zmuser'.
@amazari amazari requested a review from infinisil as a code owner March 5, 2019 16:03
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Mar 5, 2019
@@ -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 user else cfg.database.name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is syntax problem here - then is missing. I guess this particular change wasn't tested somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, sorry about that. Will fix that asap, thanks for looking into it.

Fix syntax error and use the correct variable (cfg.database.username) when not creating the db locally.
@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Mar 9, 2019
@danbst danbst merged commit d7f6cde into NixOS:master Mar 9, 2019
amazari added a commit to amazari/nixpkgs that referenced this pull request Mar 9, 2019
PR messed up db and use naming NixOS#56889 while fixing the scope of the initialDatabases property.
This patch fixes the issue.
amazari added a commit to amazari/nixpkgs that referenced this pull request Mar 9, 2019
PR NixOS#56889 messed up db and use naming while fixing the scope of the initialDatabases property.
This patch fixes the issue.
@amazari
Copy link
Contributor Author

amazari commented Mar 9, 2019

Thanks @danbst for the merge.
Sadly I ***ed up and made a stupid mistake. It is fixed in #57125 . Would you mind reviewing it so master doesn't stay broken for too long ?
Sorry for that!

@@ -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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Why would you want a different user when having zoneminder create the database?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants