You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/02/13 12:29:25 UTC

[GitHub] [couchdb-docker] florianb opened a new pull request #170: Fix169 by enforcing safe admin credentials

florianb opened a new pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170
 
 
   ## Overview
   
   1. Checks for existence of admin credentials **before** starting Couch.
   2. If providing initial credentials by ENV the password is checked for a considerable secure length of 16 characters, otherwise a warning is printed to `stderr`.
   
   ## Testing recommendations
   
   ```shell
   docker build -t couchdb:3.0.0. dev
   docker run -i --name couchdb3dev couchdb:3.0.0
   docker rm couchdb3dev
   docker run -i --name couchdb3dev -e COUCHDB_USER=admin couchdb:3.0.0
   docker rm couchdb3dev
   docker run -i --name couchdb3dev -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=123456789abcde couchdb:3.0.0
   docker rm couchdb3dev
   docker run -i --name couchdb3dev -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=123456789abcdef couchdb:3.0.0
   docker rm couchdb3dev
   ```
   
   ## GitHub issue number
   
   #169 
   
   ## Checklist
   
   - [ ] Code is written and works correctly;
   - [ ] Changes are covered by tests;
   - [ ] Documentation reflects the changes;
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali closed pull request #170: Fix169 by enforcing admin credentials

Posted by GitBox <gi...@apache.org>.
wohali closed pull request #170: Fix169 by enforcing admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378993551
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
 
 Review comment:
   I guess i based it of from the wrong file version? I have fixed it in minutes.. :smile:

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378933533
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
 
 Review comment:
   This is unexpected, can you explain why you're checking for this everywhere? It may not be true, but we may still want the find operation to occur.
   
   /cc @kocolosk 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378952484
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
 
 Review comment:
   Thank you for reviewing @wohali - this line is a leftover from the original [docker-entrypoint.sh:35](https://github.com/apache/couchdb-docker/blob/6a011e4068cc275c896473e011e12e3a087164fa/3.0.0/docker-entrypoint.sh#L35).
   
   Should i review the entire docker-entrypoint script? I do currently not expect too much changes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378962126
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
+		# Check that we own everything in /opt/couchdb and fix if necessary. We also
+		# add the `-f` flag in all the following invocations because there may be
+		# cases where some of these ownership and permissions issues are non-fatal
+		# (e.g. a config file owned by root with o+r is actually fine), and we don't
+		# to be too aggressive about crashing here ...
+		find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
 
-	# Ensure that data files have the correct permissions. We were previously
-	# preventing any access to these files outside of couchdb:couchdb, but it
-	# turns out that CouchDB itself does not set such restrictive permissions
-	# when it creates the files. The approach taken here ensures that the
-	# contents of the datadir have the same permissions as they had when they
-	# were initially created. This should minimize any startup delay.
-	find /opt/couchdb/data -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
-	find /opt/couchdb/data -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+		# Ensure that data files have the correct permissions. We were previously
+		# preventing any access to these files outside of couchdb:couchdb, but it
+		# turns out that CouchDB itself does not set such restrictive permissions
+		# when it creates the files. The approach taken here ensures that the
+		# contents of the datadir have the same permissions as they had when they
+		# were initially created. This should minimize any startup delay.
+		find /opt/couchdb/data -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+		find /opt/couchdb/data -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
 
-	# Do the same thing for configuration files and directories. Technically
-	# CouchDB only needs read access to the configuration files as all online
-	# changes will be applied to the "docker.ini" file below, but we set 644
-	# for the sake of consistency.
-	find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
-	find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+		# Do the same thing for configuration files and directories. Technically
+		# CouchDB only needs read access to the configuration files as all online
+		# changes will be applied to the "docker.ini" file below, but we set 644
+		# for the sake of consistency.
+		find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+		find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+	fi
 
 	if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
 		echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
 	fi
 
-	# Ensure that CouchDB will write custom settings in this file
-	touch /opt/couchdb/etc/local.d/docker.ini
+	# Check if admin users are missing
+	if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+		# Check if admin-credentials are being provided
+		if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
+			# Check if the admin-password is 16 characters long, otherwise print a warning
+			if [ $(echo "$COUCHDB_PASSWORD" | wc -c) -lt 16 ]; then
 
 Review comment:
   I will remove that line.
   
   I added the line to make users aware of weak passwords and make accidential data leaks (like mentioned in the ZDNet article [Data leaks: The most common sources](https://www.zdnet.com/pictures/data-leaks-the-most-common-sources/7/)) less likely.
   
   Since container are so easy to spin up i thought it would be a good idea to hint for sane password length.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378934525
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
+		# Check that we own everything in /opt/couchdb and fix if necessary. We also
+		# add the `-f` flag in all the following invocations because there may be
+		# cases where some of these ownership and permissions issues are non-fatal
+		# (e.g. a config file owned by root with o+r is actually fine), and we don't
+		# to be too aggressive about crashing here ...
+		find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
 
-	# Ensure that data files have the correct permissions. We were previously
-	# preventing any access to these files outside of couchdb:couchdb, but it
-	# turns out that CouchDB itself does not set such restrictive permissions
-	# when it creates the files. The approach taken here ensures that the
-	# contents of the datadir have the same permissions as they had when they
-	# were initially created. This should minimize any startup delay.
-	find /opt/couchdb/data -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
-	find /opt/couchdb/data -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+		# Ensure that data files have the correct permissions. We were previously
+		# preventing any access to these files outside of couchdb:couchdb, but it
+		# turns out that CouchDB itself does not set such restrictive permissions
+		# when it creates the files. The approach taken here ensures that the
+		# contents of the datadir have the same permissions as they had when they
+		# were initially created. This should minimize any startup delay.
+		find /opt/couchdb/data -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+		find /opt/couchdb/data -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
 
-	# Do the same thing for configuration files and directories. Technically
-	# CouchDB only needs read access to the configuration files as all online
-	# changes will be applied to the "docker.ini" file below, but we set 644
-	# for the sake of consistency.
-	find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
-	find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+		# Do the same thing for configuration files and directories. Technically
+		# CouchDB only needs read access to the configuration files as all online
+		# changes will be applied to the "docker.ini" file below, but we set 644
+		# for the sake of consistency.
+		find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+		find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+	fi
 
 	if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
 		echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
 	fi
 
-	# Ensure that CouchDB will write custom settings in this file
-	touch /opt/couchdb/etc/local.d/docker.ini
+	# Check if admin users are missing
+	if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+		# Check if admin-credentials are being provided
+		if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
+			# Check if the admin-password is 16 characters long, otherwise print a warning
+			if [ $(echo "$COUCHDB_PASSWORD" | wc -c) -lt 16 ]; then
 
 Review comment:
   This check is unexpected and should be removed. We have no idea if CouchDB is being run in production, in development, etc.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
wohali commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378992020
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
 
 Review comment:
   Yeah, I'm a bit confused here as well. It may just be the diff display. If you can sort this out it'd be appreciated.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on a change in pull request #170: Fix169 by enforcing admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on a change in pull request #170: Fix169 by enforcing admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r379018564
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -55,10 +55,25 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
 	# Ensure that CouchDB will write custom settings in this file
 	touch /opt/couchdb/etc/local.d/docker.ini
 
-	if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
-		# Create admin only if not already present
-		if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+
+	# Check if admin users are missing then
+	if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+		# Check if admin credentials provided
+		if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
 
 Review comment:
   You're right - my bad. I should have understood what's happening there.. :disappointed:
   
   Containers should be idempotent. When researching if you really leave the password unhashed in the ini file and if your Ini-parser supports any kind of escape-statements for values i stumbled over [Issue 2188: Admin username with = in name gets corrupted on initial password encrypt](https://github.com/apache/couchdb/issues/2188) (where i left an educated guess about the cause for the :bug:).
   
   And i had to learn you're in fact writing the hashed password back into the config file.
   
   So if the password isn't used for anything else then authentication a user should be fine with throwing away the container with the forgotten password and creating a new one (given the data is mounted as external storage).
   
   If the password is also used to internally encrypt or sign anything this wouldn't work though.
   
   Since i guess the first applies you might want to close this PR.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali commented on a change in pull request #170: Fix169 by enforcing admin credentials

Posted by GitBox <gi...@apache.org>.
wohali commented on a change in pull request #170: Fix169 by enforcing admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r379039074
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -55,10 +55,25 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
 	# Ensure that CouchDB will write custom settings in this file
 	touch /opt/couchdb/etc/local.d/docker.ini
 
-	if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
-		# Create admin only if not already present
-		if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+
+	# Check if admin users are missing then
+	if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+		# Check if admin credentials provided
+		if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
 
 Review comment:
   Right, you'd have to attach your data to a new container with a new .ini file, server admins aren't stored anywhere other than in the ini files.
   
   We'll go ahead and close this thanks :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on a change in pull request #170: Fix169 by enforcing safe admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r378963511
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -25,40 +25,75 @@ if [ "$1" = 'couchdb' ]; then
 fi
 
 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
-	# Check that we own everything in /opt/couchdb and fix if necessary. We also
-	# add the `-f` flag in all the following invocations because there may be
-	# cases where some of these ownership and permissions issues are non-fatal
-	# (e.g. a config file owned by root with o+r is actually fine), and we don't
-	# to be too aggressive about crashing here ...
-	find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+	# this is where runtime configuration changes will be written.
+	# we need to explicitly touch it here in case /opt/couchdb/etc has
+	# been mounted as an external volume, in which case it won't exist.
+	# If running as the couchdb user (i.e. container starts as root),
+	# write permissions will be granted below.
+	touch /opt/couchdb/etc/local.d/docker.ini
+
+	# if user is root, assume running under the couchdb user (default)
+	# and ensure it is able to access files and directories that may be mounted externally
+	if [ "$(id -u)" = '0' ]; then
 
 Review comment:
   :thinking: It looks like i somehow polluted my commit - it tells me i actually added that line but i'm pretty sure i didn't.. Investigating... :mag: 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] wohali commented on a change in pull request #170: Fix169 by enforcing admin credentials

Posted by GitBox <gi...@apache.org>.
wohali commented on a change in pull request #170: Fix169 by enforcing admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#discussion_r379009684
 
 

 ##########
 File path: dev/docker-entrypoint.sh
 ##########
 @@ -55,10 +55,25 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
 	# Ensure that CouchDB will write custom settings in this file
 	touch /opt/couchdb/etc/local.d/docker.ini
 
-	if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
-		# Create admin only if not already present
-		if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+
+	# Check if admin users are missing then
+	if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+		# Check if admin credentials provided
+		if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
 
 Review comment:
   So, embarrassing admission time, I'd forgotten I'd already added a check in here. We may not need this PR :wink: sorry about that :disappointed: 
   
   This proposed change means that if there's already an admin specified in the file, we don't use `COUCHDB_USER` and `COUCHDB_PASSWORD` at all. That might be surprising to someone. For instance, what if I'm trying to recover a lost password in a stopped container? I can't decide if this is a valid use case or not. What do you think?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb-docker] florianb commented on issue #170: Fix169 by enforcing admin credentials

Posted by GitBox <gi...@apache.org>.
florianb commented on issue #170: Fix169 by enforcing admin credentials
URL: https://github.com/apache/couchdb-docker/pull/170#issuecomment-585869685
 
 
   I changed it to make a minimum viable change. The second check for admin credentials in 92 also aim for fallback credentials in the `default.d/*.ini`-files *and* check explicitly for a non-comment line after the admin-section.
   
   I have the feeling that could be cleaned up, too. Also could the error message be deduplicated.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services