docker
docker copied to clipboard
Fix S3 `use_ssl` and `autocreate` default values
Description
From the PHP Manual for getenv
, we have
getenv(string $varname, bool $local_only = false): string|false
Returns the value of the environment variable varname, or false if the environment variable varname does not exist.
Now check this out
https://github.com/nextcloud/docker/blob/a15c755399e299914acebe0a5005dd5ddff0db56/.config/s3.config.php#L3
https://github.com/nextcloud/docker/blob/a15c755399e299914acebe0a5005dd5ddff0db56/.config/s3.config.php#L19
Value not set -> getenv
returns false
-> use_ssl
gets false
-> ternary goes to false
This is a great example of why to not allow poorly written code into a codebase. It obfuscates things.
Should probably be
// if defined and value is "false" then set to false
!(getenv('OBJECTSTORE_S3_SSL') && strtolower(getenv('OBJECTSTORE_S3_SSL')) === 'false')
// demorgans law
// if not defined or doesn't have value "false" then set to true
!getenv('OBJECTSTORE_S3_SSL') || strtolower(getenv('OBJECTSTORE_S3_SSL')) !== 'false'
There are several other suspicious variables. Using a ternary operator for a boolean expression is redundant. Not relying on truthy falsy values in favor of explicit checks is also somewhat suspicious here.
https://github.com/nextcloud/docker/blob/a15c755399e299914acebe0a5005dd5ddff0db56/.config/s3.config.php#L18-L23
https://github.com/nextcloud/docker/blob/a15c755399e299914acebe0a5005dd5ddff0db56/.config/swift.config.php#L8
Requirements
- build docker image
- [ ] set only
OBJECTSTORE_S3_BUCKET
(use defaults) - exec in
- examine config/config.php and check default values against README
- [ ]
autocreate
istrue
- [ ]
use_ssl
istrue
- [x]
use_path_style
isfalse
- [x]
legacy_auth
isfalse
- [ ]
- [x] set only
OBJECTSTORE_SWIFT_URL
- [x]
autocreate
isfalse
- [x]
will pick this up if my other PRs are resolved