From 859538cb1919b0c3ac38ccafc7c16078ffbb7c8c Mon Sep 17 00:00:00 2001 From: fwang12 Date: Mon, 25 Oct 2021 21:39:53 +0800 Subject: [PATCH 1/2] Make kerberos enabled kyuubi server unit test runnable for osx environment --- .../test/scala/org/apache/kyuubi/KerberizedTestHelper.scala | 2 ++ .../scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala | 3 +++ 2 files changed, 5 insertions(+) diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala index ea032fdf820..87a9f68cd49 100644 --- a/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala @@ -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()) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala index dd6f8e119db..8ce04cefd1b 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala @@ -45,8 +45,11 @@ 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")) + .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() From f00605454838941271880fa2d06ab965343caf8f Mon Sep 17 00:00:00 2001 From: fwang12 Date: Mon, 25 Oct 2021 23:09:34 +0800 Subject: [PATCH 2/2] complete KRB5_CONFIG --- .../scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala index 8ce04cefd1b..1f50fc514dc 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KinitAuxiliaryService.scala @@ -46,6 +46,7 @@ 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()