Summary: | IOUtil.getTempDir(..): Difficulties to determine executable access permission on Windows via BATCH file execution | ||
---|---|---|---|
Product: | [JogAmp] Gluegen | Reporter: | Sven Gothel <sgothel> |
Component: | core | Assignee: | Sven Gothel <sgothel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | askinner, gouessej, rene |
Priority: | --- | ||
Version: | 2.3.0 | ||
Hardware: | All | ||
OS: | windows | ||
Type: | DEFECT | SCM Refs: |
150ea4f231c9629ef9ef354e3f1a92a516d46f91
181dc8ae227cd5cbecf60ab8d973bb8eef7c45f0
cb5f02b05b97dc05a3f7d4d3e3821e1fc3ae2c59
|
Workaround: | --- | ||
Bug Depends on: | |||
Bug Blocks: | 1015, 1109, 1219 |
Description
Sven Gothel
2014-12-11 17:53:11 CET
150ea4f231c9629ef9ef354e3f1a92a516d46f91 Try using explicit call to Windows 'cmd.exe' w/ referencing the BATCH file location, via 'Runtime.getRuntime().exec(new String[] { "cmd", "/c", "a.bat" } );' While the bug itself could not be reproduced here, I could test on Windows 7 (64bit and 32bit), as well as an WindowsXP 32bit that no regression occured. (In reply to comment #1) > 150ea4f231c9629ef9ef354e3f1a92a516d46f91 > > Try using explicit call to Windows 'cmd.exe' w/ referencing the BATCH > file location, > via > 'Runtime.getRuntime().exec(new String[] { "cmd", "/c", "a.bat" } );' > > While the bug itself could not be reproduced here, > I could test on Windows 7 (64bit and 32bit), as well as an WindowsXP > 32bit > that no regression occured. TODO: Validate whether this modified exec test still detects the execution permission restriction as described in Bug 1015 <https://jogamp.org/bugzilla/show_bug.cgi?id=1015>. (In reply to comment #2) > TODO: Validate whether this modified exec test > still detects the execution permission restriction > as described in Bug 1015 <https://jogamp.org/bugzilla/show_bug.cgi?id=1015>. Adding the software restriction as described in Bug 1015 comment 2 on path 'C:\Documents and Settings\sven\temp-noexec' leads to proper no-exec detection: IOUtil.testDirImpl(tempX1): <C:\Documents and Settings\sven\temp-noexec>, create true, exec true: false ^^ Leads to use the home folder 'C:\Users\sven\' Using the unrestricted exec path 'C:\Documents and Settings\sven\temp-exec' still works. Hence the 'cmd /c a.bat' batch file execution is still restricted by software restrictions, no regression here. (In reply to comment #3) > Using the unrestricted exec path 'C:\Documents and Settings\sven\temp-exec' > still works. > > Hence the 'cmd /c a.bat' batch file execution is still > restricted by software restrictions, no regression here. Setting up a directory 'C:\Users\sven\temp-noexec2' via ACLs (Advanced Security Settings), i.e. deny "Traverse Folder / Execute File" permissions does _not_ work w/ this 'cmd /c a.bat' batch file exec test. See Bug 1015 comment 3! (In reply to comment #4) > Setting up a directory 'C:\Users\sven\temp-noexec2' > via ACLs (Advanced Security Settings), > i.e. deny "Traverse Folder / Execute File" permissions > does _not_ work w/ this 'cmd /c a.bat' batch file exec test. But it works w/ the simple 'a.bat' exec test: +++ IOUtil.getTempRoot(): tempX1 <C:\Documents and Settings\sven\temp-noexec2>, used true IOUtil.getTempRoot(): tempX3 <C:\Documents and Settings\sven\temp-noexec2>, used false IOUtil.getTempRoot(): tempX4 <C:\Users\sven>, used true IOUtil.getTempRoot(): tempX2 <null>, used false IOUtil.testDirExec: <C:\Documents and Settings\sven\temp-noexec2\jogamp_exe_tst6314597605367855228.bat>: Caught IOException: Cannot run program "C:\Documents and Settings\sven\temp-noexec2\jogamp_exe_tst6314597605367855228.bat": CreateProcess error=5, Access is denied IOUtil.testDirExec(): <C:\Documents and Settings\sven\temp-noexec2>: res -2 IOUtil.testDirExec(): total 125ms, create 109ms, execute 16ms IOUtil.testDirImpl(tempX1): <C:\Documents and Settings\sven\temp-noexec2>, create true, exec true: false +++ Hence we need to figure out how to test .. or why 'a.bat' doesn't work on some machines. Note above log snippet shows a different behavior, i.e. exposes a different error (error 5) than this bugs original (error 2)! Here, error 5 is as expected! 181dc8ae227cd5cbecf60ab8d973bb8eef7c45f0 Batch file execution test via direct call, i.e.'a.bat', does not work on some Windows machine, not reproducible here! A workaround would be to call the batch file explicit via 'CMD /c a.bat': - works when using 'Software Restriction Policies' (Bug 1015 Comment 2) - does _not_ work when denying ACL "Traverse Folder / Execute File" permission (Bug 1015 Comment 3) Due to this bug, we need to use a native execution: - Performing executable test w/ native exe file instead of batch file on Windows x86 32bit and 64bit, - using [1] TinyPE XP-W8 Compatible - x86 32bit and 64bit - 268 bytes - Tested on: WinXP-32bit, Win7-64bit and Win8-64bit - Author/License: Ange Albertini, BSD Licence, 2010-2013 - On all other Windows machines (ARM, ..), we still use direct execution of 'a.bat' but may add native exe files for missing platforms. +++ This patch injects said binaries within the java jar file and copies it into the 'to be tested' temp folder for execution. [1] TinyPE XP-W8 Compatible - x86 32bit and 64bit - 268 bytes is included within 'src/native/tinype-corkami', build manually and imported as 'src/java/com/jogamp/common/util/bin/exe-windows-i586-268b.bin'. +++ (In reply to comment #6) > 181dc8ae227cd5cbecf60ab8d973bb8eef7c45f0 Backported to b22x, commit cb5f02b05b97dc05a3f7d4d3e3821e1fc3ae2c59 *** Bug 1103 has been marked as a duplicate of this bug. *** I can just confirm that when exe-windows-i586-268b.bin is missing, I get this kind of exception under Windows 8.1: java.io.IOException: Could not determine a temporary executable directory at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1168) at com.jogamp.common.util.cache.TempFileCache.<clinit>(TempFileCache.java:80) at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:88) at com.jogamp.common.os.Platform$1.run(Platform.java:309) at java.security.AccessController.doPrivileged(Native Method) at com.jogamp.common.os.Platform.<clinit>(Platform.java:287) at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:146) When putting it into my fat JARs, it works anew. I tested with OpenJDK 1.7 update 60 and Oracle Java 1.8 update 45 both with an applet and an application. (In reply to Julien Gouesse from comment #9) > I can just confirm that when exe-windows-i586-268b.bin is missing, I get > this kind of exception under Windows 8.1: You are saying that 'exe-windows-i586-268b.bin' is missing in the fat jar? See below .. its in the latest fat-jar .. +++ <http://jogamp.org/deployment/archive/master/gluegen_888-joal_614-jogl_1438-jocl_1083-signed/> unzip -l jogamp-fat.jar | grep \.bin 0 2015-09-15 17:05 com/jogamp/common/util/bin/ 268 2015-09-15 07:59 com/jogamp/common/util/bin/exe-windows-i586-268b.bin +++ It was missing from my own fat JAR, sorry for the confusion. |