From d92850fdd8357ccefff98758fc66824e2e7f87bb Mon Sep 17 00:00:00 2001 From: Kaloyan Enimanev Date: Thu, 8 Sep 2011 12:52:04 +0200 Subject: [PATCH 04/10] bugfix: only run executable once, set executable flags only when required --- .../java/com/izforge/izpack/util/FileExecutor.java | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/izpack-util/src/main/java/com/izforge/izpack/util/FileExecutor.java b/izpack-util/src/main/java/com/izforge/izpack/util/FileExecutor.java index ce4a609..8976d22 100644 --- a/izpack-util/src/main/java/com/izforge/izpack/util/FileExecutor.java +++ b/izpack-util/src/main/java/com/izforge/izpack/util/FileExecutor.java @@ -317,9 +317,6 @@ public class FileExecutor { int exitStatus = 0; String[] output = new String[2]; - // String permissions = (System.getProperty("user.name").equals("root")) - // ? "a+x" : "u+x"; - String permissions = "a+x"; // loop through all executables Iterator efileIterator = this.files.iterator(); @@ -339,15 +336,17 @@ public class FileExecutor if (ExecutableFile.BIN == efile.type && currentStage != ExecutableFile.UNINSTALL && OsVersion.IS_UNIX) { - // fix executable permission for unix systems Debug.trace("making file executable (setting executable flag)"); - String[] params = {"/bin/chmod", permissions, file.toString()}; - exitStatus = executeCommand(params, output); - if (exitStatus != 0) + if (false == file.canExecute()) { - handler.emitWarning("file execution error", "Error executing \n" + params[0] - + " " + params[1] + " " + params[2]); - continue; + try + { + file.setExecutable(true, false); + } catch (SecurityException se) + { + handler.emitWarning("Cannot make file executable", file.getPath()); + continue; + } } } -- 1.7.4.1