gp1314 opened a new pull request, #6326:
URL: https://github.com/apache/hadoop/pull/6326
<!--
Thanks for sending a pull request!
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
2. Make sure your PR title starts with JIRA issue id, e.g.,
'HADOOP-17799. Your PR title ...'.
-->
### Description of PR
- In a Kerberos environment, the namenode cannot fetch editlog from
journalnode because the request is rejected (403).

- GetJournalEditServlet checks if the request's username meets the
requirements through the isValidRequestor function. After
[HDFS-16686](https://issues.apache.org/jira/browse/HDFS-16686) is merged,
remotePrincipal becomes ugi.getUserName().
- In a Kerberos environment, ugi.getUserName() gets the
request.getRemoteUser() via DfsServlet's getUGI to get the username, and this
username is not a full name.
- Therefore, the obtained username is similar to namenode01 instead of
namenode01/host01@@REALM.TLD, which meansit fails to pass the isValidRequestor
check.

**reproduction**
- In the TestGetJournalEditServlet add testSecurityRequestNameNode
```
@Test
public void testSecurityRequestNameNode() throws IOException,
ServletException {
// Test: Make a request from a namenode
CONF.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
UserGroupInformation.setConfiguration(CONF);
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getParameter(UserParam.NAME)).thenReturn("nn/[email protected]");
when(request.getRemoteUser()).thenReturn("jn");
boolean isValid = SERVLET.isValidRequestor(request, CONF);
assertThat(isValid).isTrue();
}
```
### How was this patch tested?
### For code changes:
- [x] Does the title or this PR starts with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the
endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]