ContainerLocalizer { Callable<Path> download(Path destDirPath, LocalResource rsrc, UserGroupInformation ugi) throws IOException { if (rsrc.getVisibility() == LocalResourceVisibility.PRIVATE) { createParentDirs(destDirPath); } diskValidator.checkStatus(new File(destDirPath.toUri().getRawPath())); return new FSDownloadWrapper(lfs, ugi, conf, destDirPath, rsrc); } ContainerLocalizer(FileContext lfs, String user, String appId,
      String localizerId, List<Path> localDirs,
      RecordFactory recordFactory); @Private @VisibleForTesting LocalizationProtocol getProxy(final InetSocketAddress nmAddr); @SuppressWarnings("deprecation") void runLocalization(final InetSocketAddress nmAddr); static List<String> getJavaOpts(Configuration conf); static void buildMainArgs(List<String> command,
      String user, String appId, String locId,
      InetSocketAddress nmAddr, List<String> localDirs, Configuration conf); static void main(String[] argv); static final String FILECACHE; static final String APPCACHE; static final String USERCACHE; static final String TOKEN_FILE_NAME_FMT; }
@Test(timeout = 10000) public void testUserCacheDirPermission() throws Exception { Configuration conf = new Configuration(); conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077"); FileContext lfs = FileContext.getLocalFSFileContext(conf); Path fileCacheDir = lfs.makeQualified(new Path(basedir, "filecache")); lfs.mkdir(fileCacheDir, FsPermission.getDefault(), true); RecordFactory recordFactory = mock(RecordFactory.class); ContainerLocalizer localizer = new ContainerLocalizer(lfs, UserGroupInformation.getCurrentUser().getUserName(), "application_01", "container_01", new ArrayList<Path>(), recordFactory); LocalResource rsrc = mock(LocalResource.class); when(rsrc.getVisibility()).thenReturn(LocalResourceVisibility.PRIVATE); Path destDirPath = new Path(fileCacheDir, "0/0/85"); FsPermission wrongPerm = new FsPermission((short) 0700); lfs.mkdir(destDirPath.getParent().getParent(), wrongPerm, false); lfs.mkdir(destDirPath.getParent(), wrongPerm, false); localizer .download(destDirPath, rsrc, UserGroupInformation.getCurrentUser()); Assert .assertEquals("Cache directory permissions filecache/0/0 is incorrect", USERCACHE_DIR_PERM, lfs.getFileStatus(destDirPath.getParent()).getPermission()); Assert.assertEquals("Cache directory permissions filecache/0 is incorrect", USERCACHE_DIR_PERM, lfs.getFileStatus(destDirPath.getParent().getParent()).getPermission()); }