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

CouchDB only writes to the final file in the config chain #777

Open
S-Aggarwal opened this issue Aug 24, 2017 · 7 comments
Open

CouchDB only writes to the final file in the config chain #777

S-Aggarwal opened this issue Aug 24, 2017 · 7 comments

Comments

@S-Aggarwal
Copy link

Expected Behavior

If you add a new admin using the [admins] section of the locals.ini file, the password should get salted and encrypted (using pkbdf2) after restarting CouchDB.

Current Behavior

The password remains in plaintext while a copy is created in the 10-admins.ini file in the local.d directory where the encrypted password is stored.

Files after restarting CouchDB:
locals.ini

[admins]
;admin = mysecretpassword
testadmin = testpass

locals.d/10-admins.ini

[admins]
testadmin = -pbkdf2-1c9e78dae1afdf034b5777a62a8a7e8a0c8e93fd,56a7565edee375ebb7cb872185ea364c,10

Possible Solution

Edit local.ini with encrypted password as well after parsing it on start-up.

Your Environment

  • Version used: CouchDB 2.1.0
  • Operating System and version (desktop or mobile): Ubuntu 16.04
@wohali
Copy link
Member

wohali commented Aug 25, 2017

CouchDB always writes to the last file in the config chain, which draws file in the following order:

etc/default.ini
etc/default.d/* (processed in alphanumeric order)
etc/local.ini
etc/local.d/* (same)

What you are observing is the current behaviour, if you have an etc/local.d/whatever.ini file the encrypted password will be written there, not into etc/local.ini.

Improving this functionality is useful, and something that's been on the verbal backlog for a while, but will require a near-complete rewrite of the current config system. (Read: this won't happen very soon, nor is it strictly speaking a bug.)

I will retitle this issue and leave it open to track future work.

@wohali wohali changed the title Adding admins through local.ini doesn't encrypt passwords after restart CouchDB only writes to the final file in the config chain Aug 25, 2017
@ahayes
Copy link

ahayes commented Jun 19, 2018

This gave me quite a bit of grief today. Note that this behaviour does not match the documentation at https://docs.couchdb.org/en/2.1.1/config/auth.html#server-administrators

A side-effect is that attempting to reset the admin password using the local.ini file doesn't seem to take hold. I now assume this is because it doesn't consider the local.ini version to be relevant when there is a local.d/10-admins.ini file present with the same user listed in it. Only new users have their info copied over.

@wohali
Copy link
Member

wohali commented Jun 19, 2018

Thanks for the info @ahayes . We'd welcome your improvements to the documentation over at https://github.com/apache/couchdb-documentation . Pull requests are welcome! :)

@ahayes
Copy link

ahayes commented Jun 19, 2018

Thanks @wohali. I can give it a shot. Can you confirm that this new behaviour is standard on all couchdb platforms? I could then modify the docs to simply point at the 10-admins.ini file rather than local.ini sections talking about [admins]. Also, do you know which version introduced this change?

@wohali
Copy link
Member

wohali commented Jun 19, 2018

10-admins.ini is specific to how the Debian package installer works, so no, that's not global. The described behaviour here is new as of 2.0.0, which is when many breaking changes were introduced.

ahayes added a commit to ahayes/couchdb-documentation that referenced this issue Jun 19, 2018
@janl
Copy link
Member

janl commented Jul 14, 2018

@wohali what about swapping local.ini and local.d/ in the chain, so that local.ini reigns supreme?

@wohali
Copy link
Member

wohali commented Jul 15, 2018

@janl That would break the approach @kocolosk has set up for the Docker images, kubernetes and the helm chart. It also would be backwards compatibility breaking. I don't like it.

wohali pushed a commit to apache/couchdb-documentation that referenced this issue Nov 15, 2018
* Clarify use of relevant [admins] section

Helps with issue apache/couchdb#777
nickva pushed a commit to nickva/couchdb that referenced this issue Sep 7, 2022
* Clarify use of relevant [admins] section

Helps with issue apache#777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants