├── settings.gradle ├── sk1er_mod.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── src └── main │ ├── java │ └── club │ │ └── sk1er │ │ └── resourceexploitfix │ │ ├── ResourceExploitFix.java │ │ ├── tweaker │ │ ├── transform │ │ │ └── ResourceTransformer.java │ │ ├── ClassTransformer.java │ │ └── ResourceTweaker.java │ │ ├── hook │ │ └── NetHandlerPlayClientHook.java │ │ └── asm │ │ └── NetHandlerPlayClientTransformer.java │ └── resources │ └── mcmod.info ├── mod_info.txt ├── .gitignore ├── README.md ├── LICENSE ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Resource Exploit Fix' -------------------------------------------------------------------------------- /sk1er_mod.properties: -------------------------------------------------------------------------------- 1 | mod_id=resourceexploitfix 2 | display_name=Resource Exploit Fix 3 | not_complete=false 4 | hide=false 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sk1erLLC/Resource-Exploit-Fix/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | modGroup=club.sk1er 2 | modVersion=2.0 3 | modBaseName=Resource Exploit Fix 4 | forgeVersion=1.8.9-11.15.1.2318-1.8.9 5 | mcpVersion=stable_22 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 01 11:24:50 EST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip 7 | -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/ResourceExploitFix.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix; 2 | 3 | import net.minecraftforge.fml.common.Mod; 4 | 5 | @Mod(modid = "resourceexploitfix", name = "Resource Exploit Fix", version = "2.0") 6 | public class ResourceExploitFix { 7 | } 8 | -------------------------------------------------------------------------------- /mod_info.txt: -------------------------------------------------------------------------------- 1 |

This has been superseded by Patcher.

2 |
3 |

Resource Exploit Fix fixes a security exploit in Minecraft 1.8

4 |
5 |

This exploit allows the server to check if you have a file on your computer, and wasn't fixed until 1.9.

6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | eclipse 3 | bin 4 | *.launch 5 | .settings 6 | .metadata 7 | .classpath 8 | .project 9 | 10 | # idea 11 | out 12 | classes 13 | *.ipr 14 | *.iws 15 | *.iml 16 | .idea 17 | 18 | # gradle 19 | build 20 | .gradle 21 | 22 | #Netbeans 23 | .nb-gradle 24 | .nb-gradle-properties 25 | 26 | # other 27 | run 28 | .DS_Store 29 | Thumbs.db -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Resource Exploit Fix 2 | Fixes a security exploit in 1.8 preventing malicious servers from checking if files exist on a player's computer. 3 | 4 | **This exploit cannot be used to read the contents of a file and can only tell the server if a specific file exists.** 5 | 6 | **Please read the detailed report of the bug: https://ungeek.eu/minecraft-18-file-access/** 7 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "resourceexploitfix", 4 | "name": "Resource Exploit Fix", 5 | "description": "Fixes a critical bug in Minecraft 1.8.X that can be exploited to check if files exist on a users computer", 6 | "version": "2.0", 7 | "mcversion": "1.8.9", 8 | "url": "https://ungeek.eu/minecraft-18-file-access/", 9 | "updateUrl": "", 10 | "authorList": [ 11 | "Sk1er LLC", 12 | "Punkeel" 13 | ], 14 | "credits": "", 15 | "logoFile": "", 16 | "screenshots": [], 17 | "dependencies": [] 18 | } 19 | ] -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/tweaker/transform/ResourceTransformer.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix.tweaker.transform; 2 | 3 | import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.objectweb.asm.tree.MethodNode; 6 | 7 | public interface ResourceTransformer { 8 | String[] getClassNames(); 9 | void transform(ClassNode classNode, String name); 10 | 11 | default String mapMethodName(ClassNode classNode, MethodNode methodNode) { 12 | return FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(classNode.name, methodNode.name, methodNode.desc); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sk1er LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/hook/NetHandlerPlayClientHook.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix.hook; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.entity.EntityPlayerSP; 5 | import net.minecraft.client.network.NetHandlerPlayClient; 6 | import net.minecraft.network.play.client.C19PacketResourcePackStatus; 7 | import net.minecraft.util.ChatComponentText; 8 | import net.minecraft.util.EnumChatFormatting; 9 | 10 | import java.io.UnsupportedEncodingException; 11 | import java.net.URI; 12 | import java.net.URISyntaxException; 13 | import java.net.URLDecoder; 14 | import java.nio.charset.StandardCharsets; 15 | 16 | public class NetHandlerPlayClientHook { 17 | 18 | public static boolean validateResourcePackUrl(NetHandlerPlayClient client, String url, String hash) { 19 | try { 20 | URI uri = new URI(url); 21 | String scheme = uri.getScheme(); 22 | boolean isLevelProtocol = "level".equals(scheme); 23 | 24 | if (!"http".equals(scheme) && !"https".equals(scheme) && !isLevelProtocol) { 25 | client.getNetworkManager().sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD)); 26 | throw new URISyntaxException(url, "Wrong protocol"); 27 | } 28 | 29 | url = URLDecoder.decode(url.substring("level://".length()), StandardCharsets.UTF_8.toString()); 30 | 31 | if (isLevelProtocol && (url.contains("..") || !url.endsWith("/resources.zip"))) { 32 | System.out.println("Malicious server tried to access " + url); 33 | EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; 34 | 35 | if (player != null) { 36 | player.addChatMessage(new ChatComponentText( 37 | EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + 38 | "[WARNING] The current server has attempted to be malicious but we have stopped them.")); 39 | } 40 | 41 | throw new URISyntaxException(url, "Invalid levelstorage resourcepack path"); 42 | } 43 | 44 | return true; 45 | } catch (URISyntaxException e) { 46 | return false; 47 | } catch (UnsupportedEncodingException e) { 48 | e.printStackTrace(); 49 | } 50 | 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/asm/NetHandlerPlayClientTransformer.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix.asm; 2 | 3 | import club.sk1er.resourceexploitfix.tweaker.transform.ResourceTransformer; 4 | import org.objectweb.asm.Opcodes; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.objectweb.asm.tree.InsnList; 7 | import org.objectweb.asm.tree.InsnNode; 8 | import org.objectweb.asm.tree.JumpInsnNode; 9 | import org.objectweb.asm.tree.LabelNode; 10 | import org.objectweb.asm.tree.MethodInsnNode; 11 | import org.objectweb.asm.tree.MethodNode; 12 | import org.objectweb.asm.tree.VarInsnNode; 13 | 14 | public class NetHandlerPlayClientTransformer implements ResourceTransformer { 15 | @Override 16 | public String[] getClassNames() { 17 | return new String[]{"net.minecraft.client.network.NetHandlerPlayClient"}; 18 | } 19 | 20 | @Override 21 | public void transform(ClassNode classNode, String name) { 22 | for (MethodNode methodNode : classNode.methods) { 23 | String methodName = mapMethodName(classNode, methodNode); 24 | 25 | if (methodName.equals("handleResourcePack") || methodName.equals("func_175095_a")) { 26 | methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), cancelIfNotSafe()); 27 | break; 28 | } 29 | 30 | break; 31 | } 32 | } 33 | 34 | private InsnList cancelIfNotSafe() { 35 | InsnList list = new InsnList(); 36 | list.add(new VarInsnNode(Opcodes.ALOAD, 0)); 37 | list.add(new VarInsnNode(Opcodes.ALOAD, 1)); 38 | list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/network/play/server/S48PacketResourcePackSend", 39 | "func_179784_b", "()Ljava/lang/String;", false)); 40 | list.add(new VarInsnNode(Opcodes.ALOAD, 1)); 41 | list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/network/play/server/S48PacketResourcePackSend", 42 | "func_179783_a", "()Ljava/lang/String;", false)); 43 | list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "club/sk1er/resourceexploitfix/hook/NetHandlerPlayClientHook", 44 | "validateResourcePackUrl", "(Lnet/minecraft/client/network/NetHandlerPlayClient;Ljava/lang/String;Ljava/lang/String;)Z", false)); 45 | LabelNode labelNode = new LabelNode(); 46 | list.add(new JumpInsnNode(Opcodes.IFNE, labelNode)); 47 | list.add(new InsnNode(Opcodes.RETURN)); 48 | list.add(labelNode); 49 | return list; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/tweaker/ClassTransformer.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix.tweaker; 2 | 3 | import club.sk1er.resourceexploitfix.asm.NetHandlerPlayClientTransformer; 4 | import club.sk1er.resourceexploitfix.tweaker.transform.ResourceTransformer; 5 | import com.google.common.collect.ArrayListMultimap; 6 | import com.google.common.collect.Multimap; 7 | import net.minecraft.launchwrapper.IClassTransformer; 8 | import org.apache.logging.log4j.LogManager; 9 | import org.apache.logging.log4j.Logger; 10 | import org.objectweb.asm.ClassReader; 11 | import org.objectweb.asm.ClassWriter; 12 | import org.objectweb.asm.tree.ClassNode; 13 | 14 | import java.util.Collection; 15 | 16 | public class ClassTransformer implements IClassTransformer { 17 | 18 | private static final Logger LOGGER = LogManager.getLogger("ResourceTransformer"); 19 | private final Multimap transformerMap = ArrayListMultimap.create(); 20 | 21 | public ClassTransformer() { 22 | registerTransformer(new NetHandlerPlayClientTransformer()); 23 | } 24 | 25 | private void registerTransformer(ResourceTransformer transformer) { 26 | for (String cls : transformer.getClassNames()) { 27 | transformerMap.put(cls, transformer); 28 | } 29 | } 30 | 31 | @Override 32 | public byte[] transform(String name, String transformedName, byte[] bytes) { 33 | if (bytes == null) return null; 34 | 35 | Collection transformers = transformerMap.get(transformedName); 36 | if (transformers.isEmpty()) return bytes; 37 | 38 | LOGGER.info("Found {} transformers for {}", transformers.size(), transformedName); 39 | 40 | ClassReader classReader = new ClassReader(bytes); 41 | ClassNode classNode = new ClassNode(); 42 | classReader.accept(classNode, ClassReader.EXPAND_FRAMES); 43 | 44 | transformers.forEach(transformer -> { 45 | LOGGER.info("Applying transformer {} on {}...", transformer.getClass().getName(), transformedName); 46 | transformer.transform(classNode, transformedName); 47 | }); 48 | 49 | ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); 50 | 51 | try { 52 | classNode.accept(classWriter); 53 | } catch (Throwable e) { 54 | System.out.println("Exception when transforming " + transformedName + " : " + e.getClass().getSimpleName()); 55 | e.printStackTrace(); 56 | } 57 | 58 | return classWriter.toByteArray(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/club/sk1er/resourceexploitfix/tweaker/ResourceTweaker.java: -------------------------------------------------------------------------------- 1 | package club.sk1er.resourceexploitfix.tweaker; 2 | 3 | import net.minecraftforge.common.ForgeVersion; 4 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 5 | 6 | import java.util.Map; 7 | 8 | @IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) 9 | public class ResourceTweaker implements IFMLLoadingPlugin { 10 | /** 11 | * Return a list of classes that implements the IClassTransformer interface 12 | * 13 | * @return a list of classes that implements the IClassTransformer interface 14 | */ 15 | @Override 16 | public String[] getASMTransformerClass() { 17 | return new String[]{ClassTransformer.class.getName()}; 18 | } 19 | 20 | /** 21 | * Return a class name that implements "ModContainer" for injection into the mod list 22 | * The "getName" function should return a name that other mods can, if need be, 23 | * depend on. 24 | * Trivially, this modcontainer will be loaded before all regular mod containers, 25 | * which means it will be forced to be "immutable" - not susceptible to normal 26 | * sorting behaviour. 27 | * All other mod behaviours are available however- this container can receive and handle 28 | * normal loading events 29 | */ 30 | @Override 31 | public String getModContainerClass() { 32 | return null; 33 | } 34 | 35 | /** 36 | * Return the class name of an implementor of "IFMLCallHook", that will be run, in the 37 | * main thread, to perform any additional setup this coremod may require. It will be 38 | * run prior to Minecraft starting, so it CANNOT operate on minecraft 39 | * itself. The game will deliberately crash if this code is detected to trigger a 40 | * minecraft class loading (TODO: implement crash ;) ) 41 | */ 42 | @Override 43 | public String getSetupClass() { 44 | return null; 45 | } 46 | 47 | /** 48 | * Inject coremod data into this coremod 49 | * This data includes: 50 | * "mcLocation" : the location of the minecraft directory, 51 | * "coremodList" : the list of coremods 52 | * "coremodLocation" : the file this coremod loaded from, 53 | * 54 | * @param data 55 | */ 56 | @Override 57 | public void injectData(Map data) { 58 | 59 | } 60 | 61 | /** 62 | * Return an optional access transformer class for this coremod. It will be injected post-deobf 63 | * so ensure your ATs conform to the new srgnames scheme. 64 | * 65 | * @return the name of an access transformer class or null if none is provided 66 | */ 67 | @Override 68 | public String getAccessTransformerClass() { 69 | return null; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | --------------------------------------------------------------------------------