summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satserver
diff options
context:
space:
mode:
authorSimon Rettberg2015-01-23 19:19:58 +0100
committerSimon Rettberg2015-01-23 19:19:58 +0100
commit2eb5cea8578c2884c6f30fa379212bbfc1554bed (patch)
tree12d4eb781782e07e41b084444a2185a978e90c98 /src/main/java/org/openslx/satserver
parentPimp my boot menu (diff)
downloadtmlite-bwlp-2eb5cea8578c2884c6f30fa379212bbfc1554bed.tar.gz
tmlite-bwlp-2eb5cea8578c2884c6f30fa379212bbfc1554bed.tar.xz
tmlite-bwlp-2eb5cea8578c2884c6f30fa379212bbfc1554bed.zip
Stuff
Diffstat (limited to 'src/main/java/org/openslx/satserver')
-rw-r--r--src/main/java/org/openslx/satserver/util/Exec.java7
-rw-r--r--src/main/java/org/openslx/satserver/util/Util.java10
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/openslx/satserver/util/Exec.java b/src/main/java/org/openslx/satserver/util/Exec.java
index 1f810eb..db59b0d 100644
--- a/src/main/java/org/openslx/satserver/util/Exec.java
+++ b/src/main/java/org/openslx/satserver/util/Exec.java
@@ -14,8 +14,13 @@ public class Exec
*/
public static int sync( String... command )
{
+ return syncAt( "/", command );
+ }
+
+ public static int syncAt( String cwd, String... command )
+ {
ProcessBuilder pb = new ProcessBuilder( command );
- pb.directory( new File( "/" ) );
+ pb.directory( new File( cwd ) );
Process p;
try {
p = pb.start();
diff --git a/src/main/java/org/openslx/satserver/util/Util.java b/src/main/java/org/openslx/satserver/util/Util.java
index 2df4c73..fcf10ed 100644
--- a/src/main/java/org/openslx/satserver/util/Util.java
+++ b/src/main/java/org/openslx/satserver/util/Util.java
@@ -22,6 +22,8 @@ public class Util
*/
public static boolean startsWith( String stringToCheck, String... compareTo )
{
+ if ( stringToCheck == null )
+ return false;
for ( String check : compareTo ) {
if ( stringToCheck.startsWith( check ) )
return true;
@@ -77,4 +79,12 @@ public class Util
FileUtils.writeStringToFile( file, string, StandardCharsets.UTF_8 );
}
+ private static final String[] DEFAULT_ALLOWED_DIRS =
+ { "/tmp/", "/opt/openslx/configs/" };
+
+ public static boolean isAllowedDir( String dir )
+ {
+ return startsWith( dir, DEFAULT_ALLOWED_DIRS );
+ }
+
}