svn merge -c 1386838 FIXES: YARN-108. FSDownload can create cache directories with the wrong permissions (Jason Lowe via bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1386841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1f438df5aa
commit
bd85d36592
|
@ -73,6 +73,9 @@ Release 0.23.4 - UNRELEASED
|
||||||
|
|
||||||
Change package of YarnClient to org.apache.hadoop. (Bikas Saha via vinodkv)
|
Change package of YarnClient to org.apache.hadoop. (Bikas Saha via vinodkv)
|
||||||
|
|
||||||
|
YARN-108. FSDownload can create cache directories with the wrong
|
||||||
|
permissions (Jason Lowe via bobby)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -82,6 +82,13 @@ public class FSDownload implements Callable<Path> {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createDir(Path path, FsPermission perm) throws IOException {
|
||||||
|
files.mkdir(path, perm, false);
|
||||||
|
if (!perm.equals(files.getUMask().applyUMask(perm))) {
|
||||||
|
files.setPermission(path, perm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Path copy(Path sCopy, Path dstdir) throws IOException {
|
private Path copy(Path sCopy, Path dstdir) throws IOException {
|
||||||
FileSystem sourceFs = sCopy.getFileSystem(conf);
|
FileSystem sourceFs = sCopy.getFileSystem(conf);
|
||||||
Path dCopy = new Path(dstdir, sCopy.getName() + ".tmp");
|
Path dCopy = new Path(dstdir, sCopy.getName() + ".tmp");
|
||||||
|
@ -144,9 +151,9 @@ public class FSDownload implements Callable<Path> {
|
||||||
} while (files.util().exists(tmp));
|
} while (files.util().exists(tmp));
|
||||||
destDirPath = tmp;
|
destDirPath = tmp;
|
||||||
|
|
||||||
files.mkdir(destDirPath, cachePerms, false);
|
createDir(destDirPath, cachePerms);
|
||||||
final Path dst_work = new Path(destDirPath + "_tmp");
|
final Path dst_work = new Path(destDirPath + "_tmp");
|
||||||
files.mkdir(dst_work, cachePerms, false);
|
createDir(dst_work, cachePerms);
|
||||||
|
|
||||||
Path dFinal = files.makeQualified(new Path(dst_work, sCopy.getName()));
|
Path dFinal = files.makeQualified(new Path(dst_work, sCopy.getName()));
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -42,6 +42,7 @@ import junit.framework.Assert;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
import org.apache.hadoop.fs.FileContext;
|
import org.apache.hadoop.fs.FileContext;
|
||||||
import org.apache.hadoop.fs.FileStatus;
|
import org.apache.hadoop.fs.FileStatus;
|
||||||
|
@ -115,6 +116,7 @@ public class TestFSDownload {
|
||||||
public void testDownload() throws IOException, URISyntaxException,
|
public void testDownload() throws IOException, URISyntaxException,
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
|
||||||
FileContext files = FileContext.getLocalFSFileContext(conf);
|
FileContext files = FileContext.getLocalFSFileContext(conf);
|
||||||
final Path basedir = files.makeQualified(new Path("target",
|
final Path basedir = files.makeQualified(new Path("target",
|
||||||
TestFSDownload.class.getSimpleName()));
|
TestFSDownload.class.getSimpleName()));
|
||||||
|
@ -162,8 +164,14 @@ public class TestFSDownload {
|
||||||
Path localized = p.getValue().get();
|
Path localized = p.getValue().get();
|
||||||
assertEquals(sizes[Integer.valueOf(localized.getName())], p.getKey()
|
assertEquals(sizes[Integer.valueOf(localized.getName())], p.getKey()
|
||||||
.getSize());
|
.getSize());
|
||||||
FileStatus status = files.getFileStatus(localized);
|
|
||||||
|
FileStatus status = files.getFileStatus(localized.getParent());
|
||||||
FsPermission perm = status.getPermission();
|
FsPermission perm = status.getPermission();
|
||||||
|
assertEquals("Cache directory permissions are incorrect",
|
||||||
|
new FsPermission((short)0755), perm);
|
||||||
|
|
||||||
|
status = files.getFileStatus(localized);
|
||||||
|
perm = status.getPermission();
|
||||||
System.out.println("File permission " + perm +
|
System.out.println("File permission " + perm +
|
||||||
" for rsrc vis " + p.getKey().getVisibility().name());
|
" for rsrc vis " + p.getKey().getVisibility().name());
|
||||||
assert(rsrcVis.containsKey(p.getKey()));
|
assert(rsrcVis.containsKey(p.getKey()));
|
||||||
|
|
Loading…
Reference in New Issue