Copilot commented on code in PR #720:
URL: https://github.com/apache/ranger/pull/720#discussion_r2488268999


##########
dev-support/ranger-docker/scripts/solr/ranger-solr.sh:
##########
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SOLR_INSTALL_DIR=/opt/solr
+
+if [ ! -e ${SOLR_INSTALL_DIR}/.setupDone ]
+then
+  if [ "${KERBEROS_ENABLED}" == "true" ]
+  then
+    /home/ranger/scripts/wait_for_keytab.sh HTTP.keytab
+  fi
+
+  touch "${SOLR_INSTALL_DIR}"/.setupDone
+fi
+
+if [ "${KERBEROS_ENABLED}" == "true" ]
+then
+  export SOLR_AUTH_TYPE=kerberos
+  export 
SOLR_AUTHENTICATION_OPTS="-Djava.security.auth.login.config=/opt/solr/server/etc/jaas.conf
 -Dsolr.kerberos.jaas.appname=Client -Djava.security.krb5.conf=/etc/krb5.conf 
-Dsolr.kerberos.keytab=/etc/keytabs/HTTP.keytab 
-Dsolr.kerberos.principal=HTTP/[email protected] 
-Dsolr.kerberos.cookie.domain=ranger-solr 
-Dsolr.kerberos.name.rules=RULE:[2:\$1/\$2@\$0]([ndj]n/.*@EXAMPLE\.COM)s/.*/hdfs/\
+RULE:[2:\$1/\$2@\$0]([rn]m/.*@EXAMPLE\.COM)s/.*/yarn/\
+RULE:[2:\$1/\$2@\$0](jhs/.*@EXAMPLE\.COM)s/.*/mapred/\
+DEFAULT"

Review Comment:
   [nitpick] The SOLR_AUTHENTICATION_OPTS is constructed as a multi-line string 
with line continuations. This complex string should be broken down or 
constructed more clearly for better readability and maintainability.
   ```suggestion
     
JAAS_CONFIG="-Djava.security.auth.login.config=/opt/solr/server/etc/jaas.conf"
     JAAS_APPNAME="-Dsolr.kerberos.jaas.appname=Client"
     KRB5_CONF="-Djava.security.krb5.conf=/etc/krb5.conf"
     KERBEROS_KEYTAB="-Dsolr.kerberos.keytab=/etc/keytabs/HTTP.keytab"
     
KERBEROS_PRINCIPAL="-Dsolr.kerberos.principal=HTTP/[email protected]"
     COOKIE_DOMAIN="-Dsolr.kerberos.cookie.domain=ranger-solr"
     
KERBEROS_NAME_RULES="-Dsolr.kerberos.name.rules=RULE:[2:\$1/\$2@\$0]([ndj]n/.*@EXAMPLE\.COM)s/.*/hdfs/\
   RULE:[2:\$1/\$2@\$0]([rn]m/.*@EXAMPLE\.COM)s/.*/yarn/\
   RULE:[2:\$1/\$2@\$0](jhs/.*@EXAMPLE\.COM)s/.*/mapred/\
   DEFAULT"
     export SOLR_AUTHENTICATION_OPTS="${JAAS_CONFIG} ${JAAS_APPNAME} 
${KRB5_CONF} ${KERBEROS_KEYTAB} ${KERBEROS_PRINCIPAL} ${COOKIE_DOMAIN} 
${KERBEROS_NAME_RULES}"
   ```



##########
dev-support/ranger-docker/scripts/kdc/entrypoint.sh:
##########
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+REALM="${REALM:-EXAMPLE.COM}"
+KDC_HOST="${KDC_HOST:-ranger-kdc.rangernw}"
+MASTER_PASSWORD="${MASTER_PASSWORD:-masterpassword}"
+ADMIN_PRINC="${ADMIN_PRINCIPAL:-admin/admin}"
+ADMIN_PASSWORD="${ADMIN_PASSWORD:-adminpassword}"
+
+DB_DIR=/var/kerberos/krb5kdc
+KEYTABS_DIR=/etc/keytabs
+
+function create_principal_and_keytab() {

Review Comment:
   [nitpick] In bash scripts, it's recommended to use lowercase function names. 
Consider renaming to `create_principal_and_keytab` following bash naming 
conventions.



##########
dev-support/ranger-docker/scripts/wait_for_keytab.sh:
##########
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+KEYTABS_DIR=/etc/keytabs
+
+KEYTAB=${KEYTABS_DIR}/$1
+
+for i in {1..5}; do

Review Comment:
   [nitpick] The retry count '5' is hardcoded. Consider making this 
configurable through an environment variable or constant at the top of the 
script for easier maintenance.
   ```suggestion
   # Number of times to retry waiting for the keytab (can be overridden by 
KEYTAB_RETRY_COUNT env var)
   RETRY_COUNT="${KEYTAB_RETRY_COUNT:-5}"
   
   KEYTABS_DIR=/etc/keytabs
   
   KEYTAB=${KEYTABS_DIR}/$1
   
   for ((i=1; i<=RETRY_COUNT; i++)); do
   ```



-- 
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]

Reply via email to