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

nixos/kibana: add passwordFile option (#24288) #30662

Closed
wants to merge 1 commit into from

Conversation

schneefux
Copy link
Contributor

Motivation for this change

Added a warning if the elasticsearch password is stored in the nix store, added the passwordFile option to be used instead.
Tested Kibana 5 by looking at the generated /var/lib/kibana/config.json, once with the password option set and once using the passwordFile option.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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/)
  • Fits CONTRIBUTING.md.

@schneefux
Copy link
Contributor Author

Tested & fixed the expression producing an error when no password was set.

''}
${optionalString (cfg.elasticsearch.passwordFile != null) ''
ELASTIC_PASSWORD=$(head -n1 ${cfg.elasticsearch.passwordFile})
sed -e "s,PASSWORD_REPLACED_PRESTART,$ELASTIC_PASSWORD,g" -i ${cfgFileRun}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fails if there are special characters like " in the password. Is there a better approach?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this will fail, bash doesn't interpret the quotes in an expanded string.

${optionalString (cfg.elasticsearch.passwordFile == null) ''
sed -e 's,"password":"PASSWORD_REPLACED_PRESTART"\,,,g' -i ${cfgFileRun}
''}
${optionalString (cfg.elasticsearch.passwordFile != null) ''
Copy link
Member

Choose a reason for hiding this comment

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

Use

if (cfg.elasticsearch.passwordFile == null) then ''
  sed ...
'' else ''
  ELASTIC_PASSWORD=...
''

instead

''}
${optionalString (cfg.elasticsearch.passwordFile != null) ''
ELASTIC_PASSWORD=$(head -n1 ${cfg.elasticsearch.passwordFile})
sed -e "s,PASSWORD_REPLACED_PRESTART,$ELASTIC_PASSWORD,g" -i ${cfgFileRun}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this will fail, bash doesn't interpret the quotes in an expanded string.

@infinisil
Copy link
Member

Ping

Copy link
Member

@matthewbauer matthewbauer left a comment

Choose a reason for hiding this comment

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

See @infinisil's comments

@schneefux
Copy link
Contributor Author

Sorry, I am no longer using Kibana on NixOS so I cannot maintain this pull request. If anyone wants to take over, please do!

@infinisil infinisil closed this Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants