### Question:
ContainerLaunch implements Callable<Integer> { static void writeLaunchEnv(OutputStream out, Map<String,String> environment, Map<Path,List<String>> resources, List<String> command) throws IOException { ShellScriptBuilder sb = new ShellScriptBuilder(); if (environment != null) { for (Map.Entry<String,String> env : environment.entrySet()) { sb.env(env.getKey().toString(), env.getValue().toString()); } } if (resources != null) { for (Map.Entry<Path,List<String>> entry : resources.entrySet()) { for (String linkName : entry.getValue()) { sb.symlink(entry.getKey(), linkName); } } } ArrayList<String> cmd = new ArrayList<String>(2 * command.size() + 5); cmd.add("exec /bin/bash "); cmd.add("-c "); cmd.add("\""); for (String cs : command) { cmd.add(cs.toString()); cmd.add(" "); } cmd.add("\""); sb.line(cmd.toArray(new String[cmd.size()])); PrintStream pout = null; try { pout = new PrintStream(out); sb.write(pout); } finally { if (out != null) { out.close(); } } } ContainerLaunch(Configuration configuration, Dispatcher dispatcher,
      ContainerExecutor exec, Application app, Container container,
      LocalDirsHandlerService dirsHandler); @Override @SuppressWarnings("unchecked") // dispatcher not typed Integer call(); void cleanupContainer(); static String getRelativeContainerLogDir(String appIdStr,
      String containerIdStr); void sanitizeEnv(Map<String, String> environment, 
      Path pwd, List<Path> appDirs); static final String CONTAINER_SCRIPT; static final String FINAL_CONTAINER_TOKENS_FILE; }### Answer:
@Test public void testSpecialCharSymlinks() throws IOException { File shellFile = null; File tempFile = null; String badSymlink = "foo@zz%_#*&!-+= bar()"; File symLinkFile = null; try { shellFile = new File(tmpDir, "hello.sh"); tempFile = new File(tmpDir, "temp.sh"); String timeoutCommand = "echo \"hello\""; PrintWriter writer = new PrintWriter(new FileOutputStream(shellFile)); shellFile.setExecutable(true); writer.println(timeoutCommand); writer.close(); Map<Path, List<String>> resources = new HashMap<Path, List<String>>(); Path path = new Path(shellFile.getAbsolutePath()); resources.put(path, Arrays.asList(badSymlink)); FileOutputStream fos = new FileOutputStream(tempFile); Map<String, String> env = new HashMap<String, String>(); List<String> commands = new ArrayList<String>(); commands.add("/bin/sh ./\\\"" + badSymlink + "\\\""); ContainerLaunch.writeLaunchEnv(fos, env, resources, commands); fos.flush(); fos.close(); tempFile.setExecutable(true); Shell.ShellCommandExecutor shexc = new Shell.ShellCommandExecutor(new String[]{tempFile.getAbsolutePath()}, tmpDir); shexc.execute(); assertEquals(shexc.getExitCode(), 0); assert(shexc.getOutput().contains("hello")); symLinkFile = new File(tmpDir, badSymlink); } finally { if (shellFile != null && shellFile.exists()) { shellFile.delete(); } if (tempFile != null && tempFile.exists()) { tempFile.delete(); } if (symLinkFile != null && symLinkFile.exists()) { symLinkFile.delete(); } } }