You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/11/27 16:52:48 UTC
[karaf] branch karaf-4.2.x updated: reference:file must be chrooted
in home or base but must also use a representation karaf can resolve from
anyway instead of relying on '.' being the used home or base
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
new d9ce402 reference:file must be chrooted in home or base but must also use a representation karaf can resolve from anyway instead of relying on '.' being the used home or base
d9ce402 is described below
commit d9ce40263e16386a83292c7508e54dc6eeaff700
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Wed Nov 27 17:00:57 2019 +0100
reference:file must be chrooted in home or base but must also use a representation karaf can resolve from anyway instead of relying on '.' being the used home or base
---
main/src/main/java/org/apache/karaf/main/Main.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/main/src/main/java/org/apache/karaf/main/Main.java b/main/src/main/java/org/apache/karaf/main/Main.java
index d39b479..00cba42 100644
--- a/main/src/main/java/org/apache/karaf/main/Main.java
+++ b/main/src/main/java/org/apache/karaf/main/Main.java
@@ -550,14 +550,21 @@ public class Main {
}
private void installAndStartBundles(ArtifactResolver resolver, BundleContext context, List<BundleInfo> bundles) {
+ final URI home = !bundles.isEmpty() ? config.karafHome.toURI() : null;
+ final URI base = !bundles.isEmpty() ? config.karafBase.toURI() : null;
for (BundleInfo bundleInfo : bundles) {
try {
Bundle b;
if (bundleInfo.uri.toString().startsWith("reference:file:")) {
URI temp = URI.create(bundleInfo.uri.toString().substring("reference:file:".length()));
URI resolvedURI = resolver.resolve(temp);
- URI finalUri = URI.create("reference:file:" + config.karafBase.toURI().relativize(resolvedURI));
- b = context.installBundle(finalUri.toString());
+ final String asciiString = resolvedURI.toASCIIString();
+ if (asciiString.startsWith(home.toASCIIString()) ||
+ asciiString.startsWith(base.toASCIIString())) {
+ b = context.installBundle(URI.create("reference:" + asciiString).toString());
+ } else {
+ throw new IllegalArgumentException("Can't resolve bundle '" + bundleInfo.uri + "'");
+ }
} else {
URI resolvedURI = resolver.resolve(bundleInfo.uri);
b = context.installBundle(bundleInfo.uri.toString(), resolvedURI.toURL().openStream());