Skip to content

Commit

Permalink
[KYUUBI #1291] [TEST] Transfer KRB5_CONF to kinit and fix kerberos UT…
Browse files Browse the repository at this point in the history
… on macOS

### _Why are the changes needed?_
1. transfer KRB5_CONF of KyuubiServer to kinit process in case the system KRB5_CONF is not same with `java.security.krb5.conf` of KyuubiServer JVM.
2. The UT with kerberos enabled KyuubiServer can not pass on osx environment, such as `KyuubiOperationKerberosAndPlainAuthSuite` (#1266). For the root cause, see details in https://stackoverflow.com/questions/27053539/openldap-kerberos-unable-to-reach-any-kdc-in-realm

### _How was this patch tested?_
`KyuubiOperationKerberosAndPlainAuthSuite` can pass on my MacBook, without this PR, it will fail on MacBook.

Closes #1291 from turboFei/kinit_ut.

Closes #1291

f006054 [fwang12] complete KRB5_CONFIG
859538c [fwang12] Make kerberos enabled kyuubi server unit test runnable for osx environment

Authored-by: fwang12 <fwang12@ebay.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
  • Loading branch information
turboFei authored and pan3793 committed Oct 25, 2021
1 parent 2675e9a commit 99934e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
if (s.contains("libdefaults")) {
rewritten = true
s + addedConfig
} else if (s.contains(hostName)) {
s + "\n" + s.replace(hostName, s"tcp/$hostName")
} else {
s
}).filter(!_.trim.startsWith("#")).mkString(System.lineSeparator())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ class KinitAuxiliaryService() extends AbstractService("KinitAuxiliaryService") {

require(keytab.nonEmpty && principal.nonEmpty, "principal or keytab is missing")
UserGroupInformation.loginUserFromKeytab(principal.get, keytab.get)
val krb5Conf = Option(System.getProperty("java.security.krb5.conf"))
.orElse(Option(System.getenv("KRB5_CONFIG")))
.getOrElse("/etc/krb5.conf")
val commands = Seq("kinit", "-kt", keytab.get, principal.get)
val kinitProc = new ProcessBuilder(commands: _*).inheritIO()
kinitProc.environment().put("KRB5_CONFIG", krb5Conf)
kinitTask = new Runnable {
override def run(): Unit = {
val process = kinitProc.start()
Expand Down

0 comments on commit 99934e8

Please sign in to comment.