Description
Elasticsearch is unable to install plugins when the plugin requires to install certain configuration (e.g. repository-s3
) in the config directory.
It complains of lacking the corresponding permissions to write in the directory even when the permissions are correct.
Elasticsearch version: 5.6.15
Plugins installed: repository-s3
JVM version: 1.8.201
OS version: Debian 9
Description of the problem including expected versus actual behavior:
I'm using Bitnami ElasticSearch Docker Image which allows to install plugins (using elasticsearch-plugin install
command) during the bootstrap of the container by listing them in the env. variable "ELASTICSEARCH_PLUGINS".
This image is a non-root container (it runs as user 1001
by default) and it uses the directory /opt/bitnami/elasticsearch/config as "config dir". By default, this directory has the permissions configuration below:
- Permissions: 775
- Ownership: root:root
Please note that the user running the "install plugin command" (the user 1001) belongs to the "root" group and, therefore, it has permissions to write on that directory. You can check it running the command below:
$ docker run --rm bitnami/elasticsearch:6 /bin/bash -c 'mkdir /opt/bitnami/elasticsearch/config/new-directory && ls -la /opt/bitnami/elasticsearch/config'
However, Elasticsearch complains of lacking permissions when trying to install the plugin (see provided logs).
I think the reason might be related to the code below:
For some reason I don't understand, the elasticsearch-plugin install
command tries to modify the ownership of the "config dir" and then, it complains about being unable to create the repository-s3
directory even having the proper permissions!
- Why is this necessary?
- Shouldn't it check whether the user has writing permissions and create the directory if so?
Steps to reproduce:
Run the command below:
$ docker run --rm -e "ELASTICSEARCH_PLUGINS=repository-s3" -e "BITNAMI_DEBUG=true" bitnami/elasticsearch:6
Provide logs (if relevant):
Checking if url exists: https://artifacts.elastic.co/downloads/elasticsearch-plugins/repository-s3/repository-s3-linux-x86_64-6.7.1.zip
Downloading repository-s3 from elastic
Retrieving zip from https://artifacts.elastic.co/downloads/elasticsearch-plugins/repository-s3/repository-s3-6.7.1.zip
- Plugin information:
Name: repository-s3
Description: The S3 repository plugin adds S3 repositories
Version: 6.7.1
Elasticsearch Version: 6.7.1
Java Version: 1.8
Native Controller: false
Extended Plugins: []
* Classname: org.elasticsearch.repositories.s3.S3RepositoryPlugin
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.RuntimePermission getClassLoader
* java.lang.reflect.ReflectPermission suppressAccessChecks
* java.net.SocketPermission * connect,resolve
* java.util.PropertyPermission es.allow_insecure_settings read,write
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Exception in thread "main" java.nio.file.FileSystemException: /opt/bitnami/elasticsearch/config/repository-s3: Operation not permitted
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Posix.setOwners(UnixFileAttributeViews.java:252)
at sun.nio.fs.UnixFileAttributeViews$Posix.setOwner(UnixFileAttributeViews.java:274)
at org.elasticsearch.plugins.InstallPluginCommand.setOwnerGroup(InstallPluginCommand.java:919)
at org.elasticsearch.plugins.InstallPluginCommand.installConfig(InstallPluginCommand.java:892)
at org.elasticsearch.plugins.InstallPluginCommand.installPluginSupportFiles(InstallPluginCommand.java:826)
at org.elasticsearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:807)
at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:776)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:231)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:216)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:77)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)