diff --git a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java index 95fc2373766..9e17eec2e93 100644 --- a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java +++ b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java @@ -304,7 +304,9 @@ class InstallPluginCommand extends SettingCommand { // be on the safe side: do not rely on that directories are always extracted // before their children (although this makes sense, but is it guaranteed?) - Files.createDirectories(targetFile.getParent()); + if (!Files.isSymbolicLink(targetFile.getParent())) { + Files.createDirectories(targetFile.getParent()); + } if (entry.isDirectory() == false) { try (OutputStream out = Files.newOutputStream(targetFile)) { int len; diff --git a/qa/vagrant/src/test/resources/packaging/scripts/module_and_plugin_test_cases.bash b/qa/vagrant/src/test/resources/packaging/scripts/module_and_plugin_test_cases.bash index 19d9f69ece0..32118fda389 100644 --- a/qa/vagrant/src/test/resources/packaging/scripts/module_and_plugin_test_cases.bash +++ b/qa/vagrant/src/test/resources/packaging/scripts/module_and_plugin_test_cases.bash @@ -113,6 +113,28 @@ fi fi } +@test "[$GROUP] install jvm-example plugin with a symlinked plugins path" { + # Clean up after the last time this test was run + rm -rf /tmp/plugins.* + rm -rf /tmp/old_plugins.* + + rm -rf "$ESPLUGINS" + local es_plugins=$(mktemp -d -t 'plugins.XXXX') + chown -R elasticsearch:elasticsearch "$es_plugins" + ln -s "$es_plugins" "$ESPLUGINS" + + install_jvm_example + start_elasticsearch_service + # check that symlinked plugin was actually picked up + curl -s localhost:9200/_cat/configured_example | sed 's/ *$//' > /tmp/installed + echo "foo" > /tmp/expected + diff /tmp/installed /tmp/expected + stop_elasticsearch_service + remove_jvm_example + + unlink "$ESPLUGINS" +} + @test "[$GROUP] install jvm-example plugin with a custom CONFIG_DIR" { # Clean up after the last time we ran this test rm -rf /tmp/config.*