[
https://issues.apache.org/jira/browse/HADOOP-11934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14560173#comment-14560173
]
Chris Nauroth commented on HADOOP-11934:
----------------------------------------
Hi [~lmccay]. This looks great overall! Here are a few comments, mostly minor.
# Both {{AbstractJavaKeyStoreProvider}} and {{LocalJavaKeyStoreProvider}} have
copied some class-level JavaDocs from {{JavaKeyStoreProvider}}. This isn't
completely accurate, because those comments talk about pointing to different
{{FileSystem}} implementations. Could you please revise this?
# {{AbstractJavaKeyStoreProvider}} constructor: The trunk version of the
following code would trim the password. Do we need to keep that?
{code}
try (InputStream is = pwdFile.openStream()) {
password = IOUtils.toCharArray(is);
}
{code}
{code}
try (InputStream is = pwdFile.openStream()) {
password = IOUtils.toString(is).trim().toCharArray();
}
{code}
# {{AbstractJavaKeyStoreProvider#bytesToChars}}: The existing trunk code used
{{Charsets#UTF_8}} to avoid the need to handle
{{UnsupportedEncodingException}}. Shall we keep it the same, or was this an
intentional change?
# {{AbstractJavaKeyStoreProvider#getPathAsString}}: This has the same
implementation in both subclasses. Would it make sense to refactor that up to
the base class as a {{protected final}} method?
# {{JavaKeyStoreProvider#getOutputStreamForKeystore}}: This isn't a new thing
with your patch, but I wanted to mention that this overload of the
{{FileSystem.create}} method is not atomic. First it creates the file with
default permissions (usually 644), and then setting the requested permissions
is done separately. In the case of HDFS, this is 2 separate RPCs. That means
there is a brief window in which the file has default permissions. If the
process dies after the first RPC but before the second, then the permissions
will never be changed. To do this atomically, we'd need to switch to one of
the other (much uglier) overloads of {{FileSystem#create}}. If you think
changing this would be a good improvement, then I recommend queuing up a
separate jira for that change, since we already have a mid-sized patch going
here.
# {{JavaKeyStoreProvider}} and {{LocalJavaKeyStoreProvider}}: Please add the
{{@Override}} annotation on all applicable methods.
# {{TestCredentialProviderFactory}}: After this patch, the tests fail on
Windows, due to invalid string concatenation of a test directory that contains
'\' characters, which are not valid URI characters. (See below.) There have
been similar patches in the past to fix these tests on Windows, so you could
look back at those for inspiration on how to fix this. It will probably
involve some kind of usage of {{Path#toUri}}, which results in all '/'
characters, which is valid URI syntax.
{code}
java.io.IOException: Bad configuration of
hadoop.security.credential.provider.path at
jceks://fileC:\hdc\hadoop-common-project\hadoop-common\target\test\data\creds/test.jks
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.parseAuthority(URI.java:3167)
at java.net.URI$Parser.parseHierarchical(URI.java:3078)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at
org.apache.hadoop.security.alias.CredentialProviderFactory.getProviders(CredentialProviderFactory.java:55)
at
org.apache.hadoop.security.alias.TestCredentialProviderFactory.testFactory(TestCredentialProviderFactory.java:58)
{code}
> Use of JavaKeyStoreProvider in LdapGroupsMapping causes infinite loop
> ---------------------------------------------------------------------
>
> Key: HADOOP-11934
> URL: https://issues.apache.org/jira/browse/HADOOP-11934
> Project: Hadoop Common
> Issue Type: Bug
> Components: security
> Affects Versions: 2.6.0
> Reporter: Mike Yoder
> Assignee: Larry McCay
> Attachments: HADOOP-11934.001.patch, HADOOP-11934.002.patch,
> HADOOP-11934.003.patch, HADOOP-11934.004.patch, HADOOP-11934.005.patch,
> HADOOP-11934.006.patch, HADOOP-11934.007.patch, HADOOP-11934.008.patch,
> HADOOP-11934.009.patch, HADOOP-11934.010.patch
>
>
> I was attempting to use the LdapGroupsMapping code and the
> JavaKeyStoreProvider at the same time, and hit a really interesting, yet
> fatal, issue. The code goes into what ought to have been an infinite loop,
> were it not for it overflowing the stack and Java ending the loop. Here is a
> snippet of the stack; my annotations are at the bottom.
> {noformat}
> at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:370)
> at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider.<init>(JavaKeyStoreProvider.java:88)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider.<init>(JavaKeyStoreProvider.java:65)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory.createProvider(JavaKeyStoreProvider.java:291)
> at
> org.apache.hadoop.security.alias.CredentialProviderFactory.getProviders(CredentialProviderFactory.java:58)
> at
> org.apache.hadoop.conf.Configuration.getPasswordFromCredentialProviders(Configuration.java:1863)
> at
> org.apache.hadoop.conf.Configuration.getPassword(Configuration.java:1843)
> at
> org.apache.hadoop.security.LdapGroupsMapping.getPassword(LdapGroupsMapping.java:386)
> at
> org.apache.hadoop.security.LdapGroupsMapping.setConf(LdapGroupsMapping.java:349)
> at
> org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:73)
> at
> org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
> at org.apache.hadoop.security.Groups.<init>(Groups.java:70)
> at org.apache.hadoop.security.Groups.<init>(Groups.java:66)
> at
> org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:280)
> at
> org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:283)
> at
> org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:260)
> at
> org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:804)
> at
> org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:774)
> at
> org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:647)
> at
> org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2753)
> at
> org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2745)
> at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2611)
> at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:370)
> at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider.<init>(JavaKeyStoreProvider.java:88)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider.<init>(JavaKeyStoreProvider.java:65)
> at
> org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory.createProvider(JavaKeyStoreProvider.java:291)
> at
> org.apache.hadoop.security.alias.CredentialProviderFactory.getProviders(CredentialProviderFactory.java:58)
> at
> org.apache.hadoop.conf.Configuration.getPasswordFromCredentialProviders(Configuration.java:1863)
> at
> org.apache.hadoop.conf.Configuration.getPassword(Configuration.java:1843)
> at
> org.apache.hadoop.security.LdapGroupsMapping.getPassword(LdapGroupsMapping.java:386)
> at
> org.apache.hadoop.security.LdapGroupsMapping.setConf(LdapGroupsMapping.java:349)
> at
> org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:73)
> at
> org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
> at org.apache.hadoop.security.Groups.<init>(Groups.java:70)
> at org.apache.hadoop.security.Groups.<init>(Groups.java:66)
> at
> org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:280)
> at
> org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:283)
> at
> org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:260)
> at
> org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:804)
> at
> org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:774)
> at
> org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:647)
> at
> org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2753)
> at
> org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2745)
> at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2611)
> at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:370)
> at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296){noformat}
> Here's my annotation, going from bottom to top.
> * Somehow we enter Path.getFileSystem()
> * This goes to FileSystem cache stuff, and then it wants the current user
> * So we get to UserGroupInformation.getCurrentUser(), which as you can
> imagine gets to
> * getUserToGroupsMappingService and thence to LdapGroupsMapping.setConf().
> * That code gets the needed passwords, and we're using the
> CredentialProvider, so unsurprisingly we get to
> * getPasswordFromCredentialProviders() - which chooses the
> JavaKeyStoreProvider like I told it to.
> * The JavaKeyStoreProvider, in its constructor, does "fs =
> path.getFileSystem(conf);"
> * And guess what, we're back in Path.getFileSystem, where we started at the
> beginning.
> Please let me know if I've somehow configured something incorrectly, but if I
> have I can't figure out what it is...
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)