felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1812296 - in /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime: Closure.java CommandProcessorImpl.java CommandSessionImpl.java Pipe.java
Date Mon, 16 Oct 2017 13:52:05 GMT
Author: gnodet
Date: Mon Oct 16 13:52:05 2017
New Revision: 1812296

URL: http://svn.apache.org/viewvc?rev=1812296&view=rev
Log:
[FELIX-5715] Central point to allow customization of security related checks

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java?rev=1812296&r1=1812295&r2=1812296&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java Mon
Oct 16 13:52:05 2017
@@ -593,8 +593,7 @@ public class Closure implements Function
             {
                 if (".".equals(arg))
                 {
-                    target = Reflective.invoke(session, target,
-                        args.remove(0).toString(), args);
+                    target = invoke(target, args.remove(0).toString(), args);
                     args.clear();
                 }
                 else
@@ -608,7 +607,7 @@ public class Closure implements Function
                 return target;
             }
 
-            return Reflective.invoke(session, target, args.remove(0).toString(), args);
+            return invoke(target, args.remove(0).toString(), args);
         }
         else if (cmd.getClass().isArray() && values.size() == 1)
         {
@@ -618,10 +617,15 @@ public class Closure implements Function
         }
         else
         {
-            return Reflective.invoke(session, cmd, values.remove(0).toString(), values);
+            return invoke(cmd, values.remove(0).toString(), values);
         }
     }
 
+    private Object invoke(Object target, String name, List<Object> args) throws Exception
+    {
+        return session.invoke(target, name, args);
+    }
+
     private Object assignment(String name, Object value)
     {
         session.put(name, value);

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java?rev=1812296&r1=1812295&r2=1812296&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
Mon Oct 16 13:52:05 2017
@@ -21,8 +21,10 @@ package org.apache.felix.gogo.runtime;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Method;
+import java.nio.file.Path;
 import java.util.Collections;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -400,4 +402,14 @@ public class CommandProcessorImpl implem
     {
         return new Expression(expr.toString()).eval(session.variables);
     }
+
+    public Object invoke(CommandSessionImpl session, Object target, String name, List<Object>
args) throws Exception
+    {
+        return Reflective.invoke(session, target, name, args);
+    }
+
+    public Path redirect(CommandSessionImpl session, Path path, int mode)
+    {
+        return session.currentDir().resolve(path);
+    }
 }

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java?rev=1812296&r1=1812295&r2=1812296&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
Mon Oct 16 13:52:05 2017
@@ -488,6 +488,16 @@ public class CommandSessionImpl implemen
         return processor.expr(this, expr);
     }
 
+    public Object invoke(Object target, String name, List<Object> args) throws Exception
+    {
+        return processor.invoke(this, target, name, args);
+    }
+
+    public Path redirect(Path path, int mode)
+    {
+        return processor.redirect(this, path, mode);
+    }
+
     @Override
     public List<Job> jobs()
     {

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java?rev=1812296&r1=1812295&r2=1812296&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java Mon Oct
16 13:52:05 2017
@@ -274,7 +274,7 @@ public class Pipe implements Callable<Re
                     Object val = Expander.expand(tok, closure);
                     for (Path p : toPaths(val))
                     {
-                        p = closure.session().currentDir().resolve(p);
+                        p = closure.session().redirect(p, WRITE);
                         Channel ch = Files.newByteChannel(p, options);
                         if (fd >= 0)
                         {
@@ -333,7 +333,7 @@ public class Pipe implements Callable<Re
                     Object val = Expander.expand(tok, closure);
                     for (Path p : toPaths(val))
                     {
-                        p = closure.session().currentDir().resolve(p);
+                        p = closure.session().redirect(p, READ + (output ? WRITE : 0));
                         Channel ch = Files.newByteChannel(p, options);
                         setStream(ch, fd, READ + (output ? WRITE : 0));
                     }



Mime
View raw message