@@ -414,21 +414,26 @@ def _create_zk_chroot(self):
414414 raise RuntimeError ("Failed to create Zookeeper chroot node" )
415415 self .out ("Kafka chroot created in Zookeeper!" )
416416
417+ def render_jaas (self ):
418+ self .jaas_config = self ._jaas_config ()
419+ jaas_conf = self .tmp_dir .join ("kafka_server_jaas.conf" )
420+ jaas_conf_template = self .test_resource ("kafka_server_jaas.conf" )
421+ self .render_template (jaas_conf_template , jaas_conf , vars (self ))
422+ return jaas_conf .strpath
423+
417424 def start (self ):
418425 # Configure Kafka child process
419426 properties = self .tmp_dir .join ("kafka.properties" )
420- jaas_conf = self .tmp_dir .join ("kafka_server_jaas.conf" )
421427 properties_template = self .test_resource ("kafka.properties" )
422- jaas_conf_template = self .test_resource ("kafka_server_jaas.conf" )
423428
424429 # Consider replacing w/ run_script('kafka-server-start.sh', ...)
425430 args = self .kafka_run_class_args ("kafka.Kafka" , properties .strpath )
426431 env = self .kafka_run_class_env ()
427432 if self .sasl_enabled :
433+ jaas_conf = self .render_jaas ()
428434 opts = env .get ('KAFKA_OPTS' , '' ).strip ()
429- opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf . strpath )
435+ opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf )
430436 env ['KAFKA_OPTS' ] = opts
431- self .render_template (jaas_conf_template , jaas_conf , vars (self ))
432437
433438 timeout = 5
434439 max_timeout = 120
@@ -631,6 +636,11 @@ def get_topic_names(self):
631636 cmd = self .run_script ('kafka-topics.sh' , * args )
632637 env = self .kafka_run_class_env ()
633638 env .pop ('KAFKA_LOG4J_OPTS' )
639+ if self .sasl_enabled :
640+ jaas_conf = self .render_jaas ()
641+ opts = env .get ('KAFKA_OPTS' , '' ).strip ()
642+ opts += ' -Djava.security.auth.login.config={}' .format (jaas_conf )
643+ env ['KAFKA_OPTS' ] = opts
634644 proc = subprocess .Popen (cmd , env = env , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
635645 stdout , stderr = proc .communicate ()
636646 if proc .returncode != 0 :
0 commit comments