HDFS-13738. fsck -list-corruptfileblocks has infinite loop if user is not privileged. Contributed by Yuen-Kuei Hsueh.
(cherry picked from commit4023eeba05
) (cherry picked from commit74d4fd975a
)
This commit is contained in:
parent
4b606eb9fd
commit
d502abe947
|
@ -210,8 +210,14 @@ public class DFSck extends Configured implements Tool {
|
||||||
allDone = true;
|
allDone = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (line.startsWith("Access denied for user")) {
|
||||||
|
out.println("Failed to open path '" + dir + "': Permission denied");
|
||||||
|
errCode = -1;
|
||||||
|
return errCode;
|
||||||
|
}
|
||||||
if ((line.isEmpty())
|
if ((line.isEmpty())
|
||||||
|| (line.startsWith("FSCK started by"))
|
|| (line.startsWith("FSCK started by"))
|
||||||
|
|| (line.startsWith("FSCK ended at"))
|
||||||
|| (line.startsWith("The filesystem under path")))
|
|| (line.startsWith("The filesystem under path")))
|
||||||
continue;
|
continue;
|
||||||
numCorrupt++;
|
numCorrupt++;
|
||||||
|
|
|
@ -2488,4 +2488,22 @@ public class TestFsck {
|
||||||
runFsck(cluster.getConfiguration(0), 0, true, "/");
|
runFsck(cluster.getConfiguration(0), 0, true, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFsckNonPrivilegedListCorrupt() throws Exception {
|
||||||
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
||||||
|
UserGroupInformation ugi = UserGroupInformation.createUserForTesting("systest", new String[]{""});
|
||||||
|
ugi.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
|
@Override
|
||||||
|
public Void run() throws Exception {
|
||||||
|
String path = "/";
|
||||||
|
String outStr = runFsck(conf, -1, true, path, "-list-corruptfileblocks");
|
||||||
|
|
||||||
|
assertFalse(outStr.contains("The list of corrupt files under path '" + path + "' are:"));
|
||||||
|
assertFalse(outStr.contains("The filesystem under path '" + path + "' has "));
|
||||||
|
assertTrue(outStr.contains("Failed to open path '" + path + "': Permission denied"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue