Skip to content

Commit 3fb549f

Browse files
committed
OOZIE-1726 Oozie does not support _HOST when configuring kerberos security (venkatnrangan via bzhang)
1 parent 05916d2 commit 3fb549f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.io.FileInputStream;
4242
import java.io.IOException;
4343
import java.io.InputStream;
44+
import java.net.InetAddress;
4445
import java.net.URI;
4546
import java.net.URISyntaxException;
4647
import java.security.PrivilegedExceptionAction;
@@ -164,7 +165,9 @@ private void kerberosInit(Configuration serviceConf) throws ServiceException {
164165
if (keytabFile.length() == 0) {
165166
throw new ServiceException(ErrorCode.E0026, KERBEROS_KEYTAB);
166167
}
167-
String principal = ConfigurationService.get(serviceConf, KERBEROS_PRINCIPAL);
168+
String principal = SecurityUtil.getServerPrincipal(
169+
serviceConf.get(KERBEROS_PRINCIPAL, "oozie/localhost@LOCALHOST"),
170+
InetAddress.getLocalHost().getCanonicalHostName());
168171
if (principal.length() == 0) {
169172
throw new ServiceException(ErrorCode.E0026, KERBEROS_PRINCIPAL);
170173
}

core/src/main/java/org/apache/oozie/servlet/AuthFilter.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
2222
import org.apache.hadoop.conf.Configuration;
2323
import org.apache.oozie.service.Services;
24+
import org.apache.hadoop.security.SecurityUtil;
2425

2526
import javax.servlet.FilterChain;
2627
import javax.servlet.FilterConfig;
@@ -32,6 +33,8 @@
3233
import java.io.IOException;
3334
import java.util.Map;
3435
import java.util.Properties;
36+
import java.net.InetAddress;
37+
import java.net.UnknownHostException;
3538
import org.apache.oozie.service.JobsConcurrencyService;
3639
import org.apache.oozie.util.ZKUtils;
3740

@@ -41,6 +44,7 @@
4144
*/
4245
public class AuthFilter extends AuthenticationFilter {
4346
public static final String OOZIE_PREFIX = "oozie.authentication.";
47+
private static final String KERBEROS_PRINCIPAL_CONFIG = "kerberos.principal";
4448

4549
private HttpServlet optionsServlet;
4650
private ZKUtils zkUtils = null;
@@ -105,7 +109,19 @@ protected Properties getConfiguration(String configPrefix, FilterConfig filterCo
105109
if (name.startsWith(OOZIE_PREFIX)) {
106110
String value = conf.get(name);
107111
name = name.substring(OOZIE_PREFIX.length());
108-
props.setProperty(name, value);
112+
if (name.equals(KERBEROS_PRINCIPAL_CONFIG)) {
113+
String hostName = "localhost";
114+
String principal = value;
115+
try {
116+
hostName = InetAddress.getLocalHost().getCanonicalHostName();
117+
principal = SecurityUtil.getServerPrincipal(value, hostName);
118+
} catch (IOException ioe) {
119+
// ignore.
120+
}
121+
props.setProperty(name, principal);
122+
} else {
123+
props.setProperty(name, value);
124+
}
109125
}
110126
}
111127

release-log.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- Oozie 4.2.0 release (trunk - unreleased)
22

3+
OOZIE-1726 Oozie does not support _HOST when configuring kerberos security (venkatnrangan via bzhang)
34
OOZIE-2197 ooziedb.cmd command failed due to classpath being too long on windows (me.venkatr via bzhang)
45
OOZIE-2182 SLA alert commands are not in sync with doc (puru)
56
OOZIE-2191 Upgrade jackson version for hadoop-2 profile (ryota)

0 commit comments

Comments
 (0)